Changeset 388 for trunk/ICeCoffEE/ICeCoffEE/TestParser.m
- Timestamp:
- 02/22/08 19:53:07 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/TestParser.m
r382 r388 27 27 } 28 28 29 static NSString *tc(NSString *s) { 30 NSMutableString *rs = [s mutableCopy]; 31 [rs replaceOccurrencesOfString: @"\n" withString: @"\\" options: 0 range: NSMakeRange(0, [s length])]; 32 [rs replaceOccurrencesOfString: @"\t" withString: @">" options: 0 range: NSMakeRange(0, [s length])]; 33 return [rs autorelease]; 34 } 35 29 36 NSString *ICCF_ErrString(OSStatus err, NSString *context) { 30 37 return [NSString stringWithFormat: @"%@ (%d)", context, (int)err]; … … 42 49 43 50 51 // XXX move elsewhere 52 static NSString *ICCF_StringByRemovingCharactersInSet(NSString *s, NSCharacterSet *set) { 53 NSRange range = [s rangeOfCharacterFromSet: set options: 0 range: NSMakeRange(0, [s length])]; 54 if (range.location == NSNotFound) 55 return s; 56 57 NSMutableString *ms = [s mutableCopy]; 58 do { 59 [ms deleteCharactersInRange: range]; 60 range.length = [ms length] - range.location; 61 range = [ms rangeOfCharacterFromSet: set options: 0 range: range]; 62 } while (range.location != NSNotFound); 63 64 s = [[ms copy] autorelease]; 65 [ms release]; 66 return s; 67 } 68 44 69 static BOOL check_parse(NSString *uri, NSString *text, 45 70 NSRange delimitedURIRange, NSRange initialSelectionRange) { … … 51 76 @try { 52 77 enclosingRange = ICCF_URLEnclosingRange(text, initialSelectionRange); 53 parsedURI = [text substringWithRange: enclosingRange]; 78 // XXX move trimming elsewhere 79 parsedURI = ICCF_StringByRemovingCharactersInSet([text substringWithRange: enclosingRange], [NSCharacterSet whitespaceAndNewlineCharacterSet]); 54 80 } @catch (NSException *e) { 55 81 parseException = e; … … 60 86 } 61 87 62 ps(@"Text %@", t ext);88 ps(@"Text %@", tc(text)); 63 89 pr(@"Available ", delimitedURIRange); 64 90 pr(@"Starting ", initialSelectionRange); … … 68 94 } else { 69 95 pr(@"Parsed ", enclosingRange); 70 ps(@"Parsed %@", parsedURI);71 ps(@"Desired %@", uri);96 ps(@"Parsed %@", tc(parsedURI)); 97 ps(@"Desired %@", tc(uri)); 72 98 } 73 99 return NO;
Note:
See TracChangeset
for help on using the changeset viewer.