diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-02-01 22:24:56 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-02-01 22:24:56 (GMT) |
commit | a762f4ca1872b01cfed34238b891a2dba4c1d88b (patch) | |
tree | 2991c132af246364ee8471087a6ae0b865345b79 | |
parent | 3b388ec8b3a45ae45c0934ac04627e247762293c (diff) | |
download | cpython-a762f4ca1872b01cfed34238b891a2dba4c1d88b.zip cpython-a762f4ca1872b01cfed34238b891a2dba4c1d88b.tar.gz cpython-a762f4ca1872b01cfed34238b891a2dba4c1d88b.tar.bz2 |
Got rid of an extra level of {} and funny formatting that was still
there because of the NeXT history.
-rw-r--r-- | Python/dynload_next.c | 114 |
1 files changed, 56 insertions, 58 deletions
diff --git a/Python/dynload_next.c b/Python/dynload_next.c index 9dec465..19a5da3 100644 --- a/Python/dynload_next.c +++ b/Python/dynload_next.c @@ -36,83 +36,81 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, { dl_funcptr p = NULL; char funcname[258]; + NSObjectFileImageReturnCode rc; + NSObjectFileImage image; + NSModule newModule; + NSSymbol theSym; + const char *errString; + char errBuf[512]; PyOS_snprintf(funcname, sizeof(funcname), "_init%.200s", shortname); - { - NSObjectFileImageReturnCode rc; - NSObjectFileImage image; - NSModule newModule; - NSSymbol theSym; - const char *errString; - char errBuf[512]; - #ifdef USE_DYLD_GLOBAL_NAMESPACE - if (NSIsSymbolNameDefined(funcname)) { - theSym = NSLookupAndBindSymbol(funcname); - p = (dl_funcptr)NSAddressOfSymbol(theSym); - return p; - } + if (NSIsSymbolNameDefined(funcname)) { + theSym = NSLookupAndBindSymbol(funcname); + p = (dl_funcptr)NSAddressOfSymbol(theSym); + return p; + } #endif - rc = NSCreateObjectFileImageFromFile(pathname, &image); - switch(rc) { - default: - case NSObjectFileImageFailure: - case NSObjectFileImageFormat: + rc = NSCreateObjectFileImageFromFile(pathname, &image); + switch(rc) { + default: + case NSObjectFileImageFailure: + case NSObjectFileImageFormat: /* for these a message is printed on stderr by dyld */ errString = "Can't create object file image"; - break; - case NSObjectFileImageSuccess: + break; + case NSObjectFileImageSuccess: errString = NULL; break; - case NSObjectFileImageInappropriateFile: + case NSObjectFileImageInappropriateFile: errString = "Inappropriate file type for dynamic loading"; break; - case NSObjectFileImageArch: + case NSObjectFileImageArch: errString = "Wrong CPU type in object file"; break; - case NSObjectFileImageAccess: + case NSObjectFileImageAccess: errString = "Can't read object file (no access)"; break; + } + if (errString == NULL) { + newModule = NSLinkModule(image, pathname, LINKOPTIONS); + if (newModule == NULL) { + int errNo; + char *fileName, *moreErrorStr; + NSLinkEditErrors c; + NSLinkEditError( &c, &errNo, &fileName, &moreErrorStr ); + PyOS_snprintf(errBuf, 512, "Failure linking new module: %s: %s", + fileName, moreErrorStr); + errString = errBuf; } - if (errString == NULL) { - newModule = NSLinkModule(image, pathname, LINKOPTIONS); - if (newModule == NULL) { - int errNo; - char *fileName, *moreErrorStr; - NSLinkEditErrors c; - NSLinkEditError( &c, &errNo, &fileName, &moreErrorStr ); - PyOS_snprintf(errBuf, 512, "Failure linking new module: %s: %s", - fileName, moreErrorStr); - errString = errBuf; - } - } - if (errString != NULL) { - PyErr_SetString(PyExc_ImportError, errString); - return NULL; - } + } + if (errString != NULL) { + PyErr_SetString(PyExc_ImportError, errString); + return NULL; + } #ifdef USE_DYLD_GLOBAL_NAMESPACE - if (!NSIsSymbolNameDefined(funcname)) { - /* UnlinkModule() isn't implemented in current versions, but calling it does no harm */ - NSUnLinkModule(newModule, FALSE); - PyErr_Format(PyExc_ImportError, - "Loaded module does not contain symbol %.200s", - funcname); - return NULL; - } - theSym = NSLookupAndBindSymbol(funcname); + if (!NSIsSymbolNameDefined(funcname)) { + /* UnlinkModule() isn't implemented in current versions, but calling it does no harm */ + NSUnLinkModule(newModule, FALSE); + PyErr_Format(PyExc_ImportError, + "Loaded module does not contain symbol %.200s", + funcname); + return NULL; + } + theSym = NSLookupAndBindSymbol(funcname); #else - theSym = NSLookupSymbolInModule(newModule, funcname); - if ( theSym == NULL ) { - NSUnLinkModule(newModule, FALSE); - PyErr_Format(PyExc_ImportError, - "Loaded module does not contain symbol %.200s", - funcname); - return NULL; - } -#endif - p = (dl_funcptr)NSAddressOfSymbol(theSym); + theSym = NSLookupSymbolInModule(newModule, funcname); + if ( theSym == NULL ) { + NSUnLinkModule(newModule, FALSE); + PyErr_Format(PyExc_ImportError, + "Loaded module does not contain symbol %.200s", + funcname); + return NULL; } +#endif + p = (dl_funcptr)NSAddressOfSymbol(theSym); +} return p; } |