This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
re/regexp_unicode_prop.t: Add test
[perl5.git] / caretx.c
index fe884e4..d758f73 100644 (file)
--- a/caretx.c
+++ b/caretx.c
@@ -56,8 +56,7 @@ Perl_set_caret_X(pTHX) {
     SV *const caret_x = GvSV(tmpgv);
 #if defined(OS2)
     sv_setpv(caret_x, os2_execname(aTHX));
-#else
-#  ifdef USE_KERN_PROC_PATHNAME
+#elif defined(USE_KERN_PROC_PATHNAME)
     size_t size = 0;
     int mib[4];
     mib[0] = CTL_KERN;
@@ -77,7 +76,7 @@ Perl_set_caret_X(pTHX) {
             return;
         }
     }
-#  elif defined(USE_NSGETEXECUTABLEPATH)
+#elif defined(USE_NSGETEXECUTABLEPATH)
     char buf[1];
     uint32_t size = sizeof(buf);
 
@@ -96,7 +95,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,
@@ -126,7 +125,15 @@ Perl_set_caret_X(pTHX) {
         sv_setpvn(caret_x, buf, len);
         return;
     }
-#  endif
+#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
     /* Fallback to this:  */
     sv_setpv(caret_x, PL_origargv[0]);
 #endif