Revision: 28528
http://sourceforge.net/p/bibdesk/svn/28528
Author: hofman
Date: 2024-01-03 18:41:38 +0000 (Wed, 03 Jan 2024)
Log Message:
-----------
Use ARC for AGRegex framework
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/agkit_sourceforge/agregex/AGRegex-Common.xcconfig
trunk/bibdesk_vendorsrc/agkit_sourceforge/agregex/AGRegex.m
Modified:
trunk/bibdesk_vendorsrc/agkit_sourceforge/agregex/AGRegex-Common.xcconfig
===================================================================
--- trunk/bibdesk_vendorsrc/agkit_sourceforge/agregex/AGRegex-Common.xcconfig
2024-01-03 18:26:49 UTC (rev 28527)
+++ trunk/bibdesk_vendorsrc/agkit_sourceforge/agregex/AGRegex-Common.xcconfig
2024-01-03 18:41:38 UTC (rev 28528)
@@ -5,3 +5,4 @@
ZERO_LINK = NO
COMBINE_HIDPI_IMAGES = YES
ALWAYS_SEARCH_USER_PATHS = NO
+CLANG_ENABLE_OBJC_ARC = YES
Modified: trunk/bibdesk_vendorsrc/agkit_sourceforge/agregex/AGRegex.m
===================================================================
--- trunk/bibdesk_vendorsrc/agkit_sourceforge/agregex/AGRegex.m 2024-01-03
18:26:49 UTC (rev 28527)
+++ trunk/bibdesk_vendorsrc/agkit_sourceforge/agregex/AGRegex.m 2024-01-03
18:41:38 UTC (rev 28528)
@@ -85,9 +85,9 @@
backrefPattern = [[AGRegex alloc] initWithPattern:BACKREF_PATTERN];
}
-+ (id)regexWithPattern:(NSString *)pat { return [[[self alloc]
initWithPattern:pat] autorelease]; }
++ (id)regexWithPattern:(NSString *)pat { return [[self alloc]
initWithPattern:pat]; }
-+ (id)regexWithPattern:(NSString *)pat options:(NSInteger)opts { return
[[[self alloc] initWithPattern:pat options:opts ] autorelease]; }
++ (id)regexWithPattern:(NSString *)pat options:(NSInteger)opts { return [[self
alloc] initWithPattern:pat options:opts]; }
- (id)init {
return [self initWithPattern:@""];
@@ -111,16 +111,16 @@
#else
// check for valid ASCII string
if (![pat canBeConvertedToEncoding:NSASCIIStringEncoding]) {
- [self release];
+ self = nil;
return nil;
}
#endif
if (!(regex = pcre_compile([pat UTF8String], copts, &emsg,
&eloc, NULL))) {
- [self release];
+ self = nil;
return nil;
}
if (pcre_fullinfo(regex, NULL, PCRE_INFO_CAPTURECOUNT,
&groupCount)) {
- [self release];
+ self = nil;
return nil;
}
groupCount++;
@@ -131,7 +131,6 @@
- (void)dealloc {
pcre_free(regex);
pcre_free(extra);
- [super dealloc];
}
- (AGRegexMatch *)findInString:(NSString *)str {
@@ -164,9 +163,9 @@
// ARM: Here's another performance hit with the UTF8 conversion
// convert character range to byte range
CFIndex convertedIndex;
- CFStringGetBytes((CFStringRef)str, CFRangeMake(range.location,
range.length), kCFStringEncodingUTF8, 0, FALSE, NULL, UINT_MAX,
&convertedIndex);
+ CFStringGetBytes((__bridge CFStringRef)str, CFRangeMake(range.location,
range.length), kCFStringEncodingUTF8, 0, FALSE, NULL, UINT_MAX,
&convertedIndex);
range.length = convertedIndex;
- CFStringGetBytes((CFStringRef)str, CFRangeMake(0, range.location),
kCFStringEncodingUTF8, 0, FALSE, NULL, UINT_MAX, &convertedIndex);
+ CFStringGetBytes((__bridge CFStringRef)str, CFRangeMake(0,
range.location), kCFStringEncodingUTF8, 0, FALSE, NULL, UINT_MAX,
&convertedIndex);
range.location = convertedIndex;
// convert to UTF8; we take the long way round, but it's much cheaper than
-[NSString UTF8String], especially since we dispose of this when done (but
alloca() usually works)
@@ -173,7 +172,7 @@
CFIndex bufLen;
CFRange fullRange = CFRangeMake(0, [str length]);
CFIndex converted;
- converted = CFStringGetBytes((CFStringRef)str, fullRange,
kCFStringEncodingUTF8, 0, FALSE, NULL, UINT_MAX, &bufLen);
+ converted = CFStringGetBytes((__bridge CFStringRef)str, fullRange,
kCFStringEncodingUTF8, 0, FALSE, NULL, UINT_MAX, &bufLen);
NSAssert1(converted == [str length], @"String %@ was not converted to
UTF-8 correctly", str);
UInt8 *buffer = NULL;
@@ -183,10 +182,10 @@
if(buffer == NULL){
usedStack = NO;
- buffer = NSZoneMalloc(NSDefaultMallocZone(), bufSize);
+ buffer = (UInt8 *)malloc(bufSize);
NSAssert1(buffer != NULL, @"Unable to allocate buffer of length %zu
and size UInt8", bufLen + 1);
}
- CFStringGetBytes((CFStringRef)str, fullRange, kCFStringEncodingUTF8, 0,
FALSE, buffer, bufSize, NULL);
+ CFStringGetBytes((__bridge CFStringRef)str, fullRange,
kCFStringEncodingUTF8, 0, FALSE, buffer, bufSize, NULL);
buffer[bufLen] = '\0'; // null terminate to make this a cstring
// try match
@@ -193,15 +192,15 @@
if ((error = pcre_exec(regex, extra, (char *)buffer, range.location +
range.length, range.location, options, matchv, groupCount * 3)) ==
PCRE_ERROR_NOMATCH) {
free(matchv);
if(usedStack == NO)
- NSZoneFree(NSDefaultMallocZone(), buffer);
+ free(buffer);
return nil;
}
if(usedStack == NO)
- NSZoneFree(NSDefaultMallocZone(), buffer);
+ free(buffer);
// should not get any error besides PCRE_ERROR_NOMATCH
NSAssert1(error > 0, @"unexpected error pcre_exec(): %d", error);
// return the match, match object takes ownership of matchv
- return [[[AGRegexMatch alloc] initWithRegex:self string:str
vector:matchv count:groupCount] autorelease];
+ return [[AGRegexMatch alloc] initWithRegex:self string:str
vector:matchv count:groupCount];
}
- (NSArray *)findAllInString:(NSString *)str {
@@ -217,7 +216,7 @@
}
- (NSEnumerator *)findEnumeratorInString:(NSString *)str range:(NSRange)r {
- return [[[AGRegexMatchEnumerator alloc] initWithRegex:self string:str
range:r] autorelease];
+ return [[AGRegexMatchEnumerator alloc] initWithRegex:self string:str
range:r];
}
- (NSString *)replaceWithString:(NSString *)rep inString:(NSString *)str {
@@ -391,7 +390,7 @@
// takes ownership of the passed match vector, free on dealloc
- (id)initWithRegex:(AGRegex *)re string:(NSString *)str vector:(int *)mv
count:(NSInteger)c {
if (self = [super init]) {
- regex = [re retain];
+ regex = re;
string = [str copy]; // really only copies if the string is
mutable, immutable strings are just retained
matchv = mv;
count = c;
@@ -401,9 +400,6 @@
- (void)dealloc {
free(matchv);
- [regex release];
- [string release];
- [super dealloc];
}
- (NSInteger)count {
@@ -442,7 +438,7 @@
CFIndex bufLen;
CFRange fullRange = CFRangeMake(0, [string length]);
CFIndex converted;
- converted = CFStringGetBytes((CFStringRef)string, fullRange,
kCFStringEncodingUTF8, 0, FALSE, NULL, UINT_MAX, &bufLen);
+ converted = CFStringGetBytes((__bridge CFStringRef)string, fullRange,
kCFStringEncodingUTF8, 0, FALSE, NULL, UINT_MAX, &bufLen);
NSAssert1(converted == [string length], @"String %@ was not converted to
UTF-8 correctly", string);
UInt8 *buffer = NULL;
@@ -451,16 +447,16 @@
buffer = bufSize < SAFE_ALLOCA_SIZE ? alloca(bufSize) : NULL;
if(buffer == NULL){
usedStack = NO;
- buffer = NSZoneMalloc(NSDefaultMallocZone(), bufSize);
+ buffer = (UInt8 *)malloc(bufSize);
NSAssert1(buffer != NULL, @"Unable to allocate buffer of length %zu
and size UInt8", bufLen);
}
- CFStringGetBytes((CFStringRef)string, fullRange, kCFStringEncodingUTF8, 0,
FALSE, buffer, bufSize, NULL);
+ CFStringGetBytes((__bridge CFStringRef)string, fullRange,
kCFStringEncodingUTF8, 0, FALSE, buffer, bufSize, NULL);
// convert byte locations to character locations (doesn't require
null-terminated string)
NSRange theRange = NSMakeRange(utf8charcount(buffer, start),
utf8charcount(buffer + start, end - start));
if(usedStack == NO)
- NSZoneFree(NSDefaultMallocZone(), buffer);
+ free(buffer);
return theRange;
}
@@ -492,7 +488,7 @@
- (id)initWithRegex:(AGRegex *)re string:(NSString *)s range:(NSRange)r {
if (self = [super init]) {
- regex = [re retain];
+ regex = re;
string = [s copy]; // create one immutable copy of the string so we
don't copy it over and over when the matches are created
range = r;
end = range.location + range.length;
@@ -500,12 +496,6 @@
return self;
}
-- (void)dealloc {
- [regex release];
- [string release];
- [super dealloc];
-}
-
- (id)nextObject {
AGRegexMatch *next;
if ((next = [regex findInString:string range:range])) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit