NSString updates.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9448 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
jagapen 2001-03-19 10:48:26 +00:00
parent cd4a1346a6
commit 4e07d4c0d1
2 changed files with 30 additions and 14 deletions

View file

@ -1,3 +1,11 @@
2001-03-19 Jonathan Gapen <jagapen@home.com>
* Source/NSString.m: In ([-rangeOfComposedCharacterSequenceAtIndex:]),
use the NSCharacterSet non-base character set to identify non-base
characters. In ([-cStringLength]), do not allow lossy string
conversion. In ([+localizedNameOfStringEncoding:]), use NSBundle's
([-gnustepBundle]) rather than looking in root path.
2001-03-17 Richard Frith-Macdonald <rfm@gnu.org> 2001-03-17 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSThread.h: Remove unused ivar. * Headers/Foundation/NSThread.h: Remove unused ivar.

View file

@ -64,7 +64,6 @@
#include <Foundation/NSDebug.h> #include <Foundation/NSDebug.h>
#include <base/GSFormat.h> #include <base/GSFormat.h>
#include <limits.h> #include <limits.h>
#include <string.h> // for strstr()
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
@ -1376,18 +1375,27 @@ handle_printf_atsign (FILE *stream,
unsigned start; unsigned start;
unsigned end; unsigned end;
unsigned length = [self length]; unsigned length = [self length];
unichar ch;
unichar (*caiImp)(NSString*, SEL, unsigned); unichar (*caiImp)(NSString*, SEL, unsigned);
NSCharacterSet *nbSet = [NSCharacterSet nonBaseCharacterSet];
if (anIndex >= length) if (anIndex >= length)
[NSException raise: NSRangeException format:@"Invalid location."]; [NSException raise: NSRangeException format:@"Invalid location."];
caiImp = (unichar (*)())[self methodForSelector: caiSel]; caiImp = (unichar (*)())[self methodForSelector: caiSel];
start = anIndex;
while (uni_isnonsp((*caiImp)(self, caiSel, start)) && start > 0) for (start = anIndex; start > 0; start--)
start--; {
end=start+1; ch = (*caiImp)(self, caiSel, start);
if (end < length) if ([nbSet characterIsMember: ch] == NO)
while ((end < length) && (uni_isnonsp((*caiImp)(self, caiSel, end))) ) break;
end++; }
for (end = start+1; end < length; end++)
{
ch = (*caiImp)(self, caiSel, end);
if ([nbSet characterIsMember: ch] == NO)
break;
}
return NSMakeRange(start, end-start); return NSMakeRange(start, end-start);
} }
@ -1882,7 +1890,7 @@ handle_printf_atsign (FILE *stream,
NSMutableData *m; NSMutableData *m;
d = [self dataUsingEncoding: _DefaultStringEncoding d = [self dataUsingEncoding: _DefaultStringEncoding
allowLossyConversion: NO]; allowLossyConversion: NO];
if (d == nil) if (d == nil)
{ {
[NSException raise: NSCharacterConversionException [NSException raise: NSCharacterConversionException
@ -1900,7 +1908,7 @@ handle_printf_atsign (FILE *stream,
NSMutableData *m; NSMutableData *m;
d = [self dataUsingEncoding: _DefaultStringEncoding d = [self dataUsingEncoding: _DefaultStringEncoding
allowLossyConversion: YES]; allowLossyConversion: YES];
m = [d mutableCopy]; m = [d mutableCopy];
[m appendBytes: "" length: 1]; [m appendBytes: "" length: 1];
AUTORELEASE(m); AUTORELEASE(m);
@ -1913,7 +1921,7 @@ handle_printf_atsign (FILE *stream,
NSMutableData *m; NSMutableData *m;
d = [self dataUsingEncoding: NSUTF8StringEncoding d = [self dataUsingEncoding: NSUTF8StringEncoding
allowLossyConversion: NO]; allowLossyConversion: NO];
m = [d mutableCopy]; m = [d mutableCopy];
[m appendBytes: "" length: 1]; [m appendBytes: "" length: 1];
AUTORELEASE(m); AUTORELEASE(m);
@ -1925,7 +1933,7 @@ handle_printf_atsign (FILE *stream,
NSData *d; NSData *d;
d = [self dataUsingEncoding: _DefaultStringEncoding d = [self dataUsingEncoding: _DefaultStringEncoding
allowLossyConversion: YES]; allowLossyConversion: NO];
return [d length]; return [d length];
} }
@ -2038,10 +2046,10 @@ handle_printf_atsign (FILE *stream,
/* /*
Should be path to localizable.strings file. Should be path to localizable.strings file.
Until we have it, just make shure that bundle Until we have it, just make sure that bundle
is initialized. is initialized.
*/ */
ourbundle = [NSBundle bundleWithPath: rootPath]; ourbundle = [NSBundle gnustepBundle];
ourname = GetEncodingName(encoding); ourname = GetEncodingName(encoding);
return [ourbundle localizedStringForKey: ourname return [ourbundle localizedStringForKey: ourname