From 516f8e365dd94bfc9af0fb2d86516cae5bb2ec7f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 27 Jun 2012 15:12:46 +0000 Subject: Experimental support for UNC paths (through VFS) on UNIX/Mac --- doc/filename.n | 7 +++---- generic/tclFileName.c | 8 ++------ tests/cmdAH.test | 8 ++++---- tests/fileName.test | 6 +++--- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/doc/filename.n b/doc/filename.n index d481fc9..f1cd703 100644 --- a/doc/filename.n +++ b/doc/filename.n @@ -47,7 +47,8 @@ absolute, and file names may contain any character other than slash. The file names \fB\&.\fR and \fB\&..\fR are special and refer to the current directory and the parent of the current directory respectively. Multiple adjacent slash characters are interpreted as a single -separator. Any number of trailing slash characters at the end of a +separator, except for the first double slash \fB//\fR in absolute paths. +Any number of trailing slash characters at the end of a path are simply ignored, so the paths \fBfoo\fR, \fBfoo/\fR and \fBfoo//\fR are all identical, and in particular \fBfoo/\fR does not necessarily mean a directory is being referred. @@ -150,9 +151,7 @@ The safest approach is to use names consisting of alphanumeric characters only. Care should be taken with filenames which contain spaces (common on Windows systems) and filenames where the backslash is the directory separator (Windows -native path names). Also Windows 3.1 only supports file -names with a root of no more than 8 characters and an extension of no -more than 3 characters. +native path names). .PP On Windows platforms there are file and path length restrictions. Complete paths or filenames longer than about 260 characters will lead diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 48c5454..3e78a05 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -424,14 +424,12 @@ TclpGetNativePathType( } #endif if (path[0] == '/') { -#ifdef __CYGWIN__ /* - * Check for Cygwin // network path prefix + * Check for "//" prefix */ if (path[1] == '/') { path++; } -#endif if (driveNameLengthPtr != NULL) { /* * We need this addition in case the QNX or Cygwin code was used. @@ -665,15 +663,13 @@ SplitUnixPath( if (*p == '/') { Tcl_Obj *rootElt = Tcl_NewStringObj("/", 1); p++; -#ifdef __CYGWIN__ /* - * Check for Cygwin // network path prefix + * Check for "//" prefix */ if (*p == '/') { Tcl_AppendToObj(rootElt, "/", 1); p++; } -#endif Tcl_ListObjAppendElement(NULL, result, rootElt); } diff --git a/tests/cmdAH.test b/tests/cmdAH.test index 291df8d..fbe51d2 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -303,19 +303,19 @@ test cmdAH-8.13 {Tcl_FileObjCmd: dirname} testsetplatform { test cmdAH-8.14 {Tcl_FileObjCmd: dirname} testsetplatform { testsetplatform unix file dirname //foo -} / +} // test cmdAH-8.15 {Tcl_FileObjCmd: dirname} testsetplatform { testsetplatform unix file dirname //foo/bar -} /foo +} //foo test cmdAH-8.16 {Tcl_FileObjCmd: dirname} testsetplatform { testsetplatform unix file dirname {//foo\/bar/baz} -} {/foo\/bar} +} {//foo\/bar} test cmdAH-8.17 {Tcl_FileObjCmd: dirname} testsetplatform { testsetplatform unix file dirname {//foo\/bar/baz/blat} -} {/foo\/bar/baz} +} {//foo\/bar/baz} test cmdAH-8.18 {Tcl_FileObjCmd: dirname} testsetplatform { testsetplatform unix file dirname /foo// diff --git a/tests/fileName.test b/tests/fileName.test index 251f12c..aab8d33 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -196,7 +196,7 @@ test filename-4.12 {Tcl_SplitPath: unix} {testsetplatform} { test filename-4.13 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split //foo -} "[file split //] foo" +} "// foo" test filename-4.14 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split foo//bar @@ -433,11 +433,11 @@ test filename-7.16 {Tcl_JoinPath: unix} {testsetplatform} { test filename-7.17 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join //a b -} "[file split //]a/b" +} "//a/b" test filename-7.18 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join /// a b -} "[file split //]a/b" +} "//a/b" test filename-9.1 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win -- cgit v0.12 From f942af920c1c31f578e24aae999d86191ec65f39 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 2 Aug 2012 15:44:12 +0000 Subject: integrate QNX special path handling better with TIP #402 --- generic/tclFileName.c | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 013f788..cae2657 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -411,28 +411,24 @@ TclpGetNativePathType( * Paths that begin with / are absolute. */ -#ifdef __QNX__ - /* - * Check for QNX // prefix - */ - if (*path && (pathLen > 3) && (path[0] == '/') - && (path[1] == '/') && isdigit(UCHAR(path[2]))) { - path += 3; - while (isdigit(UCHAR(*path))) { - path++; - } - } -#endif if (path[0] == '/') { /* * Check for "//" prefix */ if (path[1] == '/') { path++; +#ifdef __QNX__ + /* + * Check for QNX // prefix + */ + while (isdigit(UCHAR(path[1]))) { + path++; + } +#endif } if (driveNameLengthPtr != NULL) { /* - * We need this addition in case the QNX or Cygwin code was used. + * We need this addition in case the QNX or "//" code was used. */ *driveNameLengthPtr = (1 + path - origPath); @@ -645,20 +641,6 @@ SplitUnixPath( * Deal with the root directory as a special case. */ -#ifdef __QNX__ - /* - * Check for QNX // prefix - */ - - if ((path[0] == '/') && (path[1] == '/') - && isdigit(UCHAR(path[2]))) { /* INTL: digit */ - path += 3; - while (isdigit(UCHAR(*path))) { /* INTL: digit */ - path++; - } - } -#endif - p = path; if (*p == '/') { Tcl_Obj *rootElt = Tcl_NewStringObj("/", 1); @@ -669,6 +651,16 @@ SplitUnixPath( if (*p == '/') { Tcl_AppendToObj(rootElt, "/", 1); p++; +#ifdef __QNX__ */ + /* + * Check for QNX // prefix + */ + + while (isdigit(UCHAR(*p))) { /* INTL: digit */ + Tcl_AppendToObj(rootElt, p, 1); + p++; + } +#endif } Tcl_ListObjAppendElement(NULL, result, rootElt); } -- cgit v0.12