X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FMac-NSGetExecutablePath.git;a=blobdiff_plain;f=NSGetExecutablePath.xs;h=152a70d21e9f12897ecd998da90b86b36cf925a2;hp=c0a3a93bccce1e339aa4617a75fd5f2be1577e67;hb=HEAD;hpb=68720c70b78fdbcb3d79362b6e4bb3543e8c6da4 diff --git a/NSGetExecutablePath.xs b/NSGetExecutablePath.xs index c0a3a93..152a70d 100644 --- a/NSGetExecutablePath.xs +++ b/NSGetExecutablePath.xs @@ -8,7 +8,6 @@ #include - static const char nsgep_too_long[] = "NSGetExecutablePath() wants to return a path too large"; /* --- XS ------------------------------------------------------------------ */ @@ -29,16 +28,13 @@ PPCODE: _NSGetExecutablePath(buf, &size); if (size >= MAXPATHLEN * MAXPATHLEN) croak(nsgep_too_long); -#ifdef newSV_type - dst = newSV_type(SVt_PV); -#else - dst = sv_newmortal(); - (void) SvUPGRADE(dst, SVt_PV); -#endif + dst = sv_newmortal(); + sv_upgrade(dst, SVt_PV); buffer = SvGROW(dst, size); if (_NSGetExecutablePath(buffer, &size)) croak(nsgep_too_long); - SvCUR_set(dst, size - 1); + if (size) + SvCUR_set(dst, size - 1); SvPOK_on(dst); XPUSHs(dst); XSRETURN(1);