mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Some string mnethod tidyups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14448 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c2ace95989
commit
4aabe798ba
4 changed files with 58 additions and 50 deletions
|
@ -2,6 +2,12 @@
|
||||||
|
|
||||||
* Source/NSFileManager.m: MacOS-X ([componentsToDisplayForPath:]) and
|
* Source/NSFileManager.m: MacOS-X ([componentsToDisplayForPath:]) and
|
||||||
([displayNameAtPath:]) methods implemented. Creation date added.
|
([displayNameAtPath:]) methods implemented. Creation date added.
|
||||||
|
* Source/NSString.m: More alterations to GNUstep extension methods
|
||||||
|
to make their names consistent with other methods.
|
||||||
|
Q. Should we deprecate/remove them entirely?
|
||||||
|
* Tools/gsdoc.m: Update for changes to extension methods... though
|
||||||
|
this tool has been deprecated for some time now, so perhaps we
|
||||||
|
should remove it?
|
||||||
|
|
||||||
2002-09-13 Adam Fedor <fedor@gnu.org>
|
2002-09-13 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -363,8 +363,8 @@ extern struct objc_class _NSConstantStringClassReference;
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
|
|
||||||
@interface NSString (GNUstep)
|
@interface NSString (GNUstep)
|
||||||
- (NSString*) stringByRemovingPrefix: (NSString*)prefix;
|
- (NSString*) stringByDeletingPrefix: (NSString*)prefix;
|
||||||
- (NSString*) stringByRemovingSuffix: (NSString*)suffix;
|
- (NSString*) stringByDeletingSuffix: (NSString*)suffix;
|
||||||
- (NSString*) stringByReplacingString: (NSString*)replace
|
- (NSString*) stringByReplacingString: (NSString*)replace
|
||||||
withString: (NSString*)by;
|
withString: (NSString*)by;
|
||||||
- (NSString*) stringByTrimmingLeadSpaces;
|
- (NSString*) stringByTrimmingLeadSpaces;
|
||||||
|
@ -373,9 +373,9 @@ extern struct objc_class _NSConstantStringClassReference;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSMutableString (GNUstep)
|
@interface NSMutableString (GNUstep)
|
||||||
|
- (void) deleteSuffix: (NSString*)suffix;
|
||||||
|
- (void) deletePrefix: (NSString*)prefix;
|
||||||
- (NSString*) immutableProxy;
|
- (NSString*) immutableProxy;
|
||||||
- (void) removeSuffix: (NSString*)suffix;
|
|
||||||
- (void) removePrefix: (NSString*)prefix;
|
|
||||||
- (void) replaceString: (NSString*)replace
|
- (void) replaceString: (NSString*)replace
|
||||||
withString: (NSString*)by;
|
withString: (NSString*)by;
|
||||||
- (void) trimLeadSpaces;
|
- (void) trimLeadSpaces;
|
||||||
|
|
|
@ -4096,28 +4096,28 @@ handle_printf_atsign (FILE *stream,
|
||||||
*/
|
*/
|
||||||
@implementation NSString (GNUstep)
|
@implementation NSString (GNUstep)
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a string formed by removing the suffix string from the
|
|
||||||
* receiver. Raises an exception if the suffix is not present.
|
|
||||||
*/
|
|
||||||
- (NSString*) stringByRemovingSuffix: (NSString*)suffix
|
|
||||||
{
|
|
||||||
NSCAssert2([self hasSuffix: suffix],
|
|
||||||
@"'%@' does not have the suffix '%@'", self, suffix);
|
|
||||||
return [self substringToIndex: ([self length] - [suffix length])];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string formed by removing the prefix string from the
|
* Returns a string formed by removing the prefix string from the
|
||||||
* receiver. Raises an exception if the prefix is not present.
|
* receiver. Raises an exception if the prefix is not present.
|
||||||
*/
|
*/
|
||||||
- (NSString*) stringByRemovingPrefix: (NSString*)prefix
|
- (NSString*) stringByDeletingPrefix: (NSString*)prefix
|
||||||
{
|
{
|
||||||
NSCAssert2([self hasPrefix: prefix],
|
NSCAssert2([self hasPrefix: prefix],
|
||||||
@"'%@' does not have the prefix '%@'", self, prefix);
|
@"'%@' does not have the prefix '%@'", self, prefix);
|
||||||
return [self substringFromIndex: [prefix length]];
|
return [self substringFromIndex: [prefix length]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string formed by removing the suffix string from the
|
||||||
|
* receiver. Raises an exception if the suffix is not present.
|
||||||
|
*/
|
||||||
|
- (NSString*) stringByDeletingSuffix: (NSString*)suffix
|
||||||
|
{
|
||||||
|
NSCAssert2([self hasSuffix: suffix],
|
||||||
|
@"'%@' does not have the suffix '%@'", self, suffix);
|
||||||
|
return [self substringToIndex: ([self length] - [suffix length])];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string formed by removing leading white space from the
|
* Returns a string formed by removing leading white space from the
|
||||||
* receiver.
|
* receiver.
|
||||||
|
@ -4252,6 +4252,29 @@ handle_printf_atsign (FILE *stream,
|
||||||
@implementation NSMutableString (GNUstep)
|
@implementation NSMutableString (GNUstep)
|
||||||
@class NSImmutableString;
|
@class NSImmutableString;
|
||||||
@class GSImmutableString;
|
@class GSImmutableString;
|
||||||
|
/**
|
||||||
|
* Removes the specified suffix from the string. Raises an exception
|
||||||
|
* if the suffix is not present.
|
||||||
|
*/
|
||||||
|
- (void) deleteSuffix: (NSString*)suffix
|
||||||
|
{
|
||||||
|
NSCAssert2([self hasSuffix: suffix],
|
||||||
|
@"'%@' does not have the suffix '%@'", self, suffix);
|
||||||
|
[self deleteCharactersInRange:
|
||||||
|
NSMakeRange([self length] - [suffix length], [suffix length])];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the specified prefix from the string. Raises an exception
|
||||||
|
* if the prefix is not present.
|
||||||
|
*/
|
||||||
|
- (void) deletePrefix: (NSString*)prefix;
|
||||||
|
{
|
||||||
|
NSCAssert2([self hasPrefix: prefix],
|
||||||
|
@"'%@' does not have the prefix '%@'", self, prefix);
|
||||||
|
[self deleteCharactersInRange: NSMakeRange(0, [prefix length])];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a proxy to the receiver which will allow access to the
|
* Returns a proxy to the receiver which will allow access to the
|
||||||
* receiver as an NSString, but which will not allow any of the
|
* receiver as an NSString, but which will not allow any of the
|
||||||
|
@ -4271,29 +4294,6 @@ handle_printf_atsign (FILE *stream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the specified suffix from the string. Raises an exception
|
|
||||||
* if the suffix is not present.
|
|
||||||
*/
|
|
||||||
- (void) removeSuffix: (NSString*)suffix
|
|
||||||
{
|
|
||||||
NSCAssert2([self hasSuffix: suffix],
|
|
||||||
@"'%@' does not have the suffix '%@'", self, suffix);
|
|
||||||
[self deleteCharactersInRange:
|
|
||||||
NSMakeRange([self length] - [suffix length], [suffix length])];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the specified prefix from the string. Raises an exception
|
|
||||||
* if the prefix is not present.
|
|
||||||
*/
|
|
||||||
- (void) removePrefix: (NSString*)prefix;
|
|
||||||
{
|
|
||||||
NSCAssert2([self hasPrefix: prefix],
|
|
||||||
@"'%@' does not have the prefix '%@'", self, prefix);
|
|
||||||
[self deleteCharactersInRange: NSMakeRange(0, [prefix length])];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces all occurrances of the string replace with the string by
|
* Replaces all occurrances of the string replace with the string by
|
||||||
* in the receiver.<br />
|
* in the receiver.<br />
|
||||||
|
|
|
@ -1732,7 +1732,7 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
|
||||||
//Avoid ((xxx))
|
//Avoid ((xxx))
|
||||||
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
|
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
|
||||||
{
|
{
|
||||||
type = [[type stringWithoutPrefix: @"("] stringWithoutSuffix: @")"];
|
type = [[type stringByDeletingPrefix: @"("] stringByDeletingSuffix: @")"];
|
||||||
}
|
}
|
||||||
type = [self linkedItem: type ofTypes: typesTypes];
|
type = [self linkedItem: type ofTypes: typesTypes];
|
||||||
|
|
||||||
|
@ -1755,7 +1755,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
|
||||||
//Avoid ((xxx))
|
//Avoid ((xxx))
|
||||||
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
|
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
|
||||||
{
|
{
|
||||||
typ = [[typ stringWithoutPrefix: @"("] stringWithoutSuffix: @")"];
|
typ = [[typ stringByDeletingPrefix: @"("]
|
||||||
|
stringByDeletingSuffix: @")"];
|
||||||
}
|
}
|
||||||
typ = [self linkedItem: typ ofTypes: typesTypes];
|
typ = [self linkedItem: typ ofTypes: typesTypes];
|
||||||
[args appendString: typ];
|
[args appendString: typ];
|
||||||
|
@ -2432,7 +2433,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
|
||||||
//Avoid ((xxx))
|
//Avoid ((xxx))
|
||||||
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
|
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
|
||||||
{
|
{
|
||||||
type = [[type stringWithoutPrefix: @"("] stringWithoutSuffix: @")"];
|
type = [[type stringByDeletingPrefix: @"("]
|
||||||
|
stringByDeletingSuffix: @")"];
|
||||||
}
|
}
|
||||||
type = [self linkedItem: type ofTypes: typesTypes];
|
type = [self linkedItem: type ofTypes: typesTypes];
|
||||||
[decl appendString: type];
|
[decl appendString: type];
|
||||||
|
@ -2458,8 +2460,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
|
||||||
//Avoid ((xxx))
|
//Avoid ((xxx))
|
||||||
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
|
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
|
||||||
{
|
{
|
||||||
typ = [typ stringWithoutPrefix: @"("];
|
typ = [typ stringByDeletingPrefix: @"("];
|
||||||
typ = [typ stringWithoutSuffix: @")"];
|
typ = [typ stringByDeletingSuffix: @")"];
|
||||||
}
|
}
|
||||||
typ = [self linkedItem: typ ofTypes: typesTypes];
|
typ = [self linkedItem: typ ofTypes: typesTypes];
|
||||||
[args appendString: typ];
|
[args appendString: typ];
|
||||||
|
@ -2509,8 +2511,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
|
||||||
//Avoid ((xxx))
|
//Avoid ((xxx))
|
||||||
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
|
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
|
||||||
{
|
{
|
||||||
type = [type stringWithoutPrefix: @"("];
|
type = [type stringByDeletingPrefix: @"("];
|
||||||
type = [type stringWithoutSuffix: @")"];
|
type = [type stringByDeletingSuffix: @")"];
|
||||||
}
|
}
|
||||||
type = [self linkedItem: type ofTypes: typesTypes];
|
type = [self linkedItem: type ofTypes: typesTypes];
|
||||||
[lText appendString: type];
|
[lText appendString: type];
|
||||||
|
@ -2542,8 +2544,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
|
||||||
//Avoid ((xxx))
|
//Avoid ((xxx))
|
||||||
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
|
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
|
||||||
{
|
{
|
||||||
typ = [typ stringWithoutPrefix: @"("];
|
typ = [typ stringByDeletingPrefix: @"("];
|
||||||
typ = [typ stringWithoutSuffix: @")"];
|
typ = [typ stringByDeletingSuffix: @")"];
|
||||||
}
|
}
|
||||||
typ = [self linkedItem: typ ofTypes: typesTypes];
|
typ = [self linkedItem: typ ofTypes: typesTypes];
|
||||||
[lText appendFormat: @" (%@)%@", typ, arg];
|
[lText appendFormat: @" (%@)%@", typ, arg];
|
||||||
|
@ -4274,7 +4276,7 @@ main(int argc, char **argv, char **env)
|
||||||
NSString *key;
|
NSString *key;
|
||||||
NSArray *parts;
|
NSArray *parts;
|
||||||
|
|
||||||
argWithoutPrefix = [arg stringWithoutPrefix: @"--"];
|
argWithoutPrefix = [arg stringByDeletingPrefix: @"--"];
|
||||||
parts = [argWithoutPrefix componentsSeparatedByString: @"="];
|
parts = [argWithoutPrefix componentsSeparatedByString: @"="];
|
||||||
key = [parts objectAtIndex: 0];
|
key = [parts objectAtIndex: 0];
|
||||||
|
|
||||||
|
@ -4366,7 +4368,7 @@ main(int argc, char **argv, char **env)
|
||||||
}
|
}
|
||||||
NSCAssert1(value, @"No value for %@", key);
|
NSCAssert1(value, @"No value for %@", key);
|
||||||
[infoDictionary setObject: value
|
[infoDictionary setObject: value
|
||||||
forKey: [key stringWithoutPrefix: @"define-"]];
|
forKey: [key stringByDeletingPrefix: @"define-"]];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue