B::Deparse fixes for implicit smartmatching in given/when
[p5sagit/p5-mst-13.2.git] / ext / Cwd / Cwd.xs
index e7323ab..4958bd2 100644 (file)
@@ -1,8 +1,10 @@
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
-#define NEED_sv_2pv_nolen
-#include "ppport.h"
+#ifndef NO_PPPORT_H
+#   define NEED_sv_2pv_nolen
+#   include "ppport.h"
+#endif
 
 #ifdef I_UNISTD
 #   include <unistd.h>
@@ -77,7 +79,8 @@ bsd_realpath(const char *path, char *resolved)
        return Perl_rmsexpand(aTHX_ (char*)path, resolved, NULL, 0);
 #else
        int rootd, serrno;
-       char *p, *q, wbuf[MAXPATHLEN];
+       const char *p;
+       char *q, wbuf[MAXPATHLEN];
        int symlinks = 0;
 
        /* Save the starting point. */
@@ -110,17 +113,18 @@ bsd_realpath(const char *path, char *resolved)
 loop:
        q = strrchr(resolved, '/');
        if (q != NULL) {
+               const char *dir;
                p = q + 1;
                if (q == resolved)
-                       q = "/";
+                       dir = "/";
                else {
                        do {
                                --q;
                        } while (q > resolved && *q == '/');
                        q[1] = '\0';
-                       q = resolved;
+                       dir = resolved;
                }
-               if (chdir(q) < 0)
+               if (chdir(dir) < 0)
                        goto err1;
        } else
                p = resolved;
@@ -268,7 +272,7 @@ int Perl_getcwd_sv(pTHX_ register SV *sv)
     }
 
 #else
-
+  {
     Stat_t statbuf;
     int orig_cdev, orig_cino, cdev, cino, odev, oino, tdev, tino;
     int namelen, pathlen=0;
@@ -380,6 +384,7 @@ int Perl_getcwd_sv(pTHX_ register SV *sv)
     }
 
     return TRUE;
+  }
 #endif
 
 #else
@@ -408,6 +413,19 @@ PPCODE:
 }
 
 void
+getcwd(...)
+PROTOTYPE: DISABLE
+PPCODE:
+{
+    dXSTARG;
+    getcwd_sv(TARG);
+    XSprePUSH; PUSHTARG;
+#ifndef INCOMPLETE_TAINTS
+    SvTAINTED_on(TARG);
+#endif
+}
+
+void
 abs_path(pathsv=Nullsv)
     SV *pathsv
 PROTOTYPE: DISABLE
@@ -433,7 +451,7 @@ PPCODE:
 #endif
 }
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(UNDER_CE)
 
 void
 getdcwd(...)