Some tidyups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7965 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-11-01 12:31:21 +00:00
parent 780868f1a5
commit 1f4a646fa8
9 changed files with 394 additions and 177 deletions

View file

@ -1,3 +1,9 @@
2000-11-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: Fixed uninitialised variable bug.
* Source/NSString.m: Fixed error in xml property list parsing
* Source/GSXML.m: Various SAX things to use default implementation.
2000-10-31 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSString.m: Implemented

View file

@ -9,8 +9,8 @@
<author name="Richard Frith-Macdonald">
<email address="rfm@gnu.org"/>
</author>
<version>0.2</version>
<date>15 september, 2000</date>
<version>0.3</version>
<date>1 November, 2000</date>
</head>
<body>
@ -211,20 +211,32 @@
<method type="int">
<sel>hasInternalSubset:</sel>
<desc>
<p>Callback on internal subset declaration.
<p>
Does this document have an internal subset?
</p>
<list>
<item>Return 1 for yes</item>
<item>Return 0 for no</item>
<item>Return -1 for don't know (let parser decide)</item>
</list>
</desc>
</method>
<method type="int">
<sel>hasExternalSubset:</sel>
<desc>
<p>Does this document have an external subset.
<p>
Does this document have an external subset.
</p>
<list>
<item>Return 1 for yes</item>
<item>Return 0 for no</item>
<item>Return -1 for don't know (let parser decide)</item>
</list>
</desc>
</method>
<method type="void">
<method type="BOOL">
<sel>internalSubset:</sel>
<arg type="NSString*">name</arg>
<sel>externalID:</sel>
@ -232,12 +244,14 @@
<sel>systemID:</sel>
<arg type="NSString*">systemID</arg>
<desc>
<p>Callback on internal subset declaration.
<p>
Callback on internal subset declaration.
Return YES if handled, NO if you want the parser to handle it.
</p>
</desc>
</method>
<method type="void">
<method type="BOOL">
<sel>externalSubset:</sel>
<arg type="NSString*">name</arg>
<sel>externalID:</sel>
@ -245,20 +259,40 @@
<sel>systemID:</sel>
<arg type="NSString*">systemID</arg>
<desc>
<p>Callback on external subset declaration.
<p>
Callback on external subset declaration.
Return YES if handled, NO if you want the parser to handle it.
</p>
</desc>
</method>
<method type="void*">
<sel>resolveEntity:</sel>
<method type="NSString*">
<sel>loadEntity:</sel>
<arg type="NSString*">publicID</arg>
<sel>systemID:</sel>
<arg type="NSString*">systemID</arg>
<sel>at:</sel>
<arg type="NSString*">locationURL</arg>
<desc>
<p>The entity loader, to control the loading of external entities,
the application can either.
</p>
<p>
This method controls the loading of external entities into
the system. If it returns an empty string, the entity is not
loaded. If it returns a filename, the entity is loaded from
that file. If it returns nil, the default entity loading
mechanism is used.
</p>
<p>
The default entity loading mechanism is to construct a file
name from the locationURL, by replacing all path separators
with underscores, then attempt to locate that file in the DTDs
resource directory of the main bundle, and all the standard
system locations.
</p>
<p>
As a special case, the default loader examines the publicID
and if it is a GNUstep DTD, the loader constructs a special
name from the ID (by replacing dots with underscores and
spaces with hyphens) and looks for a file with that name
and a '.dtd' extension in the GNUstep bundles.
</p>
</desc>
</method>

View file

