Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip-602 Excluding Merge-Ins
This is equivalent to a diff from c3c75e63cd to e35fad18e7
2022-09-14
| ||
17:50 | TIP #602: Remove tilde expansion in file paths check-in: cff0348cb6 user: jan.nijtmans tags: trunk, main | |
2022-08-29
| ||
21:10 | merge-mark check-in: c65b7904a6 user: jan.nijtmans tags: trunk, main | |
14:00 | Merge 9.0 Closed-Leaf check-in: e35fad18e7 user: jan.nijtmans tags: tip-602 | |
11:54 | Merge 9.0 check-in: 55a5cd2e35 user: jan.nijtmans tags: tip-626 | |
10:15 | Merge 8.7 (already mostly prepared in tip-625-for-9 branch) check-in: c3c75e63cd user: jan.nijtmans tags: trunk, main | |
10:00 | Merge 9.0 Closed-Leaf check-in: 35df7d21f1 user: jan.nijtmans tags: tip-625-for-9 | |
09:56 | Remove TODO's already done. Only use ListSizeT for types which are 'size_t' in the Tcl 9 implementat... check-in: b8d47e9100 user: jan.nijtmans tags: core-8-branch | |
2022-08-26
| ||
23:12 | Merge 8.7 check-in: 692e27d3f1 user: jan.nijtmans tags: trunk, main | |
2022-08-19
| ||
17:02 | Do tilde expansion when initializing from TCLLIBPATH and TM env vars check-in: e1f26efd78 user: apnadkarni tags: tip-602 | |
Changes to generic/tclCmdAH.c.
︙ | ︙ | |||
267 268 269 270 271 272 273 | Tcl_WrongNumArgs(interp, 1, objv, "?dirName?"); return TCL_ERROR; } if (objc == 2) { dir = objv[1]; } else { | > | > > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | Tcl_WrongNumArgs(interp, 1, objv, "?dirName?"); return TCL_ERROR; } if (objc == 2) { dir = objv[1]; } else { dir = TclGetHomeDirObj(interp, NULL); if (dir == NULL) { return TCL_ERROR; } Tcl_IncrRefCount(dir); } if (Tcl_FSConvertToPathType(interp, dir) != TCL_OK) { result = TCL_ERROR; } else { result = Tcl_FSChdir(dir); if (result != TCL_OK) { |
︙ | ︙ | |||
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 | {"channels", TclChannelNamesCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0}, {"copy", TclFileCopyCmd, NULL, NULL, NULL, 1}, {"delete", TclFileDeleteCmd, TclCompileBasicMin0ArgCmd, NULL, NULL, 1}, {"dirname", PathDirNameCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"executable", FileAttrIsExecutableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"exists", FileAttrIsExistingCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"extension", PathExtensionCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"isdirectory", FileAttrIsDirectoryCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"isfile", FileAttrIsFileCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"join", PathJoinCmd, TclCompileBasicMin1ArgCmd, NULL, NULL, 0}, {"link", TclFileLinkCmd, TclCompileBasic1To3ArgCmd, NULL, NULL, 1}, {"lstat", FileAttrLinkStatCmd, TclCompileBasic2ArgCmd, NULL, NULL, 1}, {"mtime", FileAttrModifyTimeCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 1}, {"mkdir", TclFileMakeDirsCmd, TclCompileBasicMin0ArgCmd, NULL, NULL, 1}, | > | 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | {"channels", TclChannelNamesCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0}, {"copy", TclFileCopyCmd, NULL, NULL, NULL, 1}, {"delete", TclFileDeleteCmd, TclCompileBasicMin0ArgCmd, NULL, NULL, 1}, {"dirname", PathDirNameCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"executable", FileAttrIsExecutableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"exists", FileAttrIsExistingCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"extension", PathExtensionCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"home", TclFileHomeCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 1}, {"isdirectory", FileAttrIsDirectoryCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"isfile", FileAttrIsFileCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"join", PathJoinCmd, TclCompileBasicMin1ArgCmd, NULL, NULL, 0}, {"link", TclFileLinkCmd, TclCompileBasic1To3ArgCmd, NULL, NULL, 1}, {"lstat", FileAttrLinkStatCmd, TclCompileBasic2ArgCmd, NULL, NULL, 1}, {"mtime", FileAttrModifyTimeCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 1}, {"mkdir", TclFileMakeDirsCmd, TclCompileBasicMin0ArgCmd, NULL, NULL, 1}, |
︙ | ︙ | |||
1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 | {"size", FileAttrSizeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"split", PathSplitCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0}, {"stat", FileAttrStatCmd, TclCompileBasic2ArgCmd, NULL, NULL, 1}, {"system", PathFilesystemCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0}, {"tail", PathTailCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"tempdir", TclFileTempDirCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 1}, {"tempfile", TclFileTemporaryCmd, TclCompileBasic0To2ArgCmd, NULL, NULL, 1}, {"type", FileAttrTypeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"volumes", FilesystemVolumesCmd, TclCompileBasic0ArgCmd, NULL, NULL, 1}, {"writable", FileAttrIsWritableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {NULL, NULL, NULL, NULL, NULL, 0} }; return TclMakeEnsemble(interp, "file", initMap); } | > | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | {"size", FileAttrSizeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"split", PathSplitCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0}, {"stat", FileAttrStatCmd, TclCompileBasic2ArgCmd, NULL, NULL, 1}, {"system", PathFilesystemCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0}, {"tail", PathTailCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"tempdir", TclFileTempDirCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 1}, {"tempfile", TclFileTemporaryCmd, TclCompileBasic0To2ArgCmd, NULL, NULL, 1}, {"tildeexpand", TclFileTildeExpandCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"type", FileAttrTypeCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {"volumes", FilesystemVolumesCmd, TclCompileBasic0ArgCmd, NULL, NULL, 1}, {"writable", FileAttrIsWritableCmd, TclCompileBasic1ArgCmd, NULL, NULL, 1}, {NULL, NULL, NULL, NULL, NULL, 0} }; return TclMakeEnsemble(interp, "file", initMap); } |
︙ | ︙ |
Changes to generic/tclEnv.c.
︙ | ︙ | |||
360 361 362 363 364 365 366 | */ Tcl_Free(p); #endif /* HAVE_PUTENV_THAT_COPIES */ } Tcl_MutexUnlock(&envMutex); | < < < < < < < < < | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | */ Tcl_Free(p); #endif /* HAVE_PUTENV_THAT_COPIES */ } Tcl_MutexUnlock(&envMutex); } /* *---------------------------------------------------------------------- * * Tcl_PutEnv -- * |
︙ | ︙ |
Changes to generic/tclFCmd.c.
︙ | ︙ | |||
878 879 880 881 882 883 884 | Tcl_Obj *splitPtr; Tcl_Obj *resultPtr = NULL; splitPtr = Tcl_FSSplitPath(pathPtr, &objc); Tcl_IncrRefCount(splitPtr); if (objc != 0) { | < < < < < < < < < | | | 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 | Tcl_Obj *splitPtr; Tcl_Obj *resultPtr = NULL; splitPtr = Tcl_FSSplitPath(pathPtr, &objc); Tcl_IncrRefCount(splitPtr); if (objc != 0) { /* * Return the last component, unless it is the only component, and it * is the root of an absolute path. */ if (objc > 0) { Tcl_ListObjIndex(NULL, splitPtr, objc-1, &resultPtr); if ((objc == 1) && (Tcl_FSGetPathType(resultPtr) != TCL_PATH_RELATIVE)) { |
︙ | ︙ | |||
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 | "can't create temporary directory: %s", Tcl_PosixError(interp))); return TCL_ERROR; } Tcl_SetObjResult(interp, dirNameObj); return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 | "can't create temporary directory: %s", Tcl_PosixError(interp))); return TCL_ERROR; } Tcl_SetObjResult(interp, dirNameObj); return TCL_OK; } /* *---------------------------------------------------------------------- * * TclFileHomeCmd -- * * This function is invoked to process the "file home" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * None. * *---------------------------------------------------------------------- */ int TclFileHomeCmd( TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Tcl_Obj *homeDirObj; if (objc != 1 && objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "?user?"); return TCL_ERROR; } homeDirObj = TclGetHomeDirObj(interp, objc == 1 ? NULL : Tcl_GetString(objv[1])); if (homeDirObj == NULL) { return TCL_ERROR; } Tcl_SetObjResult(interp, homeDirObj); return TCL_OK; } /* *---------------------------------------------------------------------- * * TclFileTildeExpandCmd -- * * This function is invoked to process the "file tildeexpand" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * None. * *---------------------------------------------------------------------- */ int TclFileTildeExpandCmd( TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Tcl_Obj *expandedPathObj; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "path"); return TCL_ERROR; } expandedPathObj = TclResolveTildePath(interp, objv[1]); if (expandedPathObj == NULL) { return TCL_ERROR; } Tcl_SetObjResult(interp, expandedPathObj); return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tclFileName.c.
︙ | ︙ | |||
358 359 360 361 362 363 364 | * Determines whether a given path is relative to the current directory, * relative to the current volume, or absolute, but ONLY FOR THE NATIVE * FILESYSTEM. This function is called from tclIOUtil.c (but needs to be * here due to its dependence on static variables/functions in this * file). The exported function Tcl_FSGetPathType should be used by * extensions. * | < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | * Determines whether a given path is relative to the current directory, * relative to the current volume, or absolute, but ONLY FOR THE NATIVE * FILESYSTEM. This function is called from tclIOUtil.c (but needs to be * here due to its dependence on static variables/functions in this * file). The exported function Tcl_FSGetPathType should be used by * extensions. * * Results: * Returns one of TCL_PATH_ABSOLUTE, TCL_PATH_RELATIVE, or * TCL_PATH_VOLUME_RELATIVE. * * Side effects: * None. * *---------------------------------------------------------------------- */ Tcl_PathType TclpGetNativePathType( Tcl_Obj *pathPtr, /* Native path of interest */ size_t *driveNameLengthPtr, /* Returns length of drive, if non-NULL and * path was absolute */ Tcl_Obj **driveNameRef) { Tcl_PathType type = TCL_PATH_ABSOLUTE; const char *path = TclGetString(pathPtr); switch (tclPlatform) { case TCL_PLATFORM_UNIX: { const char *origPath = path; /* * Paths that begin with / are absolute. */ if (path[0] == '/') { ++path; #if defined(__CYGWIN__) || defined(__QNX__) /* * Check for "//" network path prefix */ if ((*path == '/') && path[1] && (path[1] != '/')) { path += 2; 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. */ *driveNameLengthPtr = (path - origPath); } } else { type = TCL_PATH_RELATIVE; } break; } case TCL_PLATFORM_WINDOWS: { Tcl_DString ds; const char *rootEnd; Tcl_DStringInit(&ds); rootEnd = ExtractWinRoot(path, &ds, 0, &type); if ((rootEnd != path) && (driveNameLengthPtr != NULL)) { *driveNameLengthPtr = rootEnd - path; if (driveNameRef != NULL) { *driveNameRef = TclDStringToObj(&ds); Tcl_IncrRefCount(*driveNameRef); } } Tcl_DStringFree(&ds); break; } } return type; } /* *--------------------------------------------------------------------------- * |
︙ | ︙ | |||
693 694 695 696 697 698 699 | elementStart = path; while ((*path != '\0') && (*path != '/')) { path++; } length = path - elementStart; if (length > 0) { Tcl_Obj *nextElt; | < < < < | < | | 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | elementStart = path; while ((*path != '\0') && (*path != '/')) { path++; } length = path - elementStart; if (length > 0) { Tcl_Obj *nextElt; nextElt = Tcl_NewStringObj(elementStart, length); Tcl_ListObjAppendElement(NULL, result, nextElt); } if (*path++ == '\0') { break; } } return result; } |
︙ | ︙ | |||
762 763 764 765 766 767 768 | elementStart = p; while ((*p != '\0') && (*p != '/') && (*p != '\\')) { p++; } length = p - elementStart; if (length > 0) { Tcl_Obj *nextElt; | | | | | | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | elementStart = p; while ((*p != '\0') && (*p != '/') && (*p != '\\')) { p++; } length = p - elementStart; if (length > 0) { Tcl_Obj *nextElt; if ((elementStart != path) && isalpha(UCHAR(elementStart[0])) && (elementStart[1] == ':')) { TclNewLiteralStringObj(nextElt, "./"); Tcl_AppendToObj(nextElt, elementStart, length); } else { nextElt = Tcl_NewStringObj(elementStart, length); } Tcl_ListObjAppendElement(NULL, result, nextElt); } } while (*p++ != '\0'); |
︙ | ︙ | |||
867 868 869 870 871 872 873 | * Remove the ./ from tilde prefixed elements, and drive-letter prefixed * elements on Windows, unless it is the first component. */ p = joining; if (length != 0) { | | > | > | | | 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | * Remove the ./ from tilde prefixed elements, and drive-letter prefixed * elements on Windows, unless it is the first component. */ p = joining; if (length != 0) { if ((p[0] == '.') && (p[1] == '/') && (tclPlatform==TCL_PLATFORM_WINDOWS) && isalpha(UCHAR(p[2])) && (p[3] == ':')) { p += 2; } } if (*p == '\0') { return; } switch (tclPlatform) { |
︙ | ︙ | |||
1141 1142 1143 1144 1145 1146 1147 | * so that "foo..o" would be split into "foo" and "..o". This is a * confusing and usually incorrect behavior, so now we split at the last * period in the name. */ return p; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 | * so that "foo..o" would be split into "foo" and "..o". This is a * confusing and usually incorrect behavior, so now we split at the last * period in the name. */ return p; } /* *---------------------------------------------------------------------- * * Tcl_GlobObjCmd -- * * This procedure is invoked to process the "glob" Tcl command. See the |
︙ | ︙ | |||
1725 1726 1727 1728 1729 1730 1731 | Tcl_Obj *pathPrefix, /* Path prefix to glob pattern, if non-null, * which is considered literally. */ int globFlags, /* Stores or'ed combination of flags */ Tcl_GlobTypeData *types) /* Struct containing acceptable types. May be * NULL. */ { const char *separators; | < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < | < < < < < | 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 | Tcl_Obj *pathPrefix, /* Path prefix to glob pattern, if non-null, * which is considered literally. */ int globFlags, /* Stores or'ed combination of flags */ Tcl_GlobTypeData *types) /* Struct containing acceptable types. May be * NULL. */ { const char *separators; char *tail; int result; Tcl_Obj *filenamesObj, *savedResultObj; separators = NULL; switch (tclPlatform) { case TCL_PLATFORM_UNIX: separators = "/"; break; case TCL_PLATFORM_WINDOWS: separators = "/\\:"; break; } if (pathPrefix != NULL) { Tcl_IncrRefCount(pathPrefix); } tail = pattern; /* * Handling empty path prefixes with glob patterns like 'C:' or * 'c:////////' is a pain on Windows if we leave it too late, since these * aren't really patterns at all! We therefore check the head of the * pattern now for such cases, if we don't have an unquoted prefix yet. * |
︙ | ︙ | |||
2347 2348 2349 2350 2351 2352 2353 | Tcl_Obj **subdirv; result = TclListObjGetElementsM(interp, subdirsPtr, &subdirc, &subdirv); for (i=0; result==TCL_OK && i<subdirc; i++) { Tcl_Obj *copy = NULL; | < < < < < < < | | 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 | Tcl_Obj **subdirv; result = TclListObjGetElementsM(interp, subdirsPtr, &subdirc, &subdirv); for (i=0; result==TCL_OK && i<subdirc; i++) { Tcl_Obj *copy = NULL; result = DoGlob(interp, matchesObj, separators, subdirv[i], 1, p+1, types); if (copy) { size_t end; Tcl_DecrRefCount(subdirv[i]); subdirv[i] = copy; TclListObjLengthM(NULL, matchesObj, &end); |
︙ | ︙ |
Changes to generic/tclIOUtil.c.
︙ | ︙ | |||
1209 1210 1211 1212 1213 1214 1215 | * (2) An additional mount point is established inside an existing * filesystem (except for the native file system; see note below). * * (3) A filesystem changes the list of available volumes (except for the * native file system; see note below). * * (4) The mapping from a string representation of a file to a full, | | < < | 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 | * (2) An additional mount point is established inside an existing * filesystem (except for the native file system; see note below). * * (3) A filesystem changes the list of available volumes (except for the * native file system; see note below). * * (4) The mapping from a string representation of a file to a full, * normalized pathname changes. * * Tcl has no control over (2) and (3), so each registered filesystem must * call Tcl_FSMountsChnaged in each of those circumstances. * * The reason for the exception in 2,3 for the native filesystem is that * the native filesystem claims every file without determining whether * whether the file exists, or even whether the pathname makes sense. |
︙ | ︙ | |||
3934 3935 3936 3937 3938 3939 3940 | while ((*p != '\0') && (*p != separator)) { p++; } length = p - elementStart; if (length > 0) { Tcl_Obj *nextElt; | < < < < < | < | | 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 | while ((*p != '\0') && (*p != separator)) { p++; } length = p - elementStart; if (length > 0) { Tcl_Obj *nextElt; nextElt = Tcl_NewStringObj(elementStart, length); Tcl_ListObjAppendElement(NULL, result, nextElt); } if (*p++ == '\0') { break; } } if (lenPtr != NULL) { |
︙ | ︙ |
Changes to generic/tclInt.h.
︙ | ︙ | |||
3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 | MODULE_SCOPE Tcl_ObjCmdProc TclFileDeleteCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileLinkCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileMakeDirsCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileReadLinkCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileRenameCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileTempDirCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileTemporaryCmd; MODULE_SCOPE void TclCreateLateExitHandler(Tcl_ExitProc *proc, void *clientData); MODULE_SCOPE void TclDeleteLateExitHandler(Tcl_ExitProc *proc, void *clientData); MODULE_SCOPE char * TclDStringAppendObj(Tcl_DString *dsPtr, Tcl_Obj *objPtr); MODULE_SCOPE char * TclDStringAppendDString(Tcl_DString *dsPtr, | > > | 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 | MODULE_SCOPE Tcl_ObjCmdProc TclFileDeleteCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileLinkCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileMakeDirsCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileReadLinkCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileRenameCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileTempDirCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileTemporaryCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileHomeCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileTildeExpandCmd; MODULE_SCOPE void TclCreateLateExitHandler(Tcl_ExitProc *proc, void *clientData); MODULE_SCOPE void TclDeleteLateExitHandler(Tcl_ExitProc *proc, void *clientData); MODULE_SCOPE char * TclDStringAppendObj(Tcl_DString *dsPtr, Tcl_Obj *objPtr); MODULE_SCOPE char * TclDStringAppendDString(Tcl_DString *dsPtr, |
︙ | ︙ | |||
3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 | MODULE_SCOPE void TclInitNotifier(void); MODULE_SCOPE void TclInitObjSubsystem(void); MODULE_SCOPE int TclInterpReady(Tcl_Interp *interp); MODULE_SCOPE int TclIsDigitProc(int byte); MODULE_SCOPE int TclIsBareword(int byte); MODULE_SCOPE Tcl_Obj * TclJoinPath(size_t elements, Tcl_Obj * const objv[], int forceRelative); MODULE_SCOPE int TclJoinThread(Tcl_ThreadId id, int *result); MODULE_SCOPE void TclLimitRemoveAllHandlers(Tcl_Interp *interp); MODULE_SCOPE Tcl_Obj * TclLindexList(Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Obj *argPtr); MODULE_SCOPE Tcl_Obj * TclLindexFlat(Tcl_Interp *interp, Tcl_Obj *listPtr, size_t indexCount, Tcl_Obj *const indexArray[]); /* TIP #280 */ | > > > > > > | 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 | MODULE_SCOPE void TclInitNotifier(void); MODULE_SCOPE void TclInitObjSubsystem(void); MODULE_SCOPE int TclInterpReady(Tcl_Interp *interp); MODULE_SCOPE int TclIsDigitProc(int byte); MODULE_SCOPE int TclIsBareword(int byte); MODULE_SCOPE Tcl_Obj * TclJoinPath(size_t elements, Tcl_Obj * const objv[], int forceRelative); MODULE_SCOPE int MakeTildeRelativePath(Tcl_Interp *interp, const char *user, const char *subPath, Tcl_DString *dsPtr); MODULE_SCOPE Tcl_Obj * TclGetHomeDirObj(Tcl_Interp *interp, const char *user); MODULE_SCOPE Tcl_Obj * TclResolveTildePath(Tcl_Interp *interp, Tcl_Obj *pathObj); MODULE_SCOPE Tcl_Obj * TclResolveTildePathList(Tcl_Obj *pathsObj); MODULE_SCOPE int TclJoinThread(Tcl_ThreadId id, int *result); MODULE_SCOPE void TclLimitRemoveAllHandlers(Tcl_Interp *interp); MODULE_SCOPE Tcl_Obj * TclLindexList(Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Obj *argPtr); MODULE_SCOPE Tcl_Obj * TclLindexFlat(Tcl_Interp *interp, Tcl_Obj *listPtr, size_t indexCount, Tcl_Obj *const indexArray[]); /* TIP #280 */ |
︙ | ︙ |
Changes to generic/tclPathObj.c.
︙ | ︙ | |||
21 22 23 24 25 26 27 | static Tcl_Obj * AppendPath(Tcl_Obj *head, Tcl_Obj *tail); static void DupFsPathInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void FreeFsPathInternalRep(Tcl_Obj *pathPtr); static void UpdateStringOfFsPath(Tcl_Obj *pathPtr); static int SetFsPathFromAny(Tcl_Interp *interp, Tcl_Obj *pathPtr); | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | static Tcl_Obj * AppendPath(Tcl_Obj *head, Tcl_Obj *tail); static void DupFsPathInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void FreeFsPathInternalRep(Tcl_Obj *pathPtr); static void UpdateStringOfFsPath(Tcl_Obj *pathPtr); static int SetFsPathFromAny(Tcl_Interp *interp, Tcl_Obj *pathPtr); static size_t FindSplitPos(const char *path, int separator); static int IsSeparatorOrNull(int ch); static Tcl_Obj * GetExtension(Tcl_Obj *pathPtr); static int MakePathFromNormalized(Tcl_Interp *interp, Tcl_Obj *pathPtr); /* * Define the 'path' object type, which Tcl uses to represent file paths |
︙ | ︙ | |||
695 696 697 698 699 700 701 | * Tcl_FSSplitPath in the handling of home directories; * Tcl_FSSplitPath preserves the "~", but this code computes the * actual full path name, if we had just a single component. */ splitPtr = Tcl_FSSplitPath(pathPtr, &splitElements); Tcl_IncrRefCount(splitPtr); | < < < < < < < < < < | | 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | * Tcl_FSSplitPath in the handling of home directories; * Tcl_FSSplitPath preserves the "~", but this code computes the * actual full path name, if we had just a single component. */ splitPtr = Tcl_FSSplitPath(pathPtr, &splitElements); Tcl_IncrRefCount(splitPtr); if (portion == TCL_PATH_TAIL) { /* * Return the last component, unless it is the only component, and * it is the root of an absolute path. */ if ((splitElements > 0) && ((splitElements > 1) || (Tcl_FSGetPathType(pathPtr) == TCL_PATH_RELATIVE))) { |
︙ | ︙ | |||
1034 1035 1036 1037 1038 1039 1040 | noQuickReturn: if (res == NULL) { TclNewObj(res); } ptr = Tcl_GetStringFromObj(res, &length); | | < < < < < < < < < < | | 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 | noQuickReturn: if (res == NULL) { TclNewObj(res); } ptr = Tcl_GetStringFromObj(res, &length); /* * A NULL value for fsPtr at this stage basically means we're trying * to join a relative path onto something which is also relative (or * empty). There's nothing particularly wrong with that. */ if (*strElt == '\0') { continue; } |
︙ | ︙ | |||
1242 1243 1244 1245 1246 1247 1248 | size_t len) { FsPath *fsPathPtr; Tcl_Obj *pathPtr; const char *p; int state = 0, count = 0; | > > > | < < < < < < < | 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 | size_t len) { FsPath *fsPathPtr; Tcl_Obj *pathPtr; const char *p; int state = 0, count = 0; /* * This comment is kept from the days of tilde expansion because * it is illustrative of a more general problem. * [Bug 2806250] - this is only a partial solution of the problem. * The PATHFLAGS != 0 representation assumes in many places that * the "tail" part stored in the normPathPtr field is itself a * relative path. Strings that begin with "~" are not relative paths, * so we must prevent their storage in the normPathPtr field. * * More generally we ought to be testing "addStrRep" for any value * that is not a relative path, but in an unconstrained VFS world * that could be just about anything, and testing could be expensive. * Since this routine plays a big role in [glob], anything that slows * it down would be unwelcome. For now, continue the risk of further * bugs when some Tcl_Filesystem uses otherwise relative path strings * as absolute path strings. Sensible Tcl_Filesystems will avoid * that by mounting on path prefixes like foo:// which cannot be the * name of a file or directory read from a native [glob] operation. */ TclNewObj(pathPtr); fsPathPtr = (FsPath *)Tcl_Alloc(sizeof(FsPath)); /* * Set up the path. */ |
︙ | ︙ | |||
2221 2222 2223 2224 2225 2226 2227 | * * However, the split/join routines are quite complex, and one has to make * sure not to break anything on Unix or Win (fCmd.test, fileName.test and * cmdAH.test exercise most of the code). */ name = Tcl_GetStringFromObj(pathPtr, &len); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 | * * However, the split/join routines are quite complex, and one has to make * sure not to break anything on Unix or Win (fCmd.test, fileName.test and * cmdAH.test exercise most of the code). */ name = Tcl_GetStringFromObj(pathPtr, &len); transPtr = TclJoinPath(1, &pathPtr, 1); /* * Now we have a translated filename in 'transPtr'. This will have forward * slashes on Windows, and will not contain any ~user sequences. */ fsPathPtr = (FsPath *)Tcl_Alloc(sizeof(FsPath)); |
︙ | ︙ | |||
2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 | /* * Path is of correct type, or is of non-zero length, so we accept it. */ return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 | /* * Path is of correct type, or is of non-zero length, so we accept it. */ return TCL_OK; } /* *---------------------------------------------------------------------- * * MakeTildeRelativePath -- * * Returns a path relative to the home directory of a user. * Note there is a difference between not specifying a user and * explicitly specifying the current user. This mimics Tcl8's tilde * expansion. * * The subPath argument is joined to the expanded home directory * as in Tcl_JoinPath. This means if it is not relative, it will * returned as the result with the home directory only checked * for user name validity. * * Results: * Returns TCL_OK on success with home directory path in *dsPtr * and TCL_ERROR on failure with error message in interp if non-NULL. * *---------------------------------------------------------------------- */ int MakeTildeRelativePath( Tcl_Interp *interp, /* May be NULL. Only used for error messages */ const char *user, /* User name. NULL -> current user */ const char *subPath, /* Rest of path. May be NULL */ Tcl_DString *dsPtr) /* Output. Is initialized by the function. Must be freed on success */ { const char *dir; Tcl_DString dirString; Tcl_DStringInit(dsPtr); Tcl_DStringInit(&dirString); if (user == NULL || user[0] == 0) { /* No user name specified -> current user */ dir = TclGetEnv("HOME", &dirString); if (dir == NULL) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't find HOME environment variable to" " expand path", -1)); Tcl_SetErrorCode(interp, "TCL", "VALUE", "PATH", "HOMELESS", NULL); } return TCL_ERROR; } } else { /* User name specified - ~user */ dir = TclpGetUserHome(user, &dirString); if (dir == NULL) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "user \"%s\" doesn't exist", user)); Tcl_SetErrorCode(interp, "TCL", "VALUE", "PATH", "NOUSER", NULL); } return TCL_ERROR; } } if (subPath) { const char *parts[2]; parts[0] = dir; parts[1] = subPath; Tcl_JoinPath(2, parts, dsPtr); } else { Tcl_JoinPath(1, &dir, dsPtr); } Tcl_DStringFree(&dirString); return TCL_OK; } /* *---------------------------------------------------------------------- * * TclGetHomeDirObj -- * * Wrapper around MakeTildeRelativePath. See that function. * * Results: * Returns a Tcl_Obj containing the home directory of a user * or NULL on failure with error message in interp if non-NULL. * *---------------------------------------------------------------------- */ Tcl_Obj * TclGetHomeDirObj( Tcl_Interp *interp, /* May be NULL. Only used for error messages */ const char *user) /* User name. NULL -> current user */ { Tcl_DString dirString; if (MakeTildeRelativePath(interp, user, NULL, &dirString) != TCL_OK) { return NULL; } return TclDStringToObj(&dirString); } /* *---------------------------------------------------------------------- * * TclResolveTildePath -- * * If the passed path is begins with a tilde, does tilde resolution * and returns a Tcl_Obj containing the resolved path. If the tilde * component cannot be resolved, returns NULL. If the path does not * begin with a tilde, returns as is. * * Results: * Returns a Tcl_Obj with resolved path. This may be a new Tcl_Obj * with ref count 0 or that pathObj that was passed in without its * ref count modified. * Returns NULL if the path begins with a ~ that cannot be resolved * and stores an error message in interp if non-NULL. * *---------------------------------------------------------------------- */ Tcl_Obj * TclResolveTildePath( Tcl_Interp *interp, /* May be NULL. Only used for error messages */ Tcl_Obj *pathObj) { const char *path; size_t len; size_t split; Tcl_DString resolvedPath; path = Tcl_GetStringFromObj(pathObj, &len); if (path[0] != '~') { return pathObj; } /* * We have multiple cases '~/foo/bar...', '~user/foo/bar...', etc. * split becomes value 1 for '~/...' as well as for '~'. Note on * Windows FindSplitPos will implicitly check for '\' as separator * in addition to what is passed. */ split = FindSplitPos(path, '/'); if (split == 1) { /* No user name specified -> current user */ if (MakeTildeRelativePath( interp, NULL, path[1] ? 2 + path : NULL, &resolvedPath) != TCL_OK) { return NULL; } } else { /* User name specified - ~user */ const char *expandedUser; Tcl_DString userName; Tcl_DStringInit(&userName); Tcl_DStringAppend(&userName, path+1, split-1); expandedUser = Tcl_DStringValue(&userName); /* path[split] is / or \0 */ if (MakeTildeRelativePath(interp, expandedUser, path[split] ? &path[split+1] : NULL, &resolvedPath) != TCL_OK) { Tcl_DStringFree(&userName); return NULL; } Tcl_DStringFree(&userName); } return TclDStringToObj(&resolvedPath); } /* *---------------------------------------------------------------------- * * TclResolveTildePathList -- * * Given a Tcl_Obj that is a list of paths, returns a Tcl_Obj containing * the paths with any ~-prefixed paths resolved. * * Empty strings and ~-prefixed paths that cannot be resolved are * removed from the returned list. * * The trailing components of the path are returned verbatim. No * processing is done on them. Moreover, no assumptions should be * made about the separators in the returned path. They may be / * or native. Appropriate path manipulations functions should be * used by caller if desired. * * Results: * Returns a Tcl_Obj with resolved paths. This may be a new Tcl_Obj with * reference count 0 or the original passed-in Tcl_Obj if no paths needed * resolution. A NULL is returned if the passed in value is not a list * or was NULL. * *---------------------------------------------------------------------- */ Tcl_Obj * TclResolveTildePathList( Tcl_Obj *pathsObj) { Tcl_Obj **objv; size_t objc; size_t i; Tcl_Obj *resolvedPaths; const char *path; if (pathsObj == NULL) { return NULL; } if (Tcl_ListObjGetElements(NULL, pathsObj, &objc, &objv) != TCL_OK) { return NULL; /* Not a list */ } /* * Figure out if any paths need resolving to avoid unnecessary allocations. */ for (i = 0; i < objc; ++i) { path = Tcl_GetString(objv[i]); if (path[0] == '~') { break; /* At least one path needs resolution */ } } if (i == objc) { return pathsObj; /* No paths needed to be resolved */ } resolvedPaths = Tcl_NewListObj(objc, NULL); for (i = 0; i < objc; ++i) { Tcl_Obj *resolvedPath; path = Tcl_GetString(objv[i]); if (path[0] == 0) { continue; /* Skip empty strings */ } resolvedPath = TclResolveTildePath(NULL, objv[i]); if (resolvedPath) { /* Paths that cannot be resolved are skipped */ Tcl_ListObjAppendElement(NULL, resolvedPaths, resolvedPath); } } return resolvedPaths; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to library/init.tcl.
︙ | ︙ | |||
43 44 45 46 47 48 49 | # # (Ticket 41c9857bdd) In a safe interpreter, this file does not set # ::auto_path (other than to {} if it is undefined). The caller, typically # a Safe Base command, is responsible for setting ::auto_path. if {![info exists auto_path]} { if {[info exists env(TCLLIBPATH)] && (![interp issafe])} { | | > > > > > > > > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # # (Ticket 41c9857bdd) In a safe interpreter, this file does not set # ::auto_path (other than to {} if it is undefined). The caller, typically # a Safe Base command, is responsible for setting ::auto_path. if {![info exists auto_path]} { if {[info exists env(TCLLIBPATH)] && (![interp issafe])} { set auto_path [apply {{} { lmap path $::env(TCLLIBPATH) { # Paths relative to unresolvable home dirs are ignored if {[catch {file tildeexpand $path} expanded_path]} { continue } set expanded_path } }}] } else { set auto_path "" } } namespace eval tcl { if {![interp issafe]} { variable Dir |
︙ | ︙ |
Changes to library/safe.tcl.
︙ | ︙ | |||
729 730 731 732 733 734 735 | } # AliasFileSubcommand handles selected subcommands of [file] in safe # interpreters that are *almost* safe. In particular, it just acts to # prevent discovery of what home directories exist. proc ::safe::AliasFileSubcommand {child subcommand name} { | < < < | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | } # AliasFileSubcommand handles selected subcommands of [file] in safe # interpreters that are *almost* safe. In particular, it just acts to # prevent discovery of what home directories exist. proc ::safe::AliasFileSubcommand {child subcommand name} { tailcall ::interp invokehidden $child tcl:file:$subcommand $name } # AliasGlob is the target of the "glob" alias in safe interpreters. proc ::safe::AliasGlob {child args} { Log $child "GLOB ! $args" NOTICE |
︙ | ︙ |
Changes to library/tm.tcl.
︙ | ︙ | |||
334 335 336 337 338 339 340 | for {set n $minor} {$n >= 0} {incr n -1} { foreach ev [::list \ TCL${major}.${n}_TM_PATH \ TCL${major}_${n}_TM_PATH \ ] { if {![info exists env($ev)]} continue foreach p [split $env($ev) $sep] { | > > | > | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | for {set n $minor} {$n >= 0} {incr n -1} { foreach ev [::list \ TCL${major}.${n}_TM_PATH \ TCL${major}_${n}_TM_PATH \ ] { if {![info exists env($ev)]} continue foreach p [split $env($ev) $sep] { # Paths relative to unresolvable home dirs are ignored if {![catch {file tildeexpand $p} expanded_path]} { path add $expanded_path } } } } return } # ::tcl::tm::roots -- |
︙ | ︙ |
Changes to tests/chanio.test.
︙ | ︙ | |||
57 58 59 60 61 62 63 | testConstraint largefileSupport [expr {$::tcl_platform(os) ne "Darwin"}] # some tests can only be run is umask is 2 if "umask" cannot be run, the # tests will be skipped. set umaskValue 0 testConstraint umask [expr {![catch {set umaskValue [scan [exec /bin/sh -c umask] %o]}]}] | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | testConstraint largefileSupport [expr {$::tcl_platform(os) ne "Darwin"}] # some tests can only be run is umask is 2 if "umask" cannot be run, the # tests will be skipped. set umaskValue 0 testConstraint umask [expr {![catch {set umaskValue [scan [exec /bin/sh -c umask] %o]}]}] testConstraint makeFileInHome [expr {![file exists $::env(HOME)/_test_] && [file writable $::env(HOME)]}] # set up a long data file for some of the following tests set path(longfile) [makeFile {} longfile] set f [open $path(longfile) w] chan configure $f -eofchar {} -translation lf for { set i 0 } { $i < 100 } { incr i} { |
︙ | ︙ | |||
5484 5485 5486 5487 5488 5489 5490 | set f [open $path(test3) RDWR] chan puts -nonewline $f "ab" chan seek $f 0 current set x [chan gets $f] chan close $f lappend x [viewFile test3] } {zzy abzzy} | | | > > | < > > < < < < < < < < | 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 | set f [open $path(test3) RDWR] chan puts -nonewline $f "ab" chan seek $f 0 current set x [chan gets $f] chan close $f lappend x [viewFile test3] } {zzy abzzy} test chan-io-40.16 {verify no tilde substitution in open} -setup { set curdir [pwd] cd [temporaryDirectory] } -body { close [open ~ w] list [file isfile ~] } -cleanup { file delete ./~ ;# ./ because don't want to delete home in case of bugs! cd $curdir } -result 1 test chan-io-41.1 {Tcl_FileeventCmd: errors} -constraints fileevent -body { chan event foo } -returnCodes error -result {wrong # args: should be "chan event channelId event ?script?"} test chan-io-41.2 {Tcl_FileeventCmd: errors} -constraints fileevent -body { chan event foo bar baz q } -returnCodes error -result {wrong # args: should be "chan event channelId event ?script?"} |
︙ | ︙ |
Changes to tests/cmdAH.test.
︙ | ︙ | |||
96 97 98 99 100 101 102 | set oldpwd [pwd] set temp $env(HOME) file delete -force $foodir } -body { set env(HOME) $oldpwd file mkdir $foodir cd $foodir | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | set oldpwd [pwd] set temp $env(HOME) file delete -force $foodir } -body { set env(HOME) $oldpwd file mkdir $foodir cd $foodir cd [file home] string equal [pwd] $oldpwd } -cleanup { cd $oldpwd file delete $foodir set env(HOME) $temp } -result 1 test cmdAH-2.4 {Tcl_CdObjCmd} -setup { |
︙ | ︙ | |||
120 121 122 123 124 125 126 | string equal [pwd] $oldpwd } -cleanup { cd $oldpwd file delete $foodir set env(HOME) $temp } -result 1 test cmdAH-2.5 {Tcl_CdObjCmd} -returnCodes error -body { | | > > > > > > > > > > > > > | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | string equal [pwd] $oldpwd } -cleanup { cd $oldpwd file delete $foodir set env(HOME) $temp } -result 1 test cmdAH-2.5 {Tcl_CdObjCmd} -returnCodes error -body { cd ~ } -result {couldn't change working directory to "~": no such file or directory} test cmdAH-2.5.1 {Tcl_CdObjCmd} -setup { set oldpwd [pwd] cd [temporaryDirectory] file delete ./~ file mkdir ~ } -body { cd ~ pwd } -cleanup { cd [temporaryDirectory] file delete ./~ cd $oldpwd } -result [file join [temporaryDirectory] ~] test cmdAH-2.6 {Tcl_CdObjCmd} -returnCodes error -body { cd _foobar } -result {couldn't change working directory to "_foobar": no such file or directory} test cmdAH-2.6.1 {Tcl_CdObjCmd} -returnCodes error -body { cd "" } -result {couldn't change working directory to "": no such file or directory} test cmdAH-2.6.2 {cd} -constraints {unix nonPortable} -setup { |
︙ | ︙ | |||
345 346 347 348 349 350 351 | } test cmdAH-5.1 {Tcl_FileObjCmd} -returnCodes error -body { file } -result {wrong # args: should be "file subcommand ?arg ...?"} test cmdAH-5.2 {Tcl_FileObjCmd} -returnCodes error -body { file x | | | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | } test cmdAH-5.1 {Tcl_FileObjCmd} -returnCodes error -body { file } -result {wrong # args: should be "file subcommand ?arg ...?"} test cmdAH-5.2 {Tcl_FileObjCmd} -returnCodes error -body { file x } -result {unknown or ambiguous subcommand "x": must be atime, attributes, channels, copy, delete, dirname, executable, exists, extension, home, isdirectory, isfile, join, link, lstat, mkdir, mtime, nativename, normalize, owned, pathtype, readable, readlink, rename, rootname, separator, size, split, stat, system, tail, tempdir, tempfile, type, volumes, or writable} test cmdAH-5.3 {Tcl_FileObjCmd} -returnCodes error -body { file exists } -result {wrong # args: should be "file exists name"} test cmdAH-5.4 {Tcl_FileObjCmd} { file exists "" } 0 |
︙ | ︙ | |||
492 493 494 495 496 497 498 | } ~bar test cmdAH-8.43 {Tcl_FileObjCmd: dirname} -setup { global env set temp $env(HOME) } -constraints testsetplatform -body { set env(HOME) "/homewontexist/test" testsetplatform unix | | | | | < < < < < < | | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | } ~bar test cmdAH-8.43 {Tcl_FileObjCmd: dirname} -setup { global env set temp $env(HOME) } -constraints testsetplatform -body { set env(HOME) "/homewontexist/test" testsetplatform unix file dirname [file home] } -cleanup { set env(HOME) $temp } -result /homewontexist test cmdAH-8.44 {Tcl_FileObjCmd: dirname} -setup { global env set temp $env(HOME) } -constraints testsetplatform -body { set env(HOME) "~" testsetplatform unix file dirname [file home] } -cleanup { set env(HOME) $temp } -result . test cmdAH-8.45 {Tcl_FileObjCmd: dirname ~} -body { file dirname ~ } -result . test cmdAH-8.46 {Tcl_FileObjCmd: dirname} { set f [file normalize [info nameof]] file exists $f set res1 [file dirname [file join $f foo/bar]] set res2 [file dirname "${f}/foo/bar"] if {$res1 eq $res2} { return "ok" |
︙ | ︙ | |||
622 623 624 625 626 627 628 | testsetplatform windows file tail {//foo/bar/baz} } baz test cmdAH-9.26 {Tcl_FileObjCmd: tail} testsetplatform { testsetplatform windows file tail {//foo/bar} } {} | | < < < < < < < | | | < < < < < < < < < < | 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | testsetplatform windows file tail {//foo/bar/baz} } baz test cmdAH-9.26 {Tcl_FileObjCmd: tail} testsetplatform { testsetplatform windows file tail {//foo/bar} } {} test cmdAH-9.42 {Tcl_FileObjCmd: tail ~} -body { file tail ~ } -result ~ test cmdAH-9.43 {Tcl_FileObjCmd: tail} -constraints testsetplatform -setup { global env set temp $env(HOME) } -body { set env(HOME) "~" testsetplatform unix file tail [file home] } -cleanup { set env(HOME) $temp } -result ~ test cmdAH-9.46 {Tcl_FileObjCmd: tail} testsetplatform { testsetplatform unix file tail {f.oo\bar/baz.bat} } baz.bat test cmdAH-9.47 {Tcl_FileObjCmd: tail} testsetplatform { testsetplatform windows file tail c:foo |
︙ | ︙ | |||
682 683 684 685 686 687 688 | } bar test cmdAH-9.52 {Tcl_FileObjCmd: tail / normalize, bug 7a9dc52b29} { list \ [file tail {~/~foo}] \ [file tail {~/test/~foo}] \ [file tail [file normalize {~/~foo}]] \ [file tail [file normalize {~/test/~foo}]] | | | 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 | } bar test cmdAH-9.52 {Tcl_FileObjCmd: tail / normalize, bug 7a9dc52b29} { list \ [file tail {~/~foo}] \ [file tail {~/test/~foo}] \ [file tail [file normalize {~/~foo}]] \ [file tail [file normalize {~/test/~foo}]] } [lrepeat 4 ~foo] # rootname test cmdAH-10.1 {Tcl_FileObjCmd: rootname} -returnCodes error -body { file rootname a b } -result {wrong # args: should be "file rootname name"} test cmdAH-10.2 {Tcl_FileObjCmd: rootname} testsetplatform { testsetplatform unix |
︙ | ︙ | |||
936 937 938 939 940 941 942 | file join a b c d } a/b/c/d # error handling of Tcl_TranslateFileName test cmdAH-15.1 {Tcl_FileObjCmd} -constraints testsetplatform -body { testsetplatform unix file atime ~_bad_user | | | 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | file join a b c d } a/b/c/d # error handling of Tcl_TranslateFileName test cmdAH-15.1 {Tcl_FileObjCmd} -constraints testsetplatform -body { testsetplatform unix file atime ~_bad_user } -returnCodes error -result {could not read "~_bad_user": no such file or directory} catch {testsetplatform $platform} # readable set gorpfile [makeFile abcde gorp.file] set dirfile [makeDirectory dir.file] test cmdAH-16.1 {Tcl_FileObjCmd: readable} { |
︙ | ︙ | |||
1059 1060 1061 1062 1063 1064 1065 | } -constraints testsetplatform -cleanup { testsetplatform $platform } -result {a\b} test cmdAH-19.9 {Tcl_FileObjCmd: ~ : exists} { file exists ~nOsUcHuSeR } 0 test cmdAH-19.10 {Tcl_FileObjCmd: ~ : nativename} -body { | < | | 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 | } -constraints testsetplatform -cleanup { testsetplatform $platform } -result {a\b} test cmdAH-19.9 {Tcl_FileObjCmd: ~ : exists} { file exists ~nOsUcHuSeR } 0 test cmdAH-19.10 {Tcl_FileObjCmd: ~ : nativename} -body { file nativename ~nOsUcHuSeR } -result ~nOsUcHuSeR # The test below has to be done in /tmp rather than the current directory in # order to guarantee (?) a local file system: some NFS file systems won't do # the stuff below correctly. test cmdAH-19.11 {Tcl_FileObjCmd: exists} -constraints {unix notRoot} -setup { file delete -force /tmp/tcl.foo.dir/file file delete -force /tmp/tcl.foo.dir } -body { |
︙ | ︙ | |||
1676 1677 1678 1679 1680 1681 1682 | } set res } -result "characterSpecial" # Error conditions test cmdAH-30.1 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { file gorp x | | < < < | 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | } set res } -result "characterSpecial" # Error conditions test cmdAH-30.1 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { file gorp x } -result {unknown or ambiguous subcommand "gorp": must be atime, attributes, channels, copy, delete, dirname, executable, exists, extension, home, isdirectory, isfile, join, link, lstat, mkdir, mtime, nativename, normalize, owned, pathtype, readable, readlink, rename, rootname, separator, size, split, stat, system, tail, tempdir, tempfile, type, volumes, or writable} test cmdAH-30.2 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { file ex x } -match glob -result {unknown or ambiguous subcommand "ex": must be *} test cmdAH-30.3 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { file is x } -match glob -result {unknown or ambiguous subcommand "is": must be *} test cmdAH-30.4 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { file z x } -match glob -result {unknown or ambiguous subcommand "z": must be *} test cmdAH-30.5 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { file read x } -match glob -result {unknown or ambiguous subcommand "read": must be *} test cmdAH-30.6 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { file s x } -match glob -result {unknown or ambiguous subcommand "s": must be *} test cmdAH-30.7 {Tcl_FileObjCmd: error conditions} -returnCodes error -body { file t x } -match glob -result {unknown or ambiguous subcommand "t": must be *} # channels # In testing 'file channels', we need to make sure that a channel created in # one interp isn't visible in another. interp create simpleInterp interp create -safe safeInterp |
︙ | ︙ |
Changes to tests/exec.test.
︙ | ︙ | |||
436 437 438 439 440 441 442 | } -returnCodes error -result "channel \"$f\" wasn't opened for reading" close $f set f [open $path(gorp.file) r] test exec-10.19 {errors in exec invocation} -constraints {exec} -body { exec cat >@ $f } -returnCodes error -result "channel \"$f\" wasn't opened for writing" close $f | | > > > > > > | | | | | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | } -returnCodes error -result "channel \"$f\" wasn't opened for reading" close $f set f [open $path(gorp.file) r] test exec-10.19 {errors in exec invocation} -constraints {exec} -body { exec cat >@ $f } -returnCodes error -result "channel \"$f\" wasn't opened for writing" close $f test exec-10.20.1 {errors in exec invocation} -constraints {unix exec notValgrind} -body { exec ~non_existent_user/foo/bar } -returnCodes error -result {couldn't execute "~non_existent_user/foo/bar": no such file or directory} test exec-10.20.1 {errors in exec invocation} -constraints {win exec notValgrind} -body { exec ~non_existent_user/foo/bar } -returnCodes error -result {couldn't execute "~non_existent_user\foo\bar": no such file or directory} test exec-10.21.1 {errors in exec invocation} -constraints {unix exec notValgrind} -body { exec [interpreter] true | ~xyzzy_bad_user/x | false } -returnCodes error -result {couldn't execute "~xyzzy_bad_user/x": no such file or directory} test exec-10.21.2 {errors in exec invocation} -constraints {win exec notValgrind} -body { exec [interpreter] true | ~xyzzy_bad_user/x | false } -returnCodes error -result {couldn't execute "~xyzzy_bad_user\x": no such file or directory} test exec-10.22 {errors in exec invocation} -constraints {exec notValgrind} -body { exec echo test > ~non_existent_user/foo/bar } -returnCodes error -result {couldn't write file "~non_existent_user/foo/bar": no such file or directory} # Commands in background. test exec-11.1 {commands in background} {exec} { set time [time {exec [interpreter] $path(sleep) 2 &}] expr {[lindex $time 0] < 1000000} } 1 test exec-11.2 {commands in background} -constraints {exec} -body { |
︙ | ︙ |
Changes to tests/fCmd.test.
︙ | ︙ | |||
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | regexp {^[^(]*\(([^)]*)\)} [exec id] -> user } } if {$user eq ""} { set user "root" } } proc createfile {file {string a}} { set f [open $file w] puts -nonewline $f $string close $f return $string } | > > > > > > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | regexp {^[^(]*\(([^)]*)\)} [exec id] -> user } } if {$user eq ""} { set user "root" } } if {[testConstraint win]} { catch { set user $::env(USERNAME) } if {$user eq ""} { set user Administrator } } proc createfile {file {string a}} { set f [open $file w] puts -nonewline $f $string close $f return $string } |
︙ | ︙ | |||
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | } on error {} { return 0 } return [string match $matchString $fileString] } proc openup {path} { testchmod 0o777 $path if {[file isdirectory $path]} { catch { foreach p [glob -directory $path *] { openup $p } } } } proc cleanup {args} { set wd [list .] foreach p [concat $wd $args] { set x "" catch { | > > > > | > > > > | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | } on error {} { return 0 } return [string match $matchString $fileString] } proc openup {path} { # Double check for inadvertent ~ -> home directory mapping if {[string match ~* $path]} { set file ./$path } testchmod 0o777 $path if {[file isdirectory $path]} { catch { foreach p [glob -directory $path *] { openup $p } } } } proc cleanup {args} { set wd [list .] foreach p [concat $wd $args] { set x "" catch { set x [glob -directory $p tf* td* ~*] } foreach file $x { # Double check for inadvertent ~ -> home directory mapping if {[string match ~* $file]} { set file ./$file } if { [catch {file delete -force -- $file}] && [testConstraint testchmod] } then { catch {openup $file} catch {file delete -force -- $file} } |
︙ | ︙ | |||
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | test fCmd-1.1 {TclFileRenameCmd} -constraints {notRoot} -setup { cleanup } -body { createfile tf1 file rename tf1 tf2 glob tf* } -result {tf2} test fCmd-2.1 {TclFileCopyCmd} -constraints {notRoot} -setup { cleanup } -body { createfile tf1 file copy tf1 tf2 lsort [glob tf*] } -result {tf1 tf2} test fCmd-3.1 {FileCopyRename: FileForceOption fails} -constraints {notRoot} -body { file rename -xyz } -returnCodes error -result {bad option "-xyz": must be -force or --} test fCmd-3.2 {FileCopyRename: not enough args} -constraints {notRoot} -body { file rename xyz } -returnCodes error -result {wrong # args: should be "file rename ?-option value ...? source ?source ...? target"} test fCmd-3.3 {FileCopyRename: Tcl_TranslateFileName fails} -constraints {notRoot} -body { file rename xyz ~_totally_bogus_user | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | test fCmd-1.1 {TclFileRenameCmd} -constraints {notRoot} -setup { cleanup } -body { createfile tf1 file rename tf1 tf2 glob tf* } -result {tf2} test fCmd-1.2 {TclFileRenameCmd when target is ~} -setup { cleanup createfile tf1 } -cleanup { file delete ./~ } -body { file rename tf1 ~ file isfile ~ } -result 1 test fCmd-1.3 {TclFileRenameCmd when target is ~user} -setup { cleanup createfile tf1 } -cleanup { file delete ./~$user } -body { file rename tf1 ~$user file isfile ~$user } -result 1 test fCmd-1.4 {TclFileRenameCmd when source is ~} -setup { cleanup createfile ./~ } -cleanup { file delete ./~ } -body { file rename ~ tf1 list [file exists ~] [file exists tf1] } -result {0 1} test fCmd-1.5 {TclFileRenameCmd when source is ~user} -setup { cleanup createfile ./~$user } -cleanup { file delete ./~$user } -body { file rename ~$user tf1 list [file exists ~$user] [file exists tf1] } -result {0 1} test fCmd-2.1 {TclFileCopyCmd} -constraints {notRoot} -setup { cleanup } -body { createfile tf1 file copy tf1 tf2 lsort [glob tf*] } -result {tf1 tf2} test fCmd-2.2 {TclFileCopyCmd when target is ~} -setup { cleanup createfile tf1 } -cleanup { file delete ./~ } -body { file copy tf1 ~ list [file exists tf1] [file exists ~] } -result {1 1} test fCmd-2.3 {TclFileCopyCmd when target is ~user} -setup { cleanup createfile tf1 } -cleanup { file delete ./~$user } -body { file copy tf1 ~$user list [file exists tf1] [file exists ~$user] } -result {1 1} test fCmd-2.4 {TclFileCopyCmd when source is ~} -setup { cleanup createfile ./~ } -cleanup { file delete ./~ } -body { file copy ~ tf1 list [file exists ~] [file exists tf1] } -result {1 1} test fCmd-2.5 {TclFileCopyCmd when source is ~user} -setup { cleanup createfile ./~$user } -cleanup { file delete ./~$user } -body { file copy ~$user tf1 list [file exists ~$user] [file exists tf1] } -result {1 1} test fCmd-3.1 {FileCopyRename: FileForceOption fails} -constraints {notRoot} -body { file rename -xyz } -returnCodes error -result {bad option "-xyz": must be -force or --} test fCmd-3.2 {FileCopyRename: not enough args} -constraints {notRoot} -body { file rename xyz } -returnCodes error -result {wrong # args: should be "file rename ?-option value ...? source ?source ...? target"} test fCmd-3.3 {FileCopyRename: Tcl_TranslateFileName fails} -constraints {notRoot} -body { file rename xyz ~_totally_bogus_user } -returnCodes error -result {error renaming "xyz": no such file or directory} test fCmd-3.4 {FileCopyRename: Tcl_TranslateFileName passes} -setup { cleanup } -constraints {notRoot} -returnCodes error -body { file copy tf1 ~ } -result {error copying "tf1": no such file or directory} test fCmd-3.5 {FileCopyRename: target doesn't exist: stat(target) != 0} -setup { cleanup |
︙ | ︙ | |||
266 267 268 269 270 271 272 | [contents [file join td1 tf3]] [contents [file join td1 tf4]] } -result {tf1 tf2 tf3 tf4} test fCmd-3.14 {FileCopyRename: FileBasename fails} -setup { cleanup } -constraints {notRoot} -returnCodes error -body { file mkdir td1 file rename ~_totally_bogus_user td1 | | | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | [contents [file join td1 tf3]] [contents [file join td1 tf4]] } -result {tf1 tf2 tf3 tf4} test fCmd-3.14 {FileCopyRename: FileBasename fails} -setup { cleanup } -constraints {notRoot} -returnCodes error -body { file mkdir td1 file rename ~_totally_bogus_user td1 } -result {error renaming "~_totally_bogus_user": no such file or directory} test fCmd-3.15 {FileCopyRename: source[0] == '\x00'} -setup { cleanup } -constraints {notRoot unixOrWin} -returnCodes error -body { file mkdir td1 file rename / td1 } -result {error renaming "/" to "td1": file already exists} test fCmd-3.16 {FileCopyRename: break on first error} -setup { |
︙ | ︙ | |||
304 305 306 307 308 309 310 | test fCmd-4.3 {TclFileMakeDirsCmd: stops on first error} -setup { cleanup } -constraints {notRoot} -body { createfile tf1 catch {file mkdir td1 td2 tf1 td3 td4} glob td1 td2 tf1 td3 td4 } -result {td1 td2 tf1} | | | > > > > > > | | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | test fCmd-4.3 {TclFileMakeDirsCmd: stops on first error} -setup { cleanup } -constraints {notRoot} -body { createfile tf1 catch {file mkdir td1 td2 tf1 td3 td4} glob td1 td2 tf1 td3 td4 } -result {td1 td2 tf1} test fCmd-4.4 {TclFileMakeDirsCmd: Tcl_TranslateFileName treats ~ as normal char} -setup { cleanup } -constraints {notRoot} -body { list [file isdir ~] [file mkdir ~] [file isdir ~] } -result {0 {} 1} test fCmd-4.4.1 {TclFileMakeDirsCmd: Tcl_TranslateFileName treats ~ as normal char} -setup { cleanup } -constraints {notRoot} -body { file mkdir ~_totally_bogus_user file isdir ~_totally_bogus_user } -result 1 test fCmd-4.5 {TclFileMakeDirsCmd: Tcl_SplitPath returns 0: *name == '\x00'} -setup { cleanup } -constraints {notRoot} -returnCodes error -body { file mkdir "" } -result {can't create directory "": no such file or directory} test fCmd-4.6 {TclFileMakeDirsCmd: one level deep} -setup { cleanup |
︙ | ︙ | |||
416 417 418 419 420 421 422 | } -constraints {notRoot unixOrWin notWine} -body { createfile tf1 createfile tf2 file mkdir td1 catch {file delete tf1 td1 $root tf2} list [file exists tf1] [file exists tf2] [file exists td1] } -cleanup {cleanup} -result {0 1 0} | > > | | > | < < | | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | } -constraints {notRoot unixOrWin notWine} -body { createfile tf1 createfile tf2 file mkdir td1 catch {file delete tf1 td1 $root tf2} list [file exists tf1] [file exists tf2] [file exists td1] } -cleanup {cleanup} -result {0 1 0} test fCmd-5.6 { TclFileDeleteCmd: Tcl_TranslateFileName treats ~user as normal char } -constraints {notRoot} -body { file delete ~_totally_bogus_user } -result {} test fCmd-5.7 { TclFileDeleteCmd: Tcl_TranslateFileName treats ~ as normal char } -constraints {notRoot} -body { createfile ~/tf1 } -returnCodes error -result {couldn't open "~/tf1": no such file or directory} test fCmd-5.8 {TclFileDeleteCmd: file doesn't exist: lstat(name) != 0} -setup { cleanup } -constraints {notRoot} -body { set x [file exists tf1] file delete tf1 list $x [file exists tf1] } -result {0 0} |
︙ | ︙ | |||
623 624 625 626 627 628 629 | } -returnCodes error -cleanup { file attributes td1 -permissions 0o755 cleanup } -match regexp -result {^error renaming "td1"( to "/tmp/tcl\d+/td1")?: permission denied$} test fCmd-6.24 {CopyRenameOneFile: error uses original name} -setup { cleanup } -constraints {unix notRoot} -body { | | | | | | | | | | | | | | | | | 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | } -returnCodes error -cleanup { file attributes td1 -permissions 0o755 cleanup } -match regexp -result {^error renaming "td1"( to "/tmp/tcl\d+/td1")?: permission denied$} test fCmd-6.24 {CopyRenameOneFile: error uses original name} -setup { cleanup } -constraints {unix notRoot} -body { file mkdir [file home]/td1/td2 set td1name [file join [file dirname [file home]] [file tail [file home]] td1] file attributes $td1name -permissions 0 file copy [file home]/td1 td1 } -returnCodes error -cleanup { file attributes $td1name -permissions 0o755 file delete -force [file home]/td1 } -result "error copying \"[file home]/td1\": permission denied" test fCmd-6.25 {CopyRenameOneFile: error uses original name} -setup { cleanup } -constraints {unix notRoot} -body { file mkdir td2 file mkdir [file home]/td1 set td1name [file join [file dirname [file home]] [file tail [file home]] td1] file attributes $td1name -permissions 0 file copy td2 [file home]/td1 } -returnCodes error -cleanup { file attributes $td1name -permissions 0o755 file delete -force [file home]/td1 } -result "error copying \"td2\" to \"[file home]/td1/td2\": permission denied" test fCmd-6.26 {CopyRenameOneFile: doesn't use original name} -setup { cleanup } -constraints {unix notRoot} -body { file mkdir [file home]/td1/td2 set td2name [file join [file dirname [file home]] [file tail [file home]] td1 td2] file attributes $td2name -permissions 0 file copy [file home]/td1 td1 } -returnCodes error -cleanup { file attributes $td2name -permissions 0o755 file delete -force [file home]/td1 } -result "error copying \"[file home]/td1\" to \"td1\": \"[file join $::env(HOME) td1 td2]\": permission denied" test fCmd-6.27 {CopyRenameOneFile: TclpCopyDirectory failed} -setup { cleanup $tmpspace } -constraints {notRoot xdev} -returnCodes error -body { file mkdir td1/td2/td3 file mkdir [file join $tmpspace td1] createfile [file join $tmpspace td1 tf1] file rename -force td1 $tmpspace |
︙ | ︙ | |||
737 738 739 740 741 742 743 | createfile -- createfile -force file delete -force -force -- -- -force glob -- -- -force } -result {no files matched glob patterns "-- -force"} test fCmd-8.1 {FileBasename: basename of ~user: argc == 1 && *path == ~} \ | | | | | | 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | createfile -- createfile -force file delete -force -force -- -- -force glob -- -- -force } -result {no files matched glob patterns "-- -force"} test fCmd-8.1 {FileBasename: basename of ~user: argc == 1 && *path == ~} \ -constraints {unix notRoot knownBug tildeexpansion} -body { # Labelled knownBug because it is dangerous [Bug: 3881] file mkdir td1 file attr td1 -perm 0o40000 file rename ~$user td1 } -returnCodes error -cleanup { file delete -force td1 } -result "error renaming \"~$user\" to \"td1/[file tail ~$user]\": permission denied" test fCmd-8.2 {FileBasename: basename of ~user: argc == 1 && *path == ~} \ -constraints {unix notRoot} -body { string equal [file tail ~$user] ~$user } -result 1 test fCmd-8.3 {file copy and path translation: ensure correct error} -body { file copy [file home] [file join this file doesnt exist] } -returnCodes error -result [subst \ {error copying "[file home]" to "[file join this file doesnt exist]": no such file or directory}] test fCmd-9.1 {file rename: comprehensive: EACCES} -setup { cleanup } -constraints {unix notRoot} -body { file mkdir td1 file mkdir td2 file attr td2 -perm 0o40000 |
︙ | ︙ | |||
1494 1495 1496 1497 1498 1499 1500 1501 1502 | file attributes tfa/dir -permissions 0o777 file delete -force tfa tfa2 } -result {1} # # Coverage tests for TclMkdirCmd() # test fCmd-15.1 {TclMakeDirsCmd: target filename translation failing} -setup { set temp $::env(HOME) | > > | | | 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 | file attributes tfa/dir -permissions 0o777 file delete -force tfa tfa2 } -result {1} # # Coverage tests for TclMkdirCmd() # # ~ is no longer a special char. Need a test case where translation fails. test fCmd-15.1 {TclMakeDirsCmd: target filename translation failing} -setup { set temp $::env(HOME) } -constraints {notRoot TODO} -body { global env unset env(HOME) catch {file mkdir ~/tfa} } -cleanup { set ::env(HOME) $temp } -result 1 # # Can Tcl_SplitPath return argc == 0? If so them we need a test for that code. # test fCmd-15.2 {TclMakeDirsCmd - one directory} -setup { catch {file delete -force -- tfa} } -constraints {notRoot} -body { file mkdir tfa |
︙ | ︙ | |||
1595 1596 1597 1598 1599 1600 1601 1602 1603 | } -result {1} test fCmd-16.4 {accept zero files (TIP 323)} -body { file delete } -result {} test fCmd-16.5 {accept zero files (TIP 323)} -body { file delete -- } -result {} test fCmd-16.6 {delete: source filename translation failing} -setup { set temp $::env(HOME) | > | | 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 | } -result {1} test fCmd-16.4 {accept zero files (TIP 323)} -body { file delete } -result {} test fCmd-16.5 {accept zero files (TIP 323)} -body { file delete -- } -result {} # ~ is no longer a special char. Need a test case where translation fails. test fCmd-16.6 {delete: source filename translation failing} -setup { set temp $::env(HOME) } -constraints {notRoot TODO} -body { global env unset env(HOME) catch {file delete ~/tfa} } -cleanup { set ::env(HOME) $temp } -result {1} test fCmd-16.7 {remove a non-empty directory without -force} -setup { |
︙ | ︙ | |||
2223 2224 2225 2226 2227 2228 2229 | test fCmd-27.2 {TclFileAttrsCmd - Tcl_TranslateFileName fails} -setup { set platform [testgetplatform] } -constraints {testsetplatform} -body { testsetplatform unix file attributes ~_totally_bogus_user } -returnCodes error -cleanup { testsetplatform $platform | | | 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 | test fCmd-27.2 {TclFileAttrsCmd - Tcl_TranslateFileName fails} -setup { set platform [testgetplatform] } -constraints {testsetplatform} -body { testsetplatform unix file attributes ~_totally_bogus_user } -returnCodes error -cleanup { testsetplatform $platform } -result {could not read "~_totally_bogus_user": no such file or directory} test fCmd-27.3 {TclFileAttrsCmd - all attributes} -setup { catch {file delete -force -- foo.tmp} } -body { createfile foo.tmp file attributes foo.tmp # Must be non-empty result } -cleanup { |
︙ | ︙ | |||
2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 | set path $env(SystemDrive)/pagefile.sys lappend r exists [file exists $path] lappend r readable [file readable $path] lappend r stat [catch {file stat $path a} e] $e } return $r } -result {exists 1 readable 0 stat 0 {}} # cleanup cleanup if {[testConstraint unix]} { removeDirectory tcl[pid] /tmp } ::tcltest::cleanupTests return # Local Variables: # mode: tcl # fill-column: 78 # End: | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 | set path $env(SystemDrive)/pagefile.sys lappend r exists [file exists $path] lappend r readable [file readable $path] lappend r stat [catch {file stat $path a} e] $e } return $r } -result {exists 1 readable 0 stat 0 {}} test fCmd-31.1 {file home} -body { file home } -result [file join $::env(HOME)] test fCmd-31.2 {file home - obeys env} -setup { set ::env(HOME) $::env(HOME)/xxx } -cleanup { set ::env(HOME) [file dirname $::env(HOME)] } -body { file home } -result [file join $::env(HOME) xxx] test fCmd-31.3 {file home - \ -> /} -constraints win -setup { set saved $::env(HOME) set ::env(HOME) C:\\backslash\\path } -cleanup { set ::env(HOME) $saved } -body { file home } -result C:/backslash/path test fCmd-31.4 {file home - error} -setup { set saved $::env(HOME) unset ::env(HOME) } -cleanup { set ::env(HOME) $saved } -body { file home } -returnCodes error -result {couldn't find HOME environment variable to expand path} test fCmd-31.5 { file home - relative path. Following 8.x ~ expansion behavior, relative paths are not made absolute } -setup { set saved $::env(HOME) set ::env(HOME) relative/path } -cleanup { set ::env(HOME) $saved } -body { file home } -result relative/path test fCmd-31.6 {file home USER} -body { # Note - as in 8.x this form does NOT necessarily give same result as # env(HOME) even when user is current user. Assume result contains user # name, else not sure how to check file home $::tcl_platform(user) } -match glob -result "*$::tcl_platform(user)*" test fCmd-31.7 {file home UNKNOWNUSER} -body { file home nosuchuser } -returnCodes error -result {user "nosuchuser" doesn't exist} test fCmd-31.8 {file home extra arg} -body { file home $::tcl_platform(user) arg } -returnCodes error -result {wrong # args: should be "file home ?user?"} test fCmd-32.1 {file tildeexpand ~} -body { file tildeexpand ~ } -result [file join $::env(HOME)] test fCmd-32.2 {file tildeexpand ~ - obeys env} -setup { set ::env(HOME) $::env(HOME)/xxx } -cleanup { set ::env(HOME) [file dirname $::env(HOME)] } -body { file tildeexpand ~ } -result [file join $::env(HOME) xxx] test fCmd-32.3 {file tildeexpand ~ - error} -setup { set saved $::env(HOME) unset ::env(HOME) } -cleanup { set ::env(HOME) $saved } -body { file tildeexpand ~ } -returnCodes error -result {couldn't find HOME environment variable to expand path} test fCmd-32.4 { file tildeexpand ~ - relative path. Following 8.x ~ expansion behavior, relative paths are not made absolute } -setup { set saved $::env(HOME) set ::env(HOME) relative/path } -cleanup { set ::env(HOME) $saved } -body { file tildeexpand ~ } -result relative/path test fCmd-32.5 {file tildeexpand ~USER} -body { # Note - as in 8.x this form does NOT necessarily give same result as # env(HOME) even when user is current user. Assume result contains user # name, else not sure how to check file tildeexpand ~$::tcl_platform(user) } -match glob -result "*$::tcl_platform(user)*" test fCmd-32.6 {file tildeexpand ~UNKNOWNUSER} -body { file tildeexpand ~nosuchuser } -returnCodes error -result {user "nosuchuser" doesn't exist} test fCmd-32.7 {file tildeexpand ~extra arg} -body { file tildeexpand ~ arg } -returnCodes error -result {wrong # args: should be "file tildeexpand path"} test fCmd-32.8 {file tildeexpand ~/path} -body { file tildeexpand ~/foo } -result [file join $::env(HOME)/foo] test fCmd-32.9 {file tildeexpand ~USER/bar} -body { # Note - as in 8.x this form does NOT necessarily give same result as # env(HOME) even when user is current user. Assume result contains user # name, else not sure how to check file tildeexpand ~$::tcl_platform(user)/bar } -match glob -result "*$::tcl_platform(user)*/bar" test fCmd-32.10 {file tildeexpand ~UNKNOWNUSER} -body { file tildeexpand ~nosuchuser/foo } -returnCodes error -result {user "nosuchuser" doesn't exist} test fCmd-32.11 {file tildeexpand /~/path} -body { file tildeexpand /~/foo } -result /~/foo test fCmd-32.12 {file tildeexpand /~user/path} -body { file tildeexpand /~$::tcl_platform(user)/foo } -result /~$::tcl_platform(user)/foo test fCmd-32.13 {file tildeexpand ./~} -body { file tildeexpand ./~ } -result ./~ test fCmd-32.14 {file tildeexpand relative/path} -body { file tildeexpand relative/path } -result relative/path test fCmd-32.15 {file tildeexpand ~\\path} -body { file tildeexpand ~\\foo } -constraints win -result [file join $::env(HOME)/foo] test fCmd-32.16 {file tildeexpand ~USER\\bar} -body { # Note - as in 8.x this form does NOT necessarily give same result as # env(HOME) even when user is current user. Assume result contains user # name, else not sure how to check file tildeexpand ~$::tcl_platform(user)\\bar } -constraints win -match glob -result "*$::tcl_platform(user)*/bar" # cleanup cleanup if {[testConstraint unix]} { removeDirectory tcl[pid] /tmp } ::tcltest::cleanupTests return # Local Variables: # mode: tcl # fill-column: 78 # End: |
Changes to tests/fileName.test.
︙ | ︙ | |||
67 68 69 70 71 72 73 | test filename-1.4 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype c:/foo } relative test filename-1.5 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ~ | | | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | test filename-1.4 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype c:/foo } relative test filename-1.5 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ~ } relative test filename-1.6 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ~/foo } relative test filename-1.7 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ~foo } relative test filename-1.8 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ./~foo } relative test filename-3.1 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows |
︙ | ︙ | |||
132 133 134 135 136 137 138 | test filename-3.12 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype //foo/bar } absolute test filename-3.13 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ~foo | | | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | test filename-3.12 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype //foo/bar } absolute test filename-3.13 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ~foo } relative test filename-3.14 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ~ } relative test filename-3.15 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ~/foo } relative test filename-3.16 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ./~foo } relative test filename-4.1 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix |
︙ | ︙ | |||
209 210 211 212 213 214 215 | test filename-4.15 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ~foo } {~foo} test filename-4.16 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ~foo/~bar | | | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | test filename-4.15 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ~foo } {~foo} test filename-4.16 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ~foo/~bar } {~foo ~bar} test filename-4.17 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ~foo/~bar/~baz } {~foo ~bar ~baz} test filename-4.18 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split foo/bar~/baz } {foo bar~ baz} if {[testConstraint testsetplatform]} { testsetplatform $platform } |
︙ | ︙ | |||
353 354 355 356 357 358 359 | test filename-6.26 {Tcl_SplitPath: win} {testsetplatform} { testsetplatform win file split ~foo } {~foo} test filename-6.27 {Tcl_SplitPath: win} {testsetplatform} { testsetplatform win file split ~foo/~bar | | | | | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | test filename-6.26 {Tcl_SplitPath: win} {testsetplatform} { testsetplatform win file split ~foo } {~foo} test filename-6.27 {Tcl_SplitPath: win} {testsetplatform} { testsetplatform win file split ~foo/~bar } {~foo ~bar} test filename-6.28 {Tcl_SplitPath: win} {testsetplatform} { testsetplatform win file split ~foo/~bar/~baz } {~foo ~bar ~baz} test filename-6.29 {Tcl_SplitPath: win} {testsetplatform} { testsetplatform win file split foo/bar~/baz } {foo bar~ baz} test filename-6.30 {Tcl_SplitPath: win} {testsetplatform} { testsetplatform win file split c:~foo } {c: ~foo} test filename-7.1 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join / a } {/a} test filename-7.2 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix |
︙ | ︙ | |||
410 411 412 413 414 415 416 | test filename-7.10 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join ~ a } {~/a} test filename-7.11 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join ~a ~b | | | | | | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | test filename-7.10 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join ~ a } {~/a} test filename-7.11 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join ~a ~b } {~a/~b} test filename-7.12 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join ./~a b } {./~a/b} test filename-7.13 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join ./~a ~b } {./~a/~b} test filename-7.14 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join ./~a ./~b } {./~a/./~b} test filename-7.15 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join a . b } {a/./b} test filename-7.16 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join a . ./~b } {a/././~b} test filename-7.17 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join //a b } "/a/b" test filename-7.18 {Tcl_JoinPath: unix} {testsetplatform} { testsetplatform unix file join /// a b |
︙ | ︙ | |||
486 487 488 489 490 491 492 | test filename-9.10 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win file join ~/~foo } {~/~foo} test filename-9.11 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win file join ~ ./~foo | | | | 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | test filename-9.10 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win file join ~/~foo } {~/~foo} test filename-9.11 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win file join ~ ./~foo } {~/./~foo} test filename-9.12 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win file join / ~foo } {/~foo} test filename-9.13 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win file join ./a/ b c } {./a/b/c} test filename-9.14 {Tcl_JoinPath: win} {testsetplatform} { testsetplatform win file join ./~a/ b c |
︙ | ︙ | |||
596 597 598 599 600 601 602 | set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "/home/test" testsetplatform unix testtranslatefilename ~/foo } -cleanup { set env(HOME) $temp | | | | | | | | | | | | | | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "/home/test" testsetplatform unix testtranslatefilename ~/foo } -cleanup { set env(HOME) $temp } -result {~/foo} test filename-10.7 {Tcl_TranslateFileName} -setup { global env set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { unset env(HOME) testsetplatform unix testtranslatefilename ~/foo } -cleanup { set env(HOME) $temp } -result {~/foo} test filename-10.8 {Tcl_TranslateFileName} -setup { global env set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "/home/test" testsetplatform unix testtranslatefilename ~ } -cleanup { set env(HOME) $temp } -result {~} test filename-10.9 {Tcl_TranslateFileName} -setup { global env set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "/home/test/" testsetplatform unix testtranslatefilename ~ } -cleanup { set env(HOME) $temp } -result {~} test filename-10.10 {Tcl_TranslateFileName} -setup { global env set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "/home/test/" testsetplatform unix testtranslatefilename ~/foo } -cleanup { set env(HOME) $temp } -result {~/foo} test filename-10.17 {Tcl_TranslateFileName} -setup { global env set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "\\home\\" testsetplatform windows testtranslatefilename ~/foo } -cleanup { set env(HOME) $temp } -result {~\foo} test filename-10.18 {Tcl_TranslateFileName} -setup { global env set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "\\home\\" testsetplatform windows testtranslatefilename ~/foo\\bar } -cleanup { set env(HOME) $temp } -result {~\foo\bar} test filename-10.19 {Tcl_TranslateFileName} -setup { global env set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "c:" testsetplatform windows testtranslatefilename ~/foo } -cleanup { set env(HOME) $temp } -result {~\foo} test filename-10.20 {Tcl_TranslateFileName} -body { testtranslatefilename ~blorp/foo } -constraints {testtranslatefilename testtranslatefilename} \ -result {~blorp\foo} test filename-10.21 {Tcl_TranslateFileName} -setup { global env set temp $env(HOME) } -constraints {testsetplatform testtranslatefilename} -body { set env(HOME) "c:\\" testsetplatform windows testtranslatefilename ~/foo } -cleanup { set env(HOME) $temp } -result {~\foo} test filename-10.22 {Tcl_TranslateFileName} -body { testsetplatform windows testtranslatefilename foo//bar } -constraints {testsetplatform testtranslatefilename} -result {foo\bar} if {[testConstraint testsetplatform]} { testsetplatform $platform } |
︙ | ︙ | |||
709 710 711 712 713 714 715 | } -result {bad option "-gorp": must be -directory, -join, -nocomplain, -path, -tails, -types, or --} test filename-11.3 {Tcl_GlobCmd} -body { glob -nocomplai } -result {} test filename-11.4 {Tcl_GlobCmd} -body { glob -nocomplain } -result {} | | > | | | | | | | | | | | | | | 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | } -result {bad option "-gorp": must be -directory, -join, -nocomplain, -path, -tails, -types, or --} test filename-11.3 {Tcl_GlobCmd} -body { glob -nocomplai } -result {} test filename-11.4 {Tcl_GlobCmd} -body { glob -nocomplain } -result {} test filename-11.5 {Tcl_GlobCmd} -body { # Should not error out because of ~ catch {glob -nocomplain * ~xyqrszzz} } -result 0 test filename-11.6 {Tcl_GlobCmd} -returnCodes error -body { glob ~xyqrszzz } -result {no files matched glob pattern "~xyqrszzz"} test filename-11.7 {Tcl_GlobCmd} -returnCodes error -body { glob -- -nocomplain } -result {no files matched glob pattern "-nocomplain"} test filename-11.8 {Tcl_GlobCmd} -body { glob -nocomplain -- -nocomplain } -result {} test filename-11.9 {Tcl_GlobCmd} -constraints {testsetplatform} -body { testsetplatform unix glob ~\\xyqrszzz/bar } -returnCodes error -result {no files matched glob pattern "~\xyqrszzz/bar"} test filename-11.10 {Tcl_GlobCmd} -constraints {testsetplatform} -body { testsetplatform unix glob -nocomplain ~\\xyqrszzz/bar } -result {} test filename-11.11 {Tcl_GlobCmd} -constraints {testsetplatform} -body { testsetplatform unix glob ~xyqrszzz\\/\\bar } -returnCodes error -result {no files matched glob pattern "~xyqrszzz\/\bar"} test filename-11.12 {Tcl_GlobCmd} -constraints {testsetplatform} -setup { testsetplatform unix set home $env(HOME) } -body { unset env(HOME) glob ~/* } -returnCodes error -cleanup { set env(HOME) $home } -result {no files matched glob pattern "~/*"} if {[testConstraint testsetplatform]} { testsetplatform $platform } test filename-11.13 {Tcl_GlobCmd} -body { file join [lindex [glob ~] 0] } -returnCodes error -result {no files matched glob pattern "~"} set oldpwd [pwd] set oldhome $env(HOME) catch {cd [makeDirectory tcl[pid]]} set env(HOME) [pwd] file delete -force globTest file mkdir globTest/a1/b1 file mkdir globTest/a1/b2 file mkdir globTest/a2/b3 file mkdir globTest/a3 touch globTest/x1.c touch globTest/y1.c touch globTest/z1.c touch "globTest/weird name.c" touch globTest/a1/b1/x2.c touch globTest/a1/b2/y2.c touch globTest/.1 touch globTest/x,z1.c test filename-11.14 {Tcl_GlobCmd} -body { glob ~/globTest } -returnCodes error -result {no files matched glob pattern "~/globTest"} test filename-11.15 {Tcl_GlobCmd} -body { glob ~\\/globTest } -returnCodes error -result {no files matched glob pattern "~\/globTest"} test filename-11.16 {Tcl_GlobCmd} { glob globTest } {globTest} set globname "globTest" set horribleglobname "glob\[\{Test" set tildeglobname "./~test.txt" |
︙ | ︙ | |||
1248 1249 1250 1251 1252 1253 1254 | lsort [glob globTest/*/] } {globTest/a1/ globTest/a2/ globTest/a3/} test filename-14.17 {asterisks, question marks, and brackets} -setup { global env set temp $env(HOME) } -body { set env(HOME) [file join $env(HOME) globTest] | | | 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 | lsort [glob globTest/*/] } {globTest/a1/ globTest/a2/ globTest/a3/} test filename-14.17 {asterisks, question marks, and brackets} -setup { global env set temp $env(HOME) } -body { set env(HOME) [file join $env(HOME) globTest] glob [file home]/z* } -cleanup { set env(HOME) $temp } -result [list [file join $env(HOME) globTest z1.c]] test filename-14.18 {asterisks, question marks, and brackets} {unixOrWin} { lsort [glob globTest/*.c goo/*] } {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c} test filename-14.20 {asterisks, question marks, and brackets} { |
︙ | ︙ | |||
1345 1346 1347 1348 1349 1350 1351 | test filename-15.4 {unix specific no complain: no errors, good result} \ {unix nonPortable} { # test fails because if an error occurs, the interp's result is reset... # or you don't run at scriptics where the outser and welch users exists glob -nocomplain ~ouster ~foo ~welch } {/home/ouster /home/welch} test filename-15.4.1 {no complain: errors, sequencing} { | | < < > | < | < < < | < < < < | | | | 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 | test filename-15.4 {unix specific no complain: no errors, good result} \ {unix nonPortable} { # test fails because if an error occurs, the interp's result is reset... # or you don't run at scriptics where the outser and welch users exists glob -nocomplain ~ouster ~foo ~welch } {/home/ouster /home/welch} test filename-15.4.1 {no complain: errors, sequencing} { # ~xxx no longer expanded so errors about unknown users should not occur list [catch {glob -nocomplain ~wontexist ~blahxyz ~} res1] $res1 \ [catch {glob -nocomplain ~ ~blahxyz ~wontexist} res2] $res2 } {0 {} 0 {}} test filename-15.4.2 {no complain: errors, sequencing} -body { # test used to fail because if an error occurs, the interp's result is # reset... list [list [catch {glob -nocomplain ~wontexist *} res1] $res1] \ [list [catch {glob -nocomplain * ~wontexist} res2] $res2] } -match compareWords -result equal test filename-15.5 {unix specific globbing} {unix nonPortable} { glob ~ouster/.csh* } "/home/ouster/.cshrc" # 15.6 removed. It checked if glob ~ returned valid information if # home directory contained glob chars. Since ~ expansion is no longer # supported, the test was meaningless test filename-15.7 {glob tilde} -body { glob ~ } -returnCodes error -result {no files matched glob pattern "~"} test filename-15.8 {win and unix specific globbing} -constraints {unixOrWin} -setup { global env set temp $env(HOME) } -body { touch $env(HOME)/globTest/anyname set env(HOME) $env(HOME)/globTest/anyname glob ~ } -cleanup { set env(HOME) $temp catch {file delete -force $env(HOME)/globTest/anyname} } -returnCodes error -result {no files matched glob pattern "~"} # The following tests are only valid for Windows systems. set oldDir [pwd] if {[testConstraint win]} { cd c:/ file delete -force globTest file mkdir globTest |
︙ | ︙ | |||
1562 1563 1564 1565 1566 1567 1568 | removeFile test $d removeDirectory ./~foo $dd removeDirectory isolate } -result ~foo/test test fileName-20.6 {Bug 2837800} -setup { # Recall that we have $env(HOME) set so that references # to ~ point to [temporaryDirectory] | | | 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 | removeFile test $d removeDirectory ./~foo $dd removeDirectory isolate } -result ~foo/test test fileName-20.6 {Bug 2837800} -setup { # Recall that we have $env(HOME) set so that references # to ~ point to [temporaryDirectory] makeFile {} test [file home] set dd [makeDirectory isolate] set d [makeDirectory ./~ $dd] set savewd [pwd] cd $dd } -body { glob -nocomplain */test } -cleanup { |
︙ | ︙ | |||
1598 1599 1600 1601 1602 1603 1604 | makeFile {} ./~test $d } -body { file tail [lindex [glob -nocomplain isolate/*] 0] } -cleanup { removeFile ./~test $d removeDirectory isolate cd $savewd | | < < < < < < < < < < < < | | | | | 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 | makeFile {} ./~test $d } -body { file tail [lindex [glob -nocomplain isolate/*] 0] } -cleanup { removeFile ./~test $d removeDirectory isolate cd $savewd } -result ~test test fileName-20.10 {globbing for special chars} -setup { set s [makeDirectory sub [file home]] makeFile {} fileName-20.10 $s set d [makeDirectory isolate] set savewd [pwd] cd $d } -body { glob -nocomplain -directory [file home] -join * fileName-20.10 } -cleanup { cd $savewd removeDirectory isolate removeFile fileName-20.10 $s removeDirectory sub [file home] } -result [file home]/sub/fileName-20.10 # cleanup catch {file delete -force C:/globTest} cd [temporaryDirectory] file delete -force globTest cd $oldpwd catch {removeDirectory tcl[pid]} |
︙ | ︙ |
Changes to tests/fileSystem.test.
︙ | ︙ | |||
263 264 265 266 267 268 269 | file delete -force dir2.link file delete -force link.file dir.link file delete -force dir2 file delete -force [file join dir.dir dirinside.link] removeFile [file join dir.dir inside.file] removeDirectory [file join dir.dir dirinside.dir] removeDirectory dir.dir | | > > | | | < < < | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | file delete -force dir2.link file delete -force link.file dir.link file delete -force dir2 file delete -force [file join dir.dir dirinside.link] removeFile [file join dir.dir inside.file] removeDirectory [file join dir.dir dirinside.dir] removeDirectory dir.dir test filesystem-1.30 { normalisation of nonexistent user - verify no tilde expansion } -body { file normalize ~noonewiththisname } -result [file join [pwd] ~noonewiththisname] test filesystem-1.30.1 {normalisation of existing user} -body { file normalize ~$::tcl_platform(user) } -result [file join [pwd] ~$::tcl_platform(user)] test filesystem-1.31 {link normalisation: link near filesystem root} {testsetplatform} { testsetplatform unix file normalize /foo/../bar } {/bar} test filesystem-1.32 {link normalisation: link near filesystem root} {testsetplatform} { testsetplatform unix file normalize /../bar |
︙ | ︙ | |||
469 470 471 472 473 474 475 | testfilesystem 1 set filesystemReport {} catch {glob *} testfilesystem 0 return $filesystemReport } -match glob -result {*{matchindirectory *}*} | > | > > | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | testfilesystem 1 set filesystemReport {} catch {glob *} testfilesystem 0 return $filesystemReport } -match glob -result {*{matchindirectory *}*} # This test is meaningless if there is no tilde expansion test filesystem-5.1 {cache and ~} -constraints { testfilesystem tildeexpansion } -setup { set orig $::env(HOME) } -body { set ::env(HOME) /foo/bar/blah set testdir ~ set res1 "Parent of ~ (/foo/bar/blah) is [file dirname $testdir]" set ::env(HOME) /a/b/c set res2 "Parent of ~ (/a/b/c) is [file dirname $testdir]" |
︙ | ︙ | |||
935 936 937 938 939 940 941 | lappend res $file lappend res [file exists $file] [catch {file tail $file} r] $r lappend res [catch {file tail $file} r] $r } -cleanup { cd [tcltest::temporaryDirectory] file delete -force tilde cd $origdir | | | | | 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 | lappend res $file lappend res [file exists $file] [catch {file tail $file} r] $r lappend res [catch {file tail $file} r] $r } -cleanup { cd [tcltest::temporaryDirectory] file delete -force tilde cd $origdir } -result {1 0 ~testNotExist ~testNotExist 1 0 ~testNotExist 0 ~testNotExist} test filesystem-9.8 {path objects and glob and file tail and tilde} -setup { set res {} set origdir [pwd] cd [tcltest::temporaryDirectory] } -body { file mkdir tilde close [open tilde/~testNotExist w] cd tilde set file1 [lindex [glob *test*] 0] set file2 "~testNotExist" lappend res $file1 $file2 lappend res [catch {file tail $file1} r] $r lappend res [catch {file tail $file2} r] $r } -cleanup { cd [tcltest::temporaryDirectory] file delete -force tilde cd $origdir } -result {~testNotExist ~testNotExist 0 ~testNotExist 0 ~testNotExist} test filesystem-9.9 {path objects and glob and file tail and tilde} -setup { set res {} set origdir [pwd] cd [tcltest::temporaryDirectory] } -body { file mkdir tilde close [open tilde/~testNotExist w] cd tilde set file1 [lindex [glob *test*] 0] set file2 "~testNotExist" lappend res [catch {file exists $file1} r] $r lappend res [catch {file exists $file2} r] $r lappend res [string equal $file1 $file2] } -cleanup { cd [tcltest::temporaryDirectory] file delete -force tilde cd $origdir } -result {0 1 0 1 1} # ---------------------------------------------------------------------- test filesystem-10.1 {Bug 3414754} { string match */ [file join [pwd] foo/] } 0 |
︙ | ︙ |
Changes to tests/io.test.
︙ | ︙ | |||
5961 5962 5963 5964 5965 5966 5967 | } -result 1 test io-40.17 {tilde substitution in open} { set home $::env(HOME) unset ::env(HOME) set x [list [catch {open ~/foo} msg] $msg] set ::env(HOME) $home set x | | | 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 | } -result 1 test io-40.17 {tilde substitution in open} { set home $::env(HOME) unset ::env(HOME) set x [list [catch {open ~/foo} msg] $msg] set ::env(HOME) $home set x } {1 {couldn't open "~/foo": no such file or directory}} test io-41.1 {Tcl_FileeventCmd: errors} {fileevent} { list [catch {fileevent foo} msg] $msg } {1 {wrong # args: should be "fileevent channelId event ?script?"}} test io-41.2 {Tcl_FileeventCmd: errors} {fileevent} { list [catch {fileevent foo bar baz q} msg] $msg } {1 {wrong # args: should be "fileevent channelId event ?script?"}} |
︙ | ︙ |
Changes to tests/safe.test.
︙ | ︙ | |||
1617 1618 1619 1620 1621 1622 1623 | set d [format %c 126] file join {$p(:0:)} $d } } -cleanup { safe::interpDelete $i set env(HOME) $savedHOME unset savedHOME | | | | | | 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 | set d [format %c 126] file join {$p(:0:)} $d } } -cleanup { safe::interpDelete $i set env(HOME) $savedHOME unset savedHOME } -result {$p(:0:)/~} test safe-16.6 {Bug 3529949: defang ~ in paths used by AliasGlob (2)} -setup { set savedHOME $env(HOME) set env(HOME) /foo/bar set i [safe::interpCreate] } -body { $i eval { set d [format %c 126] file join {$p(:0:)/foo/bar} $d } } -cleanup { safe::interpDelete $i set env(HOME) $savedHOME unset savedHOME } -result {$p(:0:)/foo/bar/~} test safe-16.7 {Bug 3529949: defang ~user in paths used by AliasGlob (1)} -setup { set i [safe::interpCreate] set user $tcl_platform(user) } -body { string map [list $user USER] [$i eval [list file join {$p(:0:)} ~$user]] } -cleanup { safe::interpDelete $i unset user } -result {$p(:0:)/~USER} test safe-16.8 {Bug 3529949: defang ~user in paths used by AliasGlob (2)} -setup { set i [safe::interpCreate] set user $tcl_platform(user) } -body { string map [list $user USER] [$i eval [list file join {$p(:0:)/foo/bar} ~$user]] } -cleanup { safe::interpDelete $i unset user } -result {$p(:0:)/foo/bar/~USER} # cleanup set ::auto_path $SaveAutoPath unset SaveAutoPath TestsDir PathMapp unset -nocomplain path rename mapList {} rename mapAndSortList {} |
︙ | ︙ |
Changes to tests/winFile.test.
︙ | ︙ | |||
24 25 26 27 28 29 30 | if {[testConstraint testvolumetype]} { testConstraint notNTFS [expr {[testvolumetype] eq "NTFS"}] } testConstraint notWine [expr {![info exists ::env(CI_USING_WINE)]}] test winFile-1.1 {TclpGetUserHome} -constraints {win} -body { glob ~nosuchuser | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | if {[testConstraint testvolumetype]} { testConstraint notNTFS [expr {[testvolumetype] eq "NTFS"}] } testConstraint notWine [expr {![info exists ::env(CI_USING_WINE)]}] test winFile-1.1 {TclpGetUserHome} -constraints {win} -body { glob ~nosuchuser } -returnCodes error -result {no files matched glob pattern "~nosuchuser"} test winFile-1.2 {TclpGetUserHome} -constraints {win nonPortable} -body { # The administrator account should always exist. glob ~administrator } -match glob -result * test winFile-1.4 {TclpGetUserHome} {win nonPortable} { catch {glob ~stanton@workgroup} } {0} |
︙ | ︙ |
Changes to unix/tclUnixInit.c.
︙ | ︙ | |||
858 859 860 861 862 863 864 865 866 867 868 869 870 871 | Tcl_SetVar2(interp, "tcl_pkgPath", NULL, pkgPath, TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); } else #endif /* HAVE_COREFOUNDATION */ { Tcl_SetVar2(interp, "tcl_pkgPath", NULL, pkgPath, TCL_GLOBAL_ONLY); } #ifdef DJGPP Tcl_SetVar2(interp, "tcl_platform", "platform", "dos", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "tcl_platform", "platform", "unix", TCL_GLOBAL_ONLY); #endif | > > > > > > > > > > > > | 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 | Tcl_SetVar2(interp, "tcl_pkgPath", NULL, pkgPath, TCL_GLOBAL_ONLY | TCL_APPEND_VALUE); } else #endif /* HAVE_COREFOUNDATION */ { Tcl_SetVar2(interp, "tcl_pkgPath", NULL, pkgPath, TCL_GLOBAL_ONLY); } { /* Some platforms build configure scripts expect ~ expansion so do that */ Tcl_Obj *origPaths; Tcl_Obj *resolvedPaths; origPaths = Tcl_GetVar2Ex(interp, "tcl_pkgPath", NULL, TCL_GLOBAL_ONLY); resolvedPaths = TclResolveTildePathList(origPaths); if (resolvedPaths != origPaths && resolvedPaths != NULL) { Tcl_SetVar2Ex(interp, "tcl_pkgPath", NULL, resolvedPaths, TCL_GLOBAL_ONLY); } } #ifdef DJGPP Tcl_SetVar2(interp, "tcl_platform", "platform", "dos", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "tcl_platform", "platform", "unix", TCL_GLOBAL_ONLY); #endif |
︙ | ︙ |
Changes to win/tclWinFCmd.c.
︙ | ︙ | |||
1711 1712 1713 1714 1715 1716 1717 | * fprintf(stderr, "%d\n", ((WCHAR *) nativeName)[0]); */ Tcl_DStringInit(&dsTemp); Tcl_WCharToUtfDString(nativeName, TCL_INDEX_NONE, &dsTemp); Tcl_DStringFree(&ds); | < < < < < < < < < < | < | | 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 | * fprintf(stderr, "%d\n", ((WCHAR *) nativeName)[0]); */ Tcl_DStringInit(&dsTemp); Tcl_WCharToUtfDString(nativeName, TCL_INDEX_NONE, &dsTemp); Tcl_DStringFree(&ds); tempPath = TclDStringToObj(&dsTemp); Tcl_ListObjReplace(NULL, splitPath, i, 1, 1, &tempPath); FindClose(handle); } } *attributePtrPtr = Tcl_FSJoinPath(splitPath, -1); if (splitPath != NULL) { |
︙ | ︙ |