Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use NSInteger/NSUInteger

Fix tests
  • Loading branch information...
commit 1583354968d3fe6a560da55ff1236d72365f5c20 1 parent f4534a2
Satoshi Nakagawa authored
12 framework/CocoaOniguruma.xcodeproj/project.pbxproj
@@ -517,11 +517,7 @@
517 517 ALWAYS_SEARCH_USER_PATHS = NO;
518 518 COMBINE_HIDPI_IMAGES = YES;
519 519 COPY_PHASE_STRIP = NO;
520   - FRAMEWORK_SEARCH_PATHS = (
521   - "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
522   - /Developer/Library/Frameworks,
523   - "\"$(SRCROOT)/build/Debug\"",
524   - );
  520 + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
525 521 GCC_DYNAMIC_NO_PIC = NO;
526 522 GCC_ENABLE_OBJC_EXCEPTIONS = YES;
527 523 GCC_OPTIMIZATION_LEVEL = 0;
@@ -547,11 +543,7 @@
547 543 COMBINE_HIDPI_IMAGES = YES;
548 544 COPY_PHASE_STRIP = YES;
549 545 DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
550   - FRAMEWORK_SEARCH_PATHS = (
551   - "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
552   - /Developer/Library/Frameworks,
553   - "\"$(SRCROOT)/build/Debug\"",
554   - );
  546 + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
555 547 GCC_ENABLE_OBJC_EXCEPTIONS = YES;
556 548 GCC_PRECOMPILE_PREFIX_HEADER = YES;
557 549 GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
12 framework/core/OnigRegexp.h
@@ -68,12 +68,12 @@ typedef enum {
68 68
69 69 - (NSString*)target;
70 70
71   -- (int)count;
72   -- (NSString*)stringAt:(int)index;
  71 +- (NSUInteger)count;
  72 +- (NSString*)stringAt:(NSUInteger)index;
73 73 - (NSArray*)strings;
74   -- (NSRange)rangeAt:(int)index;
75   -- (int)locationAt:(int)index;
76   -- (int)lengthAt:(int)index;
  74 +- (NSRange)rangeAt:(NSUInteger)index;
  75 +- (NSUInteger)locationAt:(NSUInteger)index;
  76 +- (NSUInteger)lengthAt:(NSUInteger)index;
77 77
78 78 - (NSString*)body;
79 79 - (NSRange)bodyRange;
@@ -83,7 +83,7 @@ typedef enum {
83 83
84 84 // named capture support
85 85 - (NSArray*)captureNames;
86   -- (int)indexForName:(NSString*)name;
  86 +- (NSInteger)indexForName:(NSString*)name;
87 87 - (NSIndexSet*)indexesForName:(NSString*)name;
88 88 - (NSString*)stringForName:(NSString*)name;
89 89 - (NSArray*)stringsForName:(NSString*)name;
23 framework/core/OnigRegexp.m
@@ -53,12 +53,6 @@ - (void)dealloc
53 53 #endif
54 54 }
55 55
56   -- (void)finalize
57   -{
58   - if (_entity) onig_free(_entity);
59   - [super finalize];
60   -}
61   -
62 56 + (OnigRegexp*)compile:(NSString*)expression
63 57 {
64 58 return [self compile:expression ignorecase:NO multiline:NO extended:NO error:NULL];
@@ -238,7 +232,7 @@ - (OnigResult*)match:(NSString*)target start:(int)start
238 232
239 233 - (NSUInteger)captureCount
240 234 {
241   - return onig_number_of_captures(_entity);
  235 + return onig_number_of_captures(_entity);
242 236 }
243 237
244 238 - (NSString*)expression
@@ -296,12 +290,12 @@ - (int)size
296 290 return [self count];
297 291 }
298 292
299   -- (int)count
  293 +- (NSUInteger)count
300 294 {
301 295 return _region->num_regs;
302 296 }
303 297
304   -- (NSString*)stringAt:(int)index
  298 +- (NSString*)stringAt:(NSUInteger)index
305 299 {
306 300 return [_target substringWithRange:[self rangeAt:index]];
307 301 }
@@ -316,17 +310,17 @@ - (NSArray*)strings
316 310 return array;
317 311 }
318 312
319   -- (NSRange)rangeAt:(int)index
  313 +- (NSRange)rangeAt:(NSUInteger)index
320 314 {
321 315 return NSMakeRange([self locationAt:index], [self lengthAt:index]);
322 316 }
323 317
324   -- (int)locationAt:(int)index
  318 +- (NSUInteger)locationAt:(NSUInteger)index