@ -12,8 +12,8 @@
<dt>Richard Frith-Macdonald
<dd>
</dl>
<p>Version: 0.2</p>
<p>Date: 15 september, 2000</p>
<p>Version: 0.3</p>
<p>Date: 1 November, 2000</p>
<h2><a name ="cont-0">GSSAXHandler</a></h2>
<h2><a name ="GSSAXHandler">GSSAXHandler</a></h2>
<p><b>Declared in: </b> GSXML.h</p>
@ -72,12 +72,12 @@ XML SAX Handler.</p>
<li><a href ="GSSAXHandler.html#method-20">-internalSubset:externalID:systemID:</a>
<li><a href ="GSSAXHandler.html#method-5">-isStandalone</a>
<li><a href ="GSSAXHandler.html#method-1">-lib</a>
<li><a href ="GSSAXHandler.html#method-22">-loadEntity:at:</a>
<li><a href ="GSSAXHandler.html#method-25">-namespaceDecl:href:prefix:</a>
<li><a href ="GSSAXHandler.html#method-26">-notationDecl:systemId:</a>
<li><a href ="GSSAXHandler.html#method-2">-parser</a>
<li><a href ="GSSAXHandler.html#method-11">-processInstruction:value:</a>
<li><a href ="GSSAXHandler.html#method-31">-reference:</a>
<li><a href ="GSSAXHandler.html#method-22">-resolveEntity:systemID:</a>
<li><a href ="GSSAXHandler.html#method-3">-startDocument</a>
<li><a href ="GSSAXHandler.html#method-6">-startElement:attributes:</a>
<li><a href ="GSSAXHandler.html#method-30">-unparsedEntityDecl:public:system:notationName:</a>
@ -288,13 +288,35 @@ Callback on external subset declaration.
<hr>
<h3><a name ="method-22">resolveEntity:systemID:</a></h3>
- (void*) <b>resolveEntity:</b> (NSString*)publicID <b>systemID:</b> (NSString*)systemID;<br>
<h3><a name ="method-22">loadEntity:at:</a></h3>
- (NSString*) <b>loadEntity:</b> (NSString*)publicID <b>at:</b> (NSString*)locationURL;<br>
<p>
The entity loader, to control the loading of external entities,
the application can either.
</p>
<p>
This method controls the loading of external entities into
the system. If it returns an empty string, the entity is not
loaded. If it returns a filename, the entity is loaded from
that file. If it returns nil, the default entity loading
mechanism is used.
</p>
<p>
The default entity loading mechanism is to construct a file
name from the locationURL, by replacing all path separators
with underscores, then attempt to locate that file in the DTDs
resource directory of the main bundle, and all the standard
system locations.
</p>
<p>
As a special case, the default loader examines the publicID
and if it is a GNUstep DTD, the loader constructs a special
name from the ID (by replacing dots with underscores and
spaces with hyphens) and looks for a file with that name
and a '.dtd' extension in the GNUstep bundles.
</p>
<hr>

View file

@ -9,8 +9,8 @@
<author name="Richard Frith-Macdonald">
<email address="rfm@gnu.org"/>
</author>
<version>0.1</version>
<date>15 September, 2000</date>
<version>0.2</version>
<date>1 November, 2000</date>
</head>
<body>
@ -359,17 +359,7 @@
<sel>errNo</sel>
<desc>
<p>
Return error code.
</p>
</desc>
</method>
<method type="void">
<sel>setExternalEntityLoader</sel>
<arg type="void*">function</arg>
<desc>
<p>
Set a external entity loader.
Return error code for last parse operation.
</p>
</desc>
</method>

View file

@ -203,7 +203,6 @@ typedef xmlNsType GSXMLNamespaceType;
- (int) errNo;
- (BOOL) getWarnings: (BOOL)yesno;
- (BOOL) keepBlanks: (BOOL)yesno;
- (void) setExternalEntityLoader: (void*)function;
- (BOOL) substituteEntities: (BOOL)yesno;
@end
@ -243,15 +242,17 @@ typedef xmlNsType GSXMLNamespaceType;
- (void) cdataBlock: (NSString*)value;
- (int) hasInternalSubset;
- (void) internalSubset: (NSString*)name
- (BOOL) internalSubset: (NSString*)name
externalID: (NSString*)externalID
systemID: (NSString*)systemID;
- (int) hasExternalSubset;
- (void) externalSubset: (NSString*)name
- (BOOL) externalSubset: (NSString*)name
externalID: (NSString*)externalID
systemID: (NSString*)systemID;
- (void*) resolveEntity: (NSString*)publicId
systemID: (NSString*)systemID;
- (NSString*) loadEntity: (NSString*)publicId
at: (NSString*)locationURL;
- (void*) getEntity: (NSString*)name;
- (void*) getParameterEntity: (NSString*)name;

View file

