OSDN Git Service

2003-02-11 Martin M. Hunt <hunt@redhat.com>
authorhunt <hunt>
Wed, 12 Feb 2003 04:20:58 +0000 (04:20 +0000)
committerhunt <hunt>
Wed, 12 Feb 2003 04:20:58 +0000 (04:20 +0000)
From Mumit Khan  <khan@nanotech.wisc.edu>

* generic/tclIOUtil.c (SetFsPathFromAny): Add Cygwin specific
code to convert POSIX filename to native format.
* generic/tclFileName.c (Tcl_TranslateFileName): And remove
from here.
(TclDoGlob): Adjust.
* win/tclWinFile.c (TclpObjChdir): Use chdir on Cygwin.

tcl/ChangeLog
tcl/generic/tclFileName.c
tcl/generic/tclIOUtil.c
tcl/win/tclWinFile.c

index b915511..e005e11 100644 (file)
@@ -1,3 +1,14 @@
+2003-02-11  Martin M. Hunt  <hunt@redhat.com>
+       From Mumit Khan  <khan@nanotech.wisc.edu>
+
+       * generic/tclIOUtil.c (SetFsPathFromAny): Add Cygwin specific
+       code to convert POSIX filename to native format.
+       * generic/tclFileName.c (Tcl_TranslateFileName): And remove
+       from here.
+       (TclDoGlob): Adjust.
+       * win/tclWinFile.c (TclpObjChdir): Use chdir on Cygwin.
+
+
 2003-02-06  Martin M. Hunt  <hunt@redhat.com>
 
        * win/tcl.m4 (SC_CONFIG_CFLAGS): Don't default to -O.
index 3be1236..b989e4b 100644 (file)
@@ -1356,31 +1356,12 @@ Tcl_TranslateFileName(interp, name, bufferPtr)
      */
 
     if (tclPlatform == TCL_PLATFORM_WINDOWS) {
-#if defined(__CYGWIN__) && defined(__WIN32__)
-
-       extern int cygwin_conv_to_win32_path 
-           _ANSI_ARGS_((CONST char *, char *));
-       char winbuf[MAX_PATH];
-
-       /*
-        * In the Cygwin world, call conv_to_win32_path in order to use the
-        * mount table to translate the file name into something Windows will
-        * understand.  Take care when converting empty strings!
-        */
-       if (Tcl_DStringLength(bufferPtr)) {
-           cygwin_conv_to_win32_path(Tcl_DStringValue(bufferPtr), winbuf);
-           Tcl_DStringFree(bufferPtr);
-           Tcl_DStringAppend(bufferPtr, winbuf, -1);
-       }
-#else /* __CYGWIN__ && __WIN32__ */
-
        register char *p;
        for (p = Tcl_DStringValue(bufferPtr); *p != '\0'; p++) {
            if (*p == '/') {
                *p = '\\';
            }
        }
-#endif /* __CYGWIN__ && __WIN32__ */
     }
     return Tcl_DStringValue(bufferPtr);
 }
@@ -2336,25 +2317,6 @@ TclDoGlob(interp, separators, headPtr, tail, types)
             * element.  Add an extra slash if this is a UNC path.
             */
 
-#if defined(__CYGWIN__) && defined(__WIN32__)
-           {
-
-           extern int cygwin_conv_to_win32_path 
-               _ANSI_ARGS_((CONST char *, char *));
-           char winbuf[MAX_PATH];
-
-           /*
-            * In the Cygwin world, call conv_to_win32_path in order to use
-            * the mount table to translate the file name into something
-            * Windows will understand.
-            */
-           cygwin_conv_to_win32_path(Tcl_DStringValue(headPtr), winbuf);
-           Tcl_DStringFree(headPtr);
-           Tcl_DStringAppend(headPtr, winbuf, -1);
-
-           }
-#endif /* __CYGWIN__ && __WIN32__ */
-
            if (*name == ':') {
                Tcl_DStringAppend(headPtr, ":", 1);
                if (count > 1) {
@@ -2570,11 +2532,24 @@ TclDoGlob(interp, separators, headPtr, tail, types)
                if (Tcl_DStringLength(headPtr) == 0) {
                    if (((*name == '\\') && (name[1] == '/' || name[1] == '\\'))
                            || (*name == '/')) {
-                       Tcl_DStringAppend(headPtr, "\\", 1);
+                       Tcl_DStringAppend(headPtr, "/", 1);
                    } else {
                        Tcl_DStringAppend(headPtr, ".", 1);
                    }
                }
+#if defined(__CYGWIN__) && defined(__WIN32__)
+               {
+
+               extern int cygwin_conv_to_win32_path 
+                   _ANSI_ARGS_((CONST char *, char *));
+               char winbuf[MAX_PATH+1];
+
+               cygwin_conv_to_win32_path(Tcl_DStringValue(headPtr), winbuf);
+               Tcl_DStringFree(headPtr);
+               Tcl_DStringAppend(headPtr, winbuf, -1);
+
+               }
+#endif /* __CYGWIN__ && __WIN32__ */
                /* 
                 * Convert to forward slashes.  This is required to pass
                 * some Tcl tests.  We should probably remove the conversions
index af1bd03..2a74e62 100644 (file)
@@ -3947,6 +3947,28 @@ SetFsPathFromAny(interp, objPtr)
        transPtr = Tcl_FSJoinToPath(objPtr,0,NULL);
     }
 
+#if defined(__CYGWIN__) && defined(__WIN32__)
+    {
+
+    extern int cygwin_conv_to_win32_path 
+       _ANSI_ARGS_((CONST char *, char *));
+    char winbuf[MAX_PATH+1];
+
+    /*
+     * In the Cygwin world, call conv_to_win32_path in order to use the
+     * mount table to translate the file name into something Windows will
+     * understand.  Take care when converting empty strings!
+     */
+    name = Tcl_GetStringFromObj(transPtr, &len);
+    if (len > 0) {
+       cygwin_conv_to_win32_path(name, winbuf);
+       TclWinNoBackslash(winbuf);
+       Tcl_SetStringObj(transPtr, winbuf, -1);
+    }
+
+    }
+#endif /* __CYGWIN__ && __WIN32__ */
+
     /* 
      * Now we have a translated filename in 'transPtr'.  This will have
      * forward slashes on Windows, and will not contain any ~user
index 5ec41cf..9495cae 100644 (file)
@@ -1330,9 +1330,25 @@ TclpObjChdir(pathPtr)
 {
     int result;
     CONST TCHAR *nativePath;
+#ifdef __CYGWIN__
+    extern int cygwin_conv_to_posix_path 
+       _ANSI_ARGS_((CONST char *, char *));
+    char posixPath[MAX_PATH+1];
+    CONST char *path;
+    Tcl_DString ds;
+#endif /* __CYGWIN__ */
+
 
     nativePath = (CONST TCHAR *) Tcl_FSGetNativePath(pathPtr);
+#ifdef __CYGWIN__
+    /* Cygwin chdir only groks POSIX path. */
+    path = Tcl_WinTCharToUtf(nativePath, -1, &ds);
+    cygwin_conv_to_posix_path(path, posixPath);
+    result = (chdir(posixPath) == 0 ? 1 : 0);
+    Tcl_DStringFree(&ds);
+#else /* __CYGWIN__ */
     result = (*tclWinProcs->setCurrentDirectoryProc)(nativePath);
+#endif /* __CYGWIN__ */
 
     if (result == 0) {
        TclWinConvertError(GetLastError());