From 1a2119427013511de4e74706942c27bd1ea50ce5 Mon Sep 17 00:00:00 2001 From: Adeel Date: Thu, 14 May 2020 06:47:39 +0300 Subject: [PATCH] Implement GetEntrypointExecutableAbsPath on SunOS * Implement `GetEntrypointExecutableAbsolutePath`. * Fix a warning from newer gawk (v5.0.1 from 2019): > ```sh > awk: /runtime/src/coreclr/src/nativeresources/processrc.awk:54: > warning: regexp escape sequence `\"' is not a known regexp operator > ``` --- .../hosts/unixcoreruncommon/coreruncommon.cpp | 37 +++++++++++++++++++ src/coreclr/src/nativeresources/processrc.awk | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/hosts/unixcoreruncommon/coreruncommon.cpp b/src/coreclr/src/hosts/unixcoreruncommon/coreruncommon.cpp index aac6e24ecea11f..b927f3802e683e 100644 --- a/src/coreclr/src/hosts/unixcoreruncommon/coreruncommon.cpp +++ b/src/coreclr/src/hosts/unixcoreruncommon/coreruncommon.cpp @@ -116,6 +116,43 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable) { result = false; } +#elif defined(__sun) + const char *path; + if ((path = getexecname()) == NULL) + { + result = false; + } + else if (*path != '/') + { + char *cwd; + if ((cwd = getcwd(NULL, PATH_MAX)) == NULL) + { + result = false; + } + else + { + char *joined; + if (asprintf(&joined, "%s/%s", cwd, path) < 0) + { + result = false; + } + else + { + entrypointExecutable.assign(joined); + result = true; + free(joined); + } + + free(cwd); + } + } + else + { + entrypointExecutable.assign(path); + result = true; + } + + free((void*)path); #else #if HAVE_GETAUXVAL && defined(AT_EXECFN) diff --git a/src/coreclr/src/nativeresources/processrc.awk b/src/coreclr/src/nativeresources/processrc.awk index 4e6ad55c458711..f8eec8d091d928 100644 --- a/src/coreclr/src/nativeresources/processrc.awk +++ b/src/coreclr/src/nativeresources/processrc.awk @@ -51,7 +51,7 @@ BEGIN { var = var + 0; # Extract string content starting with either " or L" - idx = match($0, /L?\"/); + idx = match($0, /L?"/); content = substr($0, idx); # remove the L prefix from strings