@ -37,6 +37,8 @@
#include <Foundation/NSURL.h>
#include <Foundation/NSMapTable.h>
#include <Foundation/NSException.h>
#include <Foundation/NSBundle.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSFileManager.h>
extern int xmlDoValidityCheckingDefaultValue;
@ -83,6 +85,9 @@ setupCache()
}
}
static xmlParserInputPtr
loadEntityFunction(const char *url, const char *eid, xmlParserCtxtPtr *ctxt);
/* Internal interfaces */
@interface GSXMLParser (Private)
@ -833,6 +838,7 @@ static NSString *endMarker = @"At end of incremental parse";
{
if (cacheDone == NO)
setupCache();
xmlSetExternalEntityLoader((xmlExternalEntityLoader)loadEntityFunction);
}
+ (GSXMLParser*) parser
@ -1159,11 +1165,6 @@ static NSString *endMarker = @"At end of incremental parse";
return !(xmlGetWarningsDefaultValue = yesno);
}
- (void) setExternalEntityLoader: (void*)function
{
xmlSetExternalEntityLoader((xmlExternalEntityLoader)function);
}
- (int) errNo
{
return ((xmlParserCtxtPtr)lib)->errNo;
@ -1246,6 +1247,143 @@ static NSString *endMarker = @"At end of incremental parse";
*/
#define HANDLER (GSSAXHandler*)(((xmlParserCtxtPtr)ctx)->_private)
static xmlParserInputPtr
loadEntityFunction(const char *url, const char *eid, xmlParserCtxtPtr *ctx)
{
extern xmlParserInputPtr xmlNewInputFromFile();
NSString *file;
xmlParserInputPtr ret = 0;
NSString *entityId;
NSString *location ;
NSArray *components;
NSMutableString *local;
unsigned count;
unsigned index;
NSCAssert(ctx, @"No Context");
if (eid == 0 || url == 0)
return 0;
entityId = UTF8Str(eid);
location = UTF8Str(url);
components = [location pathComponents];
local = [NSMutableString string];
/*
* Build a local filename by replacing path separator characters with
* something else.
*/
count = [components count];
if (count > 0)
{
count--;
for (index = 0; index < count; index++)
{
[local appendString: [components objectAtIndex: index]];
[local appendString: @"_"];
}
[local appendString: [components objectAtIndex: index]];
}
/*
* Now ask the SAXHandler callback for the name of a local file
*/
file = [HANDLER loadEntity: entityId at: location];
if (file == nil)
{
/*
* Special case - GNUstep DTDs - should be installed in the GNUstep
* system bundle - so we look for them there.
*/
if ([entityId hasPrefix: @"-//GNUstep//DTD "] == YES)
{
NSCharacterSet *ws = [NSCharacterSet whitespaceCharacterSet];
NSMutableString *name;
NSString *found;
unsigned len;
NSRange r;
/*
* Extract the relevent DTD name
*/
name = AUTORELEASE([entityId mutableCopy]);
r = NSMakeRange(0, 16);
[name deleteCharactersInRange: r];
len = [name length];
r = [name rangeOfString: @"/" options: NSLiteralSearch];
if (r.length > 0)
{
r.length = len - r.location;
[name deleteCharactersInRange: r];
len = [name length];
}
/*
* Convert dots to underscores.
*/
r = [name rangeOfString: @"." options: NSLiteralSearch];
while (r.length > 0)
{
[name replaceCharactersInRange: r withString: @"_"];
r.location++;
r.length = len - r.location;
r = [name rangeOfString: @"."
options: NSLiteralSearch
range: r];
}
/*
* Convert whitespace to hyphens.
*/
r = [name rangeOfCharacterFromSet: ws options: NSLiteralSearch];
while (r.length > 0)
{
[name replaceCharactersInRange: r withString: @"-"];
r.location++;
r.length = len - r.location;
r = [name rangeOfCharacterFromSet: ws
options: NSLiteralSearch
range: r];
}
found = [NSBundle pathForGNUstepResource: name
ofType: @"dtd"
inDirectory: @"DTDs"];
if (found == nil)
{
NSLog(@"unable to find GNUstep DTD - '%@' for '%s'", name, eid);
}
else
{
file = found;
}
}
/*
* DTD not found - so we look for it in standard locations.
*/
if (file == nil)
{
file = [[NSBundle mainBundle] pathForResource: local
ofType: @""
inDirectory: @"DTDs"];
if (file == nil)
{
file = [NSBundle pathForGNUstepResource: local
ofType: @""
inDirectory: @"DTDs"];
}
}
}
if ([file length] > 0)
{
ret = xmlNewInputFromFile(ctx, [file fileSystemRepresentation]);
}
return ret;
}
static void
startDocumentFunction(void *ctx)
{
@ -1270,15 +1408,25 @@ isStandaloneFunction(void *ctx)
static int
hasInternalSubsetFunction(void *ctx)
{
int has;
NSCAssert(ctx,@"No Context");
return [HANDLER hasInternalSubset];
has = [HANDLER hasInternalSubset];
if (has < 0)
has = (*xmlDefaultSAXHandler.hasInternalSubset)(ctx);
return has;
}
static int
hasExternalSubsetFunction(void *ctx)
{
int has;
NSCAssert(ctx,@"No Context");
return [HANDLER hasExternalSubset];
has = [HANDLER hasExternalSubset];
if (has < 0)
has = (*xmlDefaultSAXHandler.hasExternalSubset)(ctx);
return has;
}
static void
@ -1286,9 +1434,10 @@ internalSubsetFunction(void *ctx, const char *name,
const xmlChar *ExternalID, const xmlChar *SystemID)
{
NSCAssert(ctx,@"No Context");
[HANDLER internalSubset: UTF8Str(name)
externalID: UTF8Str(ExternalID)
systemID: UTF8Str(SystemID)];
if ([HANDLER internalSubset: UTF8Str(name)
externalID: UTF8Str(ExternalID)
systemID: UTF8Str(SystemID)] == NO)
(*xmlDefaultSAXHandler.internalSubset)(ctx, name, ExternalID, SystemID);
}
static void
@ -1296,17 +1445,10 @@ externalSubsetFunction(void *ctx, const char *name,
const xmlChar *ExternalID, const xmlChar *SystemID)
{
NSCAssert(ctx,@"No Context");
[HANDLER externalSubset: UTF8Str(name)
externalID: UTF8Str(ExternalID)
systemID: UTF8Str(SystemID)];
}
static xmlParserInputPtr
resolveEntityFunction(void *ctx, const char *publicId, const char *systemId)
{
NSCAssert(ctx,@"No Context");
return [HANDLER resolveEntity: UTF8Str(publicId)
systemID: UTF8Str(systemId)];
if ([HANDLER externalSubset: UTF8Str(name)
externalID: UTF8Str(ExternalID)
systemID: UTF8Str(SystemID)] == NO)
(*xmlDefaultSAXHandler.externalSubset)(ctx, name, ExternalID, SystemID);
}
static xmlEntityPtr
@ -1491,9 +1633,6 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
#undef HANDLER
#undef HANDLER
+ (GSSAXHandler*) handler
{
return AUTORELEASE([[self alloc] init]);
@ -1576,9 +1715,10 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
{
}
- (void) resolveEntity: (NSString*)publicIdEntity
systemEntity: (NSString*)systemIdEntity
- (NSString*) loadEntity: (NSString*)publicId
at: (NSString*)location
{
return nil;
}
- (void) namespaceDecl: (NSString*)name
@ -1648,10 +1788,11 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
return 0;
}
- (void) internalSubset: (NSString*)name
externalID: (NSString*)externalID
systemID: (NSString*)systemID
- (BOOL) internalSubset: (NSString*)name
externalID: (NSString*)externalID
systemID: (NSString*)systemID
{
return NO;
}
- (int) hasExternalSubset
@ -1659,10 +1800,11 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
return 0;
}
- (void) externalSubset: (NSString*)name
externalID: (NSString*)externalID
systemID: (NSString*)systemID
- (BOOL) externalSubset: (NSString*)name
externalID: (NSString*)externalID
ystemID: (NSString*)systemID
{
return NO;
}
- (void*) getEntity: (NSString*)name
@ -1680,7 +1822,7 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
return NO;
else
{
memset(lib, 0, sizeof(xmlSAXHandler));
memcpy(lib, &xmlDefaultSAXHandler, sizeof(htmlSAXHandler));
#define LIB ((xmlSAXHandlerPtr)lib)
LIB->internalSubset = (void*) internalSubsetFunction;
@ -1688,7 +1830,6 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
LIB->isStandalone = (void*) isStandaloneFunction;
LIB->hasInternalSubset = (void*) hasInternalSubsetFunction;
LIB->hasExternalSubset = (void*) hasExternalSubsetFunction;
LIB->resolveEntity = (void*) resolveEntityFunction;
LIB->getEntity = (void*) getEntityFunction;
LIB->entityDecl = (void*) entityDeclFunction;
LIB->notationDecl = (void*) notationDeclFunction;
@ -1728,7 +1869,7 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
return NO;
else
{
memset(lib, 0, sizeof(htmlSAXHandler));
memcpy(lib, &xmlDefaultSAXHandler, sizeof(htmlSAXHandler));
#define LIB ((htmlSAXHandlerPtr)lib)
LIB->internalSubset = (void*) internalSubsetFunction;
@ -1736,7 +1877,6 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
LIB->isStandalone = (void*) isStandaloneFunction;
LIB->hasInternalSubset = (void*) hasInternalSubsetFunction;
LIB->hasExternalSubset = (void*) hasExternalSubsetFunction;
LIB->resolveEntity = (void*) resolveEntityFunction;
LIB->getEntity = (void*) getEntityFunction;
LIB->entityDecl = (void*) entityDeclFunction;
LIB->notationDecl = (void*) notationDeclFunction;

View file

@ -47,10 +47,10 @@
#include <string.h>
@interface NSObject (PrivateFrameworks)
+ (NSString *)frameworkEnv;
+ (NSString *)frameworkPath;
+ (NSString *)frameworkVersion;
+ (NSString **)frameworkClasses;
+ (NSString*) frameworkEnv;
+ (NSString*) frameworkPath;
+ (NSString*) frameworkVersion;
+ (NSString**) frameworkClasses;
@end
typedef enum {
@ -58,11 +58,11 @@ typedef enum {
} bundle_t;
/* Class variables - We keep track of all the bundles */
static NSBundle* _mainBundle = nil;
static NSMapTable* _bundles = NULL;
static NSBundle *_mainBundle = nil;
static NSMapTable *_bundles = NULL;
/* Keep the path to the executable file for finding the main bundle. */
static NSString *_executable_path;
static NSString *_executable_path;
/*
* An empty strings file table for use when localization files can't be found.
@ -71,37 +71,37 @@ static NSDictionary *_emptyTable = nil;
/* This is for bundles that we can't unload, so they shouldn't be
dealloced. This is true for all bundles right now */
static NSMapTable* _releasedBundles = NULL;
static NSMapTable *_releasedBundles = NULL;
/* When we are linking in an object file, objc_load_modules calls our
callback routine for every Class and Category loaded. The following
variable stores the bundle that is currently doing the loading so we know
where to store the class names.
*/
static NSBundle* _loadingBundle = nil;
static NSBundle* _gnustep_bundle = nil;
static NSRecursiveLock* load_lock = nil;
static BOOL _strip_after_loading = NO;
static NSBundle *_loadingBundle = nil;
static NSBundle *_gnustep_bundle = nil;
static NSRecursiveLock *load_lock = nil;
static BOOL _strip_after_loading = NO;
static NSString* gnustep_target_dir =
static NSString *gnustep_target_dir =
#ifdef GNUSTEP_TARGET_DIR
@GNUSTEP_TARGET_DIR;
#else
nil;
#endif
static NSString* gnustep_target_cpu =
static NSString *gnustep_target_cpu =
#ifdef GNUSTEP_TARGET_CPU
@GNUSTEP_TARGET_CPU;
#else
nil;
#endif
static NSString* gnustep_target_os =
static NSString *gnustep_target_os =
#ifdef GNUSTEP_TARGET_OS
@GNUSTEP_TARGET_OS;
#else
nil;
#endif
static NSString* library_combo =
static NSString *library_combo =
#ifdef LIBRARY_COMBO
@LIBRARY_COMBO;
#else
@ -120,10 +120,10 @@ static BOOL
bundle_directory_readable(NSString *path)
{
NSFileManager *mgr = [NSFileManager defaultManager];
BOOL directory;
BOOL directory;
if (![mgr fileExistsAtPath: path isDirectory: &directory]
|| !directory)
if ([mgr fileExistsAtPath: path isDirectory: &directory] == NO
|| !directory)
return NO;
return [mgr isReadableFileAtPath: path];
@ -185,7 +185,7 @@ _bundle_resource_path(NSString *primary, NSString* bundlePath, NSString *lang)
primary = [primary stringByAppendingPathComponent: bundlePath];
if (lang)
primary = [primary stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.lproj", lang]];
[NSString stringWithFormat: @"%@.lproj", lang]];
return primary;
}
@ -194,12 +194,14 @@ static NSString *
_bundle_name_first_match(NSString* directory, NSString* name)
{
NSFileManager *mgr = [NSFileManager defaultManager];
NSEnumerator *filelist;
NSString *path, *match, *cleanname;
NSEnumerator *filelist;
NSString *path;
NSString *match;
NSString *cleanname;
/* name might have a directory in it also, so account for this */
path = [[directory stringByAppendingPathComponent: name]
stringByDeletingLastPathComponent];
stringByDeletingLastPathComponent];
cleanname = [name lastPathComponent];
filelist = [[mgr directoryContentsAtPath: path] objectEnumerator];
while ((match = [filelist nextObject]))
@ -220,12 +222,13 @@ _bundle_name_first_match(NSString* directory, NSString* name)
+ (BOOL) _addFrameworkFromClass:(Class)frameworkClass
{
NSBundle *bundle;
NSString **fmClasses, *bundlePath = nil;
int len = strlen(frameworkClass->name);
NSBundle *bundle;
NSString **fmClasses;
NSString *bundlePath = nil;
int len = strlen(frameworkClass->name);
if (len > 12*sizeof(char)
&& !strncmp("NSFramework_", frameworkClass->name, sizeof(char)*12))
&& !strncmp("NSFramework_", frameworkClass->name, sizeof(char)*12))
{
NSString *varEnv, *path, *name;
@ -234,24 +237,22 @@ _bundle_name_first_match(NSString* directory, NSString* name)
varEnv = [frameworkClass frameworkEnv];
if (varEnv && [varEnv length])
bundlePath = [[[NSProcessInfo processInfo] environment]
objectForKey: varEnv];
objectForKey: varEnv];
path = [frameworkClass frameworkPath];
if (path && [path length])
{
if (bundlePath)
bundlePath = [bundlePath
stringByAppendingPathComponent: path];
bundlePath = [bundlePath stringByAppendingPathComponent: path];
else
bundlePath = path;
}
else
bundlePath = [bundlePath
stringByAppendingPathComponent: @"Library/Frameworks"];
stringByAppendingPathComponent: @"Library/Frameworks"];
bundlePath = [bundlePath stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.framework",
name]];
[NSString stringWithFormat: @"%@.framework", name]];
bundle = [NSBundle bundleWithPath: bundlePath];
bundle->_bundleType = NSBUNDLE_FRAMEWORK;
@ -268,8 +269,7 @@ _bundle_name_first_match(NSString* directory, NSString* name)
value = [NSValue valueWithNonretainedObject: class];
[(NSMutableArray *)[bundle _bundleClasses]
addObject: value];
[(NSMutableArray *)[bundle _bundleClasses] addObject: value];
if (_loadingBundle)
{
@ -282,7 +282,7 @@ _bundle_name_first_match(NSString* directory, NSString* name)
if ([obj nonretainedObjectValue] == class)
{
[(NSMutableArray *)_loadingBundle->_bundleClasses
removeObject: obj];
removeObject: obj];
break;
}
}
@ -381,14 +381,13 @@ _bundle_load_callback(Class theClass, Category *theCategory)
NSString *name;
name = [NSString stringWithCString: &cString[3]
length: i-3];
length: i-3];
bundlePath = [s stringByAppendingPathComponent:
[NSString stringWithFormat:
@"%@.framework", name]];
[NSString stringWithFormat: @"%@.framework", name]];
name = [NSString stringWithFormat: @"NSFramework_%@",
name];
name];
ASSIGN(lastFrameworkName, name);
ASSIGN(lastSymbolPath, path);
@ -404,8 +403,11 @@ _bundle_load_callback(Class theClass, Category *theCategory)
if ([[lastComponent pathExtension] length] == 0)
{
frameworkVersion = lastComponent;
s = [s stringByDeletingLastPathComponent]; // remove version
bundlePath = [s stringByDeletingLastPathComponent]; // remove version dir
/*
* remove version and version directory.
*/
s = [s stringByDeletingLastPathComponent];
bundlePath = [s stringByDeletingLastPathComponent];
if ([[bundlePath pathExtension] isEqual: @"framework"] == YES)
{
@ -465,9 +467,8 @@ _bundle_load_callback(Class theClass, Category *theCategory)
/* Don't store categories */
if (!theCategory)
[(NSMutableArray *)[bundle _bundleClasses]
addObject: [NSValue
valueWithNonretainedObject: (id)theClass]];
[(NSMutableArray *)[bundle _bundleClasses] addObject: [NSValue
valueWithNonretainedObject: (id)theClass]];
}
@ -663,7 +664,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
for (i = 0; i < j && found == NO; i++)
{
if ([[bundleClasses objectAtIndex: i]
nonretainedObjectValue] == aClass)
nonretainedObjectValue] == aClass)
found = YES;
}
@ -843,7 +844,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
for (i = 0; i < j && found == NO; i++)
{
if ([[_bundleClasses objectAtIndex: i]
nonretainedObjectValue] == theClass)
nonretainedObjectValue] == theClass)
found = YES;
}
@ -912,7 +913,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
_loadingBundle = self;
_bundleClasses = RETAIN([NSMutableArray arrayWithCapacity: 2]);
if (objc_load_module([object cString],
stderr, _bundle_load_callback, NULL, NULL))
stderr, _bundle_load_callback, NULL, NULL))
{
[load_lock unlock];
return NO;
@ -928,7 +929,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
classEnumerator = [_bundleClasses objectEnumerator];
while ((class = [classEnumerator nextObject]))
[classNames addObject: NSStringFromClass([class
nonretainedObjectValue])];
nonretainedObjectValue])];
[load_lock unlock];
@ -936,7 +937,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
postNotificationName: NSBundleDidLoadNotification
object: self
userInfo: [NSDictionary dictionaryWithObject: classNames
forKey: NSLoadedClasses]];
forKey: NSLoadedClasses]];
return YES;
}
@ -1007,16 +1008,16 @@ _bundle_load_callback(Class theClass, Category *theCategory)
if (ext && [ext length] != 0)
{
fullpath = [path stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.%@", name, ext]];
[NSString stringWithFormat: @"%@.%@", name, ext]];
if ( bundle_file_readable(fullpath) )
{
if (gnustep_target_os)
{
NSString* platpath;
platpath = [path stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@-%@.%@",
name, gnustep_target_os, ext]];
if ( bundle_file_readable(platpath) )
[NSString stringWithFormat: @"%@-%@.%@",
name, gnustep_target_os, ext]];
if (bundle_file_readable(platpath))
fullpath = platpath;
}
}
@ -1028,15 +1029,16 @@ _bundle_load_callback(Class theClass, Category *theCategory)
fullpath = _bundle_name_first_match(path, name);
if (fullpath && gnustep_target_os)
{
NSString* platpath;
NSString *platpath;
platpath = _bundle_name_first_match(path,
[NSString stringWithFormat: @"%@-%@",
name, gnustep_target_os]);
if (platpath)
[NSString stringWithFormat: @"%@-%@",
name, gnustep_target_os]);
if (platpath != nil)
fullpath = platpath;
}
}
if (fullpath)
if (fullpath != nil)
break;
}
@ -1223,8 +1225,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
if (_bundleType == NSBUNDLE_FRAMEWORK)
return [_path stringByAppendingPathComponent:
[NSString stringWithFormat:@"Versions/%@/Resources",
version]];
[NSString stringWithFormat:@"Versions/%@/Resources", version]];
else
return [_path stringByAppendingPathComponent: @"Resources"];
}
@ -1333,17 +1334,22 @@ _bundle_load_callback(Class theClass, Category *theCategory)
ofType: (NSString *)ext
inDirectory: (NSString *)bundlePath;
{
NSString *path;
NSBundle *user_bundle = nil, *local_bundle = nil;
NSProcessInfo *pInfo;
NSDictionary *env;
NSMutableString *user, *local;
NSString *path;
NSBundle *user_bundle = nil;
NSBundle *local_bundle = nil;
NSBundle *network_bundle = nil;
NSProcessInfo *pInfo;
NSDictionary *env;
NSMutableString *user;
NSMutableString *local;
NSMutableString *network;
/*
The path of where to search for the resource files
is based upon environment variables.
GNUSTEP_USER_ROOT
GNUSTEP_LOCAL_ROOT
GNUSTEP_NETWORK_ROOT
GNUSTEP_SYSTEM_ROOT
*/
pInfo = [NSProcessInfo processInfo];
@ -1352,33 +1358,45 @@ _bundle_load_callback(Class theClass, Category *theCategory)
[user appendString: @"/Libraries"];
local = AUTORELEASE([[env objectForKey: @"GNUSTEP_LOCAL_ROOT"] mutableCopy]);
[local appendString: @"/Libraries"];
network = AUTORELEASE([[env objectForKey: @"GNUSTEP_NETWORK_ROOT"]
mutableCopy]);
[network appendString: @"/Libraries"];
if (user)
if (user != nil)
user_bundle = [NSBundle bundleWithPath: user];
if (local)
if (local != nil)
local_bundle = [NSBundle bundleWithPath: local];
if (network != nil)
network_bundle = [NSBundle bundleWithPath: network];
/* Gather up the paths */
/* Search user first */
path = [user_bundle pathForResource: name
ofType: ext
inDirectory: bundlePath];
if (path)
ofType: ext
inDirectory: bundlePath];
if (path != nil)
return path;
/* Search local second */
path = [local_bundle pathForResource: name
ofType: ext
inDirectory: bundlePath];
if (path)
ofType: ext
inDirectory: bundlePath];
if (path != nil)
return path;
/* Search network third */
path = [network_bundle pathForResource: name
ofType: ext
inDirectory: bundlePath];
if (path != nil)
return path;
/* Search system last */
path = [_gnustep_bundle pathForResource: name
ofType: ext
inDirectory: bundlePath];
if (path)
ofType: ext
inDirectory: bundlePath];
if (path != nil)
return path;
/* Didn't find it */

