diff options
author | Steve Bennett <steveb@workware.net.au> | 2009-07-29 07:23:58 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 10:11:03 +1000 |
commit | 83dcd361c1a44264abd46de8f88d146dbaa4d0ab (patch) | |
tree | 2cd4016e6c82204a505368f2bd0a0acfae7caf55 /jim-package.c | |
parent | a318fbc2f1c2c5c3ad23f0f61e9d3b205f1580d3 (diff) | |
download | jimtcl-83dcd361c1a44264abd46de8f88d146dbaa4d0ab.zip jimtcl-83dcd361c1a44264abd46de8f88d146dbaa4d0ab.tar.gz jimtcl-83dcd361c1a44264abd46de8f88d146dbaa4d0ab.tar.bz2 |
Fix some runtime errors
Need to duplicate a possibly shared object when loading a package fails
Need to initialise signal-related fields in the jim interp
Return an error from 'lsort -command' on failure
Diffstat (limited to 'jim-package.c')
-rw-r--r-- | jim-package.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/jim-package.c b/jim-package.c index 26e8316..d963b4d 100644 --- a/jim-package.c +++ b/jim-package.c @@ -35,9 +35,11 @@ static char *JimFindPackage(Jim_Interp *interp, char **prefixes, if (prefixes[i] == NULL) continue; snprintf(buf, sizeof(buf), "%s/%s.tcl", prefixes[i], pkgName); + if (access(buf, R_OK) == 0) { return Jim_StrDup(buf); } + snprintf(buf, sizeof(buf), "%s/%s.so", prefixes[i], pkgName); if (access(buf, R_OK) == 0) { return Jim_StrDup(buf); @@ -125,9 +127,14 @@ const char *Jim_PackageRequire(Jim_Interp *interp, const char *name, int flags) /* No way... return an error. */ if (flags & JIM_ERRMSG) { int len; - Jim_GetString(Jim_GetResult(interp), &len); - Jim_AppendStrings(interp, Jim_GetResult(interp), len ? "\n" : "", + Jim_Obj *resultObj = Jim_GetResult(interp); + if (Jim_IsShared(resultObj)) { + resultObj = Jim_DuplicateObj(interp, resultObj); + } + Jim_GetString(resultObj, &len); + Jim_AppendStrings(interp, resultObj, len ? "\n" : "", "Can't find package '", name, "'", NULL); + Jim_SetResult(interp, resultObj); } return NULL; } else { |