In perl.git, the branch blead has been updated

<https://perl5.git.perl.org/perl.git/commitdiff/03b94aa47e981af3c7b0118bfb11facda2b95251?hp=ab473f03f7b27ae267ddf8126e0b91ea1f3eef5e>

- Log -----------------------------------------------------------------
commit 03b94aa47e981af3c7b0118bfb11facda2b95251
Author: Aaron Crane <a...@cpan.org>
Date:   Tue Oct 9 14:41:10 2018 +0100

    RT#133573: $^X fallback when platform-specific technique fails

-----------------------------------------------------------------------

Summary of changes:
 caretx.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/caretx.c b/caretx.c
index d758f730de..247708de8c 100644
--- a/caretx.c
+++ b/caretx.c
@@ -56,7 +56,19 @@ Perl_set_caret_X(pTHX) {
     SV *const caret_x = GvSV(tmpgv);
 #if defined(OS2)
     sv_setpv(caret_x, os2_execname(aTHX));
-#elif defined(USE_KERN_PROC_PATHNAME)
+    return;
+#elif defined(WIN32)
+    char *ansi;
+    WCHAR widename[MAX_PATH];
+    GetModuleFileNameW(NULL, widename, sizeof(widename)/sizeof(WCHAR));
+    ansi = win32_ansipath(widename);
+    sv_setpv(caret_x, ansi);
+    win32_free(ansi);
+    return;
+#else
+    /* We can try a platform-specific one if possible; if it fails, or we
+     * aren't running on a suitable platform, we'll fall back to argv[0]. */
+# ifdef USE_KERN_PROC_PATHNAME
     size_t size = 0;
     int mib[4];
     mib[0] = CTL_KERN;
@@ -76,7 +88,7 @@ Perl_set_caret_X(pTHX) {
             return;
         }
     }
-#elif defined(USE_NSGETEXECUTABLEPATH)
+# elif defined(USE_NSGETEXECUTABLEPATH)
     char buf[1];
     uint32_t size = sizeof(buf);
 
@@ -95,7 +107,7 @@ Perl_set_caret_X(pTHX) {
             return;
         }
     }
-#elif defined(HAS_PROCSELFEXE)
+# elif defined(HAS_PROCSELFEXE)
     char buf[MAXPATHLEN];
     SSize_t len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1);
     /* NOTE: if the length returned by readlink() is sizeof(buf) - 1,
@@ -125,15 +137,7 @@ Perl_set_caret_X(pTHX) {
         sv_setpvn(caret_x, buf, len);
         return;
     }
-#elif defined(WIN32)
-    char *ansi;
-    WCHAR widename[MAX_PATH];
-    GetModuleFileNameW(NULL, widename, sizeof(widename)/sizeof(WCHAR));
-    ansi = win32_ansipath(widename);
-    sv_setpv(caret_x, ansi);
-    win32_free(ansi);
-    return;
-#else
+# endif
     /* Fallback to this:  */
     sv_setpv(caret_x, PL_origargv[0]);
 #endif

-- 
Perl5 Master Repository

Reply via email to