[Patch Perl@12856] MULTIPLICITY on VMS
[p5sagit/p5-mst-13.2.git] / ext / Cwd / Cwd.xs
index b6f27b8..19d3afd 100644 (file)
@@ -70,15 +70,18 @@ bsd_realpath(path, resolved)
        char *resolved;
 {
 #ifdef VMS
-       return Perl_rmsexpand((char*)path, resolved, NULL, 0);
+       dTHX;
+       return Perl_rmsexpand(aTHX_ (char*)path, resolved, NULL, 0);
 #else
        struct stat sb;
-       int fd, n, rootd, serrno;
+       int n, rootd, serrno;
        char *p, *q, wbuf[MAXPATHLEN];
        int symlinks = 0;
 
        /* Save the starting point. */
 #ifdef HAS_FCHDIR
+       int fd;
+
        if ((fd = open(".", O_RDONLY)) < 0) {
                (void)strcpy(resolved, ".");
                return (NULL);
@@ -120,7 +123,7 @@ loop:
        } else
                p = resolved;
 
-#ifdef HAS_LSTAT
+#if defined(HAS_LSTAT) && defined(HAS_READLINK) && defined(HAS_SYMLINK)
        /* Deal with the last component. */
        if (lstat(p, &sb) == 0) {
                if (S_ISLNK(sb.st_mode)) {
@@ -224,22 +227,20 @@ PPCODE:
 {
     dXSTARG;
     char *path;
-    STRLEN len;
     char buf[MAXPATHLEN];
 
-    if (pathsv)
-      path = SvPV(pathsv, len);
-    else {
-        path = ".";
-        len  = 1;
-    }
+    path = pathsv ? SvPV_nolen(pathsv) : ".";
 
     if (bsd_realpath(path, buf)) {
         sv_setpvn(TARG, buf, strlen(buf));
         SvPOK_only(TARG);
+       SvTAINTED_on(TARG);
     }
     else
-      sv_setsv(TARG, &PL_sv_undef);
+        sv_setsv(TARG, &PL_sv_undef);
 
     XSprePUSH; PUSHTARG;
+#ifndef INCOMPLETE_TAINTS
+    SvTAINTED_on(TARG);
+#endif
 }