Tcl Source Code

Hex Artifact Content
Login

Artifact c37bdab391476feba064d126e5044c185a9103d4:

Attachment "tclUnixPipe.diff" to ticket [878333ffff] added by sussner 2004-01-16 22:25:55.
0000: 64 69 66 66 20 2d 4e 72 75 20 74 63 6c 2f 75 6e  diff -Nru tcl/un
0010: 69 78 2f 74 63 6c 55 6e 69 78 50 69 70 65 2e 63  ix/tclUnixPipe.c
0020: 20 74 63 6c 5f 6d 6f 64 2f 75 6e 69 78 2f 74 63   tcl_mod/unix/tc
0030: 6c 55 6e 69 78 50 69 70 65 2e 63 0a 2d 2d 2d 20  lUnixPipe.c.--- 
0040: 74 63 6c 2f 75 6e 69 78 2f 74 63 6c 55 6e 69 78  tcl/unix/tclUnix
0050: 50 69 70 65 2e 63 09 32 30 30 33 2d 30 32 2d 32  Pipe.c.2003-02-2
0060: 32 20 30 31 3a 32 35 3a 30 37 2e 30 30 30 30 30  2 01:25:07.00000
0070: 30 30 30 30 20 2b 30 31 30 30 0a 2b 2b 2b 20 74  0000 +0100.+++ t
0080: 63 6c 5f 6d 6f 64 2f 75 6e 69 78 2f 74 63 6c 55  cl_mod/unix/tclU
0090: 6e 69 78 50 69 70 65 2e 63 09 32 30 30 34 2d 30  nixPipe.c.2004-0
00a0: 31 2d 31 36 20 31 35 3a 35 35 3a 35 30 2e 30 30  1-16 15:55:50.00
00b0: 30 30 30 30 30 30 30 20 2b 30 31 30 30 0a 40 40  0000000 +0100.@@
00c0: 20 2d 32 34 33 2c 39 20 2b 32 34 33 2c 33 32 20   -243,9 +243,32 
00d0: 40 40 0a 20 54 63 6c 5f 4f 62 6a 2a 20 0a 20 54  @@. Tcl_Obj* . T
00e0: 63 6c 70 54 65 6d 70 46 69 6c 65 4e 61 6d 65 28  clpTempFileName(
00f0: 29 0a 20 7b 0a 2b 23 69 66 6e 64 65 66 20 5f 5f  ). {.+#ifndef __
0100: 73 67 69 0a 20 20 20 20 20 63 68 61 72 20 66 69  sgi.     char fi
0110: 6c 65 4e 61 6d 65 5b 4c 5f 74 6d 70 6e 61 6d 20  leName[L_tmpnam 
0120: 2b 20 39 5d 3b 0a 20 20 20 20 20 54 63 6c 5f 4f  + 9];.     Tcl_O
0130: 62 6a 20 2a 72 65 73 75 6c 74 20 3d 20 4e 55 4c  bj *result = NUL
0140: 4c 3b 0a 20 20 20 20 20 69 6e 74 20 66 64 3b 0a  L;.     int fd;.
0150: 2b 23 65 6c 73 65 0a 2b 20 20 20 20 2f 2a 20 54  +#else.+    /* T
0160: 68 65 73 65 20 63 68 61 6e 67 65 73 20 63 6f 6e  hese changes con
0170: 63 65 72 6e 20 6d 61 69 6e 6c 79 20 6c 6f 61 64  cern mainly load
0180: 69 6e 67 20 64 79 6e 61 6d 69 63 20 6c 69 62 72  ing dynamic libr
0190: 61 72 69 65 73 20 66 72 6f 6d 0a 2b 20 20 20 20  aries from.+    
01a0: 20 2a 20 6f 74 68 65 72 73 20 74 68 61 6e 20 74   * others than t
01b0: 68 65 20 6e 61 74 69 76 65 20 66 69 6c 65 73 79  he native filesy
01c0: 73 74 65 6d 2c 20 65 2e 67 2e 20 76 66 73 20 6f  stem, e.g. vfs o
01d0: 66 20 61 20 74 63 6c 6b 69 74 2e 0a 2b 20 20 20  f a tclkit..+   
01e0: 20 20 2a 0a 2b 20 20 20 20 20 2a 20 49 52 49 58    *.+     * IRIX
01f0: 20 64 6f 65 73 20 6e 6f 74 20 67 65 6e 65 72 61   does not genera
0200: 74 65 20 64 69 66 66 65 72 65 6e 74 20 74 65 6d  te different tem
0210: 70 6f 72 61 72 79 20 66 69 6c 65 6e 61 6d 65 73  porary filenames
0220: 20 77 68 65 6e 20 75 73 69 6e 67 0a 2b 20 20 20   when using.+   
0230: 20 20 2a 20 74 68 65 20 63 6f 70 79 54 6f 50 74    * the copyToPt
0240: 72 2d 6d 65 63 68 61 6e 69 73 6d 20 6f 66 20 54  r-mechanism of T
0250: 63 6c 5f 46 53 4c 6f 61 64 46 69 6c 65 28 29 2e  cl_FSLoadFile().
0260: 20 41 6c 74 68 6f 75 67 68 20 74 68 65 20 70 72   Although the pr
0270: 65 76 69 6f 75 73 0a 2b 20 20 20 20 20 2a 20 74  evious.+     * t
0280: 65 6d 70 6f 72 61 72 79 20 66 69 6c 65 20 77 61  emporary file wa
0290: 73 20 64 65 6c 65 74 65 64 20 69 6d 6d 65 64 69  s deleted immedi
02a0: 61 74 65 6c 79 20 61 6e 64 20 61 20 54 63 6c 43  ately and a TclC
02b0: 72 6f 73 73 46 69 6c 65 73 79 73 74 65 6d 43 6f  rossFilesystemCo
02c0: 70 79 28 29 0a 2b 20 20 20 20 20 2a 20 74 6f 6f  py().+     * too
02d0: 6b 20 70 6c 61 63 65 2c 20 74 68 65 20 63 6f 6e  k place, the con
02e0: 74 65 6e 74 20 6f 66 20 74 68 65 20 70 72 65 76  tent of the prev
02f0: 69 6f 75 73 20 74 65 6d 70 6f 72 61 72 79 20 66  ious temporary f
0300: 69 6c 65 20 28 73 61 6d 65 0a 2b 20 20 20 20 20  ile (same.+     
0310: 2a 20 66 69 6c 65 6e 61 6d 65 21 21 21 29 20 73  * filename!!!) s
0320: 65 65 6d 73 20 74 6f 20 62 65 20 70 72 65 73 65  eems to be prese
0330: 6e 74 2e 20 49 2e 65 2e 20 6f 6e 6c 79 20 74 68  nt. I.e. only th
0340: 65 20 66 69 72 73 74 20 64 79 6e 61 6d 69 63 20  e first dynamic 
0350: 6c 69 62 72 61 72 79 0a 2b 20 20 20 20 20 2a 20  library.+     * 
0360: 69 73 20 6c 6f 61 64 65 64 20 28 65 2e 67 2e 20  is loaded (e.g. 
0370: 49 74 63 6c 5f 49 6e 69 74 20 77 61 73 20 66 6f  Itcl_Init was fo
0380: 75 6e 64 29 20 62 75 74 20 61 6c 6c 20 66 6f 6c  und) but all fol
0390: 6c 6f 77 69 6e 67 20 6c 69 62 72 61 72 69 65 73  lowing libraries
03a0: 0a 2b 20 20 20 20 20 2a 20 66 61 69 6c 20 28 65  .+     * fail (e
03b0: 2e 67 2e 20 22 63 6f 75 6c 64 6e 27 74 20 66 69  .g. "couldn't fi
03c0: 6e 64 20 70 72 6f 63 65 64 75 72 65 20 54 6b 5f  nd procedure Tk_
03d0: 49 6e 69 74 22 29 2e 20 55 73 69 6e 67 20 61 20  Init"). Using a 
03e0: 64 69 66 66 65 72 65 6e 74 0a 2b 20 20 20 20 20  different.+     
03f0: 2a 20 74 65 6d 70 6f 72 61 72 79 20 66 69 6c 65  * temporary file
0400: 6e 61 6d 65 20 73 65 65 6d 73 20 74 6f 20 73 6f  name seems to so
0410: 6c 76 65 20 74 68 69 73 20 70 72 6f 62 6c 65 6d  lve this problem
0420: 2e 20 46 6f 72 20 74 68 69 73 20 61 20 73 74 61  . For this a sta
0430: 74 69 63 0a 2b 20 20 20 20 20 2a 20 63 6f 75 6e  tic.+     * coun
0440: 74 65 72 20 69 73 20 69 6e 63 6c 75 64 65 64 20  ter is included 
0450: 69 6e 20 74 68 65 20 74 65 6d 70 6f 72 61 72 79  in the temporary
0460: 20 66 69 6c 65 6e 61 6d 65 2e 20 49 74 20 69 73   filename. It is
0470: 20 35 20 64 69 67 69 74 73 20 6c 6f 6e 67 2c 0a   5 digits long,.
0480: 2b 20 20 20 20 20 2a 20 69 2e 65 2e 20 31 30 30  +     * i.e. 100
0490: 30 30 20 64 79 6e 61 6d 69 63 20 6c 69 62 72 61  00 dynamic libra
04a0: 72 69 65 73 20 63 6f 75 6c 64 20 62 65 20 6c 6f  ries could be lo
04b0: 61 64 65 64 20 66 72 6f 6d 20 61 20 74 63 6c 6b  aded from a tclk
04c0: 69 74 20 28 73 68 6f 75 6c 64 0a 2b 20 20 20 20  it (should.+    
04d0: 20 2a 20 62 65 20 73 75 66 66 69 63 69 65 6e 74   * be sufficient
04e0: 20 66 6f 72 20 74 68 65 20 6e 65 78 74 20 66 65   for the next fe
04f0: 77 20 79 65 61 72 73 20 3a 2d 29 20 29 0a 2b 20  w years :-) ).+ 
0500: 20 20 20 20 2a 2f 0a 2b 20 20 20 20 63 68 61 72      */.+    char
0510: 20 66 69 6c 65 4e 61 6d 65 5b 4c 5f 74 6d 70 6e   fileName[L_tmpn
0520: 61 6d 20 2b 20 39 20 2b 20 35 5d 3b 0a 2b 20 20  am + 9 + 5];.+  
0530: 20 20 54 63 6c 5f 4f 62 6a 20 2a 72 65 73 75 6c    Tcl_Obj *resul
0540: 74 20 3d 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 69  t = NULL;.+    i
0550: 6e 74 20 66 64 3b 0a 2b 20 20 20 20 73 74 61 74  nt fd;.+    stat
0560: 69 63 20 69 6e 74 20 63 74 72 3d 30 3b 0a 2b 20  ic int ctr=0;.+ 
0570: 20 20 20 63 68 61 72 20 63 74 72 53 74 72 5b 31     char ctrStr[1
0580: 35 5d 3b 0a 2b 23 65 6e 64 69 66 0a 20 0a 20 20  5];.+#endif. .  
0590: 20 20 20 2f 2a 0a 20 20 20 20 20 20 2a 20 57 65     /*.      * We
05a0: 20 73 68 6f 75 6c 64 20 61 6c 73 6f 20 63 68 65   should also che
05b0: 63 6b 20 61 67 61 69 6e 73 74 20 6d 61 6b 69 6e  ck against makin
05c0: 67 20 6d 6f 72 65 20 74 68 65 6e 20 54 4d 50 5f  g more then TMP_
05d0: 4d 41 58 20 6f 66 20 74 68 65 73 65 2e 0a 40 40  MAX of these..@@
05e0: 20 2d 32 35 35 2c 37 20 2b 32 37 38 2c 31 34 20   -255,7 +278,14 
05f0: 40 40 0a 20 20 20 20 20 69 66 20 28 66 69 6c 65  @@.     if (file
0600: 4e 61 6d 65 5b 73 74 72 6c 65 6e 28 66 69 6c 65  Name[strlen(file
0610: 4e 61 6d 65 29 20 2d 20 31 5d 20 21 3d 20 27 2f  Name) - 1] != '/
0620: 27 29 20 7b 0a 20 09 73 74 72 63 61 74 28 66 69  ') {. .strcat(fi
0630: 6c 65 4e 61 6d 65 2c 20 22 2f 22 29 3b 09 09 2f  leName, "/");../
0640: 2a 20 49 4e 54 4c 3a 20 4e 61 74 69 76 65 2e 20  * INTL: Native. 
0650: 2a 2f 0a 20 20 20 20 20 7d 0a 2b 23 69 66 6e 64  */.     }.+#ifnd
0660: 65 66 20 5f 5f 73 67 69 0a 20 20 20 20 20 73 74  ef __sgi.     st
0670: 72 63 61 74 28 66 69 6c 65 4e 61 6d 65 2c 20 22  rcat(fileName, "
0680: 74 63 6c 58 58 58 58 58 58 22 29 3b 0a 2b 23 65  tclXXXXXX");.+#e
0690: 6c 73 65 0a 2b 20 20 20 20 2f 2a 20 61 64 64 20  lse.+    /* add 
06a0: 73 74 61 74 69 63 20 63 74 72 2a 2f 0a 2b 20 20  static ctr*/.+  
06b0: 20 20 73 6e 70 72 69 6e 74 66 28 63 74 72 53 74    snprintf(ctrSt
06c0: 72 2c 31 34 2c 22 74 63 6c 25 30 35 69 58 58 58  r,14,"tcl%05iXXX
06d0: 58 58 58 22 2c 63 74 72 2b 2b 29 3b 0a 2b 20 20  XXX",ctr++);.+  
06e0: 20 20 73 74 72 63 61 74 28 66 69 6c 65 4e 61 6d    strcat(fileNam
06f0: 65 2c 20 63 74 72 53 74 72 29 3b 0a 2b 23 65 6e  e, ctrStr);.+#en
0700: 64 69 66 0a 2b 0a 20 20 20 20 20 66 64 20 3d 20  dif.+.     fd = 
0710: 6d 6b 73 74 65 6d 70 28 66 69 6c 65 4e 61 6d 65  mkstemp(fileName
0720: 29 3b 09 09 2f 2a 20 49 4e 54 4c 3a 20 4e 61 74  );../* INTL: Nat
0730: 69 76 65 2e 20 2a 2f 0a 20 20 20 20 20 69 66 20  ive. */.     if 
0740: 28 66 64 20 3d 3d 20 2d 31 29 20 7b 0a 20 09 72  (fd == -1) {. .r
0750: 65 74 75 72 6e 20 4e 55 4c 4c 3b 0a              eturn NULL;.