Tcl Source Code

Hex Artifact Content
Login

Artifact 9a0e7e654d9a06c19502ea3a26ba0f7553597a19:

Attachment "tclLoadDl.c.patch" to ticket [1503729fff] added by kenstir 2006-06-10 04:09:08.
0000: 2d 2d 2d 20 73 79 6e 63 3a 2f 2f 73 72 63 2e 6d  --- sync://src.m
0010: 61 74 72 69 78 6f 6e 65 2e 6e 65 74 3a 32 36 34  atrixone.net:264
0020: 37 2f 50 72 6f 6a 65 63 74 73 2f 53 79 6e 63 49  7/Projects/SyncI
0030: 6e 63 2f 76 65 6e 64 6f 72 2f 74 63 6c 2f 74 63  nc/vendor/tcl/tc
0040: 6c 38 2e 34 2e 32 2f 75 6e 69 78 2f 74 63 6c 4c  l8.4.2/unix/tclL
0050: 6f 61 64 44 6c 2e 63 3b 31 2e 33 0a 2b 2b 2b 20  oadDl.c;1.3.+++ 
0060: 66 69 6c 65 3a 2f 2f 2f 68 6f 6d 65 2f 6b 65 6e  file:///home/ken
0070: 2f 62 75 69 6c 64 2f 72 65 6c 35 30 2f 73 72 63  /build/rel50/src
0080: 2f 76 65 6e 64 6f 72 2f 74 63 6c 2f 74 63 6c 38  /vendor/tcl/tcl8
0090: 2e 34 2e 32 2f 75 6e 69 78 2f 74 63 6c 4c 6f 61  .4.2/unix/tclLoa
00a0: 64 44 6c 2e 63 0a 40 40 20 2d 36 38 2c 36 20 2b  dDl.c.@@ -68,6 +
00b0: 36 38 2c 37 20 40 40 0a 20 7b 0a 20 20 20 20 20  68,7 @@. {.     
00c0: 56 4f 49 44 20 2a 68 61 6e 64 6c 65 3b 0a 20 20  VOID *handle;.  
00d0: 20 20 20 43 4f 4e 53 54 20 63 68 61 72 20 2a 6e     CONST char *n
00e0: 61 74 69 76 65 3b 0a 2b 20 20 20 20 43 4f 4e 53  ative;.+    CONS
00f0: 54 20 63 68 61 72 20 2a 65 72 72 20 3d 20 4e 55  T char *err = NU
0100: 4c 4c 3b 0a 20 0a 20 20 20 20 20 2f 2a 20 0a 20  LL;. .     /* . 
0110: 20 20 20 20 20 2a 20 46 69 72 73 74 20 74 72 79       * First try
0120: 20 74 68 65 20 66 75 6c 6c 20 70 61 74 68 20 74   the full path t
0130: 68 65 20 75 73 65 72 20 67 61 76 65 20 75 73 2e  he user gave us.
0140: 20 20 54 68 69 73 20 69 73 20 70 61 72 74 69 63    This is partic
0150: 75 6c 61 72 6c 79 0a 40 40 20 2d 38 36 2c 31 33  ularly.@@ -86,13
0160: 20 2b 38 37 2c 31 39 20 40 40 0a 20 09 63 68 61   +87,19 @@. .cha
0170: 72 20 2a 66 69 6c 65 4e 61 6d 65 20 3d 20 54 63  r *fileName = Tc
0180: 6c 5f 47 65 74 53 74 72 69 6e 67 28 70 61 74 68  l_GetString(path
0190: 50 74 72 29 3b 0a 20 09 6e 61 74 69 76 65 20 3d  Ptr);. .native =
01a0: 20 54 63 6c 5f 55 74 66 54 6f 45 78 74 65 72 6e   Tcl_UtfToExtern
01b0: 61 6c 44 53 74 72 69 6e 67 28 4e 55 4c 4c 2c 20  alDString(NULL, 
01c0: 66 69 6c 65 4e 61 6d 65 2c 20 2d 31 2c 20 26 64  fileName, -1, &d
01d0: 73 29 3b 0a 20 09 68 61 6e 64 6c 65 20 3d 20 64  s);. .handle = d
01e0: 6c 6f 70 65 6e 28 6e 61 74 69 76 65 2c 20 52 54  lopen(native, RT
01f0: 4c 44 5f 4e 4f 57 20 7c 20 52 54 4c 44 5f 47 4c  LD_NOW | RTLD_GL
0200: 4f 42 41 4c 29 3b 0a 2b 09 2f 2a 20 41 66 74 65  OBAL);.+./* Afte
0210: 72 20 61 20 66 61 69 6c 65 64 20 64 6c 6f 70 65  r a failed dlope
0220: 6e 28 29 2c 20 79 6f 75 20 68 61 76 65 20 74 6f  n(), you have to
0230: 20 63 61 6c 6c 20 64 6c 65 72 72 6f 72 28 29 20   call dlerror() 
0240: 62 65 66 6f 72 65 20 61 6e 79 0a 2b 09 20 20 20  before any.+.   
0250: 6f 74 68 65 72 20 64 79 6e 61 6d 69 63 20 6c 69  other dynamic li
0260: 6e 6b 69 6e 67 20 61 63 74 69 76 69 74 79 2e 20  nking activity. 
0270: 2a 2f 0a 2b 09 69 66 20 28 68 61 6e 64 6c 65 20  */.+.if (handle 
0280: 3d 3d 20 4e 55 4c 4c 29 0a 2b 09 20 20 20 20 65  == NULL).+.    e
0290: 72 72 20 3d 20 73 74 72 64 75 70 28 64 6c 65 72  rr = strdup(dler
02a0: 72 6f 72 28 29 29 3b 0a 20 09 54 63 6c 5f 44 53  ror());. .Tcl_DS
02b0: 74 72 69 6e 67 46 72 65 65 28 26 64 73 29 3b 0a  tringFree(&ds);.
02c0: 20 20 20 20 20 7d 0a 20 20 20 20 20 0a 20 20 20       }.     .   
02d0: 20 20 69 66 20 28 68 61 6e 64 6c 65 20 3d 3d 20    if (handle == 
02e0: 4e 55 4c 4c 29 20 7b 0a 20 09 54 63 6c 5f 41 70  NULL) {. .Tcl_Ap
02f0: 70 65 6e 64 52 65 73 75 6c 74 28 69 6e 74 65 72  pendResult(inter
0300: 70 2c 20 22 63 6f 75 6c 64 6e 27 74 20 6c 6f 61  p, "couldn't loa
0310: 64 20 66 69 6c 65 20 5c 22 22 2c 20 0a 20 09 09  d file \"", . ..
0320: 09 20 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 28  . Tcl_GetString(
0330: 70 61 74 68 50 74 72 29 2c 0a 2d 09 09 09 20 22  pathPtr),.-... "
0340: 5c 22 3a 20 22 2c 20 64 6c 65 72 72 6f 72 28 29  \": ", dlerror()
0350: 2c 20 28 63 68 61 72 20 2a 29 20 4e 55 4c 4c 29  , (char *) NULL)
0360: 3b 0a 2b 09 09 09 20 22 5c 22 3a 20 22 2c 20 65  ;.+... "\": ", e
0370: 72 72 20 3f 20 65 72 72 20 3a 20 22 3c 75 6e 6b  rr ? err : "<unk
0380: 6e 6f 77 6e 20 65 72 72 6f 72 3e 22 2c 20 28 63  nown error>", (c
0390: 68 61 72 20 2a 29 20 4e 55 4c 4c 29 3b 0a 2b 09  har *) NULL);.+.
03a0: 69 66 20 28 65 72 72 29 0a 2b 09 20 20 20 20 66  if (err).+.    f
03b0: 72 65 65 28 28 76 6f 69 64 2a 29 65 72 72 29 3b  ree((void*)err);
03c0: 0a 20 09 72 65 74 75 72 6e 20 54 43 4c 5f 45 52  . .return TCL_ER
03d0: 52 4f 52 3b 0a 20 20 20 20 20 7d 0a 20 0a        ROR;.     }. .