Update of /cvsroot/radmind/radmind-assistant/rte
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv30411
Modified Files:
NSString(RXAdditions).h NSString(RXAdditions).m
Log Message:
Added basic Obj-C form of argcargv.
Index: NSString(RXAdditions).m
===================================================================
RCS file: /cvsroot/radmind/radmind-assistant/rte/NSString(RXAdditions).m,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** NSString(RXAdditions).m 26 Apr 2006 01:05:26 -0000 1.15
--- NSString(RXAdditions).m 6 Jun 2006 19:59:58 -0000 1.16
***************
*** 86,91 ****
{
NSMutableString *line = [[ NSMutableString alloc ] init ];
! NSString *transcriptLine = nil;
! char ftype, pm, *path;
ftype = [[ dict objectForKey: @"type" ]
--- 86,91 ----
{
NSMutableString *line = [[ NSMutableString alloc ] init ];
! NSString *transcriptLine = nil, *pm;
! char ftype, *path;
ftype = [[ dict objectForKey: @"type" ]
***************
*** 93,98 ****
/* if this is an apply-able transcript line, print out the + and - signs */
! if (( pm = [[ dict objectForKey: @"pm" ] characterAtIndex: 0 ] ) != '0' ) {
! [ line appendFormat: @"%c ", pm ];
}
/* likewise, if line is transcript marker in an apply-able transcript... */
--- 93,99 ----
/* if this is an apply-able transcript line, print out the + and - signs */
! pm = [ dict objectForKey: @"pm" ];
! if ( ![ pm isEqualToString: @"0" ] ) {
! [ line appendFormat: @"%@ ", pm ];
}
/* likewise, if line is transcript marker in an apply-able transcript... */
***************
*** 276,278 ****
--- 277,326 ----
}
+ #define WORD 0
+ #define WHITE 1
+
+ - ( NSArray * )componentsSeparatedByCharactersInSet: ( NSCharacterSet * )set
+ {
+ NSMutableArray *stringComponents = nil;
+ NSRange range;
+ NSString *tmp;
+ int i, loc, state = WORD;
+
+ stringComponents = [[ NSMutableArray alloc ] init ];
+
+ for ( loc = i = 0; i < [ self length ]; i++ ) {
+ switch ( [ self characterAtIndex: i ] ) {
+ case ' ' :
+ case '\t':
+ case '\n':
+ case '\r':
+ if ( state == WORD ) {
+ range = NSMakeRange( loc, ( i - loc ));
+ tmp = [ self substringWithRange: range ];
+ [ stringComponents addObject: tmp ];
+ state = WHITE;
+ }
+ break;
+
+ default:
+ if ( state == WHITE ) {
+ loc = i;
+ state = WORD;
+ }
+ /* consume remaining characters */
+ if ( i == ( [ self length ] - 1 )) {
+ range = NSMakeRange( loc, ( [ self length ] - loc ));
+ tmp = [ self substringWithRange: range ];
+ [ stringComponents addObject: tmp ];
+ }
+ }
+ }
+
+ if ( stringComponents != nil ) {
+ [ stringComponents autorelease ];
+ }
+
+ return( stringComponents );
+ }
+
@end
Index: NSString(RXAdditions).h
===================================================================
RCS file: /cvsroot/radmind/radmind-assistant/rte/NSString(RXAdditions).h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** NSString(RXAdditions).h 24 Feb 2006 21:45:47 -0000 1.8
--- NSString(RXAdditions).h 6 Jun 2006 19:59:58 -0000 1.9
***************
*** 34,37 ****
--- 34,38 ----
- ( NSString * )descriptiveSizeString;
- ( NSString * )transcriptObjectTypeFromString;
+ - ( NSArray * )componentsSeparatedByCharactersInSet: ( NSCharacterSet * )set;
@end
|