diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-09-13 21:58:56 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-09-14 11:26:36 +0200 |
commit | 82552a9540a0bcb64cc40ce79ac31db19a151182 (patch) | |
tree | 1f6f372592c40a14300b2e766c47d0e027bdc3d5 /perl.c | |
parent | 700dd4f8ecb172f1dd4eff765271d599cfa3fe02 (diff) | |
download | perl-82552a9540a0bcb64cc40ce79ac31db19a151182.tar.gz |
Simplify S_set_caret_X() by returning early if we set caret_x.
This avoids duplicating the fallback code to set caret_x to PL_origargv[0].
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -1395,7 +1395,10 @@ S_set_caret_X(pTHX) { GV* tmpgv = gv_fetchpvs("\030", GV_ADD|GV_NOTQUAL, SVt_PV); /* $^X */ if (tmpgv) { SV *const caret_x = GvSV(tmpgv); -#ifdef HAS_PROCSELFEXE +#if defined(OS2) + sv_setpv(caret_x, os2_execname(aTHX)); +#else +# ifdef HAS_PROCSELFEXE char buf[MAXPATHLEN]; int len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1); @@ -1417,17 +1420,12 @@ S_set_caret_X(pTHX) { */ if (len > 0 && memchr(buf, '/', len)) { sv_setpvn(caret_x, buf, len); + return; } - else { - sv_setpv(caret_x, PL_origargv[0]); - } -#else -#ifdef OS2 - sv_setpv(caret_x, os2_execname(aTHX)); -#else +# endif + /* Fallback to this: */ sv_setpv(caret_x, PL_origargv[0]); #endif -#endif } } |