Tcl Source Code

Hex Artifact Content
Login

Artifact faca4d6489a86999cfb0d8746599d19d44382d9c:

Attachment "c84b_filesystem.patch" to ticket [929534ffff] added by tauvan 2004-05-23 11:29:26.
0000: 00 15 63 38 34 62 5f 66 69 6c 65 73 79 73 74 65  ..c84b_filesyste
0010: 6d 2e 70 61 74 63 68 00 00 00 00 00 00 00 00 00  m.patch.........
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 26 68 00 00 00 00 c2 bc c3 95 c2  .....&h....¼Õ�
0060: 97 60 c2 bc c3 95 c2 97 c2 80 00 00 00 6d 42 49  �`¼Õ—€...mBI
0070: 4e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  N...............
0080: 00 c2 82 c2 81 c2 8d c2 82 00 00 49 6e 64 65 78  .‚‚..Index
0090: 3a 20 75 6e 69 78 2f 74 63 6c 55 6e 69 78 46 43  : unix/tclUnixFC
00a0: 6d 64 2e 63 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  md.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 3d 0a 52 43 53 20 66 69 6c  ========.RCS fil
00f0: 65 3a 20 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f  e: /cvsroot/tcl/
0100: 74 63 6c 2f 75 6e 69 78 2f 74 63 6c 55 6e 69 78  tcl/unix/tclUnix
0110: 46 43 6d 64 2e 63 2c 76 0a 72 65 74 72 69 65 76  FCmd.c,v.retriev
0120: 69 6e 67 20 72 65 76 69 73 69 6f 6e 20 31 2e 32  ing revision 1.2
0130: 38 2e 32 2e 32 0a 64 69 66 66 20 2d 75 20 2d 70  8.2.2.diff -u -p
0140: 20 2d 72 31 2e 32 38 2e 32 2e 32 20 74 63 6c 55   -r1.28.2.2 tclU
0150: 6e 69 78 46 43 6d 64 2e 63 0a 2d 2d 2d 20 75 6e  nixFCmd.c.--- un
0160: 69 78 2f 74 63 6c 55 6e 69 78 46 43 6d 64 2e 63  ix/tclUnixFCmd.c
0170: 09 33 20 4f 63 74 20 32 30 30 33 20 31 37 3a 34  .3 Oct 2003 17:4
0180: 35 3a 33 37 20 2d 30 30 30 30 09 31 2e 32 38 2e  5:37 -0000.1.28.
0190: 32 2e 32 0a 2b 2b 2b 20 75 6e 69 78 2f 74 63 6c  2.2.+++ unix/tcl
01a0: 55 6e 69 78 46 43 6d 64 2e 63 09 32 33 20 4d 61  UnixFCmd.c.23 Ma
01b0: 79 20 32 30 30 34 20 30 33 3a 30 33 3a 34 37 20  y 2004 03:03:47 
01c0: 2d 30 30 30 30 0a 40 40 20 2d 31 36 34 35 2c 31  -0000.@@ -1645,1
01d0: 35 34 20 2b 31 36 34 35 2c 31 35 38 20 40 40 20  54 +1645,158 @@ 
01e0: 47 65 74 4d 6f 64 65 46 72 6f 6d 50 65 72 6d 53  GetModeFromPermS
01f0: 74 72 69 6e 67 28 69 6e 74 65 72 70 2c 20 6d 6f  tring(interp, mo
0200: 64 65 53 74 72 69 6e 67 0a 20 20 20 20 20 72 65  deString.     re
0210: 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 20 7d 0a  turn TCL_OK;. }.
0220: 20 0c 0a 2b 73 74 61 74 69 63 20 76 6f 69 64 0a   ..+static void.
0230: 2b 66 69 6e 64 50 61 74 68 28 63 6f 6e 73 74 20  +findPath(const 
0240: 63 68 61 72 20 2a 6f 72 67 50 61 74 68 2c 20 63  char *orgPath, c
0250: 68 61 72 20 2a 2a 72 65 74 50 61 74 68 2c 20 69  har **retPath, i
0260: 6e 74 20 2a 69 64 78 29 20 7b 0a 2b 20 20 20 20  nt *idx) {.+    
0270: 73 74 72 75 63 74 20 73 74 61 74 20 63 75 72 53  struct stat curS
0280: 74 61 74 42 75 66 3b 0a 2b 20 20 20 20 63 68 61  tatBuf;.+    cha
0290: 72 20 2a 6e 65 77 4e 61 6d 65 20 3d 20 4e 55 4c  r *newName = NUL
02a0: 4c 3b 0a 2b 20 20 20 20 63 68 61 72 20 2a 70 61  L;.+    char *pa
02b0: 74 68 42 75 66 66 65 72 20 3d 20 2a 72 65 74 50  thBuffer = *retP
02c0: 61 74 68 3b 0a 2b 20 20 20 20 69 6e 74 20 70 42  ath;.+    int pB
02d0: 64 65 78 20 3d 20 30 2c 20 6f 50 64 65 78 20 3d  dex = 0, oPdex =
02e0: 20 2a 69 64 78 2c 20 72 65 64 65 78 3b 0a 2b 20   *idx, redex;.+ 
02f0: 20 20 20 69 6e 74 20 6f 50 6c 65 6e 20 3d 20 73     int oPlen = s
0300: 74 72 6c 65 6e 28 6f 72 67 50 61 74 68 29 3b 0a  trlen(orgPath);.
0310: 2b 20 20 20 20 0a 2b 20 20 20 20 65 72 72 6e 6f  +    .+    errno
0320: 20 3d 20 30 3b 0a 2b 20 20 20 20 0a 2b 20 20 20   = 0;.+    .+   
0330: 20 69 66 20 28 70 61 74 68 42 75 66 66 65 72 20   if (pathBuffer 
0340: 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20  == NULL) {.+    
0350: 20 20 20 20 70 61 74 68 42 75 66 66 65 72 20 3d      pathBuffer =
0360: 20 28 63 68 61 72 20 2a 29 6d 61 6c 6c 6f 63 28   (char *)malloc(
0370: 32 2a 4d 41 58 50 41 54 48 4c 45 4e 20 2b 20 31  2*MAXPATHLEN + 1
0380: 29 3b 0a 2b 20 20 20 20 20 20 20 20 62 7a 65 72  );.+        bzer
0390: 6f 28 70 61 74 68 42 75 66 66 65 72 2c 20 4d 41  o(pathBuffer, MA
03a0: 58 50 41 54 48 4c 45 4e 29 3b 0a 2b 20 20 20 20  XPATHLEN);.+    
03b0: 20 20 20 20 2a 72 65 74 50 61 74 68 20 3d 20 70      *retPath = p
03c0: 61 74 68 42 75 66 66 65 72 3b 0a 2b 20 20 20 20  athBuffer;.+    
03d0: 7d 0a 2b 20 20 20 20 0a 2b 20 20 20 20 69 66 20  }.+    .+    if 
03e0: 28 6f 50 64 65 78 20 3d 3d 20 30 20 26 26 20 6f  (oPdex == 0 && o
03f0: 72 67 50 61 74 68 5b 30 5d 20 21 3d 20 27 2f 27  rgPath[0] != '/'
0400: 29 20 7b 0a 2b 0a 2b 20 20 20 20 20 20 20 20 2f  ) {.+.+        /
0410: 2a 20 68 6f 6d 65 20 63 6f 64 65 20 6e 65 65 64  * home code need
0420: 65 64 20 66 6f 72 20 72 75 6e 6e 69 6e 67 20 63  ed for running c
0430: 6d 64 41 48 2e 74 65 73 74 20 2a 2f 0a 2b 20 20  mdAH.test */.+  
0440: 20 20 20 20 20 20 63 68 61 72 20 2a 68 6f 6d 65        char *home
0450: 20 3d 20 67 65 74 65 6e 76 28 22 48 4f 4d 45 22   = getenv("HOME"
0460: 29 3b 0a 2b 20 20 20 20 20 20 20 20 69 6e 74 20  );.+        int 
0470: 69 20 3d 20 73 74 72 6c 65 6e 28 68 6f 6d 65 29  i = strlen(home)
0480: 3b 0a 2b 20 20 20 20 20 20 20 20 69 66 20 28 69  ;.+        if (i
0490: 20 21 3d 20 6f 50 6c 65 6e 29 20 7b 0a 2b 20 20   != oPlen) {.+  
04a0: 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 69            for (i
04b0: 2d 2d 3b 20 69 20 3e 3d 20 30 3b 20 69 2d 2d 29  --; i >= 0; i--)
04c0: 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20   {.+            
04d0: 20 20 20 20 69 66 20 28 68 6f 6d 65 5b 69 20 2b      if (home[i +
04e0: 20 31 5d 20 21 3d 20 6f 72 67 50 61 74 68 5b 69   1] != orgPath[i
04f0: 5d 20 26 26 20 68 6f 6d 65 5b 69 20 2b 20 31 5d  ] && home[i + 1]
0500: 20 21 3d 20 27 2f 27 29 0a 2b 20 20 20 20 20 20   != '/').+      
0510: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72                br
0520: 65 61 6b 3b 0a 2b 20 20 20 20 20 20 20 20 20 20  eak;.+          
0530: 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 20 20 20    }.+           
0540: 20 69 66 20 28 69 20 3c 20 30 29 20 7b 0a 2b 20   if (i < 0) {.+ 
0550: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
0560: 50 6c 65 6e 20 3d 20 73 74 72 6c 65 6e 28 68 6f  Plen = strlen(ho
0570: 6d 65 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20  me);.+          
0580: 20 20 20 20 20 20 64 6f 20 7b 20 70 61 74 68 42        do { pathB
0590: 75 66 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 68  uffer[pBdex] = h
05a0: 6f 6d 65 5b 6f 50 64 65 78 5d 3b 20 70 42 64 65  ome[oPdex]; pBde
05b0: 78 2b 2b 3b 20 6f 50 64 65 78 2b 2b 3b 20 7d 0a  x++; oPdex++; }.
05c0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
05d0: 20 77 68 69 6c 65 20 28 6f 50 64 65 78 20 3c 20   while (oPdex < 
05e0: 6f 50 6c 65 6e 29 3b 0a 2b 20 20 20 20 20 20 20  oPlen);.+       
05f0: 20 20 20 20 20 20 20 20 20 70 61 74 68 42 75 66           pathBuf
0600: 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 30 3b 0a  fer[pBdex] = 0;.
0610: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
0620: 20 72 65 74 75 72 6e 3b 0a 2b 20 20 20 20 20 20   return;.+      
0630: 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20        }.+       
0640: 20 7d 20 65 6c 73 65 20 69 66 20 28 6f 72 67 50   } else if (orgP
0650: 61 74 68 5b 30 5d 20 3d 3d 20 27 7e 27 29 20 7b  ath[0] == '~') {
0660: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 64 6f  .+            do
0670: 20 7b 20 70 61 74 68 42 75 66 66 65 72 5b 70 42   { pathBuffer[pB
0680: 64 65 78 5d 20 3d 20 68 6f 6d 65 5b 6f 50 64 65  dex] = home[oPde
0690: 78 5d 3b 20 70 42 64 65 78 2b 2b 3b 20 6f 50 64  x]; pBdex++; oPd
06a0: 65 78 2b 2b 3b 20 7d 0a 2b 20 20 20 20 20 20 20  ex++; }.+       
06b0: 20 20 20 20 20 77 68 69 6c 65 20 28 6f 50 64 65       while (oPde
06c0: 78 20 3c 20 6f 50 6c 65 6e 29 3b 0a 2b 20 20 20  x < oPlen);.+   
06d0: 20 20 20 20 20 20 20 20 20 70 61 74 68 42 75 66           pathBuf
06e0: 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 30 3b 0a  fer[pBdex] = 0;.
06f0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74  +            ret
0700: 75 72 6e 3b 0a 2b 20 20 20 20 20 20 20 20 7d 0a  urn;.+        }.
0710: 2b 0a 2b 20 20 20 20 20 20 20 20 67 65 74 63 77  +.+        getcw
0720: 64 28 70 61 74 68 42 75 66 66 65 72 2c 20 28 32  d(pathBuffer, (2
0730: 2a 4d 41 58 50 41 54 48 4c 45 4e 29 29 3b 0a 2b  *MAXPATHLEN));.+
0740: 20 20 20 20 20 20 20 20 70 42 64 65 78 20 3d 20          pBdex = 
0750: 2a 69 64 78 20 3d 20 73 74 72 6c 65 6e 28 70 61  *idx = strlen(pa
0760: 74 68 42 75 66 66 65 72 29 3b 0a 2b 20 20 20 20  thBuffer);.+    
0770: 20 20 20 20 0a 2b 20 20 20 20 20 20 20 20 70 61      .+        pa
0780: 74 68 42 75 66 66 65 72 5b 70 42 64 65 78 2b 2b  thBuffer[pBdex++
0790: 5d 20 3d 20 27 2f 27 3b 0a 2b 20 20 20 20 20 20  ] = '/';.+      
07a0: 20 20 64 6f 20 7b 20 70 61 74 68 42 75 66 66 65    do { pathBuffe
07b0: 72 5b 70 42 64 65 78 5d 20 3d 20 6f 72 67 50 61  r[pBdex] = orgPa
07c0: 74 68 5b 6f 50 64 65 78 5d 3b 20 70 42 64 65 78  th[oPdex]; pBdex
07d0: 2b 2b 3b 20 6f 50 64 65 78 2b 2b 3b 20 7d 0a 2b  ++; oPdex++; }.+
07e0: 20 20 20 20 20 20 20 20 77 68 69 6c 65 20 28 6f          while (o
07f0: 50 64 65 78 20 3c 20 6f 50 6c 65 6e 29 3b 0a 2b  Pdex < oPlen);.+
0800: 20 20 20 20 20 20 20 20 70 61 74 68 42 75 66 66          pathBuff
0810: 65 72 5b 70 42 64 65 78 5d 20 3d 20 30 3b 0a 2b  er[pBdex] = 0;.+
0820: 20 20 20 20 20 20 20 20 66 69 6e 64 50 61 74 68          findPath
0830: 28 70 61 74 68 42 75 66 66 65 72 2c 20 26 6e 65  (pathBuffer, &ne
0840: 77 4e 61 6d 65 2c 20 69 64 78 29 3b 0a 2b 20 20  wName, idx);.+  
0850: 20 20 20 20 20 20 66 72 65 65 28 70 61 74 68 42        free(pathB
0860: 75 66 66 65 72 29 3b 0a 2b 20 20 20 20 20 20 20  uffer);.+       
0870: 20 2a 72 65 74 50 61 74 68 20 3d 20 6e 65 77 4e   *retPath = newN
0880: 61 6d 65 3b 0a 2b 20 20 20 20 20 20 20 20 72 65  ame;.+        re
0890: 74 75 72 6e 3b 0a 2b 20 20 20 20 7d 0a 2b 0a 2b  turn;.+    }.+.+
08a0: 20 20 20 20 77 68 69 6c 65 20 28 70 42 64 65 78      while (pBdex
08b0: 20 3c 20 6f 50 64 65 78 29 20 70 61 74 68 42 75   < oPdex) pathBu
08c0: 66 66 65 72 5b 70 42 64 65 78 2b 2b 5d 20 3d 20  ffer[pBdex++] = 
08d0: 6f 72 67 50 61 74 68 5b 70 42 64 65 78 5d 3b 0a  orgPath[pBdex];.
08e0: 2b 20 20 20 20 6f 50 64 65 78 20 3d 20 70 42 64  +    oPdex = pBd
08f0: 65 78 3b 0a 2b 66 69 6e 64 6e 65 78 74 3a 0a 2b  ex;.+findnext:.+
0900: 20 20 20 20 72 65 64 65 78 20 3d 20 6f 50 64 65      redex = oPde
0910: 78 20 2b 20 31 3b 0a 2b 20 20 20 20 64 6f 20 7b  x + 1;.+    do {
0920: 20 70 61 74 68 42 75 66 66 65 72 5b 70 42 64 65   pathBuffer[pBde
0930: 78 5d 20 3d 20 6f 72 67 50 61 74 68 5b 6f 50 64  x] = orgPath[oPd
0940: 65 78 5d 3b 20 70 42 64 65 78 2b 2b 3b 20 6f 50  ex]; pBdex++; oP
0950: 64 65 78 2b 2b 3b 20 7d 0a 2b 20 20 20 20 77 68  dex++; }.+    wh
0960: 69 6c 65 20 28 6f 72 67 50 61 74 68 5b 6f 50 64  ile (orgPath[oPd
0970: 65 78 5d 20 21 3d 20 27 2f 27 20 26 26 20 6f 50  ex] != '/' && oP
0980: 64 65 78 20 3c 20 6f 50 6c 65 6e 29 3b 0a 2b 20  dex < oPlen);.+ 
0990: 20 20 20 69 66 20 28 6f 50 64 65 78 20 3d 3d 20     if (oPdex == 
09a0: 6f 50 6c 65 6e 29 20 7b 0a 2b 20 20 20 20 20 20  oPlen) {.+      
09b0: 20 20 2a 69 64 78 20 3d 20 72 65 64 65 78 20 2d    *idx = redex -
09c0: 20 31 3b 0a 2b 20 20 20 20 20 20 20 20 72 65 74   1;.+        ret
09d0: 75 72 6e 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 20  urn;.+    }.+   
09e0: 20 6c 73 74 61 74 28 70 61 74 68 42 75 66 66 65   lstat(pathBuffe
09f0: 72 2c 20 26 63 75 72 53 74 61 74 42 75 66 29 3b  r, &curStatBuf);
0a00: 0a 2b 20 20 20 20 69 66 20 28 53 5f 49 53 4c 4e  .+    if (S_ISLN
0a10: 4b 28 63 75 72 53 74 61 74 42 75 66 2e 73 74 5f  K(curStatBuf.st_
0a20: 6d 6f 64 65 29 29 20 7b 0a 2b 20 20 20 20 20 20  mode)) {.+      
0a30: 20 20 69 6e 74 20 6e 6f 72 6d 50 61 74 68 4c 65    int normPathLe
0a40: 6e 3b 0a 2b 20 20 20 20 20 20 20 20 0a 2b 20 20  n;.+        .+  
0a50: 20 20 20 20 20 20 6e 6f 72 6d 50 61 74 68 4c 65        normPathLe
0a60: 6e 20 3d 20 72 65 61 64 6c 69 6e 6b 28 70 61 74  n = readlink(pat
0a70: 68 42 75 66 66 65 72 2c 20 28 26 70 61 74 68 42  hBuffer, (&pathB
0a80: 75 66 66 65 72 5b 72 65 64 65 78 5d 29 2c 20 28  uffer[redex]), (
0a90: 32 2a 4d 41 58 50 41 54 48 4c 45 4e 20 2d 20 72  2*MAXPATHLEN - r
0aa0: 65 64 65 78 29 29 3b 0a 2b 20 20 20 20 20 20 20  edex));.+       
0ab0: 20 70 61 74 68 42 75 66 66 65 72 5b 72 65 64 65   pathBuffer[rede
0ac0: 78 20 2b 20 6e 6f 72 6d 50 61 74 68 4c 65 6e 5d  x + normPathLen]
0ad0: 20 3d 20 30 3b 0a 2b 20 20 20 20 20 20 20 20 69   = 0;.+        i
0ae0: 66 20 28 70 61 74 68 42 75 66 66 65 72 5b 72 65  f (pathBuffer[re
0af0: 64 65 78 5d 20 3d 3d 20 27 2f 27 29 20 7b 0a 2b  dex] == '/') {.+
0b00: 20 20 20 20 20 20 20 20 20 20 20 20 70 42 64 65              pBde
0b10: 78 20 3d 20 30 3b 0a 2b 20 20 20 20 20 20 20 20  x = 0;.+        
0b20: 20 20 20 20 64 6f 20 7b 20 70 61 74 68 42 75 66      do { pathBuf
0b30: 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 70 61 74  fer[pBdex] = pat
0b40: 68 42 75 66 66 65 72 5b 72 65 64 65 78 5d 3b 20  hBuffer[redex]; 
0b50: 70 42 64 65 78 2b 2b 3b 20 72 65 64 65 78 2b 2b  pBdex++; redex++
0b60: 3b 20 7d 0a 2b 20 20 20 20 20 20 20 20 20 20 20  ; }.+           
0b70: 20 77 68 69 6c 65 20 28 2d 2d 6e 6f 72 6d 50 61   while (--normPa
0b80: 74 68 4c 65 6e 20 3e 20 30 29 3b 0a 2b 20 20 20  thLen > 0);.+   
0b90: 20 20 20 20 20 7d 20 65 6c 73 65 20 69 66 20 28       } else if (
0ba0: 70 61 74 68 42 75 66 66 65 72 5b 72 65 64 65 78  pathBuffer[redex
0bb0: 5d 20 3d 3d 20 27 2e 27 20 26 26 20 70 61 74 68  ] == '.' && path
0bc0: 42 75 66 66 65 72 5b 72 65 64 65 78 20 2b 20 31  Buffer[redex + 1
0bd0: 5d 20 3d 3d 20 27 2e 27 20 26 26 20 70 61 74 68  ] == '.' && path
0be0: 42 75 66 66 65 72 5b 72 65 64 65 78 20 2b 20 32  Buffer[redex + 2
0bf0: 5d 20 3d 3d 20 27 2f 27 29 20 7b 0a 2b 20 20 20  ] == '/') {.+   
0c00: 20 20 20 20 20 20 20 20 20 70 42 64 65 78 20 3d           pBdex =
0c10: 20 72 65 64 65 78 3b 0a 2b 20 20 20 20 20 20 20   redex;.+       
0c20: 20 20 20 20 20 64 6f 20 7b 0a 2b 20 20 20 20 20       do {.+     
0c30: 20 20 20 20 20 20 20 20 20 20 20 70 42 64 65 78             pBdex
0c40: 20 2d 3d 20 32 3b 0a 2b 20 20 20 20 20 20 20 20   -= 2;.+        
0c50: 20 20 20 20 20 20 20 20 72 65 64 65 78 20 2b 3d          redex +=
0c60: 20 33 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20   3;.+           
0c70: 20 20 20 20 20 6e 6f 72 6d 50 61 74 68 4c 65 6e       normPathLen
0c80: 20 2d 3d 20 33 3b 0a 2b 20 20 20 20 20 20 20 20   -= 3;.+        
0c90: 20 20 20 20 20 20 20 20 77 68 69 6c 65 20 28 70          while (p
0ca0: 61 74 68 42 75 66 66 65 72 5b 70 42 64 65 78 5d  athBuffer[pBdex]
0cb0: 20 21 3d 20 27 2f 27 20 26 26 20 70 42 64 65 78   != '/' && pBdex
0cc0: 20 3e 20 30 29 20 70 42 64 65 78 2d 2d 3b 0a 2b   > 0) pBdex--;.+
0cd0: 20 20 20 20 20 20 20 20 20 20 20 20 7d 20 77 68              } wh
0ce0: 69 6c 65 20 28 70 61 74 68 42 75 66 66 65 72 5b  ile (pathBuffer[
0cf0: 72 65 64 65 78 5d 20 3d 3d 20 27 2e 27 20 26 26  redex] == '.' &&
0d00: 20 70 61 74 68 42 75 66 66 65 72 5b 72 65 64 65   pathBuffer[rede
0d10: 78 20 2b 20 31 5d 20 3d 3d 20 27 2e 27 20 26 26  x + 1] == '.' &&
0d20: 20 70 61 74 68 42 75 66 66 65 72 5b 72 65 64 65   pathBuffer[rede
0d30: 78 20 2b 20 32 5d 20 3d 3d 20 27 2f 27 20 26 26  x + 2] == '/' &&
0d40: 20 70 42 64 65 78 20 3e 20 30 29 3b 0a 2b 20 20   pBdex > 0);.+  
0d50: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 70 42            if (pB
0d60: 64 65 78 20 3d 3d 20 30 29 20 7b 20 72 65 64 65  dex == 0) { rede
0d70: 78 2d 2d 3b 20 6e 6f 72 6d 50 61 74 68 4c 65 6e  x--; normPathLen
0d80: 2b 2b 3b 20 7d 0a 2b 20 20 20 20 20 20 20 20 20  ++; }.+         
0d90: 20 20 20 64 6f 20 7b 20 70 61 74 68 42 75 66 66     do { pathBuff
0da0: 65 72 5b 70 42 64 65 78 5d 20 3d 20 70 61 74 68  er[pBdex] = path
0db0: 42 75 66 66 65 72 5b 72 65 64 65 78 5d 3b 20 70  Buffer[redex]; p
0dc0: 42 64 65 78 2b 2b 3b 20 72 65 64 65 78 2b 2b 3b  Bdex++; redex++;
0dd0: 20 7d 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20   }.+            
0de0: 77 68 69 6c 65 20 28 2d 2d 6e 6f 72 6d 50 61 74  while (--normPat
0df0: 68 4c 65 6e 20 3e 20 30 29 3b 0a 2b 20 20 20 20  hLen > 0);.+    
0e00: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20      } else {.+  
0e10: 20 20 20 20 20 20 20 20 20 20 70 42 64 65 78 20            pBdex 
0e20: 3d 20 72 65 64 65 78 20 2b 20 6e 6f 72 6d 50 61  = redex + normPa
0e30: 74 68 4c 65 6e 3b 0a 2b 20 20 20 20 20 20 20 20  thLen;.+        
0e40: 7d 0a 2b 20 20 20 20 20 20 20 20 64 6f 20 7b 20  }.+        do { 
0e50: 70 61 74 68 42 75 66 66 65 72 5b 70 42 64 65 78  pathBuffer[pBdex
0e60: 5d 20 3d 20 6f 72 67 50 61 74 68 5b 6f 50 64 65  ] = orgPath[oPde
0e70: 78 5d 3b 20 70 42 64 65 78 2b 2b 3b 20 6f 50 64  x]; pBdex++; oPd
0e80: 65 78 2b 2b 3b 20 7d 0a 2b 20 20 20 20 20 20 20  ex++; }.+       
0e90: 20 77 68 69 6c 65 20 28 6f 50 64 65 78 20 3c 20   while (oPdex < 
0ea0: 6f 50 6c 65 6e 29 3b 0a 2b 20 20 20 20 20 20 20  oPlen);.+       
0eb0: 20 70 61 74 68 42 75 66 66 65 72 5b 70 42 64 65   pathBuffer[pBde
0ec0: 78 5d 20 3d 20 30 3b 0a 2b 20 20 20 20 20 20 20  x] = 0;.+       
0ed0: 20 2a 69 64 78 20 3d 20 30 3b 0a 2b 20 20 20 20   *idx = 0;.+    
0ee0: 20 20 20 20 66 69 6e 64 50 61 74 68 28 70 61 74      findPath(pat
0ef0: 68 42 75 66 66 65 72 2c 20 26 6e 65 77 4e 61 6d  hBuffer, &newNam
0f00: 65 2c 20 69 64 78 29 3b 0a 2b 20 20 20 20 20 20  e, idx);.+      
0f10: 20 20 66 72 65 65 28 70 61 74 68 42 75 66 66 65    free(pathBuffe
0f20: 72 29 3b 0a 2b 20 20 20 20 20 20 20 20 2a 72 65  r);.+        *re
0f30: 74 50 61 74 68 20 3d 20 6e 65 77 4e 61 6d 65 3b  tPath = newName;
0f40: 0a 2b 20 20 20 20 20 20 20 20 72 65 74 75 72 6e  .+        return
0f50: 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 69 66  ;.+    }.+    if
0f60: 20 28 65 72 72 6e 6f 29 20 7b 0a 2b 20 20 20 20   (errno) {.+    
0f70: 20 20 20 20 64 6f 20 7b 20 70 61 74 68 42 75 66      do { pathBuf
0f80: 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 6f 72 67  fer[pBdex] = org
0f90: 50 61 74 68 5b 6f 50 64 65 78 5d 3b 20 70 42 64  Path[oPdex]; pBd
0fa0: 65 78 2b 2b 3b 20 6f 50 64 65 78 2b 2b 3b 20 7d  ex++; oPdex++; }
0fb0: 0a 2b 20 20 20 20 20 20 20 20 77 68 69 6c 65 20  .+        while 
0fc0: 28 6f 50 64 65 78 20 3c 20 6f 50 6c 65 6e 29 3b  (oPdex < oPlen);
0fd0: 0a 2b 20 20 20 20 20 20 20 20 70 61 74 68 42 75  .+        pathBu
0fe0: 66 66 65 72 5b 70 42 64 65 78 5d 20 3d 20 30 3b  ffer[pBdex] = 0;
0ff0: 0a 2b 20 20 20 20 20 20 20 20 2a 69 64 78 20 3d  .+        *idx =
1000: 20 72 65 64 65 78 20 2d 20 31 3b 0a 2b 20 20 20   redex - 1;.+   
1010: 20 20 20 20 20 72 65 74 75 72 6e 3b 0a 2b 20 20       return;.+  
1020: 20 20 7d 0a 2b 20 20 20 20 67 6f 74 6f 20 66 69    }.+    goto fi
1030: 6e 64 6e 65 78 74 3b 0a 2b 7d 0a 2b 0a 20 2f 2a  ndnext;.+}.+. /*
1040: 0a 2d 20 2a 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 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a  ---------------.
1090: 2b 20 2a 20 20 54 63 6c 4f 62 6a 4e 6f 72 6d 61  + *  TclObjNorma
10a0: 6c 69 7a 65 50 61 74 68 2e 63 0a 20 20 2a 0a 2d  lizePath.c.  *.-
10b0: 20 2a 20 54 63 6c 70 4f 62 6a 4e 6f 72 6d 61 6c   * TclpObjNormal
10c0: 69 7a 65 50 61 74 68 20 2d 2d 0a 2b 20 2a 20 20  izePath --.+ *  
10d0: 09 54 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 74  .This function t
10e0: 61 6b 65 73 20 61 20 70 61 74 68 20 73 74 72 69  akes a path stri
10f0: 6e 67 20 61 6e 64 20 72 65 70 6c 61 63 65 73 20  ng and replaces 
1100: 69 74 0a 2b 20 2a 09 77 69 74 68 20 61 20 6e 6f  it.+ *.with a no
1110: 72 6d 61 6c 69 7a 65 64 20 70 61 74 68 2e 20 54  rmalized path. T
1120: 68 65 20 65 6e 74 65 72 69 6e 67 20 70 61 74 68  he entering path
1130: 20 73 74 72 69 6e 67 0a 2b 20 2a 09 6d 75 73 74   string.+ *.must
1140: 20 62 65 20 76 6f 69 64 20 6f 66 20 2e 2e 2f 2c   be void of ../,
1150: 20 2e 2f 20 73 65 71 75 65 6e 63 65 73 2e 20 54   ./ sequences. T
1160: 68 65 20 72 65 74 75 72 6e 65 64 20 70 61 74 68  he returned path
1170: 0a 2b 20 2a 09 77 69 6c 6c 20 62 65 20 6e 6f 72  .+ *.will be nor
1180: 6d 61 6c 69 7a 65 64 20 75 70 20 74 6f 20 6e 65  malized up to ne
1190: 78 74 43 68 65 63 6b 70 6f 69 6e 74 2c 20 77 68  xtCheckpoint, wh
11a0: 69 63 68 20 70 6f 69 6e 74 73 20 74 6f 0a 2b 20  ich points to.+ 
11b0: 2a 09 65 69 74 68 65 72 20 74 68 65 20 6c 61 73  *.either the las
11c0: 74 20 70 61 74 68 20 73 65 70 61 72 61 74 6f 72  t path separator
11d0: 20 6f 72 20 74 68 65 20 6f 66 66 65 6e 64 69 6e   or the offendin
11e0: 67 20 73 65 70 61 72 61 74 6f 72 2e 0a 2b 20 2a  g separator..+ *
11f0: 09 54 68 65 20 65 6e 64 20 77 6f 72 64 20 6f 66  .The end word of
1200: 20 74 68 65 20 70 61 74 68 20 77 69 6c 6c 20 6e   the path will n
1210: 6f 74 20 62 65 20 6e 6f 72 6d 61 6c 69 7a 65 64  ot be normalized
1220: 2c 20 69 74 20 69 73 0a 2b 20 2a 09 74 6f 74 61  , it is.+ *.tota
1230: 6c 6c 79 20 69 67 6e 6f 72 65 64 2e 0a 2b 20 2a  lly ignored..+ *
1240: 20 20 0a 2b 20 2a 20 20 52 65 73 75 6c 74 73 3a    .+ *  Results:
1250: 0a 2b 20 2a 09 70 61 74 68 50 74 72 20 61 6c 74  .+ *.pathPtr alt
1260: 65 72 65 64 20 77 69 74 68 20 72 65 73 75 6c 74  ered with result
1270: 20 6f 66 20 6e 6f 72 6d 61 6c 69 7a 61 74 69 6f   of normalizatio
1280: 6e 0a 2b 20 2a 09 6e 65 78 74 43 68 65 63 6b 70  n.+ *.nextCheckp
1290: 6f 69 6e 74 20 70 6f 69 6e 74 73 20 74 6f 20 65  oint points to e
12a0: 6e 64 20 73 65 70 61 72 61 74 6f 72 20 6f 72 20  nd separator or 
12b0: 6f 66 66 65 6e 64 69 6e 67 2c 0a 2b 20 2a 09 69  offending,.+ *.i
12c0: 65 2e 2e 20 74 68 65 20 6c 61 73 74 20 67 6f 6f  e.. the last goo
12d0: 64 20 73 65 70 61 72 61 74 6f 72 20 70 72 69 6f  d separator prio
12e0: 72 20 74 6f 20 70 72 6f 62 6c 65 6d 20 70 61 74  r to problem pat
12f0: 68 0a 20 20 2a 0a 2d 20 2a 09 54 68 69 73 20 66  h.  *.- *.This f
1300: 75 6e 63 74 69 6f 6e 20 73 63 61 6e 73 20 74 68  unction scans th
1310: 72 6f 75 67 68 20 61 20 70 61 74 68 20 73 70 65  rough a path spe
1320: 63 69 66 69 63 61 74 69 6f 6e 20 61 6e 64 20 72  cification and r
1330: 65 70 6c 61 63 65 73 0a 2d 20 2a 09 69 74 2c 20  eplaces.- *.it, 
1340: 69 6e 20 70 6c 61 63 65 2c 20 77 69 74 68 20 61  in place, with a
1350: 20 6e 6f 72 6d 61 6c 69 7a 65 64 20 76 65 72 73   normalized vers
1360: 69 6f 6e 2e 20 20 41 20 6e 6f 72 6d 61 6c 69 7a  ion.  A normaliz
1370: 65 64 20 76 65 72 73 69 6f 6e 0a 2d 20 2a 09 69  ed version.- *.i
1380: 73 20 6f 6e 65 20 69 6e 20 77 68 69 63 68 20 61  s one in which a
1390: 6c 6c 20 73 79 6d 6c 69 6e 6b 73 20 69 6e 20 74  ll symlinks in t
13a0: 68 65 20 70 61 74 68 20 61 72 65 20 72 65 70 6c  he path are repl
13b0: 61 63 65 64 20 77 69 74 68 0a 2d 20 2a 09 74 68  aced with.- *.th
13c0: 65 69 72 20 65 78 70 61 6e 64 65 64 20 66 6f 72  eir expanded for
13d0: 6d 20 28 65 78 63 65 70 74 20 61 20 73 79 6d 6c  m (except a syml
13e0: 69 6e 6b 20 61 74 20 74 68 65 20 76 65 72 79 20  ink at the very 
13f0: 65 6e 64 20 6f 66 20 74 68 65 0a 2d 20 2a 09 70  end of the.- *.p
1400: 61 74 68 29 2e 0a 2b 20 2a 20 20 53 69 64 65 20  ath)..+ *  Side 
1410: 65 66 66 65 63 74 73 3a 0a 2b 20 2a 09 69 66 20  effects:.+ *.if 
1420: 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 20 70  nextCheckpoint p
1430: 6f 69 6e 74 73 20 74 6f 20 65 6e 64 20 73 65 70  oints to end sep
1440: 61 72 61 74 6f 72 2c 20 64 6f 20 6e 6f 74 0a 2b  arator, do not.+
1450: 20 2a 09 6d 61 6b 65 20 61 73 73 75 6d 70 74 69   *.make assumpti
1460: 6f 6e 20 6f 66 20 61 20 66 75 6c 6c 79 20 71 75  on of a fully qu
1470: 61 6c 69 66 69 65 64 20 70 61 74 68 2e 0a 2b 20  alified path..+ 
1480: 2a 09 4f 63 63 75 72 61 6e 63 65 3a 20 77 68 65  *.Occurance: whe
1490: 6e 20 22 6a 6f 69 6e 22 20 61 64 64 73 20 74 6f  n "join" adds to
14a0: 20 61 20 66 69 6c 65 20 69 6e 73 74 65 61 64 20   a file instead 
14b0: 6f 66 20 64 69 72 65 63 74 6f 72 79 2e 0a 2b 20  of directory..+ 
14c0: 2a 09 54 68 65 20 66 69 6c 65 20 77 69 6c 6c 20  *.The file will 
14d0: 62 65 20 6e 6f 72 6d 61 6c 69 7a 65 64 20 62 75  be normalized bu
14e0: 74 20 69 73 20 6e 6f 74 20 61 20 64 69 72 65 63  t is not a direc
14f0: 74 6f 72 79 2e 0a 20 20 2a 0a 2d 20 2a 20 52 65  tory..  *.- * Re
1500: 73 75 6c 74 73 3a 0a 2d 20 2a 09 54 68 65 20 6e  sults:.- *.The n
1510: 65 77 20 27 6e 65 78 74 43 68 65 63 6b 70 6f 69  ew 'nextCheckpoi
1520: 6e 74 27 20 76 61 6c 75 65 2c 20 67 69 76 69 6e  nt' value, givin
1530: 67 20 61 73 20 66 61 72 20 61 73 20 77 65 20 63  g as far as we c
1540: 6f 75 6c 64 0a 2d 20 2a 09 75 6e 64 65 72 73 74  ould.- *.underst
1550: 61 6e 64 20 69 6e 20 74 68 65 20 70 61 74 68 2e  and in the path.
1560: 0a 2d 20 2a 0a 2d 20 2a 20 53 69 64 65 20 65 66  .- *.- * Side ef
1570: 66 65 63 74 73 3a 0a 2d 20 2a 09 54 68 65 20 70  fects:.- *.The p
1580: 61 74 68 50 74 72 20 73 74 72 69 6e 67 2c 20 69  athPtr string, i
1590: 73 20 6d 6f 64 69 66 69 65 64 2e 0a 2d 20 2a 0a  s modified..- *.
15a0: 2d 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  - *-------------
15b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
15c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
15d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
15e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b  --------------.+
15f0: 20 2a 20 20 52 65 74 75 72 6e 73 3a 0a 2b 20 2a   *  Returns:.+ *
1600: 09 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 0a  .nextCheckpoint.
1610: 2b 20 2a 09 70 61 74 68 50 74 72 0a 20 20 2a 2f  + *.pathPtr.  */
1620: 0a 2b 0a 20 69 6e 74 0a 20 54 63 6c 70 4f 62 6a  .+. int. TclpObj
1630: 4e 6f 72 6d 61 6c 69 7a 65 50 61 74 68 28 69 6e  NormalizePath(in
1640: 74 65 72 70 2c 20 70 61 74 68 50 74 72 2c 20 6e  terp, pathPtr, n
1650: 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 29 0a 20  extCheckpoint). 
1660: 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a      Tcl_Interp *
1670: 69 6e 74 65 72 70 3b 0a 20 20 20 20 20 54 63 6c  interp;.     Tcl
1680: 5f 4f 62 6a 20 2a 70 61 74 68 50 74 72 3b 0a 20  _Obj *pathPtr;. 
1690: 20 20 20 20 69 6e 74 20 6e 65 78 74 43 68 65 63      int nextChec
16a0: 6b 70 6f 69 6e 74 3b 0a 20 7b 0a 2d 20 20 20 20  kpoint;. {.-    
16b0: 63 68 61 72 20 2a 63 75 72 72 65 6e 74 50 61 74  char *currentPat
16c0: 68 45 6e 64 50 6f 73 69 74 69 6f 6e 3b 0a 20 20  hEndPosition;.  
16d0: 20 20 20 69 6e 74 20 70 61 74 68 4c 65 6e 3b 0a     int pathLen;.
16e0: 2d 20 20 20 20 63 68 61 72 20 63 75 72 3b 0a 2b  -    char cur;.+
16f0: 20 20 20 20 63 68 61 72 20 2a 72 65 73 6f 6c 76      char *resolv
1700: 65 64 50 61 74 68 20 3d 20 4e 55 4c 4c 3b 0a 20  edPath = NULL;. 
1710: 20 20 20 20 63 68 61 72 20 2a 70 61 74 68 20 3d      char *path =
1720: 20 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 46 72   Tcl_GetStringFr
1730: 6f 6d 4f 62 6a 28 70 61 74 68 50 74 72 2c 20 26  omObj(pathPtr, &
1740: 70 61 74 68 4c 65 6e 29 3b 0a 2d 23 69 66 6e 64  pathLen);.-#ifnd
1750: 65 66 20 4e 4f 5f 52 45 41 4c 50 41 54 48 0a 2d  ef NO_REALPATH.-
1760: 20 20 20 20 63 68 61 72 20 6e 6f 72 6d 50 61 74      char normPat
1770: 68 5b 4d 41 58 50 41 54 48 4c 45 4e 5d 3b 0a 2d  h[MAXPATHLEN];.-
1780: 20 20 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 20      Tcl_DString 
1790: 64 73 3b 0a 2d 20 20 20 20 43 4f 4e 53 54 20 63  ds;.-    CONST c
17a0: 68 61 72 20 2a 6e 61 74 69 76 65 50 61 74 68 3b  har *nativePath;
17b0: 20 0a 2d 23 65 6e 64 69 66 0a 2d 20 20 20 20 2f   .-#endif.-    /
17c0: 2a 20 0a 2d 20 20 20 20 20 2a 20 57 65 20 61 64  * .-     * We ad
17d0: 64 20 27 31 27 20 68 65 72 65 20 62 65 63 61 75  d '1' here becau
17e0: 73 65 20 69 66 20 6e 65 78 74 43 68 65 63 6b 70  se if nextCheckp
17f0: 6f 69 6e 74 20 69 73 20 7a 65 72 6f 20 77 65 20  oint is zero we 
1800: 6b 6e 6f 77 0a 2d 20 20 20 20 20 2a 20 74 68 61  know.-     * tha
1810: 74 20 27 2f 27 20 65 78 69 73 74 73 2c 20 61 6e  t '/' exists, an
1820: 64 20 69 66 20 69 74 20 69 73 6e 27 74 20 7a 65  d if it isn't ze
1830: 72 6f 2c 20 69 74 20 6d 75 73 74 20 70 6f 69 6e  ro, it must poin
1840: 74 20 61 74 0a 2d 20 20 20 20 20 2a 20 61 20 64  t at.-     * a d
1850: 69 72 65 63 74 6f 72 79 20 73 65 70 61 72 61 74  irectory separat
1860: 6f 72 20 77 68 69 63 68 20 77 65 20 61 6c 73 6f  or which we also
1870: 20 6b 6e 6f 77 20 65 78 69 73 74 73 2e 0a 2d 20   know exists..- 
1880: 20 20 20 20 2a 2f 0a 2d 20 20 20 20 63 75 72 72      */.-    curr
1890: 65 6e 74 50 61 74 68 45 6e 64 50 6f 73 69 74 69  entPathEndPositi
18a0: 6f 6e 20 3d 20 70 61 74 68 20 2b 20 6e 65 78 74  on = path + next
18b0: 43 68 65 63 6b 70 6f 69 6e 74 3b 0a 2d 20 20 20  Checkpoint;.-   
18c0: 20 69 66 20 28 2a 63 75 72 72 65 6e 74 50 61 74   if (*currentPat
18d0: 68 45 6e 64 50 6f 73 69 74 69 6f 6e 20 3d 3d 20  hEndPosition == 
18e0: 27 2f 27 29 20 7b 0a 2d 09 63 75 72 72 65 6e 74  '/') {.-.current
18f0: 50 61 74 68 45 6e 64 50 6f 73 69 74 69 6f 6e 2b  PathEndPosition+
1900: 2b 3b 0a 2d 20 20 20 20 7d 0a 2d 0a 2d 23 69 66  +;.-    }.-.-#if
1910: 6e 64 65 66 20 4e 4f 5f 52 45 41 4c 50 41 54 48  ndef NO_REALPATH
1920: 0a 2d 20 20 20 20 2f 2a 20 46 6f 72 20 73 70 65  .-    /* For spe
1930: 65 64 2c 20 74 72 79 20 74 6f 20 67 65 74 20 74  ed, try to get t
1940: 68 65 20 65 6e 74 69 72 65 20 70 61 74 68 20 69  he entire path i
1950: 6e 20 6f 6e 65 20 67 6f 20 2a 2f 0a 2d 20 20 20  n one go */.-   
1960: 20 69 66 20 28 6e 65 78 74 43 68 65 63 6b 70 6f   if (nextCheckpo
1970: 69 6e 74 20 3d 3d 20 30 29 20 7b 0a 2d 20 20 20  int == 0) {.-   
1980: 20 20 20 20 20 63 68 61 72 20 2a 6c 61 73 74 44       char *lastD
1990: 69 72 20 3d 20 73 74 72 72 63 68 72 28 63 75 72  ir = strrchr(cur
19a0: 72 65 6e 74 50 61 74 68 45 6e 64 50 6f 73 69 74  rentPathEndPosit
19b0: 69 6f 6e 2c 20 27 2f 27 29 3b 0a 2d 09 69 66 20  ion, '/');.-.if 
19c0: 28 6c 61 73 74 44 69 72 20 21 3d 20 4e 55 4c 4c  (lastDir != NULL
19d0: 29 20 7b 0a 2d 09 20 20 20 20 6e 61 74 69 76 65  ) {.-.    native
19e0: 50 61 74 68 20 3d 20 54 63 6c 5f 55 74 66 54 6f  Path = Tcl_UtfTo
19f0: 45 78 74 65 72 6e 61 6c 44 53 74 72 69 6e 67 28  ExternalDString(
1a00: 4e 55 4c 4c 2c 20 70 61 74 68 2c 20 0a 2d 09 09  NULL, path, .-..
1a10: 09 09 09 09 20 20 6c 61 73 74 44 69 72 20 2d 20  ....  lastDir - 
1a20: 70 61 74 68 2c 20 26 64 73 29 3b 0a 2d 09 20 20  path, &ds);.-.  
1a30: 20 20 69 66 20 28 52 65 61 6c 70 61 74 68 28 6e    if (Realpath(n
1a40: 61 74 69 76 65 50 61 74 68 2c 20 6e 6f 72 6d 50  ativePath, normP
1a50: 61 74 68 29 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a  ath) != NULL) {.
1a60: 2d 09 09 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e  -..nextCheckpoin
1a70: 74 20 3d 20 6c 61 73 74 44 69 72 20 2d 20 70 61  t = lastDir - pa
1a80: 74 68 3b 0a 2d 09 09 67 6f 74 6f 20 77 68 6f 6c  th;.-..goto whol
1a90: 65 53 74 72 69 6e 67 4f 6b 3b 0a 2d 09 20 20 20  eStringOk;.-.   
1aa0: 20 7d 0a 2d 09 7d 0a 2d 20 20 20 20 7d 0a 2d 20   }.-.}.-    }.- 
1ab0: 20 20 20 2f 2a 20 45 6c 73 65 20 64 6f 20 69 74     /* Else do it
1ac0: 20 74 68 65 20 73 6c 6f 77 20 77 61 79 20 2a 2f   the slow way */
1ad0: 0a 2d 23 65 6e 64 69 66 0a 2d 20 20 20 20 0a 2d  .-#endif.-    .-
1ae0: 20 20 20 20 77 68 69 6c 65 20 28 31 29 20 7b 0a      while (1) {.
1af0: 2d 09 63 75 72 20 3d 20 2a 63 75 72 72 65 6e 74  -.cur = *current
1b00: 50 61 74 68 45 6e 64 50 6f 73 69 74 69 6f 6e 3b  PathEndPosition;
1b10: 0a 2d 09 69 66 20 28 28 63 75 72 20 3d 3d 20 27  .-.if ((cur == '
1b20: 2f 27 29 20 26 26 20 28 70 61 74 68 20 21 3d 20  /') && (path != 
1b30: 63 75 72 72 65 6e 74 50 61 74 68 45 6e 64 50 6f  currentPathEndPo
1b40: 73 69 74 69 6f 6e 29 29 20 7b 0a 2d 09 20 20 20  sition)) {.-.   
1b50: 20 2f 2a 20 52 65 61 63 68 65 64 20 64 69 72 65   /* Reached dire
1b60: 63 74 6f 72 79 20 73 65 70 61 72 61 74 6f 72 20  ctory separator 
1b70: 2a 2f 0a 2d 09 20 20 20 20 54 63 6c 5f 44 53 74  */.-.    Tcl_DSt
1b80: 72 69 6e 67 20 64 73 3b 0a 2d 09 20 20 20 20 43  ring ds;.-.    C
1b90: 4f 4e 53 54 20 63 68 61 72 20 2a 6e 61 74 69 76  ONST char *nativ
1ba0: 65 50 61 74 68 3b 0a 2d 09 20 20 20 20 69 6e 74  ePath;.-.    int
1bb0: 20 61 63 63 65 73 73 4f 6b 3b 0a 2d 0a 2d 09 20   accessOk;.-.-. 
1bc0: 20 20 20 6e 61 74 69 76 65 50 61 74 68 20 3d 20     nativePath = 
1bd0: 54 63 6c 5f 55 74 66 54 6f 45 78 74 65 72 6e 61  Tcl_UtfToExterna
1be0: 6c 44 53 74 72 69 6e 67 28 4e 55 4c 4c 2c 20 70  lDString(NULL, p
1bf0: 61 74 68 2c 20 0a 2d 09 09 20 20 20 20 63 75 72  ath, .-..    cur
1c00: 72 65 6e 74 50 61 74 68 45 6e 64 50 6f 73 69 74  rentPathEndPosit
1c10: 69 6f 6e 20 2d 20 70 61 74 68 2c 20 26 64 73 29  ion - path, &ds)
1c20: 3b 0a 2d 09 20 20 20 20 61 63 63 65 73 73 4f 6b  ;.-.    accessOk
1c30: 20 3d 20 61 63 63 65 73 73 28 6e 61 74 69 76 65   = access(native
1c40: 50 61 74 68 2c 20 46 5f 4f 4b 29 3b 0a 2d 09 20  Path, F_OK);.-. 
1c50: 20 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 46 72     Tcl_DStringFr
1c60: 65 65 28 26 64 73 29 3b 0a 2d 09 20 20 20 20 69  ee(&ds);.-.    i
1c70: 66 20 28 61 63 63 65 73 73 4f 6b 20 21 3d 20 30  f (accessOk != 0
1c80: 29 20 7b 0a 2d 09 09 2f 2a 20 46 69 6c 65 20 64  ) {.-../* File d
1c90: 6f 65 73 6e 27 74 20 65 78 69 73 74 20 2a 2f 0a  oesn't exist */.
1ca0: 2d 09 09 62 72 65 61 6b 3b 0a 2d 09 20 20 20 20  -..break;.-.    
1cb0: 7d 0a 2d 09 20 20 20 20 2f 2a 20 55 70 64 61 74  }.-.    /* Updat
1cc0: 65 20 74 68 65 20 61 63 63 65 70 74 61 62 6c 65  e the acceptable
1cd0: 20 70 6f 69 6e 74 20 2a 2f 0a 2d 09 20 20 20 20   point */.-.    
1ce0: 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 20 3d  nextCheckpoint =
1cf0: 20 63 75 72 72 65 6e 74 50 61 74 68 45 6e 64 50   currentPathEndP
1d00: 6f 73 69 74 69 6f 6e 20 2d 20 70 61 74 68 3b 0a  osition - path;.
1d10: 2d 09 7d 20 65 6c 73 65 20 69 66 20 28 63 75 72  -.} else if (cur
1d20: 20 3d 3d 20 30 29 20 7b 0a 2d 09 20 20 20 20 2f   == 0) {.-.    /
1d30: 2a 20 52 65 61 63 68 65 64 20 65 6e 64 20 6f 66  * Reached end of
1d40: 20 73 74 72 69 6e 67 20 2a 2f 0a 2d 09 20 20 20   string */.-.   
1d50: 20 62 72 65 61 6b 3b 0a 2d 09 7d 0a 2d 09 63 75   break;.-.}.-.cu
1d60: 72 72 65 6e 74 50 61 74 68 45 6e 64 50 6f 73 69  rrentPathEndPosi
1d70: 74 69 6f 6e 2b 2b 3b 0a 2d 20 20 20 20 7d 0a 2d  tion++;.-    }.-
1d80: 20 20 20 20 2f 2a 20 0a 2d 20 20 20 20 20 2a 20      /* .-     * 
1d90: 57 65 20 73 68 6f 75 6c 64 20 72 65 61 6c 6c 79  We should really
1da0: 20 6e 6f 77 20 63 6f 6e 76 65 72 74 20 74 68 69   now convert thi
1db0: 73 20 74 6f 20 61 20 63 61 6e 6f 6e 69 63 61 6c  s to a canonical
1dc0: 20 70 61 74 68 2e 20 20 57 65 20 64 6f 0a 2d 20   path.  We do.- 
1dd0: 20 20 20 20 2a 20 74 68 61 74 20 77 69 74 68 20      * that with 
1de0: 27 72 65 61 6c 70 61 74 68 27 20 69 66 20 77 65  'realpath' if we
1df0: 20 68 61 76 65 20 69 74 20 61 76 61 69 6c 61 62   have it availab
1e00: 6c 65 2e 20 20 4f 74 68 65 72 77 69 73 65 20 77  le.  Otherwise w
1e10: 65 20 63 6f 75 6c 64 0a 2d 20 20 20 20 20 2a 20  e could.-     * 
1e20: 73 74 65 70 20 74 68 72 6f 75 67 68 20 65 76 65  step through eve
1e30: 72 79 20 73 69 6e 67 6c 65 20 70 61 74 68 20 63  ry single path c
1e40: 6f 6d 70 6f 6e 65 6e 74 2c 20 63 68 65 63 6b 69  omponent, checki
1e50: 6e 67 20 77 68 65 74 68 65 72 20 69 74 20 69 73  ng whether it is
1e60: 20 61 20 0a 2d 20 20 20 20 20 2a 20 73 79 6d 6c   a .-     * syml
1e70: 69 6e 6b 2c 20 62 75 74 20 74 68 61 74 20 77 6f  ink, but that wo
1e80: 75 6c 64 20 62 65 20 61 20 6c 6f 74 20 6f 66 20  uld be a lot of 
1e90: 77 6f 72 6b 2c 20 61 6e 64 20 6d 6f 73 74 20 6d  work, and most m
1ea0: 6f 64 65 72 6e 20 4f 53 65 73 20 0a 2d 20 20 20  odern OSes .-   
1eb0: 20 20 2a 20 68 61 76 65 20 27 72 65 61 6c 70 61    * have 'realpa
1ec0: 74 68 27 2e 0a 2d 20 20 20 20 20 2a 2f 0a 2d 23  th'..-     */.-#
1ed0: 69 66 6e 64 65 66 20 4e 4f 5f 52 45 41 4c 50 41  ifndef NO_REALPA
1ee0: 54 48 0a 2d 20 20 20 20 2f 2a 20 0a 2d 20 20 20  TH.-    /* .-   
1ef0: 20 20 2a 20 49 66 20 77 65 20 6f 6e 6c 79 20 68    * If we only h
1f00: 61 64 20 27 2f 66 6f 6f 27 20 6f 72 20 27 2f 27  ad '/foo' or '/'
1f10: 20 74 68 65 6e 20 77 65 20 6e 65 76 65 72 20 69   then we never i
1f20: 6e 63 72 65 6d 65 6e 74 20 6e 65 78 74 43 68 65  ncrement nextChe
1f30: 63 6b 70 6f 69 6e 74 0a 2d 20 20 20 20 20 2a 20  ckpoint.-     * 
1f40: 61 6e 64 20 77 65 20 64 6f 6e 27 74 20 6e 65 65  and we don't nee
1f50: 64 20 6f 72 20 77 61 6e 74 20 74 6f 20 67 6f 20  d or want to go 
1f60: 74 68 72 6f 75 67 68 20 27 52 65 61 6c 70 61 74  through 'Realpat
1f70: 68 27 2e 20 20 41 6c 73 6f 2c 20 6f 6e 20 73 6f  h'.  Also, on so
1f80: 6d 65 0a 2d 20 20 20 20 20 2a 20 70 6c 61 74 66  me.-     * platf
1f90: 6f 72 6d 73 2c 20 70 61 73 73 69 6e 67 20 61 6e  orms, passing an
1fa0: 20 65 6d 70 74 79 20 73 74 72 69 6e 67 20 74 6f   empty string to
1fb0: 20 27 52 65 61 6c 70 61 74 68 27 20 77 69 6c 6c   'Realpath' will
1fc0: 20 67 69 76 65 20 75 73 20 74 68 65 0a 2d 20 20   give us the.-  
1fd0: 20 20 20 2a 20 6e 6f 72 6d 61 6c 69 7a 65 64 20     * normalized 
1fe0: 70 77 64 2c 20 77 68 69 63 68 20 69 73 20 6e 6f  pwd, which is no
1ff0: 74 20 77 68 61 74 20 77 65 20 77 61 6e 74 20 61  t what we want a
2000: 74 20 61 6c 6c 21 0a 2d 20 20 20 20 20 2a 2f 0a  t all!.-     */.
2010: 2d 20 20 20 20 69 66 20 28 6e 65 78 74 43 68 65  -    if (nextChe
2020: 63 6b 70 6f 69 6e 74 20 3d 3d 20 30 29 20 72 65  ckpoint == 0) re
2030: 74 75 72 6e 20 30 3b 0a 2d 20 20 20 20 0a 2d 20  turn 0;.-    .- 
2040: 20 20 20 6e 61 74 69 76 65 50 61 74 68 20 3d 20     nativePath = 
2050: 54 63 6c 5f 55 74 66 54 6f 45 78 74 65 72 6e 61  Tcl_UtfToExterna
2060: 6c 44 53 74 72 69 6e 67 28 4e 55 4c 4c 2c 20 70  lDString(NULL, p
2070: 61 74 68 2c 20 6e 65 78 74 43 68 65 63 6b 70 6f  ath, nextCheckpo
2080: 69 6e 74 2c 20 26 64 73 29 3b 0a 2d 20 20 20 20  int, &ds);.-    
2090: 69 66 20 28 52 65 61 6c 70 61 74 68 28 6e 61 74  if (Realpath(nat
20a0: 69 76 65 50 61 74 68 2c 20 6e 6f 72 6d 50 61 74  ivePath, normPat
20b0: 68 29 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2d 09  h) != NULL) {.-.
20c0: 69 6e 74 20 6e 65 77 4e 6f 72 6d 4c 65 6e 3b 0a  int newNormLen;.
20d0: 2d 09 77 68 6f 6c 65 53 74 72 69 6e 67 4f 6b 3a  -.wholeStringOk:
20e0: 0a 2d 09 6e 65 77 4e 6f 72 6d 4c 65 6e 20 3d 20  .-.newNormLen = 
20f0: 73 74 72 6c 65 6e 28 6e 6f 72 6d 50 61 74 68 29  strlen(normPath)
2100: 3b 0a 2d 09 69 66 20 28 28 6e 65 77 4e 6f 72 6d  ;.-.if ((newNorm
2110: 4c 65 6e 20 3d 3d 20 54 63 6c 5f 44 53 74 72 69  Len == Tcl_DStri
2120: 6e 67 4c 65 6e 67 74 68 28 26 64 73 29 29 0a 2d  ngLength(&ds)).-
2130: 09 09 26 26 20 28 73 74 72 63 6d 70 28 6e 6f 72  ..&& (strcmp(nor
2140: 6d 50 61 74 68 2c 20 6e 61 74 69 76 65 50 61 74  mPath, nativePat
2150: 68 29 20 3d 3d 20 30 29 29 20 7b 0a 2d 09 20 20  h) == 0)) {.-.  
2160: 20 20 2f 2a 20 53 74 72 69 6e 67 20 69 73 20 75    /* String is u
2170: 6e 63 68 61 6e 67 65 64 20 2a 2f 0a 2d 09 20 20  nchanged */.-.  
2180: 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 46 72 65    Tcl_DStringFre
2190: 65 28 26 64 73 29 3b 0a 2d 09 20 20 20 20 69 66  e(&ds);.-.    if
21a0: 20 28 70 61 74 68 5b 6e 65 78 74 43 68 65 63 6b   (path[nextCheck
21b0: 70 6f 69 6e 74 5d 20 21 3d 20 27 5c 30 27 29 20  point] != '\0') 
21c0: 7b 0a 2d 09 09 6e 65 78 74 43 68 65 63 6b 70 6f  {.-..nextCheckpo
21d0: 69 6e 74 2b 2b 3b 0a 2d 09 20 20 20 20 7d 0a 2d  int++;.-.    }.-
21e0: 09 20 20 20 20 72 65 74 75 72 6e 20 6e 65 78 74  .    return next
21f0: 43 68 65 63 6b 70 6f 69 6e 74 3b 0a 2d 09 7d 0a  Checkpoint;.-.}.
2200: 2d 09 0a 2d 09 2f 2a 20 0a 2d 09 20 2a 20 46 72  -..-./* .-. * Fr
2210: 65 65 20 75 70 20 74 68 65 20 6e 61 74 69 76 65  ee up the native
2220: 20 70 61 74 68 20 61 6e 64 20 70 75 74 20 69 6e   path and put in
2230: 20 69 74 73 20 70 6c 61 63 65 20 74 68 65 0a 2d   its place the.-
2240: 09 20 2a 20 63 6f 6e 76 65 72 74 65 64 2c 20 6e  . * converted, n
2250: 6f 72 6d 61 6c 69 7a 65 64 20 70 61 74 68 2e 0a  ormalized path..
2260: 2d 09 20 2a 2f 0a 2d 09 54 63 6c 5f 44 53 74 72  -. */.-.Tcl_DStr
2270: 69 6e 67 46 72 65 65 28 26 64 73 29 3b 0a 2d 09  ingFree(&ds);.-.
2280: 54 63 6c 5f 45 78 74 65 72 6e 61 6c 54 6f 55 74  Tcl_ExternalToUt
2290: 66 44 53 74 72 69 6e 67 28 4e 55 4c 4c 2c 20 6e  fDString(NULL, n
22a0: 6f 72 6d 50 61 74 68 2c 20 28 69 6e 74 29 20 6e  ormPath, (int) n
22b0: 65 77 4e 6f 72 6d 4c 65 6e 2c 20 26 64 73 29 3b  ewNormLen, &ds);
22c0: 0a 2d 0a 2d 09 69 66 20 28 70 61 74 68 5b 6e 65  .-.-.if (path[ne
22d0: 78 74 43 68 65 63 6b 70 6f 69 6e 74 5d 20 21 3d  xtCheckpoint] !=
22e0: 20 27 5c 30 27 29 20 7b 0a 2d 09 20 20 20 20 2f   '\0') {.-.    /
22f0: 2a 20 6e 6f 74 20 61 74 20 65 6e 64 2c 20 61 70  * not at end, ap
2300: 70 65 6e 64 20 72 65 6d 61 69 6e 69 6e 67 20 70  pend remaining p
2310: 61 74 68 20 2a 2f 0a 2d 09 20 20 20 20 69 6e 74  ath */.-.    int
2320: 20 6e 6f 72 6d 4c 65 6e 20 3d 20 54 63 6c 5f 44   normLen = Tcl_D
2330: 53 74 72 69 6e 67 4c 65 6e 67 74 68 28 26 64 73  StringLength(&ds
2340: 29 3b 0a 2d 09 20 20 20 20 54 63 6c 5f 44 53 74  );.-.    Tcl_DSt
2350: 72 69 6e 67 41 70 70 65 6e 64 28 26 64 73 2c 20  ringAppend(&ds, 
2360: 70 61 74 68 20 2b 20 6e 65 78 74 43 68 65 63 6b  path + nextCheck
2370: 70 6f 69 6e 74 2c 0a 2d 09 09 20 20 20 20 70 61  point,.-..    pa
2380: 74 68 4c 65 6e 20 2d 20 6e 65 78 74 43 68 65 63  thLen - nextChec
2390: 6b 70 6f 69 6e 74 29 3b 0a 2d 09 20 20 20 20 2f  kpoint);.-.    /
23a0: 2a 20 0a 2d 09 20 20 20 20 20 2a 20 57 65 20 72  * .-.     * We r
23b0: 65 63 6f 67 6e 69 73 65 20 75 70 20 74 6f 20 61  ecognise up to a
23c0: 6e 64 20 69 6e 63 6c 75 64 69 6e 67 20 74 68 65  nd including the
23d0: 20 64 69 72 65 63 74 6f 72 79 0a 2d 09 20 20 20   directory.-.   
23e0: 20 20 2a 20 73 65 70 61 72 61 74 6f 72 2e 0a 2d    * separator..-
23f0: 09 20 20 20 20 20 2a 2f 09 0a 2d 09 20 20 20 20  .     */..-.    
2400: 6e 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 20 3d  nextCheckpoint =
2410: 20 6e 6f 72 6d 4c 65 6e 20 2b 20 31 3b 0a 2d 09   normLen + 1;.-.
2420: 7d 20 65 6c 73 65 20 7b 0a 2d 09 20 20 20 20 2f  } else {.-.    /
2430: 2a 20 57 65 20 72 65 63 6f 67 6e 69 73 65 20 74  * We recognise t
2440: 68 65 20 77 68 6f 6c 65 20 73 74 72 69 6e 67 20  he whole string 
2450: 2a 2f 20 0a 2d 09 20 20 20 20 6e 65 78 74 43 68  */ .-.    nextCh
2460: 65 63 6b 70 6f 69 6e 74 20 3d 20 54 63 6c 5f 44  eckpoint = Tcl_D
2470: 53 74 72 69 6e 67 4c 65 6e 67 74 68 28 26 64 73  StringLength(&ds
2480: 29 3b 0a 2d 09 7d 0a 2d 09 2f 2a 20 0a 2d 09 20  );.-.}.-./* .-. 
2490: 2a 20 4f 76 65 72 77 72 69 74 65 20 77 69 74 68  * Overwrite with
24a0: 20 74 68 65 20 6e 6f 72 6d 61 6c 69 7a 65 64 20   the normalized 
24b0: 70 61 74 68 2e 0a 2d 09 20 2a 2f 0a 2d 09 54 63  path..-. */.-.Tc
24c0: 6c 5f 53 65 74 53 74 72 69 6e 67 4f 62 6a 28 70  l_SetStringObj(p
24d0: 61 74 68 50 74 72 2c 20 54 63 6c 5f 44 53 74 72  athPtr, Tcl_DStr
24e0: 69 6e 67 56 61 6c 75 65 28 26 64 73 29 2c 0a 2d  ingValue(&ds),.-
24f0: 09 09 54 63 6c 5f 44 53 74 72 69 6e 67 4c 65 6e  ..Tcl_DStringLen
2500: 67 74 68 28 26 64 73 29 29 3b 0a 2d 20 20 20 20  gth(&ds));.-    
2510: 7d 0a 2d 20 20 20 20 54 63 6c 5f 44 53 74 72 69  }.-    Tcl_DStri
2520: 6e 67 46 72 65 65 28 26 64 73 29 3b 0a 2d 23 65  ngFree(&ds);.-#e
2530: 6e 64 69 66 09 2f 2a 20 21 4e 4f 5f 52 45 41 4c  ndif./* !NO_REAL
2540: 50 41 54 48 20 2a 2f 0a 20 0a 2b 20 20 20 20 6e  PATH */. .+    n
2550: 65 78 74 43 68 65 63 6b 70 6f 69 6e 74 20 3d 20  extCheckpoint = 
2560: 30 3b 0a 2b 20 20 20 20 66 69 6e 64 50 61 74 68  0;.+    findPath
2570: 28 70 61 74 68 2c 20 26 72 65 73 6f 6c 76 65 64  (path, &resolved
2580: 50 61 74 68 2c 20 26 6e 65 78 74 43 68 65 63 6b  Path, &nextCheck
2590: 70 6f 69 6e 74 29 3b 0a 2b 20 20 20 20 69 66 20  point);.+    if 
25a0: 28 72 65 73 6f 6c 76 65 64 50 61 74 68 29 20 7b  (resolvedPath) {
25b0: 0a 2b 20 20 20 20 20 20 20 20 54 63 6c 5f 44 53  .+        Tcl_DS
25c0: 74 72 69 6e 67 20 64 73 3b 0a 2b 20 20 20 20 20  tring ds;.+     
25d0: 20 20 20 70 61 74 68 4c 65 6e 20 3d 20 73 74 72     pathLen = str
25e0: 6c 65 6e 28 72 65 73 6f 6c 76 65 64 50 61 74 68  len(resolvedPath
25f0: 29 3b 0a 2b 20 20 20 20 20 20 20 20 54 63 6c 5f  );.+        Tcl_
2600: 45 78 74 65 72 6e 61 6c 54 6f 55 74 66 44 53 74  ExternalToUtfDSt
2610: 72 69 6e 67 28 4e 55 4c 4c 2c 20 72 65 73 6f 6c  ring(NULL, resol
2620: 76 65 64 50 61 74 68 2c 20 70 61 74 68 4c 65 6e  vedPath, pathLen
2630: 2c 20 26 64 73 29 3b 0a 2b 20 20 20 20 20 20 20  , &ds);.+       
2640: 20 54 63 6c 5f 53 65 74 53 74 72 69 6e 67 4f 62   Tcl_SetStringOb
2650: 6a 28 70 61 74 68 50 74 72 2c 20 54 63 6c 5f 44  j(pathPtr, Tcl_D
2660: 53 74 72 69 6e 67 56 61 6c 75 65 28 26 64 73 29  StringValue(&ds)
2670: 2c 20 54 63 6c 5f 44 53 74 72 69 6e 67 4c 65 6e  , Tcl_DStringLen
2680: 67 74 68 28 26 64 73 29 29 3b 0a 2b 20 20 20 20  gth(&ds));.+    
2690: 20 20 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 46      Tcl_DStringF
26a0: 72 65 65 28 26 64 73 29 3b 0a 2b 20 20 20 20 20  ree(&ds);.+     
26b0: 20 20 20 66 72 65 65 28 72 65 73 6f 6c 76 65 64     free(resolved
26c0: 50 61 74 68 29 3b 0a 2b 20 20 20 20 7d 0a 20 20  Path);.+    }.  
26d0: 20 20 20 72 65 74 75 72 6e 20 6e 65 78 74 43 68     return nextCh
26e0: 65 63 6b 70 6f 69 6e 74 3b 0a 20 7d 0a 2d 0a 2d  eckpoint;. }.-.-
26f0: 0a 2d 0a 00 00 00 00 00 00 00 00 00 00 00 00 00  .-..............
2700: 00 00 00 00 00 00 00 00 00 00 00                 ...........