mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Merge from 1.4.0
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14208 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
995a21c468
commit
c16674f37a
14 changed files with 260 additions and 91 deletions
|
@ -1296,6 +1296,11 @@ static NSMapTable *nodeNames = 0;
|
|||
return desc;
|
||||
}
|
||||
|
||||
- (void) setNamespace: (GSXMLNamespace *)space
|
||||
{
|
||||
xmlSetNs (lib, [space lib]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GSXMLNode (GSPrivate)
|
||||
|
|
|
@ -469,6 +469,11 @@ static IMP gs_objc_msg_forward (SEL sel)
|
|||
*/
|
||||
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature
|
||||
{
|
||||
if (aSignature == nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
_sig = RETAIN(aSignature);
|
||||
_numArgs = [aSignature numberOfArguments];
|
||||
_info = [aSignature methodInfo];
|
||||
|
|
|
@ -204,6 +204,11 @@ static IMP gs_objc_msg_forward (SEL sel)
|
|||
*/
|
||||
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature
|
||||
{
|
||||
if (aSignature == nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
_sig = RETAIN(aSignature);
|
||||
_numArgs = [aSignature numberOfArguments];
|
||||
_info = [aSignature methodInfo];
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
*/
|
||||
|
||||
#include <math.h>
|
||||
#if !defined(__APPLE__) || !defined(GNU_RUNTIME)
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include <Foundation/NSDecimal.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
|
|
|
@ -255,7 +255,9 @@ static NSFileManager* defaultManager = nil;
|
|||
const char *cpath;
|
||||
cpath = [self fileSystemRepresentationWithPath: completePath];
|
||||
if (CreateDirectory(cpath, NULL) == FALSE)
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -487,11 +489,14 @@ static NSFileManager* defaultManager = nil;
|
|||
|
||||
fileExists = [self fileExistsAtPath: source isDirectory: &sourceIsDir];
|
||||
if (!fileExists)
|
||||
return NO;
|
||||
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
fileExists = [self fileExistsAtPath: destination];
|
||||
if (fileExists)
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
/* Check to see if the source and destination's parent are on the same
|
||||
physical device so we can perform a rename syscall directly. */
|
||||
|
@ -591,18 +596,24 @@ static NSFileManager* defaultManager = nil;
|
|||
|
||||
res = GetFileAttributes(cpath);
|
||||
if (res == WIN32ERR)
|
||||
return NO;
|
||||
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
if (res & FILE_ATTRIBUTE_DIRECTORY)
|
||||
is_dir = YES;
|
||||
{
|
||||
is_dir = YES;
|
||||
}
|
||||
else
|
||||
is_dir = NO;
|
||||
{
|
||||
is_dir = NO;
|
||||
}
|
||||
#else
|
||||
struct stat statbuf;
|
||||
|
||||
if (lstat(cpath, &statbuf) != 0)
|
||||
return NO;
|
||||
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
is_dir = ((statbuf.st_mode & S_IFMT) == S_IFDIR);
|
||||
#endif /* MINGW */
|
||||
}
|
||||
|
@ -631,11 +642,15 @@ static NSFileManager* defaultManager = nil;
|
|||
RELEASE(info);
|
||||
}
|
||||
else
|
||||
result = NO;
|
||||
{
|
||||
result = NO;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
return YES;
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -655,7 +670,9 @@ static NSFileManager* defaultManager = nil;
|
|||
result = [self removeFileAtPath: next handler: handler];
|
||||
RELEASE(arp);
|
||||
if (result == NO)
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (rmdir([path fileSystemRepresentation]) < 0)
|
||||
|
@ -676,11 +693,15 @@ static NSFileManager* defaultManager = nil;
|
|||
RELEASE(info);
|
||||
}
|
||||
else
|
||||
result = NO;
|
||||
{
|
||||
result = NO;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
return YES;
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -892,14 +913,18 @@ static NSFileManager* defaultManager = nil;
|
|||
const char* cpath = [self fileSystemRepresentationWithPath: path];
|
||||
|
||||
if (cpath == 0 || *cpath == '\0')
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__MINGW__)
|
||||
DWORD res= GetFileAttributes(cpath);
|
||||
|
||||
if (res == WIN32ERR)
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
#else
|
||||
return (access(cpath, R_OK) == 0);
|
||||
|
@ -912,14 +937,17 @@ static NSFileManager* defaultManager = nil;
|
|||
const char* cpath = [self fileSystemRepresentationWithPath: path];
|
||||
|
||||
if (cpath == 0 || *cpath == '\0')
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__MINGW__)
|
||||
DWORD res= GetFileAttributes(cpath);
|
||||
|
||||
if (res == WIN32ERR)
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
return (res & FILE_ATTRIBUTE_READONLY) ? NO : YES;
|
||||
#else
|
||||
return (access(cpath, W_OK) == 0);
|
||||
|
@ -959,7 +987,9 @@ static NSFileManager* defaultManager = nil;
|
|||
const char* cpath = [self fileSystemRepresentationWithPath: path];
|
||||
|
||||
if (cpath == 0 || *cpath == '\0')
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO - handle directories
|
||||
|
@ -967,7 +997,9 @@ static NSFileManager* defaultManager = nil;
|
|||
DWORD res= GetFileAttributes(cpath);
|
||||
|
||||
if (res == WIN32ERR)
|
||||
return NO;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return (res & FILE_ATTRIBUTE_READONLY) ? NO : YES;
|
||||
#else
|
||||
cpath = [self fileSystemRepresentationWithPath:
|
||||
|
@ -1216,8 +1248,9 @@ static NSFileManager* defaultManager = nil;
|
|||
* See if this is a directory (don't follow links).
|
||||
*/
|
||||
if ([self fileExistsAtPath: path isDirectory: &is_dir] == NO || is_dir == NO)
|
||||
return nil;
|
||||
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
/* We initialize the directory enumerator with justContents == YES,
|
||||
which tells the NSDirectoryEnumerator code that we only enumerate
|
||||
the contents non-recursively once, and exit. NSDirectoryEnumerator
|
||||
|
@ -1232,8 +1265,9 @@ static NSFileManager* defaultManager = nil;
|
|||
addImp = [content methodForSelector: @selector(addObject:)];
|
||||
|
||||
while ((path = (*nxtImp)(direnum, @selector(nextObject))) != nil)
|
||||
(*addImp)(content, @selector(addObject:), path);
|
||||
|
||||
{
|
||||
(*addImp)(content, @selector(addObject:), path);
|
||||
}
|
||||
RELEASE(direnum);
|
||||
|
||||
return content;
|
||||
|
@ -1257,8 +1291,9 @@ static NSFileManager* defaultManager = nil;
|
|||
IMP addImp;
|
||||
|
||||
if (![self fileExistsAtPath: path isDirectory: &isDir] || !isDir)
|
||||
return nil;
|
||||
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
direnum = [[NSDirectoryEnumerator alloc] initWithDirectoryPath: path
|
||||
recurseIntoSubdirectories: YES
|
||||
followSymlinks: NO
|
||||
|
@ -1301,9 +1336,13 @@ static NSFileManager* defaultManager = nil;
|
|||
int llen = readlink(cpath, lpath, PATH_MAX-1);
|
||||
|
||||
if (llen > 0)
|
||||
return [self stringWithFileSystemRepresentation: lpath length: llen];
|
||||
{
|
||||
return [self stringWithFileSystemRepresentation: lpath length: llen];
|
||||
}
|
||||
else
|
||||
return nil;
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
|
@ -1414,7 +1453,12 @@ static NSFileManager* defaultManager = nil;
|
|||
newpath = [newpath stringByReplacingString: @"/" withString: @"\\"];
|
||||
return [newpath cString];
|
||||
#else
|
||||
return [[path stringByStandardizingPath] cString];
|
||||
/*
|
||||
* NB ... Don't standardize path, since that would automatically
|
||||
* follow symbolic links ... and mess up any code wishing to
|
||||
* examine the link itsself.
|
||||
*/
|
||||
return [path cString];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -631,19 +631,45 @@ _arg_addr(NSInvocation *inv, int index)
|
|||
|
||||
- (id) initWithSelector: (SEL)aSelector
|
||||
{
|
||||
return [self initWithArgframe: 0 selector: aSelector];
|
||||
const char *types;
|
||||
NSMethodSignature *newSig;
|
||||
|
||||
types = sel_get_type(aSelector);
|
||||
if (types == 0)
|
||||
{
|
||||
types = sel_get_type(sel_get_any_typed_uid(sel_get_name(aSelector)));
|
||||
}
|
||||
if (types == 0)
|
||||
{
|
||||
NSLog(@"Couldn't find encoding type for selector %s.",
|
||||
sel_get_name(aSelector));
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
newSig = [NSMethodSignature signatureWithObjCTypes: types];
|
||||
return [self initWithMethodSignature: newSig];
|
||||
}
|
||||
|
||||
- (id) initWithTarget: anObject selector: (SEL)aSelector, ...
|
||||
{
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
NSMethodSignature *newSig;
|
||||
|
||||
self = [self initWithArgframe: 0 selector: aSelector];
|
||||
if (anObject)
|
||||
{
|
||||
newSig = [anObject methodSignatureForSelector: aSelector];
|
||||
self = [self initWithMethodSignature: newSig];
|
||||
}
|
||||
else
|
||||
{
|
||||
self = [self initWithSelector: aSelector];
|
||||
}
|
||||
if (self)
|
||||
{
|
||||
int i;
|
||||
|
||||
[self setTarget: anObject];
|
||||
[self setSelector: aSelector];
|
||||
va_start (ap, aSelector);
|
||||
for (i = 3; i <= _numArgs; i++)
|
||||
{
|
||||
|
@ -758,22 +784,7 @@ _arg_addr(NSInvocation *inv, int index)
|
|||
|
||||
- (id) initWithArgframe: (arglist_t)frame selector: (SEL)aSelector
|
||||
{
|
||||
const char *types;
|
||||
NSMethodSignature *newSig;
|
||||
|
||||
types = sel_get_type(aSelector);
|
||||
if (types == 0)
|
||||
{
|
||||
types = sel_get_type(sel_get_any_typed_uid(sel_get_name(aSelector)));
|
||||
}
|
||||
if (types == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Couldn't find encoding type for selector %s.",
|
||||
sel_get_name(aSelector)];
|
||||
}
|
||||
newSig = [NSMethodSignature signatureWithObjCTypes: types];
|
||||
self = [self initWithMethodSignature: newSig];
|
||||
self = [self initWithSelector: aSelector];
|
||||
if (self)
|
||||
{
|
||||
[self setSelector: aSelector];
|
||||
|
@ -799,6 +810,11 @@ _arg_addr(NSInvocation *inv, int index)
|
|||
*/
|
||||
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature
|
||||
{
|
||||
if (aSignature == nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
_sig = RETAIN(aSignature);
|
||||
_numArgs = [aSignature numberOfArguments];
|
||||
_info = [aSignature methodInfo];
|
||||
|
|
|
@ -1840,7 +1840,7 @@ handle_printf_atsign (FILE *stream,
|
|||
forRange: (NSRange)aRange
|
||||
{
|
||||
unichar thischar;
|
||||
unsigned start, end, len;
|
||||
unsigned start, end, len, termlen;
|
||||
unichar (*caiImp)(NSString*, SEL, unsigned int);
|
||||
|
||||
len = [self length];
|
||||
|
@ -1903,10 +1903,10 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
if (lineEndIndex || contentsEndIndex)
|
||||
{
|
||||
BOOL found = NO;
|
||||
end = aRange.location + aRange.length;
|
||||
while (end < len)
|
||||
{
|
||||
BOOL done = NO;
|
||||
|
||||
thischar = (*caiImp)(self, caiSel, end);
|
||||
switch (thischar)
|
||||
|
@ -1915,22 +1915,24 @@ handle_printf_atsign (FILE *stream,
|
|||
case (unichar)0x000D:
|
||||
case (unichar)0x2028:
|
||||
case (unichar)0x2029:
|
||||
done = YES;
|
||||
found = YES;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
end++;
|
||||
if (done)
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
termlen = 1;
|
||||
if (lineEndIndex)
|
||||
{
|
||||
if (end < len
|
||||
&& ((*caiImp)(self, caiSel, end) == (unichar)0x000D)
|
||||
&& ((*caiImp)(self, caiSel, end+1) == (unichar)0x000A))
|
||||
&& ((*caiImp)(self, caiSel, end-1) == (unichar)0x000D)
|
||||
&& ((*caiImp)(self, caiSel, end) == (unichar)0x000A))
|
||||
{
|
||||
*lineEndIndex = end+1;
|
||||
termlen = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1939,9 +1941,9 @@ handle_printf_atsign (FILE *stream,
|
|||
}
|
||||
if (contentsEndIndex)
|
||||
{
|
||||
if (end < len)
|
||||
if (found)
|
||||
{
|
||||
*contentsEndIndex = end-1;
|
||||
*contentsEndIndex = end-termlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue