From b3838ea4450c4d290daa647c9a7f62d4e55ee7c0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 1 Dec 2022 17:27:03 +0000 Subject: Backport TIP #402: General Platform UNC Support from 8.7, but only for Cygwin and QNX. This was already partially present, but was never completed. --- generic/tclFileName.c | 32 +++++++------------------------- unix/tclUnixFile.c | 5 ++--- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/generic/tclFileName.c b/generic/tclFileName.c index b6a6439..dcd3d0e 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -5,7 +5,7 @@ * and network form. * * Copyright (c) 1995-1998 Sun Microsystems, Inc. - * Copyright (c) 1998-1999 by Scriptics Corporation. + * Copyright (c) 1998-1999 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -422,22 +422,11 @@ TclpGetNativePathType( while (*path && *path != '/') { ++path; } -#if defined(__CYGWIN__) - /* UNC paths need to be followed by a share name */ - if (*path++ && (*path && *path != '/')) { - ++path; - while (*path && *path != '/') { - ++path; - } - } else { - path = origPath + 1; - } -#endif } #endif if (driveNameLengthPtr != NULL) { /* - * We need this addition in case the QNX or Cygwin code was used. + * We need this addition in case the "//" code was used. */ *driveNameLengthPtr = (path - origPath); @@ -664,17 +653,6 @@ SplitUnixPath( while (*path && *path != '/') { ++path; } -#if defined(__CYGWIN__) - /* UNC paths need to be followed by a share name */ - if (*path++ && (*path && *path != '/')) { - ++path; - while (*path && *path != '/') { - ++path; - } - } else { - path = origPath + 1; - } -#endif } #endif rootElt = Tcl_NewStringObj(origPath, path - origPath); @@ -1889,7 +1867,11 @@ TclGlob( separators = "/\\"; } else if (tclPlatform == TCL_PLATFORM_UNIX) { - if (pathPrefix == NULL && tail[0] == '/') { + if (pathPrefix == NULL && tail[0] == '/' +#if defined(__CYGWIN__) || defined(__QNX__) + && tail[1] != '/' +#endif + ) { pathPrefix = Tcl_NewStringObj(tail, 1); tail++; Tcl_IncrRefCount(pathPrefix); diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index a75ae22..c269079 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -39,7 +39,6 @@ TclpFindExecutable( const char *argv0) /* The value of the application's argv[0] * (native). */ { - Tcl_Encoding encoding; #ifdef __CYGWIN__ int length; wchar_t buf[PATH_MAX] = L""; @@ -52,10 +51,10 @@ TclpFindExecutable( /* Strip '.exe' part. */ length -= 4; } - encoding = Tcl_GetEncoding(NULL, NULL); TclSetObjNameOfExecutable( - Tcl_NewStringObj(name, length), encoding); + Tcl_NewStringObj(name, length), NULL); #else + Tcl_Encoding encoding; const char *name, *p; Tcl_StatBuf statBuf; Tcl_DString buffer, nameString, cwd, utfName; -- cgit v0.12