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:
Richard Frith-Macdonald 2002-09-15 18:26:56 +00:00
parent b864196732
commit dbadb72311
4 changed files with 58 additions and 50 deletions

View file

@ -2,6 +2,12 @@
* Source/NSFileManager.m: MacOS-X ([componentsToDisplayForPath:]) and
([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>

View file

@ -363,8 +363,8 @@ extern struct objc_class _NSConstantStringClassReference;
#ifndef NO_GNUSTEP
@interface NSString (GNUstep)
- (NSString*) stringByRemovingPrefix: (NSString*)prefix;
- (NSString*) stringByRemovingSuffix: (NSString*)suffix;
- (NSString*) stringByDeletingPrefix: (NSString*)prefix;
- (NSString*) stringByDeletingSuffix: (NSString*)suffix;
- (NSString*) stringByReplacingString: (NSString*)replace
withString: (NSString*)by;
- (NSString*) stringByTrimmingLeadSpaces;
@ -373,9 +373,9 @@ extern struct objc_class _NSConstantStringClassReference;
@end
@interface NSMutableString (GNUstep)
- (void) deleteSuffix: (NSString*)suffix;
- (void) deletePrefix: (NSString*)prefix;
- (NSString*) immutableProxy;
- (void) removeSuffix: (NSString*)suffix;
- (void) removePrefix: (NSString*)prefix;
- (void) replaceString: (NSString*)replace
withString: (NSString*)by;
- (void) trimLeadSpaces;

View file

@ -4096,28 +4096,28 @@ handle_printf_atsign (FILE *stream,
*/
@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
* receiver. Raises an exception if the prefix is not present.
*/
- (NSString*) stringByRemovingPrefix: (NSString*)prefix
- (NSString*) stringByDeletingPrefix: (NSString*)prefix
{
NSCAssert2([self hasPrefix: prefix],
@"'%@' does not have the prefix '%@'", self, prefix);
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
* receiver.
@ -4252,6 +4252,29 @@ handle_printf_atsign (FILE *stream,
@implementation NSMutableString (GNUstep)
@class NSImmutableString;
@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
* 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
* in the receiver.<br />

View file

@ -1732,7 +1732,7 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
//Avoid ((xxx))
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
{
type = [[type stringWithoutPrefix: @"("] stringWithoutSuffix: @")"];
type = [[type stringByDeletingPrefix: @"("] stringByDeletingSuffix: @")"];
}
type = [self linkedItem: type ofTypes: typesTypes];
@ -1755,7 +1755,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
//Avoid ((xxx))
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
{
typ = [[typ stringWithoutPrefix: @"("] stringWithoutSuffix: @")"];
typ = [[typ stringByDeletingPrefix: @"("]
stringByDeletingSuffix: @")"];
}
typ = [self linkedItem: typ ofTypes: typesTypes];
[args appendString: typ];
@ -2432,7 +2433,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
//Avoid ((xxx))
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
{
type = [[type stringWithoutPrefix: @"("] stringWithoutSuffix: @")"];
type = [[type stringByDeletingPrefix: @"("]
stringByDeletingSuffix: @")"];
}
type = [self linkedItem: type ofTypes: typesTypes];
[decl appendString: type];
@ -2458,8 +2460,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
//Avoid ((xxx))
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
{
typ = [typ stringWithoutPrefix: @"("];
typ = [typ stringWithoutSuffix: @")"];
typ = [typ stringByDeletingPrefix: @"("];
typ = [typ stringByDeletingSuffix: @")"];
}
typ = [self linkedItem: typ ofTypes: typesTypes];
[args appendString: typ];
@ -2509,8 +2511,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
//Avoid ((xxx))
else if ([type hasPrefix: @"("] && [type hasSuffix: @")"])
{
type = [type stringWithoutPrefix: @"("];
type = [type stringWithoutSuffix: @")"];
type = [type stringByDeletingPrefix: @"("];
type = [type stringByDeletingSuffix: @")"];
}
type = [self linkedItem: type ofTypes: typesTypes];
[lText appendString: type];
@ -2542,8 +2544,8 @@ loader(const char *url, const char *eid, xmlParserCtxtPtr *ctxt)
//Avoid ((xxx))
if ([typ hasPrefix: @"("] && [typ hasSuffix: @")"])
{
typ = [typ stringWithoutPrefix: @"("];
typ = [typ stringWithoutSuffix: @")"];
typ = [typ stringByDeletingPrefix: @"("];
typ = [typ stringByDeletingSuffix: @")"];
}
typ = [self linkedItem: typ ofTypes: typesTypes];
[lText appendFormat: @" (%@)%@", typ, arg];
@ -4274,7 +4276,7 @@ main(int argc, char **argv, char **env)
NSString *key;
NSArray *parts;
argWithoutPrefix = [arg stringWithoutPrefix: @"--"];
argWithoutPrefix = [arg stringByDeletingPrefix: @"--"];
parts = [argWithoutPrefix componentsSeparatedByString: @"="];
key = [parts objectAtIndex: 0];
@ -4366,7 +4368,7 @@ main(int argc, char **argv, char **env)
}
NSCAssert1(value, @"No value for %@", key);
[infoDictionary setObject: value
forKey: [key stringWithoutPrefix: @"define-"]];
forKey: [key stringByDeletingPrefix: @"define-"]];
}
else
{