[flang-commits] [clang-tools-extra] [llvm] [clang] [flang] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed Dec 6 10:47:41 PST 2023
================
@@ -37,5 +79,34 @@ void FORTRAN_PROCEDURE_NAME(getarg)(
(void)RTNAME(GetCommandArgument)(
n, &value, nullptr, nullptr, __FILE__, __LINE__);
}
+
+// CALL GETLOG(USRNAME)
+void FORTRAN_PROCEDURE_NAME(getlog)(std::int8_t *arg, std::int64_t length) {
+ const int nameMaxLen{LOGIN_NAME_MAX + 1};
+ char str[nameMaxLen];
+
+ int error{getlogin_r(str, nameMaxLen)};
+ Terminator terminator{__FILE__, __LINE__};
+ if (error != 0) {
+ // if there is error, then get username from environment variable
+#ifdef _WIN32
+ const int charLen = 9;
----------------
klausler wrote:
It needn't be `static` or `const`.
https://github.com/llvm/llvm-project/pull/74628
More information about the flang-commits
mailing list