This is string.m in view mode; [Download] [Up]
/* string.m Copyright (C) 1995, 1996, 1997 Ovidiu Predescu and Mircea Oancea. All rights reserved. Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro> Mircea Oancea <mircea@jupiter.elcom.pub.ro> This file is part of libFoundation. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. We disclaim all warranties with regard to this software, including all implied warranties of merchantability and fitness, in no event shall we be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software. */ #include <Foundation/NSString.h> #include <Foundation/NSRange.h> #include <extensions/support.h> #include "MyRange.h" /* * Functions to check format specifiers */ void string_format_char(id string, id format) { [string initWithFormat:format, 'c']; } void string_format_short(id string, id format) { short s = 123; [string initWithFormat:format, s]; } void string_format_int(id string, id format) { [string initWithFormat:format, 123]; } void string_format_float(id string, id format) { [string initWithFormat:format, 123.456]; } void string_format_cstring(id string, id format) { [string initWithFormat:format, "bar foo bar foo"]; } void string_format_obj(id string, id format) { [string initWithFormat:format, [[NSObject new] autorelease]]; } /* Check if the specifiers correctly increase the va_list and thus, if arguments are correctly decoded from stack. */ void string_format_char_int(id string, id format) { [string initWithFormat:format, 'c', 123]; } void string_format_short_int(id string, id format) { short s = 123; [string initWithFormat:format, s, 456]; } void string_format_int_int(id string, id format) { [string initWithFormat:format, 123, 456]; } void string_format_float_int(id string, id format) { [string initWithFormat:format, 123.456, 789]; } void string_format_cstring_int(id string, id format) { [string initWithFormat:format, "bar foo bar foo", 123]; } void string_format_obj_int(id string, id format) { [string initWithFormat:format, [[NSObject new] autorelease], 123]; } @interface NSString(MethodsWithRange) @end @implementation NSString(MethodsWithRange) - (NSString*)substringWithRangeLocation:(int)loc length:(int)len { return [self substringWithRange:NSMakeRange(loc, len)]; } - (MyRange*)rangeOfString:(NSString*)aString options:(unsigned int)mask rangeLocation:(int)loc length:(int)len { NSRange range = [self rangeOfString:aString options:mask range:NSMakeRange(loc, len)]; return [[[MyRange alloc] initWithRange:range] autorelease]; } - (NSComparisonResult)compare:(NSString*)aString options:(unsigned int)mask rangeLocation:(int)loc length:(int)len { return [self compare:aString options:mask range:NSMakeRange(loc, len)]; } @end @interface NSMutableString(MethodsWithRange) @end @implementation NSMutableString(MethodsWithRange) - (void)replaceCharactersInRangeLocation:(int)location length:(int)length withString:(NSString*)aString { [self replaceCharactersInRange:NSMakeRange(location, length) withString:aString]; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.