summaryrefslogtreecommitdiff
path: root/os2
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>2001-07-02 02:21:17 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2001-07-02 13:20:50 +0000
commitf5f423e4590905c45492eda1312cb2f76a6ef9a7 (patch)
treeaec1cc8091d7e99e87e0c2658004bc2a891b9327 /os2
parent6fbe8946df869c4ec4c3a3638877b93445042402 (diff)
downloadperl-f5f423e4590905c45492eda1312cb2f76a6ef9a7.tar.gz
OS/2 cwd
Message-ID: <20010702062117.A1401@math.ohio-state.edu> p4raw-id: //depot/perl@11084
Diffstat (limited to 'os2')
-rw-r--r--os2/os2.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/os2/os2.c b/os2/os2.c
index 03c06edd73..d7d208e83b 100644
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -1971,9 +1971,11 @@ XS(XS_Cwd_sys_abspath)
{
STRLEN n_a;
char * path = (char *)SvPV(ST(0),n_a);
- char * dir;
+ char * dir, *s, *t, *e;
char p[MAXPATHLEN];
char * RETVAL;
+ int l;
+ SV *sv;
if (items < 2)
dir = NULL;
@@ -2063,8 +2065,26 @@ XS(XS_Cwd_sys_abspath)
done:
}
}
+ if (!RETVAL)
+ XSRETURN_EMPTY;
+ /* Backslashes are already converted to slashes. */
+ /* Remove trailing slashes */
+ l = strlen(RETVAL);
+ while (l > 0 && RETVAL[l-1] == '/')
+ l--;
ST(0) = sv_newmortal();
- sv_setpv((SV*)ST(0), RETVAL);
+ sv_setpvn( sv = (SV*)ST(0), RETVAL, l);
+ /* Remove duplicate slashes */
+ s = t = 1 + SvPV_force(sv, n_a);
+ e = SvEND(sv);
+ while (s < e) {
+ if (s[0] == t[-1] && s[0] == '/')
+ s++; /* Skip duplicate / */
+ else
+ *t++ = *s++;
+ }
+ *s = 0;
+ SvCUR_set(sv, s - SvPVX(sv));
}
XSRETURN(1);
}