View file

@ -102,7 +102,7 @@ static id (*plAlloc)(Class, SEL, NSZone*) = 0;
static id (*plInit)(id, SEL, unichar*, unsigned) = 0;
static SEL plSel;
static SEL cMemberSel;
static SEL cMemberSel = 0;
static NSCharacterSet *hexdigits = nil;
static BOOL (*hexdigitsImp)(id, SEL, unichar) = 0;
@ -113,6 +113,8 @@ static void setupHexdigits()
hexdigits = [NSCharacterSet characterSetWithCharactersInString:
@"0123456789abcdefABCDEF"];
IF_NO_GC(RETAIN(hexdigits));
if (cMemberSel == 0)
cMemberSel = @selector(characterIsMember:);
hexdigitsImp =
(BOOL(*)(id,SEL,unichar)) [hexdigits methodForSelector: cMemberSel];
}
@ -132,6 +134,8 @@ static void setupQuotables()
[s invert];
quotables = [s copy];
RELEASE(s);
if (cMemberSel == 0)
cMemberSel = @selector(characterIsMember:);
quotablesImp =
(BOOL(*)(id,SEL,unichar)) [quotables methodForSelector: cMemberSel];
}
@ -146,6 +150,8 @@ static void setupWhitespce()
whitespce = [NSCharacterSet characterSetWithCharactersInString:
@" \t\r\n\f\b"];
IF_NO_GC(RETAIN(whitespce));
if (cMemberSel == 0)
cMemberSel = @selector(characterIsMember:);
whitespceImp =
(BOOL(*)(id,SEL,unichar)) [whitespce methodForSelector: cMemberSel];
}
@ -3789,25 +3795,24 @@ static id parsePlItem(pldata* pld)
data = [[NSMutableData alloc] initWithCapacity: 0];
pld->pos++;
while (skipSpace(pld) == YES && pld->ptr[pld->pos] != '>')
skipSpace(pld);
while (pld->pos < max
&& (*hexdigitsImp)(hexdigits, cMemberSel, pld->ptr[pld->pos])
&& (*hexdigitsImp)(hexdigits, cMemberSel, pld->ptr[pld->pos+1]))
{
while (pld->pos < max
&& (*hexdigitsImp)(hexdigits, cMemberSel, pld->ptr[pld->pos])
&& (*hexdigitsImp)(hexdigits, cMemberSel, pld->ptr[pld->pos+1]))
{
unsigned char byte;
unsigned char byte;
byte = (char2num(pld->ptr[pld->pos])) << 4;
pld->pos++;
byte |= char2num(pld->ptr[pld->pos]);
pld->pos++;
buf[len++] = byte;
if (len == sizeof(buf))
{
[data appendBytes: buf length: len];
len = 0;
}
byte = (char2num(pld->ptr[pld->pos])) << 4;
pld->pos++;
byte |= char2num(pld->ptr[pld->pos]);
pld->pos++;
buf[len++] = byte;
if (len == sizeof(buf))
{
[data appendBytes: buf length: len];
len = 0;
}
skipSpace(pld);
}
if (pld->pos >= pld->end)
{
@ -3978,7 +3983,7 @@ GSPropertyList(NSString *string)
{
unsigned c = [string characterAtIndex: index];
if ((*whitespceImp)(whitespce, cMemberSel, c) == YES)
if ((*whitespceImp)(whitespce, cMemberSel, c) == NO)
{
break;
}
@ -3994,8 +3999,9 @@ GSPropertyList(NSString *string)
GSXMLParser *parser;
data = [string dataUsingEncoding: NSUTF8StringEncoding];
parser = [GSXMLParser parserWithData: nil];
[parser substituteEntities: NO];
parser = [GSXMLParser parser];
[parser substituteEntities: YES];
[parser doValidityChecking: YES];
if ([parser parse: data] == NO || [parser parse: nil] == NO)
{
NSLog(@"not a property list - failed to parse as XML");

View file

@ -290,7 +290,7 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
+ (NSArray*) userLanguages
{
NSArray *currLang;
NSArray *currLang = nil;
NSString *locale;
if (userLanguages)
@ -328,7 +328,7 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
}
}
if (currLang)
if (currLang != nil)
[userLanguages addObjectsFromArray: currLang];
/* Check if "English" is included. We do this to make sure all the