[flang-commits] [PATCH] D111394: [flang] Implement GET_ENVIRONMENT_VARIABLE(LENGTH)

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Oct 8 10:23:17 PDT 2021


klausler added inline comments.


================
Comment at: flang/runtime/command.cpp:86
+  std::size_t s{d.ElementBytes() - 1};
+  while (*d.OffsetElement(s) == ' ') {
+    --s;
----------------
This will fail badly when the entire name is blank.


================
Comment at: flang/runtime/environment.cpp:74
+    const char *name, std::size_t name_length) {
+  // envp is an array of strings of the form "name=value".
+  for (const char **var{envp}; *var != nullptr; ++var) {
----------------
This won't work at all if ProgramStart is never called, and it won't be called when the main program is not Fortran.  You need to test `envp` for validity and deal with the case of it being null.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111394/new/

https://reviews.llvm.org/D111394



More information about the flang-commits mailing list