325 319 {
326 320 return *(_region->beg + index) / CHAR_SIZE;
327 321 }
328 322
329   -- (int)lengthAt:(int)index
  323 +- (NSUInteger)lengthAt:(NSUInteger)index
330 324 {
331 325 return (*(_region->end + index) - *(_region->beg + index)) / CHAR_SIZE;
332 326 }
@@ -351,7 +345,8 @@ - (NSString*)postMatch
351 345 return [_target substringFromIndex:[self locationAt:0] + [self lengthAt:0]];
352 346 }
353 347
354   -- (NSMutableArray*) captureNameArray {
  348 +- (NSMutableArray*)captureNameArray
  349 +{
355 350 return self->_captureNames;
356 351 }
357 352
@@ -367,7 +362,7 @@ - (NSArray*)captureNames
367 362 return [NSArray arrayWithArray:self->_captureNames];
368 363 }
369 364
370   -- (int)indexForName:(NSString*)name
  365 +- (NSInteger)indexForName:(NSString*)name
371 366 {
372 367 NSIndexSet* indexes = [self indexesForName:name];
373 368 return indexes ? [indexes firstIndex] : -1;
2  framework/core/OnigRegexpUtility.h
@@ -20,7 +20,7 @@
20 20
21 21 - (NSArray*)split;
22 22 - (NSArray*)splitByRegexp:(id)pattern;
23   -- (NSArray*)splitByRegexp:(id)pattern limit:(int)limit;
  23 +- (NSArray*)splitByRegexp:(id)pattern limit:(NSInteger)limit;
24 24
25 25 // based on ruby's gsub
26 26
10 framework/core/OnigRegexpUtility.m
@@ -54,9 +54,9 @@ - (NSArray*)splitByRegexp:(id)pattern
54 54 return [self split:pattern limit:nil];
55 55 }
56 56
57   -- (NSArray*)splitByRegexp:(id)pattern limit:(int)limit
  57 +- (NSArray*)splitByRegexp:(id)pattern limit:(NSInteger)limit
