mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Strings patch from Frith-MacDonald.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2706 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8484a0937e
commit
db2c79f9bc
4 changed files with 117 additions and 26 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,9 +1,25 @@
|
|||
Wed Jan 21 11:45:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* src/GetDefEncoding.m: Modified GetDefEncoding() to us the NSString
|
||||
method - ([+availableStringEncodings]) so we can make the
|
||||
_availableEncodings array local to NSString.m
|
||||
|
||||
* src/NSString.m: Moved _availableEncodings here from NSString.h
|
||||
Added methods as specified in Rhapsody documentation -
|
||||
([+pathWithComponents:]), ([-isAbsolutePath]), ([-pathComponents]),
|
||||
([-stringsByAppendingPaths:])
|
||||
|
||||
* src/include/NSString.h: Moved _availableEncodings from here to
|
||||
NSString.m and added declarations for new methods -
|
||||
([+pathWithComponents:]), ([-isAbsolutePath]), ([-pathComponents]),
|
||||
([-stringsByAppendingPaths:])
|
||||
|
||||
Wed Jan 21 09:41:46 1998 Adam Fedor <fedor@spanky.doc.com>
|
||||
|
||||
* src/Makefile.postamble: Change $(LEX) to $(FLEX) and $(YACC) to
|
||||
$(BISON). Add $(GNUSTEP_OBJC_DIR) to targets with ${OEXT}.
|
||||
|
||||
Tue Jan 20 19:05:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Tue Jan 20 19:05:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Tools/GNUmakefile: Added defaults.m
|
||||
|
||||
|
|
|
@ -88,29 +88,6 @@ enum {
|
|||
NSOpenStepUnicodeReservedBase = 0xF400
|
||||
};
|
||||
|
||||
// Uncomment when implemented
|
||||
static NSStringEncoding _availableEncodings[] = {
|
||||
NSASCIIStringEncoding,
|
||||
NSNEXTSTEPStringEncoding,
|
||||
// NSJapaneseEUCStringEncoding,
|
||||
// NSUTF8StringEncoding,
|
||||
NSISOLatin1StringEncoding,
|
||||
// NSSymbolStringEncoding,
|
||||
// NSNonLossyASCIIStringEncoding,
|
||||
// NSShiftJISStringEncoding,
|
||||
// NSISOLatin2StringEncoding,
|
||||
NSUnicodeStringEncoding,
|
||||
// NSWindowsCP1251StringEncoding,
|
||||
// NSWindowsCP1252StringEncoding,
|
||||
// NSWindowsCP1253StringEncoding,
|
||||
// NSWindowsCP1254StringEncoding,
|
||||
// NSWindowsCP1250StringEncoding,
|
||||
// NSISO2022JPStringEncoding,
|
||||
// GNUstep additions
|
||||
NSCyrillicStringEncoding,
|
||||
0
|
||||
};
|
||||
|
||||
@protocol NSString <NSCoding, NSCopying, NSMutableCopying>
|
||||
|
||||
// Creating Temporary Strings
|
||||
|
@ -254,6 +231,10 @@ enum {
|
|||
- (NSString*) _normalizedString;
|
||||
|
||||
#ifndef STRICT_OPENSTEP
|
||||
+ (NSString*) pathWithComponents: (NSArray*)components;
|
||||
- (BOOL) isAbsolutePath;
|
||||
- (NSArray*) pathComponents;
|
||||
- (NSArray*) stringsByAppendingPaths: (NSArray*)paths;
|
||||
+ (NSString*) stringWithString: (NSString*) aString;
|
||||
+ (NSString*) localizedStringWithFormat: (NSString*) format, ...;
|
||||
+ (NSString*) stringWithFormat: (NSString*)format
|
||||
|
|
|
@ -57,6 +57,9 @@ NSStringEncoding GetDefEncoding()
|
|||
char *encoding;
|
||||
unsigned int count;
|
||||
NSStringEncoding ret,tmp;
|
||||
NSStringEncoding *availableEncodings;
|
||||
|
||||
availableEncodings = [NSString availableStringEncodings];
|
||||
|
||||
encoding = getenv("GNUSTEP_STRING_ENCODING");
|
||||
if(encoding)
|
||||
|
@ -81,9 +84,9 @@ NSStringEncoding GetDefEncoding()
|
|||
{
|
||||
count=0;
|
||||
tmp=0;
|
||||
while(!(_availableEncodings[count]==0))
|
||||
while(!(availableEncodings[count]==0))
|
||||
{
|
||||
if(!(ret==_availableEncodings[count]))
|
||||
if(!(ret==availableEncodings[count]))
|
||||
tmp=0;
|
||||
else
|
||||
{
|
||||
|
|
|
@ -65,6 +65,29 @@
|
|||
#include <gnustep/base/Unicode.h>
|
||||
#include <gnustep/base/GetDefEncoding.h>
|
||||
|
||||
// Uncomment when implemented
|
||||
static NSStringEncoding _availableEncodings[] = {
|
||||
NSASCIIStringEncoding,
|
||||
NSNEXTSTEPStringEncoding,
|
||||
// NSJapaneseEUCStringEncoding,
|
||||
// NSUTF8StringEncoding,
|
||||
NSISOLatin1StringEncoding,
|
||||
// NSSymbolStringEncoding,
|
||||
// NSNonLossyASCIIStringEncoding,
|
||||
// NSShiftJISStringEncoding,
|
||||
// NSISOLatin2StringEncoding,
|
||||
NSUnicodeStringEncoding,
|
||||
// NSWindowsCP1251StringEncoding,
|
||||
// NSWindowsCP1252StringEncoding,
|
||||
// NSWindowsCP1253StringEncoding,
|
||||
// NSWindowsCP1254StringEncoding,
|
||||
// NSWindowsCP1250StringEncoding,
|
||||
// NSISO2022JPStringEncoding,
|
||||
// GNUstep additions
|
||||
NSCyrillicStringEncoding,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
#if defined(__WIN32__) || defined(_WIN32)
|
||||
|
||||
|
@ -2367,6 +2390,74 @@ else
|
|||
}
|
||||
|
||||
// #ifndef STRICT_OPENSTEP
|
||||
+ (NSString*) pathWithComponents: (NSArray*)components
|
||||
{
|
||||
NSString *s = [self string];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < [components count]; i++) {
|
||||
s = [s stringByAppendingPathComponent: [components objectAtIndex: i]];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
- (BOOL) isAbsolutePath
|
||||
{
|
||||
if ([self length] > 0 && [self characterAtIndex: 0] == (unichar)'/') {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSArray*) pathComponents
|
||||
{
|
||||
NSMutableArray *a;
|
||||
NSArray *r;
|
||||
|
||||
a = [[self componentsSeparatedByString: @"/"] mutableCopy];
|
||||
if ([a count] > 0) {
|
||||
int i;
|
||||
|
||||
/* If the path began with a '/' then the first path component must
|
||||
* be a '/' rather than an empty string so that our output could be
|
||||
* fed into [+pathWithComponents:]
|
||||
*/
|
||||
if ([[a objectAtIndex: 0] length] == 0) {
|
||||
[a replaceObjectAtIndex: 0 withObject: @"/"];
|
||||
}
|
||||
/* Any empty path components (except a trailing one) must be removed. */
|
||||
for (i = [a count] - 2; i > 0; i--) {
|
||||
if ([[a objectAtIndex: i] length] == 0) {
|
||||
[a removeObjectAtIndex: i];
|
||||
}
|
||||
}
|
||||
}
|
||||
r = [a copy];
|
||||
[a release];
|
||||
return [r autorelease];
|
||||
}
|
||||
|
||||
- (NSArray*) stringsByAppendingPaths: (NSArray*)paths
|
||||
{
|
||||
NSMutableArray *a;
|
||||
NSArray *r;
|
||||
int i;
|
||||
|
||||
a = [[NSMutableArray alloc] initWithCapacity: [paths count]];
|
||||
for (i = 0; i < [paths count]; i++) {
|
||||
NSString *s = [paths objectAtIndex: i];
|
||||
|
||||
while ([s isAbsolutePath]) {
|
||||
s = [s substringFromIndex: 1];
|
||||
}
|
||||
s = [self stringByAppendingPathComponent: s];
|
||||
[a addObject: s];
|
||||
}
|
||||
r = [a copy];
|
||||
[a release];
|
||||
return [r autorelease];
|
||||
}
|
||||
|
||||
+ (NSString*) localizedStringWithFormat: (NSString*) format, ...
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
|
|
Loading…
Reference in a new issue