Attachment "tauvan.patch" to
ticket [929534ffff]
added by
tauvan
2004-05-23 11:30:56.
0000: 00 0c 74 61 75 76 61 6e 2e 70 61 74 63 68 00 00 ..tauvan.patch..
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0050: 00 00 00 00 00 27 c3 be 00 00 00 00 c2 bc c3 95 .....'þ....¼Õ
0060: 52 7d c2 bc c3 95 52 c2 81 00 00 00 6d 42 49 4e R}¼ÕR...mBIN
0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0080: c2 82 c2 81 c2 b5 c2 93 00 00 49 6e 64 65 78 3a µ..Index:
0090: 20 75 6e 69 78 2f 74 63 6c 55 6e 69 78 46 43 6d unix/tclUnixFCm
00a0: 64 2e 63 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d d.c.============
00b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
00c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
00d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
00e0: 3d 3d 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c 65 =======.RCS file
00f0: 3a 20 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f 74 : /cvsroot/tcl/t
0100: 63 6c 2f 75 6e 69 78 2f 74 63 6c 55 6e 69 78 46 cl/unix/tclUnixF
0110: 43 6d 64 2e 63 2c 76 0a 72 65 74 72 69 65 76 69 Cmd.c,v.retrievi
0120: 6e 67 20 72 65 76 69 73 69 6f 6e 20 31 2e 33 37 ng revision 1.37
0130: 0a 64 69 66 66 20 2d 75 20 2d 70 20 2d 72 31 2e .diff -u -p -r1.
0140: 33 37 20 74 63 6c 55 6e 69 78 46 43 6d 64 2e 63 37 tclUnixFCmd.c
0150: 0a 2d 2d 2d 20 75 6e 69 78 2f 74 63 6c 55 6e 69 .--- unix/tclUni
0160: 78 46 43 6d 64 2e 63 09 32 36 20 41 70 72 20 32 xFCmd.c.26 Apr 2
0170: 30 30 34 20 31 35 3a 35 31 3a 32 30 20 2d 30 30 004 15:51:20 -00
0180: 30 30 09 31 2e 33 37 0a 2b 2b 2b 20 75 6e 69 78 00.1.37.+++ unix
0190: 2f 74 63 6c 55 6e 69 78 46 43 6d 64 2e 63 09 32 /tclUnixFCmd.c.2
01a0: 32 20 4d 61 79 20 32 30 30 34 20 32 32 3a 30 39 2 May 2004 22:09
01b0: 3a 35 38 20 2d 30 30 30 30 0a 40 40 20 2d 31 37 :58 -0000.@@ -17
01c0: 30 30 2c 31 36 31 20 2b 31 37 30 30 2c 31 35 39 00,161 +1700,159
01d0: 20 40 40 20 47 65 74 4d 6f 64 65 46 72 6f 6d 50 @@ GetModeFromP
01e0: 65 72 6d 53 74 72 69 6e 67 28 69 6e 74 65 72 70 ermString(interp
01f0: 2c 20 6d 6f 64 65 53 74 72 69 6e 67 0a 20 20 20 , modeString.
0200: 20 20 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b return TCL_OK;
0210: 0a 20 7d 0a 20 0c 0a 2b 73 74 61 74 69 63 20 76 . }. ..+static v
0220: 6f 69 64 0a 2b 66 69 6e 64 50 61 74 68 28 63 6f oid.+findPath(co
0230: 6e 73 74 20 63 68 61 72 20 2a 6f 72 67 50 61 74 nst char *orgPat
0240: 68 2c 20 63 68 61 72 20 2a 2a 72 65 74 50 61 74 h, char **retPat
0250: 68 2c 20 69 6e 74 20 2a 69 64 78 29 20 7b 0a 2b h, int *idx) {.+
0260: 20 20 20 20 73 74 72 75 63 74 20 73 74 61 74 20 struct stat
0270: 63 75 72 53 74 61 74 42 75 66 3b 0a 2b 20 20 20 curStatBuf;.+
0280: 20 63 68 61 72 20 2a 6e 65 77 4e 61 6d 65 20 3d char *newName =
0290: 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 63 68 61 72 NULL;.+ char
02a0: 20 2a 70 61 74 68 42 75 66 66 65 72 20 3d 20 2a *pathBuffer = *
02b0: 72 65 74 50 61 74 68 3b 0a 2b 20 20 20 20 69 6e retPath;.+ in
02c0: 74 20 70 42 64 65 78 20 3d 20 30 2c 20 6f 50 64 t pBdex = 0, oPd
02d0: 65 78 20 3d 20 2a 69 64 78 2c 20 72 65 64 65 78 ex = *idx, redex
02e0: 3b 0a 2b 20 20 20 20 69 6e 74 20 6f 50 6c 65 6e ;.+ int oPlen
02f0: 20 3d 20 73 74 72 6c 65 6e 28 6f 72 67 50 61 74 = strlen(orgPat
0300: 68 29 3b 0a 2b 20 20 20 20 0a 2b 20 20 20 20 65 h);.+ .+ e
0310: 72 72 6e 6f 20 3d 20 30 3b 0a 2b 20 20 20 20 0a rrno = 0;.+ .
0320: 2b 20 20 20 20 69 66 20 28 70 61 74 68 42 75 66 + if (pathBuf
0330: 66 65 72 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2b fer == NULL) {.+
0340: 20 20 20 20 20 20 20 20 70 61 74 68 42 75 66 66 pathBuff
0350: 65 72 20 3d 20 28 63 68 61 72 20 2a 29 6d 61 6c er = (char *)mal
0360: 6c 6f 63 28 32 2a 4d 41 58 50 41 54 48 4c 45 4e loc(2*MAXPATHLEN
0370: 20 2b 20 31 29 3b 0a 2b 20 20 20 20 20 20 20 20 + 1);.+
0380: 62 7a 65 72 6f 28 70 61 74 68 42 75 66 66 65 72 bzero(pathBuffer
0390: 2c 20 4d 41 58 50 41 54 48 4c 45 4e 29 3b 0a 2b , MAXPATHLEN);.+
03a0: 20 20 20 20 20 20 20 20 2a 72 65 74 50 61 74 68 *retPath
03b0: 20 3d 20 70 61 74 68 42 75 66 66 65 72 3b 0a 2b = pathBuffer;.+
03c0: 20 20 20 20 7d 0a 2b 20 20 20 20 0a 2b 20 20 20 }.+ .+
03d0: 20 69 66 20 28 6f 50 64 65 78 20 3d 3d 20 30 20 if (oPdex == 0
03e0: 26 26 20 6f 72 67 50 61 74 68 5b 30 5d 20 21 3d && orgPath[0] !=
03f0: 20 27 2f 27 29 20 7b 0a 2b 0a 2b 20 20 20 20 20 '/') {.+.+
0400: 20 20 20 2f 2a 20 68 6f 6d 65 20 63 6f 64 65 20 /* home code
0410: 6e 65 65 64 65 64 20 66 6f 72 20 72 75 6e 6e 69 needed for runni
0420: 6e 67 20 63 6d 64 41 48 2e 74 65 73 74 20 2a 2f ng cmdAH.test */
0430: 0a 2b 20 20 20 20 20 20 20 20 63 68 61 72 20 2a .+ char *
0440: 68 6f 6d 65 20 3d 20 67 65 74 65 6e 76 28 22 48 home = getenv("H
0450: 4f 4d 45 22 29 3b 0a 2b 20 20 20 20 20 20 20 20 OME");.+
0460: 69 6e 74 20 69 20 3d 20 73 74 72 6c 65 6e 28 68 int i = strlen(h
0470: 6f 6d 65 29 3b 0a 2b 20 20 20 20 20 20 20 20 69 ome);.+ i
0480: 66 20 28 69 20 21 3d 20 6f 50 6c 65 6e 29 20 7b f (i != oPlen) {
0490: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 66 6f .+ fo
04a0: 72 20 28 69 2d 2d 3b 20 69 20 3e 3d 20 30 3b 20 r (i--; i >= 0;
04b0: 69 2d 2d 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 i--) {.+
04c0: 20 20 20 20 20 20 20 20 69 66 20 28 68 6f 6d 65 if (home
04d0: 5b 69 20 2b 20 31 5d 20 21 3d 20 6f 72 67 50 61 [i + 1] != orgPa
04e0: 74 68 5b 69 5d 20 26 26 20 68 6f 6d 65 5b 69 20 th[i] && home[i
04f0: 2b 20 31 5d 20 21 3d 20 27 2f 27 29 0a 2b 20 20 + 1] != '/').+
0500: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0510: 20 20 62 72 65 61 6b 3b 0a 2b 20 20 20 20 20 20 break;.+
0520: 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 }.+
0530: 20 20 20 20 20 69 66 20 28 69 20 3c 20 30 29 20 if (i < 0)
0540: 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 {.+
0550: 20 20 20 6f 50 6c 65 6e 20 3d 20 73 74 72 6c 65 oPlen = strle
0560: 6e 28 68 6f 6d 65 29 3b 0a 2b 20 20 20 20 20 20 n(home);.+
0570: 20 20 20 20 20 20 20 20 20 20 64 6f 20 7b 20 70 do { p
0580: 61 74 68 42 75 66 66 65 72 5b 70 42 64 65 78 5d athBuffer[pBdex]
0590: 20 3d 20 68 6f 6d 65 5b 6f 50 64 65 78 5d 3b 20 = home[oPdex];
05a0: 70 42 64 65 78 2b 2b 3b 20 6f 50 64 65 78 2b 2b pBdex++; oPdex++
05b0: 3b 20 7d 0a 2b 20 20 20 20 20 20 20 20 20 20 20 ; }.+
05c0: 20 20 20 20 20 77 68 69 6c 65 20 28 6f 50 64 65 while (oPde
05d0: 78 20 3c 20 6f 50 6c 65 6e 29 3b 0a 2b 20 20 20 x < oPlen);.+
05e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 61 74 pat
05f0: 68 42 75 66 66 65 72 5b 70 42 64 65 78 5d 20 3d hBuffer[pBdex] =
0600: 20 30 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 0;.+
0610: 20 20 20 20 20 72 65 74 75 72 6e 3b 0a 2b 20 20 return;.+
0620: 20 20 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 }.+
0630: 20 20 20 20 20 7d 20 65 6c 73 65 20 69 66 20 28 } else if (
0640: 6f 72 67 50 61 74 68 5b 30 5d 20 3d 3d 20 27 7e orgPath[0] == '~
0650: 27 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 ') {.+
0660: 20 20 64 6f 20 7b 20 70 61 74 68 42 75 66 66 65 do { pathBuffe
0670: 72 5b 70 42 64 65 78 5d 20 3d 20 68 6f 6d 65 5b r[pBdex] = home[
0680: 6f 50 64 65 78 5d 3b 20 70 42 64 65 78 2b 2b 3b oPdex]; pBdex++;
0690: 20 6f 50 64 65 78 2b 2b 3b 20 7d 0a 2b 20 20 20 oPdex++; }.+
06a0: 20 20 20 20 20 20 20 20 20 77 68 69 6c 65 20 28 while (
06b0: 6f 50 64 65 78 20 3c 20 6f 50 6c 65 6e 29 3b 0a oPdex < oPlen);.
06c0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 70 61 74 + pat
06d0: 68 42 75 66 66 65 72 5b 70 42 64 65 78 5d 20 3d hBuffer[pBdex] =
06e0: 20 30 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 0;.+
06f0: 20 72 65 74 75 72 6e 3b 0a 2b 20 20 20 20 20 20 return;.+
0700: 20 20 7d 0a 2b 0a 2b 20 20 20 20 20 20 20 20 67 }.+.+ g
0710: 65 74 63 77 64 28 70 61 74 68 42 75 66 66 65 72 etcwd(pathBuffer
0720: 2c 20 28 32 2a 4d 41 58 50 41 54 48 4c 45 4e 29 , (2*MAXPATHLEN)
0730: 29 3b 0a 2b 20 20 20 20 20 20 20 20 70 42 64 65 );.+ pBde
0740: 78 20 3d 20 2a 69 64 78 20 3d 20 73 74 72 6c 65 x = *idx = strle
0750: 6e 28 70 61 74 68 42 75 66 66 65 72 29 3b 0a 2b n(pathBuffer);.+
0760: 20 20 20 20 20 20 20 20 0a 2b 20 20 20 20 20 20 .+
0770: 20 20 70 61 74 68 42 75 66 66 65 72 5b 70 42 64 pathBuffer[pBd
0780: 65 78 2b 2b 5d 20 3d 20 27 2f 27 3b 0a 2b 20 20 ex++] = '/';.+
0790: 20 20 20 20 20 20 64 6f 20 7b 20 70 61 74 68 42 do { pathB
07a0: 75 66 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 6f uffer[pBdex] = o
07b0: 72 67 50 61 74 68 5b 6f 50 64 65 78 5d 3b 20 70 rgPath[oPdex]; p
07c0: 42 64 65 78 2b 2b 3b 20 6f 50 64 65 78 2b 2b 3b Bdex++; oPdex++;
07d0: 20 7d 0a 2b 20 20 20 20 20 20 20 20 77 68 69 6c }.+ whil
07e0: 65 20 28 6f 50 64 65 78 20 3c 20 6f 50 6c 65 6e e (oPdex < oPlen
07f0: 29 3b 0a 2b 20 20 20 20 20 20 20 20 70 61 74 68 );.+ path
0800: 42 75 66 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 Buffer[pBdex] =
0810: 30 3b 0a 2b 20 20 20 20 20 20 20 20 66 69 6e 64 0;.+ find
0820: 50 61 74 68 28 70 61 74 68 42 75 66 66 65 72 2c Path(pathBuffer,
0830: 20 26 6e 65 77 4e 61 6d 65 2c 20 69 64 78 29 3b &newName, idx);
0840: 0a 2b 20 20 20 20 20 20 20 20 66 72 65 65 28 70 .+ free(p
0850: 61 74 68 42 75 66 66 65 72 29 3b 0a 2b 20 20 20 athBuffer);.+
0860: 20 20 20 20 20 2a 72 65 74 50 61 74 68 20 3d 20 *retPath =
0870: 6e 65 77 4e 61 6d 65 3b 0a 2b 20 20 20 20 20 20 newName;.+
0880: 20 20 72 65 74 75 72 6e 3b 0a 2b 20 20 20 20 7d return;.+ }
0890: 0a 2b 0a 2b 20 20 20 20 77 68 69 6c 65 20 28 70 .+.+ while (p
08a0: 42 64 65 78 20 3c 20 6f 50 64 65 78 29 20 70 61 Bdex < oPdex) pa
08b0: 74 68 42 75 66 66 65 72 5b 70 42 64 65 78 2b 2b thBuffer[pBdex++
08c0: 5d 20 3d 20 6f 72 67 50 61 74 68 5b 70 42 64 65 ] = orgPath[pBde
08d0: 78 5d 3b 0a 2b 20 20 20 20 6f 50 64 65 78 20 3d x];.+ oPdex =
08e0: 20 70 42 64 65 78 3b 0a 2b 66 69 6e 64 6e 65 78 pBdex;.+findnex
08f0: 74 3a 0a 2b 20 20 20 20 72 65 64 65 78 20 3d 20 t:.+ redex =
0900: 6f 50 64 65 78 20 2b 20 31 3b 0a 2b 20 20 20 20 oPdex + 1;.+
0910: 64 6f 20 7b 20 70 61 74 68 42 75 66 66 65 72 5b do { pathBuffer[
0920: 70 42 64 65 78 5d 20 3d 20 6f 72 67 50 61 74 68 pBdex] = orgPath
0930: 5b 6f 50 64 65 78 5d 3b 20 70 42 64 65 78 2b 2b [oPdex]; pBdex++
0940: 3b 20 6f 50 64 65 78 2b 2b 3b 20 7d 0a 2b 20 20 ; oPdex++; }.+
0950: 20 20 77 68 69 6c 65 20 28 6f 72 67 50 61 74 68 while (orgPath
0960: 5b 6f 50 64 65 78 5d 20 21 3d 20 27 2f 27 20 26 [oPdex] != '/' &
0970: 26 20 6f 50 64 65 78 20 3c 20 6f 50 6c 65 6e 29 & oPdex < oPlen)
0980: 3b 0a 2b 20 20 20 20 69 66 20 28 6f 50 64 65 78 ;.+ if (oPdex
0990: 20 3d 3d 20 6f 50 6c 65 6e 29 20 7b 0a 2b 20 20 == oPlen) {.+
09a0: 20 20 20 20 20 20 2a 69 64 78 20 3d 20 72 65 64 *idx = red
09b0: 65 78 20 2d 20 31 3b 0a 2b 20 20 20 20 20 20 20 ex - 1;.+
09c0: 20 72 65 74 75 72 6e 3b 0a 2b 20 20 20 20 7d 0a return;.+ }.
09d0: 2b 20 20 20 20 6c 73 74 61 74 28 70 61 74 68 42 + lstat(pathB
09e0: 75 66 66 65 72 2c 20 26 63 75 72 53 74 61 74 42 uffer, &curStatB
09f0: 75 66 29 3b 0a 2b 20 20 20 20 69 66 20 28 53 5f uf);.+ if (S_
0a00: 49 53 4c 4e 4b 28 63 75 72 53 74 61 74 42 75 66 ISLNK(curStatBuf
0a10: 2e 73 74 5f 6d 6f 64 65 29 29 20 7b 0a 2b 20 20 .st_mode)) {.+
0a20: 20 20 20 20 20 20 69 6e 74 20 6e 6f 72 6d 50 61 int normPa
0a30: 74 68 4c 65 6e 3b 0a 2b 20 20 20 20 20 20 20 20 thLen;.+
0a40: 0a 2b 20 20 20 20 20 20 20 20 6e 6f 72 6d 50 61 .+ normPa
0a50: 74 68 4c 65 6e 20 3d 20 72 65 61 64 6c 69 6e 6b thLen = readlink
0a60: 28 70 61 74 68 42 75 66 66 65 72 2c 20 28 26 70 (pathBuffer, (&p
0a70: 61 74 68 42 75 66 66 65 72 5b 72 65 64 65 78 5d athBuffer[redex]
0a80: 29 2c 20 28 32 2a 4d 41 58 50 41 54 48 4c 45 4e ), (2*MAXPATHLEN
0a90: 20 2d 20 72 65 64 65 78 29 29 3b 0a 2b 20 20 20 - redex));.+
0aa0: 20 20 20 20 20 70 61 74 68 42 75 66 66 65 72 5b pathBuffer[
0ab0: 72 65 64 65 78 20 2b 20 6e 6f 72 6d 50 61 74 68 redex + normPath
0ac0: 4c 65 6e 5d 20 3d 20 30 3b 0a 2b 20 20 20 20 20 Len] = 0;.+
0ad0: 20 20 20 69 66 20 28 70 61 74 68 42 75 66 66 65 if (pathBuffe
0ae0: 72 5b 72 65 64 65 78 5d 20 3d 3d 20 27 2f 27 29 r[redex] == '/')
0af0: 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 {.+
0b00: 70 42 64 65 78 20 3d 20 30 3b 0a 2b 20 20 20 20 pBdex = 0;.+
0b10: 20 20 20 20 20 20 20 20 64 6f 20 7b 20 70 61 74 do { pat
0b20: 68 42 75 66 66 65 72 5b 70 42 64 65 78 5d 20 3d hBuffer[pBdex] =
0b30: 20 70 61 74 68 42 75 66 66 65 72 5b 72 65 64 65 pathBuffer[rede
0b40: 78 5d 3b 20 70 42 64 65 78 2b 2b 3b 20 72 65 64 x]; pBdex++; red
0b50: 65 78 2b 2b 3b 20 7d 0a 2b 20 20 20 20 20 20 20 ex++; }.+
0b60: 20 20 20 20 20 77 68 69 6c 65 20 28 2d 2d 6e 6f while (--no
0b70: 72 6d 50 61 74 68 4c 65 6e 20 3e 20 30 29 3b 0a rmPathLen > 0);.
0b80: 2b 20 20 20 20 20 20 20 20 7d 20 65 6c 73 65 20 + } else
0b90: 69 66 20 28 70 61 74 68 42 75 66 66 65 72 5b 72 if (pathBuffer[r
0ba0: 65 64 65 78 5d 20 3d 3d 20 27 2e 27 20 26 26 20 edex] == '.' &&
0bb0: 70 61 74 68 42 75 66 66 65 72 5b 72 65 64 65 78 pathBuffer[redex
0bc0: 20 2b 20 31 5d 20 3d 3d 20 27 2e 27 20 26 26 20 + 1] == '.' &&
0bd0: 70 61 74 68 42 75 66 66 65 72 5b 72 65 64 65 78 pathBuffer[redex
0be0: 20 2b 20 32 5d 20 3d 3d 20 27 2f 27 29 20 7b 0a + 2] == '/') {.
0bf0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 70 42 64 + pBd
0c00: 65 78 20 3d 20 72 65 64 65 78 3b 0a 2b 20 20 20 ex = redex;.+
0c10: 20 20 20 20 20 20 20 20 20 64 6f 20 7b 0a 2b 20 do {.+
0c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70 p
0c30: 42 64 65 78 20 2d 3d 20 32 3b 0a 2b 20 20 20 20 Bdex -= 2;.+
0c40: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 64 65 rede
0c50: 78 20 2b 3d 20 33 3b 0a 2b 20 20 20 20 20 20 20 x += 3;.+
0c60: 20 20 20 20 20 20 20 20 20 6e 6f 72 6d 50 61 74 normPat
0c70: 68 4c 65 6e 20 2d 3d 20 33 3b 0a 2b 20 20 20 20 hLen -= 3;.+
0c80: 20 20 20 20 20 20 20 20 20 20 20 20 77 68 69 6c whil
0c90: 65 20 28 70 61 74 68 42 75 66 66 65 72 5b 70 42 e (pathBuffer[pB
0ca0: 64 65 78 5d 20 21 3d 20 27 2f 27 20 26 26 20 70 dex] != '/' && p
0cb0: 42 64 65 78 20 3e 20 30 29 20 70 42 64 65 78 2d Bdex > 0) pBdex-
0cc0: 2d 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 -;.+
0cd0: 7d 20 77 68 69 6c 65 20 28 70 61 74 68 42 75 66 } while (pathBuf
0ce0: 66 65 72 5b 72 65 64 65 78 5d 20 3d 3d 20 27 2e fer[redex] == '.
0cf0: 27 20 26 26 20 70 61 74 68 42 75 66 66 65 72 5b ' && pathBuffer[
0d00: 72 65 64 65 78 20 2b 20 31 5d 20 3d 3d 20 27 2e redex + 1] == '.
0d10: 27 20 26 26 20 70 61 74 68 42 75 66 66 65 72 5b ' && pathBuffer[
0d20: 72 65 64 65 78 20 2b 20 32 5d 20 3d 3d 20 27 2f redex + 2] == '/
0d30: 27 20 26 26 20 70 42 64 65 78 20 3e 20 30 29 3b ' && pBdex > 0);
0d40: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .+ if
0d50: 20 28 70 42 64 65 78 20 3d 3d 20 30 29 20 7b 20 (pBdex == 0) {
0d60: 72 65 64 65 78 2d 2d 3b 20 6e 6f 72 6d 50 61 74 redex--; normPat
0d70: 68 4c 65 6e 2b 2b 3b 20 7d 0a 2b 20 20 20 20 20 hLen++; }.+
0d80: 20 20 20 20 20 20 20 64 6f 20 7b 20 70 61 74 68 do { path
0d90: 42 75 66 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 Buffer[pBdex] =
0da0: 70 61 74 68 42 75 66 66 65 72 5b 72 65 64 65 78 pathBuffer[redex
0db0: 5d 3b 20 70 42 64 65 78 2b 2b 3b 20 72 65 64 65 ]; pBdex++; rede
0dc0: 78 2b 2b 3b 20 7d 0a 2b 20 20 20 20 20 20 20 20 x++; }.+
0dd0: 20 20 20 20 77 68 69 6c 65 20 28 2d 2d 6e 6f 72 while (--nor
0de0: 6d 50 61 74 68 4c 65 6e 20 3e 20 30 29 3b 0a 2b mPathLen > 0);.+
0df0: 20 20 20 20 20 20 20 20 7d 20 65 6c 73 65 20 7b } else {
0e00: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 70 42 .+ pB
0e10: 64 65 78 20 3d 20 72 65 64 65 78 20 2b 20 6e 6f dex = redex + no
0e20: 72 6d 50 61 74 68 4c 65 6e 3b 0a 2b 20 20 20 20 rmPathLen;.+
0e30: 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 64 }.+ d
0e40: 6f 20 7b 20 70 61 74 68 42 75 66 66 65 72 5b 70 o { pathBuffer[p
0e50: 42 64 65 78 5d 20 3d 20 6f 72 67 50 61 74 68 5b Bdex] = orgPath[
0e60: 6f 50 64 65 78 5d 3b 20 70 42 64 65 78 2b 2b 3b oPdex]; pBdex++;
0e70: 20 6f 50 64 65 78 2b 2b 3b 20 7d 0a 2b 20 20 20 oPdex++; }.+
0e80: 20 20 20 20 20 77 68 69 6c 65 20 28 6f 50 64 65 while (oPde
0e90: 78 20 3c 20 6f 50 6c 65 6e 29 3b 0a 2b 20 20 20 x < oPlen);.+
0ea0: 20 20 20 20 20 70 61 74 68 42 75 66 66 65 72 5b pathBuffer[
0eb0: 70 42 64 65 78 5d 20 3d 20 30 3b 0a 2b 20 20 20 pBdex] = 0;.+
0ec0: 20 20 20 20 20 2a 69 64 78 20 3d 20 30 3b 0a 2b *idx = 0;.+
0ed0: 20 20 20 20 20 20 20 20 66 69 6e 64 50 61 74 68 findPath
0ee0: 28 70 61 74 68 42 75 66 66 65 72 2c 20 26 6e 65 (pathBuffer, &ne
0ef0: 77 4e 61 6d 65 2c 20 69 64 78 29 3b 0a 2b 20 20 wName, idx);.+
0f00: 20 20 20 20 20 20 66 72 65 65 28 70 61 74 68 42 free(pathB
0f10: 75 66 66 65 72 29 3b 0a 2b 20 20 20 20 20 20 20 uffer);.+
0f20: 20 2a 72 65 74 50 61 74 68 20 3d 20 6e 65 77 4e *retPath = newN
0f30: 61 6d 65 3b 0a 2b 20 20 20 20 20 20 20 20 72 65 ame;.+ re
0f40: 74 75 72 6e 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 turn;.+ }.+
0f50: 20 20 69 66 20 28 65 72 72 6e 6f 29 20 7b 0a 2b if (errno) {.+
0f60: 20 20 20 20 20 20 20 20 64 6f 20 7b 20 70 61 74 do { pat
0f70: 68 42 75 66 66 65 72 5b 70 42 64 65 78 5d 20 3d hBuffer[pBdex] =
0f80: 20 6f 72 67 50 61 74 68 5b 6f 50 64 65 78 5d 3b orgPath[oPdex];
0f90: 20 70 42 64 65 78 2b 2b 3b 20 6f 50 64 65 78 2b pBdex++; oPdex+
0fa0: 2b 3b 20 7d 0a 2b 20 20 20 20 20 20 20 20 77 68 +; }.+ wh
0fb0: 69 6c 65 20 28 6f 50 64 65 78 20 3c 20 6f 50 6c ile (oPdex < oPl
0fc0: 65 6e 29 3b 0a 2b 20 20 20 20 20 20 20 20 70 61 en);.+ pa
0fd0: 74 68 42 75 66 66 65 72 5b 70 42 64 65 78 5d 20 thBuffer[pBdex]
0fe0: 3d 20 30 3b 0a 2b 20 20 20 20 20 20 20 20 2a 69 = 0;.+ *i
0ff0: 64 78 20 3d 20 72 65 64 65 78 20 2d 20 31 3b 0a dx = redex - 1;.
1000: 2b 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b + return;
1010: 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 67 6f 74 .+ }.+ got
1020: 6f 20 66 69 6e 64 6e 65 78 74 3b 0a 2b 7d 0a 2b o findnext;.+}.+
1030: 0a 20 2f 2a 0a 2d 20 2a 2d 2d 2d 2d 2d 2d 2d 2d . /*.- *--------
1040: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1050: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1060: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1070: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1080: 2d 2d 2d 0a 2b 20 2a 20 20 54 63 6c 4f 62 6a 4e ---.+ * TclObjN
1090: 6f 72 6d 61 6c 69 7a 65 50 61 74 68 2e 63 0a 20 ormalizePath.c.
10a0: 20 2a 0a 2d 20 2a 20 54 63 6c 70 4f 62 6a 4e 6f *.- * TclpObjNo
10b0: 72 6d 61 6c 69 7a 65 50 61 74 68 20 2d 2d 0a 2d rmalizePath --.-
10c0: 20 2a 0a 2d 20 2a 09 54 68 69 73 20 66 75 6e 63 *.- *.This func
10d0: 74 69 6f 6e 20 73 63 61 6e 73 20 74 68 72 6f 75 tion scans throu
10e0: 67 68 20 61 20 70 61 74 68 20 73 70 65 63 69 66 gh a path specif
10f0: 69 63 61 74 69 6f 6e 20 61 6e 64 20 72 65 70 6c ication and repl
1100: 61 63 65 73 0a 2d 20 2a 09 69 74 2c 20 69 6e 20 aces.- *.it, in
1110: 70 6c 61 63 65 2c 20 77 69 74 68 20 61 20 6e 6f place, with a no
1120: 72 6d 61 6c 69 7a 65 64 20 76 65 72 73 69 6f 6e rmalized version
1130: 2e 20 20 41 20 6e 6f 72 6d 61 6c 69 7a 65 64 20 . A normalized
1140: 76 65 72 73 69 6f 6e 0a 2d 20 2a 09 69 73 20 6f version.- *.is o
1150: 6e 65 20 69 6e 20 77 68 69 63 68 20 61 6c 6c 20 ne in which all
1160: 73 79 6d 6c 69 6e 6b 73 20 69 6e 20 74 68 65 20 symlinks in the
1170: 70 61 74 68 20 61 72 65 20 72 65 70 6c 61 63 65 path are replace
1180: 64 20 77 69 74 68 0a 2d 20 2a 09 74 68 65 69 72 d with.- *.their
1190: 20 65 78 70 61 6e 64 65 64 20 66 6f 72 6d 20 28 expanded form (
11a0: 65 78 63 65 70 74 20 61 20 73 79 6d 6c 69 6e 6b except a symlink
11b0: 20 61 74 20 74 68 65 20 76 65 72 79 20 65 6e 64 at the very end
11c0: 20 6f 66 20 74 68 65 0a 2d 20 2a 09 70 61 74 68 of the.- *.path
11d0: 29 2e 0a 2d 20 2a 0a 2d 20 2a 20 52 65 73 75 6c )..- *.- * Resul
11e0: 74 73 3a 0a 2d 20 2a 09 54 68 65 20 6e 65 77 20 ts:.- *.The new
11f0: 27 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 27 'nextCheckpoint'
1200: 20 76 61 6c 75 65 2c 20 67 69 76 69 6e 67 20 61 value, giving a
1210: 73 20 66 61 72 20 61 73 20 77 65 20 63 6f 75 6c s far as we coul
1220: 64 0a 2d 20 2a 09 75 6e 64 65 72 73 74 61 6e 64 d.- *.understand
1230: 20 69 6e 20 74 68 65 20 70 61 74 68 2e 0a 2d 20 in the path..-
1240: 2a 0a 2d 20 2a 20 53 69 64 65 20 65 66 66 65 63 *.- * Side effec
1250: 74 73 3a 0a 2d 20 2a 09 54 68 65 20 70 61 74 68 ts:.- *.The path
1260: 50 74 72 20 73 74 72 69 6e 67 2c 20 69 73 20 6d Ptr string, is m
1270: 6f 64 69 66 69 65 64 2e 0a 2d 20 2a 0a 2d 20 2a odified..- *.- *
1280: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1290: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
12a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
12b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
12c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 20 -----------.+ *
12d0: 20 09 54 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 .This function
12e0: 74 61 6b 65 73 20 61 20 70 61 74 68 20 73 74 72 takes a path str
12f0: 69 6e 67 20 61 6e 64 20 72 65 70 6c 61 63 65 73 ing and replaces
1300: 20 69 74 0a 2b 20 2a 09 77 69 74 68 20 61 20 6e it.+ *.with a n
1310: 6f 72 6d 61 6c 69 7a 65 64 20 70 61 74 68 2e 20 ormalized path.
1320: 54 68 65 20 65 6e 74 65 72 69 6e 67 20 70 61 74 The entering pat
1330: 68 20 73 74 72 69 6e 67 0a 2b 20 2a 09 6d 75 73 h string.+ *.mus
1340: 74 20 62 65 20 76 6f 69 64 20 6f 66 20 2e 2e 2f t be void of ../
1350: 2c 20 2e 2f 20 73 65 71 75 65 6e 63 65 73 2e 20 , ./ sequences.
1360: 54 68 65 20 72 65 74 75 72 6e 65 64 20 70 61 74 The returned pat
1370: 68 0a 2b 20 2a 09 77 69 6c 6c 20 62 65 20 6e 6f h.+ *.will be no
1380: 72 6d 61 6c 69 7a 65 64 20 75 70 20 74 6f 20 6e rmalized up to n
1390: 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 2c 20 77 extCheckpoint, w
13a0: 68 69 63 68 20 70 6f 69 6e 74 73 20 74 6f 0a 2b hich points to.+
13b0: 20 2a 09 65 69 74 68 65 72 20 74 68 65 20 6c 61 *.either the la
13c0: 73 74 20 70 61 74 68 20 73 65 70 61 72 61 74 6f st path separato
13d0: 72 20 6f 72 20 74 68 65 20 6f 66 66 65 6e 64 69 r or the offendi
13e0: 6e 67 20 73 65 70 61 72 61 74 6f 72 2e 0a 2b 20 ng separator..+
13f0: 2a 09 54 68 65 20 65 6e 64 20 77 6f 72 64 20 6f *.The end word o
1400: 66 20 74 68 65 20 70 61 74 68 20 77 69 6c 6c 20 f the path will
1410: 6e 6f 74 20 62 65 20 6e 6f 72 6d 61 6c 69 7a 65 not be normalize
1420: 64 2c 20 69 74 20 69 73 0a 2b 20 2a 09 74 6f 74 d, it is.+ *.tot
1430: 61 6c 6c 79 20 69 67 6e 6f 72 65 64 2e 0a 2b 20 ally ignored..+
1440: 2a 20 20 0a 2b 20 2a 20 20 52 65 73 75 6c 74 73 * .+ * Results
1450: 3a 0a 2b 20 2a 09 70 61 74 68 50 74 72 20 61 6c :.+ *.pathPtr al
1460: 74 65 72 65 64 20 77 69 74 68 20 72 65 73 75 6c tered with resul
1470: 74 20 6f 66 20 6e 6f 72 6d 61 6c 69 7a 61 74 69 t of normalizati
1480: 6f 6e 0a 2b 20 2a 09 6e 65 78 74 43 68 65 63 6b on.+ *.nextCheck
1490: 70 6f 69 6e 74 20 70 6f 69 6e 74 73 20 74 6f 20 point points to
14a0: 65 6e 64 20 73 65 70 61 72 61 74 6f 72 20 6f 72 end separator or
14b0: 20 6f 66 66 65 6e 64 69 6e 67 2c 0a 2b 20 2a 09 offending,.+ *.
14c0: 69 65 2e 2e 20 74 68 65 20 6c 61 73 74 20 67 6f ie.. the last go
14d0: 6f 64 20 73 65 70 61 72 61 74 6f 72 20 70 72 69 od separator pri
14e0: 6f 72 20 74 6f 20 70 72 6f 62 6c 65 6d 20 70 61 or to problem pa
14f0: 74 68 0a 2b 20 2a 0a 2b 20 2a 20 20 53 69 64 65 th.+ *.+ * Side
1500: 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a 09 69 66 effects:.+ *.if
1510: 20 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 20 nextCheckpoint
1520: 70 6f 69 6e 74 73 20 74 6f 20 65 6e 64 20 73 65 points to end se
1530: 70 61 72 61 74 6f 72 2c 20 64 6f 20 6e 6f 74 0a parator, do not.
1540: 2b 20 2a 09 6d 61 6b 65 20 61 73 73 75 6d 70 74 + *.make assumpt
1550: 69 6f 6e 20 6f 66 20 61 20 66 75 6c 6c 79 20 71 ion of a fully q
1560: 75 61 6c 69 66 69 65 64 20 70 61 74 68 2e 0a 2b ualified path..+
1570: 20 2a 09 4f 63 63 75 72 61 6e 63 65 3a 20 77 68 *.Occurance: wh
1580: 65 6e 20 22 6a 6f 69 6e 22 20 61 64 64 73 20 74 en "join" adds t
1590: 6f 20 61 20 66 69 6c 65 20 69 6e 73 74 65 61 64 o a file instead
15a0: 20 6f 66 20 64 69 72 65 63 74 6f 72 79 2e 0a 2b of directory..+
15b0: 20 2a 09 54 68 65 20 66 69 6c 65 20 77 69 6c 6c *.The file will
15c0: 20 62 65 20 6e 6f 72 6d 61 6c 69 7a 65 64 20 62 be normalized b
15d0: 75 74 20 69 73 20 6e 6f 74 20 61 20 64 69 72 65 ut is not a dire
15e0: 63 74 6f 72 79 2e 0a 2b 20 2a 0a 2b 20 2a 20 20 ctory..+ *.+ *
15f0: 52 65 74 75 72 6e 73 3a 0a 2b 20 2a 09 6e 65 78 Returns:.+ *.nex
1600: 74 43 68 65 63 6b 70 6f 69 6e 74 0a 2b 20 2a 09 tCheckpoint.+ *.
1610: 70 61 74 68 50 74 72 0a 20 20 2a 2f 0a 2b 0a 20 pathPtr. */.+.
1620: 69 6e 74 0a 20 54 63 6c 70 4f 62 6a 4e 6f 72 6d int. TclpObjNorm
1630: 61 6c 69 7a 65 50 61 74 68 28 69 6e 74 65 72 70 alizePath(interp
1640: 2c 20 70 61 74 68 50 74 72 2c 20 6e 65 78 74 43 , pathPtr, nextC
1650: 68 65 63 6b 70 6f 69 6e 74 29 0a 20 20 20 20 20 heckpoint).
1660: 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 Tcl_Interp *inte
1670: 72 70 3b 0a 20 20 20 20 20 54 63 6c 5f 4f 62 6a rp;. Tcl_Obj
1680: 20 2a 70 61 74 68 50 74 72 3b 0a 20 20 20 20 20 *pathPtr;.
1690: 69 6e 74 20 6e 65 78 74 43 68 65 63 6b 70 6f 69 int nextCheckpoi
16a0: 6e 74 3b 0a 20 7b 0a 2d 20 20 20 20 63 68 61 72 nt;. {.- char
16b0: 20 2a 63 75 72 72 65 6e 74 50 61 74 68 45 6e 64 *currentPathEnd
16c0: 50 6f 73 69 74 69 6f 6e 3b 0a 20 20 20 20 20 69 Position;. i
16d0: 6e 74 20 70 61 74 68 4c 65 6e 3b 0a 2d 20 20 20 nt pathLen;.-
16e0: 20 63 68 61 72 20 63 75 72 3b 0a 2b 20 20 20 20 char cur;.+
16f0: 63 68 61 72 20 2a 72 65 73 6f 6c 76 65 64 50 61 char *resolvedPa
1700: 74 68 20 3d 20 4e 55 4c 4c 3b 0a 20 20 20 20 20 th = NULL;.
1710: 63 68 61 72 20 2a 70 61 74 68 20 3d 20 54 63 6c char *path = Tcl
1720: 5f 47 65 74 53 74 72 69 6e 67 46 72 6f 6d 4f 62 _GetStringFromOb
1730: 6a 28 70 61 74 68 50 74 72 2c 20 26 70 61 74 68 j(pathPtr, &path
1740: 4c 65 6e 29 3b 0a 2d 23 69 66 6e 64 65 66 20 4e Len);.-#ifndef N
1750: 4f 5f 52 45 41 4c 50 41 54 48 0a 2d 20 20 20 20 O_REALPATH.-
1760: 63 68 61 72 20 6e 6f 72 6d 50 61 74 68 5b 4d 41 char normPath[MA
1770: 58 50 41 54 48 4c 45 4e 5d 3b 0a 2d 20 20 20 20 XPATHLEN];.-
1780: 54 63 6c 5f 44 53 74 72 69 6e 67 20 64 73 3b 0a Tcl_DString ds;.
1790: 2d 20 20 20 20 43 4f 4e 53 54 20 63 68 61 72 20 - CONST char
17a0: 2a 6e 61 74 69 76 65 50 61 74 68 3b 20 0a 2d 23 *nativePath; .-#
17b0: 65 6e 64 69 66 0a 2d 20 20 20 20 2f 2a 20 0a 2d endif.- /* .-
17c0: 20 20 20 20 20 2a 20 57 65 20 61 64 64 20 27 31 * We add '1
17d0: 27 20 68 65 72 65 20 62 65 63 61 75 73 65 20 69 ' here because i
17e0: 66 20 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 f nextCheckpoint
17f0: 20 69 73 20 7a 65 72 6f 20 77 65 20 6b 6e 6f 77 is zero we know
1800: 0a 2d 20 20 20 20 20 2a 20 74 68 61 74 20 27 2f .- * that '/
1810: 27 20 65 78 69 73 74 73 2c 20 61 6e 64 20 69 66 ' exists, and if
1820: 20 69 74 20 69 73 6e 27 74 20 7a 65 72 6f 2c 20 it isn't zero,
1830: 69 74 20 6d 75 73 74 20 70 6f 69 6e 74 20 61 74 it must point at
1840: 0a 2d 20 20 20 20 20 2a 20 61 20 64 69 72 65 63 .- * a direc
1850: 74 6f 72 79 20 73 65 70 61 72 61 74 6f 72 20 77 tory separator w
1860: 68 69 63 68 20 77 65 20 61 6c 73 6f 20 6b 6e 6f hich we also kno
1870: 77 20 65 78 69 73 74 73 2e 0a 2d 20 20 20 20 20 w exists..-
1880: 2a 2f 0a 2d 20 20 20 20 63 75 72 72 65 6e 74 50 */.- currentP
1890: 61 74 68 45 6e 64 50 6f 73 69 74 69 6f 6e 20 3d athEndPosition =
18a0: 20 70 61 74 68 20 2b 20 6e 65 78 74 43 68 65 63 path + nextChec
18b0: 6b 70 6f 69 6e 74 3b 0a 2d 20 20 20 20 69 66 20 kpoint;.- if
18c0: 28 2a 63 75 72 72 65 6e 74 50 61 74 68 45 6e 64 (*currentPathEnd
18d0: 50 6f 73 69 74 69 6f 6e 20 3d 3d 20 27 2f 27 29 Position == '/')
18e0: 20 7b 0a 2d 09 63 75 72 72 65 6e 74 50 61 74 68 {.-.currentPath
18f0: 45 6e 64 50 6f 73 69 74 69 6f 6e 2b 2b 3b 0a 2d EndPosition++;.-
1900: 20 20 20 20 7d 0a 2d 0a 2d 23 69 66 6e 64 65 66 }.-.-#ifndef
1910: 20 4e 4f 5f 52 45 41 4c 50 41 54 48 0a 2d 20 20 NO_REALPATH.-
1920: 20 20 2f 2a 20 46 6f 72 20 73 70 65 65 64 2c 20 /* For speed,
1930: 74 72 79 20 74 6f 20 67 65 74 20 74 68 65 20 65 try to get the e
1940: 6e 74 69 72 65 20 70 61 74 68 20 69 6e 20 6f 6e ntire path in on
1950: 65 20 67 6f 20 2a 2f 0a 2d 20 20 20 20 69 66 20 e go */.- if
1960: 28 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 20 (nextCheckpoint
1970: 3d 3d 20 30 29 20 7b 0a 2d 20 20 20 20 20 20 20 == 0) {.-
1980: 20 63 68 61 72 20 2a 6c 61 73 74 44 69 72 20 3d char *lastDir =
1990: 20 73 74 72 72 63 68 72 28 63 75 72 72 65 6e 74 strrchr(current
19a0: 50 61 74 68 45 6e 64 50 6f 73 69 74 69 6f 6e 2c PathEndPosition,
19b0: 20 27 2f 27 29 3b 0a 2d 09 69 66 20 28 6c 61 73 '/');.-.if (las
19c0: 74 44 69 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a tDir != NULL) {.
19d0: 2d 09 20 20 20 20 6e 61 74 69 76 65 50 61 74 68 -. nativePath
19e0: 20 3d 20 54 63 6c 5f 55 74 66 54 6f 45 78 74 65 = Tcl_UtfToExte
19f0: 72 6e 61 6c 44 53 74 72 69 6e 67 28 4e 55 4c 4c rnalDString(NULL
1a00: 2c 20 70 61 74 68 2c 20 0a 2d 09 09 09 09 09 09 , path, .-......
1a10: 20 20 6c 61 73 74 44 69 72 20 2d 20 70 61 74 68 lastDir - path
1a20: 2c 20 26 64 73 29 3b 0a 2d 09 20 20 20 20 69 66 , &ds);.-. if
1a30: 20 28 52 65 61 6c 70 61 74 68 28 6e 61 74 69 76 (Realpath(nativ
1a40: 65 50 61 74 68 2c 20 6e 6f 72 6d 50 61 74 68 29 ePath, normPath)
1a50: 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2d 09 09 6e != NULL) {.-..n
1a60: 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 20 3d 20 extCheckpoint =
1a70: 6c 61 73 74 44 69 72 20 2d 20 70 61 74 68 3b 0a lastDir - path;.
1a80: 2d 09 09 67 6f 74 6f 20 77 68 6f 6c 65 53 74 72 -..goto wholeStr
1a90: 69 6e 67 4f 6b 3b 0a 2d 09 20 20 20 20 7d 0a 2d ingOk;.-. }.-
1aa0: 09 7d 0a 2d 20 20 20 20 7d 0a 2d 20 20 20 20 2f .}.- }.- /
1ab0: 2a 20 45 6c 73 65 20 64 6f 20 69 74 20 74 68 65 * Else do it the
1ac0: 20 73 6c 6f 77 20 77 61 79 20 2a 2f 0a 2d 23 65 slow way */.-#e
1ad0: 6e 64 69 66 0a 2d 20 20 20 20 0a 2d 20 20 20 20 ndif.- .-
1ae0: 77 68 69 6c 65 20 28 31 29 20 7b 0a 2d 09 63 75 while (1) {.-.cu
1af0: 72 20 3d 20 2a 63 75 72 72 65 6e 74 50 61 74 68 r = *currentPath
1b00: 45 6e 64 50 6f 73 69 74 69 6f 6e 3b 0a 2d 09 69 EndPosition;.-.i
1b10: 66 20 28 28 63 75 72 20 3d 3d 20 27 2f 27 29 20 f ((cur == '/')
1b20: 26 26 20 28 70 61 74 68 20 21 3d 20 63 75 72 72 && (path != curr
1b30: 65 6e 74 50 61 74 68 45 6e 64 50 6f 73 69 74 69 entPathEndPositi
1b40: 6f 6e 29 29 20 7b 0a 2d 09 20 20 20 20 2f 2a 20 on)) {.-. /*
1b50: 52 65 61 63 68 65 64 20 64 69 72 65 63 74 6f 72 Reached director
1b60: 79 20 73 65 70 61 72 61 74 6f 72 20 2a 2f 0a 2d y separator */.-
1b70: 09 20 20 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 . Tcl_DString
1b80: 20 64 73 3b 0a 2d 09 20 20 20 20 43 4f 4e 53 54 ds;.-. CONST
1b90: 20 63 68 61 72 20 2a 6e 61 74 69 76 65 50 61 74 char *nativePat
1ba0: 68 3b 0a 2d 09 20 20 20 20 69 6e 74 20 61 63 63 h;.-. int acc
1bb0: 65 73 73 4f 6b 3b 0a 2d 0a 2d 09 20 20 20 20 6e essOk;.-.-. n
1bc0: 61 74 69 76 65 50 61 74 68 20 3d 20 54 63 6c 5f ativePath = Tcl_
1bd0: 55 74 66 54 6f 45 78 74 65 72 6e 61 6c 44 53 74 UtfToExternalDSt
1be0: 72 69 6e 67 28 4e 55 4c 4c 2c 20 70 61 74 68 2c ring(NULL, path,
1bf0: 20 0a 2d 09 09 20 20 20 20 63 75 72 72 65 6e 74 .-.. current
1c00: 50 61 74 68 45 6e 64 50 6f 73 69 74 69 6f 6e 20 PathEndPosition
1c10: 2d 20 70 61 74 68 2c 20 26 64 73 29 3b 0a 2d 09 - path, &ds);.-.
1c20: 20 20 20 20 61 63 63 65 73 73 4f 6b 20 3d 20 61 accessOk = a
1c30: 63 63 65 73 73 28 6e 61 74 69 76 65 50 61 74 68 ccess(nativePath
1c40: 2c 20 46 5f 4f 4b 29 3b 0a 2d 09 20 20 20 20 54 , F_OK);.-. T
1c50: 63 6c 5f 44 53 74 72 69 6e 67 46 72 65 65 28 26 cl_DStringFree(&
1c60: 64 73 29 3b 0a 2d 09 20 20 20 20 69 66 20 28 61 ds);.-. if (a
1c70: 63 63 65 73 73 4f 6b 20 21 3d 20 30 29 20 7b 0a ccessOk != 0) {.
1c80: 2d 09 09 2f 2a 20 46 69 6c 65 20 64 6f 65 73 6e -../* File doesn
1c90: 27 74 20 65 78 69 73 74 20 2a 2f 0a 2d 09 09 62 't exist */.-..b
1ca0: 72 65 61 6b 3b 0a 2d 09 20 20 20 20 7d 0a 2d 09 reak;.-. }.-.
1cb0: 20 20 20 20 2f 2a 20 55 70 64 61 74 65 20 74 68 /* Update th
1cc0: 65 20 61 63 63 65 70 74 61 62 6c 65 20 70 6f 69 e acceptable poi
1cd0: 6e 74 20 2a 2f 0a 2d 09 20 20 20 20 6e 65 78 74 nt */.-. next
1ce0: 43 68 65 63 6b 70 6f 69 6e 74 20 3d 20 63 75 72 Checkpoint = cur
1cf0: 72 65 6e 74 50 61 74 68 45 6e 64 50 6f 73 69 74 rentPathEndPosit
1d00: 69 6f 6e 20 2d 20 70 61 74 68 3b 0a 2d 09 7d 20 ion - path;.-.}
1d10: 65 6c 73 65 20 69 66 20 28 63 75 72 20 3d 3d 20 else if (cur ==
1d20: 30 29 20 7b 0a 2d 09 20 20 20 20 2f 2a 20 52 65 0) {.-. /* Re
1d30: 61 63 68 65 64 20 65 6e 64 20 6f 66 20 73 74 72 ached end of str
1d40: 69 6e 67 20 2a 2f 0a 2d 09 20 20 20 20 62 72 65 ing */.-. bre
1d50: 61 6b 3b 0a 2d 09 7d 0a 2d 09 63 75 72 72 65 6e ak;.-.}.-.curren
1d60: 74 50 61 74 68 45 6e 64 50 6f 73 69 74 69 6f 6e tPathEndPosition
1d70: 2b 2b 3b 0a 2d 20 20 20 20 7d 0a 2d 20 20 20 20 ++;.- }.-
1d80: 2f 2a 20 0a 2d 20 20 20 20 20 2a 20 57 65 20 73 /* .- * We s
1d90: 68 6f 75 6c 64 20 72 65 61 6c 6c 79 20 6e 6f 77 hould really now
1da0: 20 63 6f 6e 76 65 72 74 20 74 68 69 73 20 74 6f convert this to
1db0: 20 61 20 63 61 6e 6f 6e 69 63 61 6c 20 70 61 74 a canonical pat
1dc0: 68 2e 20 20 57 65 20 64 6f 0a 2d 20 20 20 20 20 h. We do.-
1dd0: 2a 20 74 68 61 74 20 77 69 74 68 20 27 72 65 61 * that with 'rea
1de0: 6c 70 61 74 68 27 20 69 66 20 77 65 20 68 61 76 lpath' if we hav
1df0: 65 20 69 74 20 61 76 61 69 6c 61 62 6c 65 2e 20 e it available.
1e00: 20 4f 74 68 65 72 77 69 73 65 20 77 65 20 63 6f Otherwise we co
1e10: 75 6c 64 0a 2d 20 20 20 20 20 2a 20 73 74 65 70 uld.- * step
1e20: 20 74 68 72 6f 75 67 68 20 65 76 65 72 79 20 73 through every s
1e30: 69 6e 67 6c 65 20 70 61 74 68 20 63 6f 6d 70 6f ingle path compo
1e40: 6e 65 6e 74 2c 20 63 68 65 63 6b 69 6e 67 20 77 nent, checking w
1e50: 68 65 74 68 65 72 20 69 74 20 69 73 20 61 20 0a hether it is a .
1e60: 2d 20 20 20 20 20 2a 20 73 79 6d 6c 69 6e 6b 2c - * symlink,
1e70: 20 62 75 74 20 74 68 61 74 20 77 6f 75 6c 64 20 but that would
1e80: 62 65 20 61 20 6c 6f 74 20 6f 66 20 77 6f 72 6b be a lot of work
1e90: 2c 20 61 6e 64 20 6d 6f 73 74 20 6d 6f 64 65 72 , and most moder
1ea0: 6e 20 4f 53 65 73 20 0a 2d 20 20 20 20 20 2a 20 n OSes .- *
1eb0: 68 61 76 65 20 27 72 65 61 6c 70 61 74 68 27 2e have 'realpath'.
1ec0: 0a 2d 20 20 20 20 20 2a 2f 0a 2d 23 69 66 6e 64 .- */.-#ifnd
1ed0: 65 66 20 4e 4f 5f 52 45 41 4c 50 41 54 48 0a 2d ef NO_REALPATH.-
1ee0: 20 20 20 20 2f 2a 20 0a 2d 20 20 20 20 20 2a 20 /* .- *
1ef0: 49 66 20 77 65 20 6f 6e 6c 79 20 68 61 64 20 27 If we only had '
1f00: 2f 66 6f 6f 27 20 6f 72 20 27 2f 27 20 74 68 65 /foo' or '/' the
1f10: 6e 20 77 65 20 6e 65 76 65 72 20 69 6e 63 72 65 n we never incre
1f20: 6d 65 6e 74 20 6e 65 78 74 43 68 65 63 6b 70 6f ment nextCheckpo
1f30: 69 6e 74 0a 2d 20 20 20 20 20 2a 20 61 6e 64 20 int.- * and
1f40: 77 65 20 64 6f 6e 27 74 20 6e 65 65 64 20 6f 72 we don't need or
1f50: 20 77 61 6e 74 20 74 6f 20 67 6f 20 74 68 72 6f want to go thro
1f60: 75 67 68 20 27 52 65 61 6c 70 61 74 68 27 2e 20 ugh 'Realpath'.
1f70: 20 41 6c 73 6f 2c 20 6f 6e 20 73 6f 6d 65 0a 2d Also, on some.-
1f80: 20 20 20 20 20 2a 20 70 6c 61 74 66 6f 72 6d 73 * platforms
1f90: 2c 20 70 61 73 73 69 6e 67 20 61 6e 20 65 6d 70 , passing an emp
1fa0: 74 79 20 73 74 72 69 6e 67 20 74 6f 20 27 52 65 ty string to 'Re
1fb0: 61 6c 70 61 74 68 27 20 77 69 6c 6c 20 67 69 76 alpath' will giv
1fc0: 65 20 75 73 20 74 68 65 0a 2d 20 20 20 20 20 2a e us the.- *
1fd0: 20 6e 6f 72 6d 61 6c 69 7a 65 64 20 70 77 64 2c normalized pwd,
1fe0: 20 77 68 69 63 68 20 69 73 20 6e 6f 74 20 77 68 which is not wh
1ff0: 61 74 20 77 65 20 77 61 6e 74 20 61 74 20 61 6c at we want at al
2000: 6c 21 0a 2d 20 20 20 20 20 2a 2f 0a 2d 20 20 20 l!.- */.-
2010: 20 69 66 20 28 6e 65 78 74 43 68 65 63 6b 70 6f if (nextCheckpo
2020: 69 6e 74 20 3d 3d 20 30 29 20 72 65 74 75 72 6e int == 0) return
2030: 20 30 3b 0a 2d 20 20 20 20 0a 2d 20 20 20 20 6e 0;.- .- n
2040: 61 74 69 76 65 50 61 74 68 20 3d 20 54 63 6c 5f ativePath = Tcl_
2050: 55 74 66 54 6f 45 78 74 65 72 6e 61 6c 44 53 74 UtfToExternalDSt
2060: 72 69 6e 67 28 4e 55 4c 4c 2c 20 70 61 74 68 2c ring(NULL, path,
2070: 20 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 2c nextCheckpoint,
2080: 20 26 64 73 29 3b 0a 2d 20 20 20 20 69 66 20 28 &ds);.- if (
2090: 52 65 61 6c 70 61 74 68 28 6e 61 74 69 76 65 50 Realpath(nativeP
20a0: 61 74 68 2c 20 6e 6f 72 6d 50 61 74 68 29 20 21 ath, normPath) !
20b0: 3d 20 4e 55 4c 4c 29 20 7b 0a 2d 09 69 6e 74 20 = NULL) {.-.int
20c0: 6e 65 77 4e 6f 72 6d 4c 65 6e 3b 0a 2d 09 77 68 newNormLen;.-.wh
20d0: 6f 6c 65 53 74 72 69 6e 67 4f 6b 3a 0a 2d 09 6e oleStringOk:.-.n
20e0: 65 77 4e 6f 72 6d 4c 65 6e 20 3d 20 73 74 72 6c ewNormLen = strl
20f0: 65 6e 28 6e 6f 72 6d 50 61 74 68 29 3b 0a 2d 09 en(normPath);.-.
2100: 69 66 20 28 28 6e 65 77 4e 6f 72 6d 4c 65 6e 20 if ((newNormLen
2110: 3d 3d 20 54 63 6c 5f 44 53 74 72 69 6e 67 4c 65 == Tcl_DStringLe
2120: 6e 67 74 68 28 26 64 73 29 29 0a 2d 09 09 26 26 ngth(&ds)).-..&&
2130: 20 28 73 74 72 63 6d 70 28 6e 6f 72 6d 50 61 74 (strcmp(normPat
2140: 68 2c 20 6e 61 74 69 76 65 50 61 74 68 29 20 3d h, nativePath) =
2150: 3d 20 30 29 29 20 7b 0a 2d 09 20 20 20 20 2f 2a = 0)) {.-. /*
2160: 20 53 74 72 69 6e 67 20 69 73 20 75 6e 63 68 61 String is uncha
2170: 6e 67 65 64 20 2a 2f 0a 2d 09 20 20 20 20 54 63 nged */.-. Tc
2180: 6c 5f 44 53 74 72 69 6e 67 46 72 65 65 28 26 64 l_DStringFree(&d
2190: 73 29 3b 0a 2d 09 20 20 20 20 2f 2a 0a 2d 09 20 s);.-. /*.-.
21a0: 20 20 20 20 2a 20 45 6e 61 62 6c 65 20 74 68 69 * Enable thi
21b0: 73 20 74 6f 20 68 61 76 65 20 74 68 65 20 6e 61 s to have the na
21c0: 74 69 76 65 20 46 53 20 63 6c 61 69 6d 20 6e 6f tive FS claim no
21d0: 72 6d 61 6c 69 7a 61 74 69 6f 6e 20 6f 66 0a 2d rmalization of.-
21e0: 09 20 20 20 20 20 2a 20 74 68 65 20 77 68 6f 6c . * the whol
21f0: 65 20 70 61 74 68 20 66 6f 72 20 65 78 69 73 74 e path for exist
2200: 69 6e 67 20 66 69 6c 65 73 2e 20 20 54 68 61 74 ing files. That
2210: 20 77 6f 75 6c 64 20 70 65 72 6d 69 74 20 74 68 would permit th
2220: 65 0a 2d 09 20 20 20 20 20 2a 20 63 61 6c 6c 65 e.-. * calle
2230: 72 20 74 6f 20 64 65 63 6c 61 72 65 20 6e 6f 72 r to declare nor
2240: 6d 61 6c 69 7a 61 74 69 6f 6e 20 63 6f 6d 70 6c malization compl
2250: 65 74 65 20 77 69 74 68 6f 75 74 20 63 61 6c 6c ete without call
2260: 73 20 74 6f 0a 2d 09 20 20 20 20 20 2a 20 61 64 s to.-. * ad
2270: 64 69 74 69 6f 6e 61 6c 20 66 69 6c 65 73 79 73 ditional filesys
2280: 74 65 6d 73 2e 20 20 53 61 76 69 6e 67 20 6c 6f tems. Saving lo
2290: 74 73 20 6f 66 20 63 61 6c 6c 73 20 69 73 20 70 ts of calls is p
22a0: 72 6f 62 61 62 6c 79 0a 2d 09 20 20 20 20 20 2a robably.-. *
22b0: 20 77 6f 72 74 68 20 74 68 65 20 65 78 74 72 61 worth the extra
22c0: 20 61 63 63 65 73 73 28 29 20 74 69 6d 65 20 68 access() time h
22d0: 65 72 65 2e 20 20 57 68 65 6e 20 6e 6f 20 6f 74 ere. When no ot
22e0: 68 65 72 20 46 53 27 73 0a 2d 09 20 20 20 20 20 her FS's.-.
22f0: 2a 20 61 72 65 20 72 65 67 69 73 74 65 72 65 64 * are registered
2300: 20 74 68 6f 75 67 68 2c 20 74 68 69 6e 67 73 20 though, things
2310: 61 72 65 20 6c 65 73 73 20 63 6c 65 61 72 2e 0a are less clear..
2320: 2d 09 20 20 20 20 20 2a 0a 2d 09 20 20 20 20 69 -. *.-. i
2330: 66 20 28 30 20 3d 3d 20 61 63 63 65 73 73 28 6e f (0 == access(n
2340: 6f 72 6d 50 61 74 68 2c 20 46 5f 4f 4b 29 29 20 ormPath, F_OK))
2350: 7b 0a 2d 09 09 72 65 74 75 72 6e 20 70 61 74 68 {.-..return path
2360: 4c 65 6e 3b 0a 2d 09 20 20 20 20 7d 0a 2d 09 20 Len;.-. }.-.
2370: 20 20 20 20 2a 2f 0a 2d 09 20 20 20 20 72 65 74 */.-. ret
2380: 75 72 6e 20 6e 65 78 74 43 68 65 63 6b 70 6f 69 urn nextCheckpoi
2390: 6e 74 3b 0a 2d 09 7d 0a 2d 09 0a 2d 09 2f 2a 20 nt;.-.}.-..-./*
23a0: 0a 2d 09 20 2a 20 46 72 65 65 20 75 70 20 74 68 .-. * Free up th
23b0: 65 20 6e 61 74 69 76 65 20 70 61 74 68 20 61 6e e native path an
23c0: 64 20 70 75 74 20 69 6e 20 69 74 73 20 70 6c 61 d put in its pla
23d0: 63 65 20 74 68 65 0a 2d 09 20 2a 20 63 6f 6e 76 ce the.-. * conv
23e0: 65 72 74 65 64 2c 20 6e 6f 72 6d 61 6c 69 7a 65 erted, normalize
23f0: 64 20 70 61 74 68 2e 0a 2d 09 20 2a 2f 0a 2d 09 d path..-. */.-.
2400: 54 63 6c 5f 44 53 74 72 69 6e 67 46 72 65 65 28 Tcl_DStringFree(
2410: 26 64 73 29 3b 0a 2d 09 54 63 6c 5f 45 78 74 65 &ds);.-.Tcl_Exte
2420: 72 6e 61 6c 54 6f 55 74 66 44 53 74 72 69 6e 67 rnalToUtfDString
2430: 28 4e 55 4c 4c 2c 20 6e 6f 72 6d 50 61 74 68 2c (NULL, normPath,
2440: 20 28 69 6e 74 29 20 6e 65 77 4e 6f 72 6d 4c 65 (int) newNormLe
2450: 6e 2c 20 26 64 73 29 3b 0a 2d 0a 2d 09 69 66 20 n, &ds);.-.-.if
2460: 28 70 61 74 68 5b 6e 65 78 74 43 68 65 63 6b 70 (path[nextCheckp
2470: 6f 69 6e 74 5d 20 21 3d 20 27 5c 30 27 29 20 7b oint] != '\0') {
2480: 0a 2d 09 20 20 20 20 2f 2a 20 6e 6f 74 20 61 74 .-. /* not at
2490: 20 65 6e 64 2c 20 61 70 70 65 6e 64 20 72 65 6d end, append rem
24a0: 61 69 6e 69 6e 67 20 70 61 74 68 20 2a 2f 0a 2d aining path */.-
24b0: 09 20 20 20 20 69 6e 74 20 6e 6f 72 6d 4c 65 6e . int normLen
24c0: 20 3d 20 54 63 6c 5f 44 53 74 72 69 6e 67 4c 65 = Tcl_DStringLe
24d0: 6e 67 74 68 28 26 64 73 29 3b 0a 2d 09 20 20 20 ngth(&ds);.-.
24e0: 20 54 63 6c 5f 44 53 74 72 69 6e 67 41 70 70 65 Tcl_DStringAppe
24f0: 6e 64 28 26 64 73 2c 20 70 61 74 68 20 2b 20 6e nd(&ds, path + n
2500: 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 2c 0a 2d extCheckpoint,.-
2510: 09 09 20 20 20 20 70 61 74 68 4c 65 6e 20 2d 20 .. pathLen -
2520: 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 29 3b nextCheckpoint);
2530: 0a 2d 09 20 20 20 20 2f 2a 20 0a 2d 09 20 20 20 .-. /* .-.
2540: 20 20 2a 20 57 65 20 72 65 63 6f 67 6e 69 73 65 * We recognise
2550: 20 75 70 20 74 6f 20 61 6e 64 20 69 6e 63 6c 75 up to and inclu
2560: 64 69 6e 67 20 74 68 65 20 64 69 72 65 63 74 6f ding the directo
2570: 72 79 0a 2d 09 20 20 20 20 20 2a 20 73 65 70 61 ry.-. * sepa
2580: 72 61 74 6f 72 2e 0a 2d 09 20 20 20 20 20 2a 2f rator..-. */
2590: 09 0a 2d 09 20 20 20 20 6e 65 78 74 43 68 65 63 ..-. nextChec
25a0: 6b 70 6f 69 6e 74 20 3d 20 6e 6f 72 6d 4c 65 6e kpoint = normLen
25b0: 20 2b 20 31 3b 0a 2d 09 7d 20 65 6c 73 65 20 7b + 1;.-.} else {
25c0: 0a 2d 09 20 20 20 20 2f 2a 20 57 65 20 72 65 63 .-. /* We rec
25d0: 6f 67 6e 69 73 65 20 74 68 65 20 77 68 6f 6c 65 ognise the whole
25e0: 20 73 74 72 69 6e 67 20 2a 2f 20 0a 2d 09 20 20 string */ .-.
25f0: 20 20 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 nextCheckpoint
2600: 20 3d 20 54 63 6c 5f 44 53 74 72 69 6e 67 4c 65 = Tcl_DStringLe
2610: 6e 67 74 68 28 26 64 73 29 3b 0a 2d 09 7d 0a 2d ngth(&ds);.-.}.-
2620: 09 2f 2a 20 0a 2d 09 20 2a 20 4f 76 65 72 77 72 ./* .-. * Overwr
2630: 69 74 65 20 77 69 74 68 20 74 68 65 20 6e 6f 72 ite with the nor
2640: 6d 61 6c 69 7a 65 64 20 70 61 74 68 2e 0a 2d 09 malized path..-.
2650: 20 2a 2f 0a 2d 09 54 63 6c 5f 53 65 74 53 74 72 */.-.Tcl_SetStr
2660: 69 6e 67 4f 62 6a 28 70 61 74 68 50 74 72 2c 20 ingObj(pathPtr,
2670: 54 63 6c 5f 44 53 74 72 69 6e 67 56 61 6c 75 65 Tcl_DStringValue
2680: 28 26 64 73 29 2c 0a 2d 09 09 54 63 6c 5f 44 53 (&ds),.-..Tcl_DS
2690: 74 72 69 6e 67 4c 65 6e 67 74 68 28 26 64 73 29 tringLength(&ds)
26a0: 29 3b 0a 2d 20 20 20 20 7d 0a 2d 20 20 20 20 54 );.- }.- T
26b0: 63 6c 5f 44 53 74 72 69 6e 67 46 72 65 65 28 26 cl_DStringFree(&
26c0: 64 73 29 3b 0a 2d 23 65 6e 64 69 66 09 2f 2a 20 ds);.-#endif./*
26d0: 21 4e 4f 5f 52 45 41 4c 50 41 54 48 20 2a 2f 0a !NO_REALPATH */.
26e0: 20 0a 2b 20 20 20 20 6e 65 78 74 43 68 65 63 6b .+ nextCheck
26f0: 70 6f 69 6e 74 20 3d 20 30 3b 0a 2b 20 20 20 20 point = 0;.+
2700: 66 69 6e 64 50 61 74 68 28 70 61 74 68 2c 20 26 findPath(path, &
2710: 72 65 73 6f 6c 76 65 64 50 61 74 68 2c 20 26 6e resolvedPath, &n
2720: 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 29 3b 0a extCheckpoint);.
2730: 2b 20 20 20 20 69 66 20 28 72 65 73 6f 6c 76 65 + if (resolve
2740: 64 50 61 74 68 29 20 7b 0a 2b 20 20 20 20 20 20 dPath) {.+
2750: 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 20 64 73 Tcl_DString ds
2760: 3b 0a 2b 20 20 20 20 20 20 20 20 70 61 74 68 4c ;.+ pathL
2770: 65 6e 20 3d 20 73 74 72 6c 65 6e 28 72 65 73 6f en = strlen(reso
2780: 6c 76 65 64 50 61 74 68 29 3b 0a 2b 20 20 20 20 lvedPath);.+
2790: 20 20 20 20 54 63 6c 5f 45 78 74 65 72 6e 61 6c Tcl_External
27a0: 54 6f 55 74 66 44 53 74 72 69 6e 67 28 4e 55 4c ToUtfDString(NUL
27b0: 4c 2c 20 72 65 73 6f 6c 76 65 64 50 61 74 68 2c L, resolvedPath,
27c0: 20 70 61 74 68 4c 65 6e 2c 20 26 64 73 29 3b 0a pathLen, &ds);.
27d0: 2b 20 20 20 20 20 20 20 20 54 63 6c 5f 53 65 74 + Tcl_Set
27e0: 53 74 72 69 6e 67 4f 62 6a 28 70 61 74 68 50 74 StringObj(pathPt
27f0: 72 2c 20 54 63 6c 5f 44 53 74 72 69 6e 67 56 61 r, Tcl_DStringVa
2800: 6c 75 65 28 26 64 73 29 2c 20 54 63 6c 5f 44 53 lue(&ds), Tcl_DS
2810: 74 72 69 6e 67 4c 65 6e 67 74 68 28 26 64 73 29 tringLength(&ds)
2820: 29 3b 0a 2b 20 20 20 20 20 20 20 20 54 63 6c 5f );.+ Tcl_
2830: 44 53 74 72 69 6e 67 46 72 65 65 28 26 64 73 29 DStringFree(&ds)
2840: 3b 0a 2b 20 20 20 20 20 20 20 20 66 72 65 65 28 ;.+ free(
2850: 72 65 73 6f 6c 76 65 64 50 61 74 68 29 3b 0a 2b resolvedPath);.+
2860: 20 20 20 20 7d 0a 20 20 20 20 20 72 65 74 75 72 }. retur
2870: 6e 20 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 n nextCheckpoint
2880: 3b 0a 20 7d 0a 20 0c 0a 00 00 ;. }. ....