58 58 {
59   - return [self split:pattern limit:[NSNumber numberWithInt:limit]];
  59 + return [self split:pattern limit:[NSNumber numberWithInteger:limit]];
60 60 }
61 61
62 62 //
@@ -176,7 +176,7 @@ - (NSString*)replaceByRegexp:(id)pattern withCallback:(OnigReplaceCallback)callb
176 176 return s;
177 177 }
178 178 else {
179   - NSString* s = [self copy];
  179 + NSString* s = [self mutableCopy];
180 180 #if !__has_feature(objc_arc)
181 181 [s autorelease];
182 182 #endif
@@ -198,7 +198,7 @@ - (NSString*)replaceByRegexp:(id)pattern withBlock:(NSString* (^)(OnigResult*))b
198 198 // This implementation is based on ruby 1.8.
199 199 //
200 200
201   -- (NSString*)__replaceAllByRegexp:(id)pattern withCallback:(OnigReplaceCallback)callback data:(void*)data selector:(SEL)sel
  201 +- (NSString*)replaceAllByRegexp:(id)pattern withCallback:(OnigReplaceCallback)callback data:(void*)data selector:(SEL)sel
202 202 {
203 203 if (![pattern isKindOfClass:[OnigRegexp class]]) {
204 204 pattern = [OnigRegexp compile:(NSString*)pattern];
@@ -206,7 +206,7 @@ - (NSString*)__replaceAllByRegexp:(id)pattern withCallback:(OnigReplaceCallback)
206 206
207 207 OnigResult* res = [pattern search:self];
208 208 if (!res) {
209   - NSString* s = [self copy];
  209 + NSString* s = [self mutableCopy];
210 210 #if !__has_feature(objc_arc)
211 211 [s autorelease];
212 212 #endif
23 framework/tests/OnigRegexpTest.m
@@ -26,10 +26,10 @@ - (void)testNamedCaptures
26 26
27 27 STAssertNotNil(r, nil);
28 28 STAssertEquals(NSMakeRange(2,11), [r bodyRange], nil);
29   - STAssertEquals([r count], 4, nil);
30   - STAssertEquals([r indexForName:@"digits"], 1, nil);
  29 + STAssertEquals([r count], (NSUInteger)4, nil);
  30 + STAssertEquals([r indexForName:@"digits"], (NSInteger)1, nil);
31 31 STAssertEqualObjects([r indexesForName:@"digits"], [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1,2)], nil);
32   - STAssertEquals([r indexForName:@"letters"], 3, nil);
  32 + STAssertEquals([r indexForName:@"letters"], (NSInteger)3, nil);
33 33 STAssertEqualObjects([r indexesForName:@"letters"], [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(3,1)], nil);
34 34 STAssertEqualObjects([r stringForName:@"digits"], @"012", nil);
35 35
@@ -130,11 +130,6 @@ - (void)testReplace
130 130 STAssertEqualObjects([@"abc" replaceByRegexp:@"" with:@"_"], @"_abc", nil);
131 131 STAssertEqualObjects([@"abc" replaceByRegexp:@"$" with:@"_"], @"abc_", nil);
132 132 STAssertEqualObjects([@"aa 00 aa 11" replaceByRegexp:@"\\d+" with:@"digits"], @"aa digits aa 11", nil);
133   -
134   - STAssertEqualObjects([@"hello" replaceByRegexp:@"." withCallback:self selector:@selector(succReplace:)], @"i ello", nil);
135   - STAssertEqualObjects([@"hello!" replaceByRegexp:@"(.)(.)" withCallback:self selector:@selector(describeReplace:)], @"NSCFString[he]llo!", nil);
136   - STAssertEqualObjects([@"hello" replaceByRegexp:@"l" withCallback:self selector:@selector(xReplace:)], @"hexlo", nil);
137   -
138 133 STAssertEqualObjects([@"hello" replaceByRegexp:@"." withBlock:^(OnigResult* res) {
139 134 unichar ch[2];
140 135 ch[0] = [[res body] characterAtIndex:0] + 1;
@@ -144,9 +139,9 @@ - (void)testReplace
144 139
145 140 NSString* actual = [@"hello!" replaceByRegexp:@"(.)(.)" withBlock:^(OnigResult* res) {
146 141 NSString* body = [res body];
147   - return (NSString *)[NSString stringWithFormat:@"%@[%@]", [body class], body];
  142 + return [NSString stringWithFormat:@"[%@]", body];
148 143 }];
149   - STAssertEqualObjects(actual, @"NSCFString[he]llo!", nil);
  144 + STAssertEqualObjects(actual, @"[he]llo!", nil);
150 145
151 146 STAssertEqualObjects([@"hello" replaceByRegexp:@"l" withBlock:^(OnigResult* res) {
152 147 return @"x";
@@ -161,10 +156,6 @@ - (void)testReplaceAll
161 156 STAssertEqualObjects([@"abc" replaceAllByRegexp:@"." with:@"_"], @"___", nil);
162 157 STAssertEqualObjects([@"aa 00 aa 11" replaceAllByRegexp:@"\\d+" with:@"digits"], @"aa digits aa digits", nil);
163 158
164   - STAssertEqualObjects([@"hello" replaceAllByRegexp:@"." withCallback:self selector:@selector(succReplace:)], @"i f m m p ", nil);
165   - STAssertEqualObjects([@"hello!" replaceAllByRegexp:@"(.)(.)" withCallback:self selector:@selector(describeReplace:)], @"NSCFString[he]NSCFString[ll]NSCFString[o!]", nil);
166   - STAssertEqualObjects([@"hello" replaceAllByRegexp:@"l" withCallback:self selector:@selector(xReplace:)], @"hexxo", nil);
167   -
168 159 STAssertEqualObjects([@"hello" replaceAllByRegexp:@"." withBlock:^(OnigResult* res) {
169 160 unichar ch[2];
170 161 ch[0] = [[res body] characterAtIndex:0] + 1;
@@ -174,9 +165,9 @@ - (void)testReplaceAll
174 165
175 166 NSString* actual = [@"hello!" replaceAllByRegexp:@"(.)(.)" withBlock:^(OnigResult* res) {
176 167 NSString* body = [res body];
177   - return (NSString *)[NSString stringWithFormat:@"%@[%@]", [body class], body];
  168 + return (NSString *)[NSString stringWithFormat:@"[%@]", body];
178 169 }];
179   - STAssertEqualObjects(actual, @"NSCFString[he]NSCFString[ll]NSCFString[o!]", nil);
  170 + STAssertEqualObjects(actual, @"[he][ll][o!]", nil);
180 171
181 172 STAssertEqualObjects([@"hello" replaceAllByRegexp:@"l" withBlock:^(OnigResult* res) {
182 173 return @"x";

0 comments on commit 1583354

Please sign in to comment.
Something went wrong with that request. Please try again.