Diff

Differences From Artifact [8565374f0c]:

To Artifact [2224f05581]:


   157    157   "} else continue\n";
   158    158   
   159    159   /* SetExecName --
   160    160   
   161    161      Hack to get around Tcl bug 1224888.
   162    162   */
   163    163   void SetExecName(Tcl_Interp *interp) {
          164  +#if defined(HAVE_READLINK)
          165  +	if (tclExecutableName == NULL) {
          166  +		ssize_t readlink_ret;
          167  +		char procpath[PATH_MAX + 1];
          168  +		char exe_buf[PATH_MAX + 1];
          169  +		int snprintf_ret;
          170  +
          171  +		snprintf_ret = snprintf(procpath, sizeof(procpath), "/proc/%lu/exe", (unsigned long) getpid());
          172  +		if (snprintf_ret < sizeof(procpath)) {
          173  +			readlink_ret = readlink(procpath, exe_buf, sizeof(exe_buf) - 1);
          174  +
          175  +			if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) {
          176  +				exe_buf[readlink_ret] = '\0';
          177  +
          178  +				tclExecutableName = strdup(exe_buf);
          179  +
          180  +				return;
          181  +			}
          182  +		}
          183  +	}
          184  +#endif
          185  +
   164    186   	if (tclExecutableName == NULL) {
   165    187   		int len = 0;
   166    188   		Tcl_Obj *execNameObj;
   167    189   		Tcl_Obj *lobjv[1];
   168    190   
   169    191   		lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY);
   170    192   		execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv);
   171    193   
   172    194   		tclExecutableName = strdup(Tcl_GetStringFromObj(execNameObj, &len));
          195  +
          196  +		return;
   173    197   	}
          198  +
          199  +	return;
   174    200   }
   175    201   
   176    202   int TclKit_AppInit(Tcl_Interp *interp) {
   177    203   #ifdef TCLKIT_CAN_SET_ENCODING
   178    204   	Tcl_DString encodingName;
   179    205   #endif
   180    206