Changeset 375 for trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEParser.m
- Timestamp:
- 02/10/08 06:02:25 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEParser.m
r322 r375 9 9 #import "ICeCoffEEParser.h" 10 10 #import "ICeCoffEE.h" 11 12 // RFC-ordained max URL length, just to avoid passing IC/LS multi-megabyte documents13 #if ICCF_DEBUG14 const long ICCF_MAX_URL_LEN = 120; // XXX change later15 #else16 const long ICCF_MAX_URL_LEN = 1024;17 #endif18 19 void ICCF_CheckRange(NSRange range) {20 NSCAssert(range.length > 0, ICCF_LocalizedString(@"No URL is selected"));21 NSCAssert1(range.length <= ICCF_MAX_URL_LEN, ICCF_LocalizedString(@"The potential URL is longer than %lu characters"), ICCF_MAX_URL_LEN);22 }23 11 24 12 void ICCF_Delimiters(NSCharacterSet **leftPtr, NSCharacterSet **rightPtr) { … … 136 124 137 125 expandFront: 138 139 140 141 142 143 144 145 146 126 // XXX instead of 0, make this stop at the max URL length to prevent protracted searches 127 128 // XXX here's how this is supposed to work: 129 // (http://web.sabi.net/) and <http://web.sabi.net/> should work if they are the entire document, even if clicking at the end/beginning of the document, not barfing with "no URL" (correct, as now) or selecting the final >, or ) (what would happen if we remove this "add 1" accommodation). But how about "http://web.sabi.net/(foo)"? That should work too, as long as it's not preceded by a (. 130 // Should probably backport to ICeCoffEETerminal, now I finally understand the method to this madness. 131 // add 1 to range to trap delimiters that are on the edge of the selection (i.e., <...) 132 delimiterRange = [s rangeOfCharacterFromSet: urlLeftDelimiters 133 options: NSLiteralSearch | NSBackwardsSearch 134 range: NSMakeRange(0, range.location + (range.location != [s length]))]; 147 135 if (delimiterRange.location == NSNotFound) { 148 136 // extend to beginning of string … … 155 143 156 144 // in url/(parens)stuff, handle clicking inside or after (parens). 157 if ([s characterAtIndex: delimiterRange.location] == '(' &&158 range.location > 2 /* prevent wrapping, ordinarily not necessary */) {145 /*if ([s characterAtIndex: delimiterRange.location] == '(' && 146 range.location > 2) { // prevent wrapping, ordinarily not necessary 159 147 if ([s rangeOfString: @")" options: NSLiteralSearch range: range].location != NSNotFound || 160 148 [s rangeOfCharacterFromSet: [NSCharacterSet characterSetWithCharactersInString: @"/."] … … 165 153 goto expandFront; 166 154 } 167 } 155 } */ 168 156 } 169 157 … … 171 159 172 160 expandBack: 173 174 175 161 // XXX instead of length of string, make this stop at the max URL length to prevent protracted searches 162 // add 1 to range to trap delimiters that are on the edge of the selection (i.e., ...>) 163 extraLen = [s length] - range.location - range.length; 176 164 delimiterRange = [s rangeOfCharacterFromSet: urlRightDelimiters 177 165 options: NSLiteralSearch … … 185 173 range.length += delimiterRange.location - range.location - range.length; 186 174 187 // grow URL past closing paren if we've seen an open paren 188 if ([s characterAtIndex: delimiterRange.location] == ')' && 189 [s rangeOfString: @"(" options: NSLiteralSearch range: range].location != NSNotFound) { 175 // grow URL past closing paren/brace if we've seen an open paren/brace 176 unichar closing = [s characterAtIndex: delimiterRange.location]; 177 NSString *opening; 178 if (closing == ')') opening = @"("; 179 else if (closing == '}') opening = @"{"; 180 else goto checkRange; 181 if ([s rangeOfString: opening options: NSLiteralSearch range: range].location == NSNotFound) 182 goto checkRange; 183 184 if (extraLen == 0) { 185 range.length += 1; 186 ICLog(@"expanding past %c, now |%@|", closing, [s substringWithRange: range]); 187 } else { 190 188 range.length += 2; 191 ICLog(@"expanding past ), now |%@|", [s substringWithRange: range]);189 ICLog(@"expanding past %c, now |%@|", closing, [s substringWithRange: range]); 192 190 goto expandBack; 193 191 } 194 192 } 195 193 194 checkRange: 196 195 ICCF_CheckRange(range); 197 196
Note:
See TracChangeset
for help on using the changeset viewer.