aboutsummaryrefslogtreecommitdiffstats
path: root/Source/xibLocalizationPostprocessor.m
diff options
context:
space:
mode:
authorMax <dmoagx@users.noreply.github.com>2018-05-03 22:26:12 +0200
committerMax <dmoagx@users.noreply.github.com>2018-05-03 22:26:27 +0200
commitb49edf67744ba6e54b7c0bdab7dc197cf8faac96 (patch)
tree25333e30eabfc6c40c9251322d2342ff6c21a530 /Source/xibLocalizationPostprocessor.m
parent7f35608f0ab5f9192245a5bc8dd74da793788389 (diff)
downloadsequelpro-b49edf67744ba6e54b7c0bdab7dc197cf8faac96.tar.gz
sequelpro-b49edf67744ba6e54b7c0bdab7dc197cf8faac96.tar.bz2
sequelpro-b49edf67744ba6e54b7c0bdab7dc197cf8faac96.zip
Replace all non-cyclic NSAutoreleasepools with @autoreleasepool
Diffstat (limited to 'Source/xibLocalizationPostprocessor.m')
-rw-r--r--Source/xibLocalizationPostprocessor.m94
1 files changed, 47 insertions, 47 deletions
diff --git a/Source/xibLocalizationPostprocessor.m b/Source/xibLocalizationPostprocessor.m
index 1806d6b2..b75b3a9c 100644
--- a/Source/xibLocalizationPostprocessor.m
+++ b/Source/xibLocalizationPostprocessor.m
@@ -9,12 +9,12 @@ NSDictionary *load_kv_pairs(NSString *input);
int main(int argc, const char *argv[])
{
- NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init]; {
- if (argc != 3 && argc != 4) {
- fprintf(stderr, "Usage: xibLocalizationPostprocessor inputfile outputfile (Replace IB keys with their English string value)\n");
+ @autoreleasepool {
+ if (argc != 3 && argc != 4) {
+ fprintf(stderr, "Usage: xibLocalizationPostprocessor inputfile outputfile (Replace IB keys with their English string value)\n");
fprintf(stderr, " xibLocalizationPostprocessor transfile inputfile outputfile (Reverse mode: Change English keys back to IB keys in translation)\n");
- exit (-1);
- }
+ exit(-1);
+ }
NSUInteger inputFileIndex = 1;
NSDictionary *translatedStrings = nil;
@@ -31,38 +31,38 @@ int main(int argc, const char *argv[])
inputFileIndex++;
}
- NSError *error = nil;
- NSStringEncoding usedEncoding;
- NSString *rawXIBStrings = [NSString stringWithContentsOfFile:[NSString stringWithUTF8String:argv[inputFileIndex]] usedEncoding:&usedEncoding error:&error];
- if (error) {
- fprintf(stderr, "Error reading inputfile %s: %s\n", argv[inputFileIndex], error.localizedDescription.UTF8String);
- exit (-1);
- }
-
- NSMutableString *outputStrings = [NSMutableString string];
- NSUInteger lineCount = 0;
- NSString *lastComment = nil;
- for (NSString *line in [rawXIBStrings componentsSeparatedByString:@"\n"]) {
- lineCount++;
-
- if ([line hasPrefix:@"/*"]) { // eg: /* Class = "NSMenuItem"; title = "Quit Library"; ObjectID = "136"; */
- lastComment = line;
- continue;
+ NSError *error = nil;
+ NSStringEncoding usedEncoding;
+ NSString *rawXIBStrings = [NSString stringWithContentsOfFile:[NSString stringWithUTF8String:argv[inputFileIndex]] usedEncoding:&usedEncoding error:&error];
+ if (error) {
+ fprintf(stderr, "Error reading inputfile %s: %s\n", argv[inputFileIndex], error.localizedDescription.UTF8String);
+ exit(-1);
+ }
+
+ NSMutableString *outputStrings = [NSMutableString string];
+ NSUInteger lineCount = 0;
+ NSString *lastComment = nil;
+ for (NSString *line in [rawXIBStrings componentsSeparatedByString:@"\n"]) {
+ lineCount++;
+
+ if ([line hasPrefix:@"/*"]) { // eg: /* Class = "NSMenuItem"; title = "Quit Library"; ObjectID = "136"; */
+ lastComment = line;
+ continue;
+
+ } else if (line.length == 0) {
+ lastComment = nil;
+ continue;
- } else if (line.length == 0) {
- lastComment = nil;
- continue;
+ } else if ([line hasPrefix:@"\""] && [line hasSuffix:@"\";"]) { // eg: "136.title" = "Quit Library";
- } else if ([line hasPrefix:@"\""] && [line hasSuffix:@"\";"]) { // eg: "136.title" = "Quit Library";
-
- NSRange quoteEqualsQuoteRange = [line rangeOfString:@"\" = \""];
- if (quoteEqualsQuoteRange.length && NSMaxRange(quoteEqualsQuoteRange) < line.length - 1) {
- if (lastComment) {
- [outputStrings appendString:lastComment];
- [outputStrings appendString:@"\n"];
- }
+ NSRange quoteEqualsQuoteRange = [line rangeOfString:@"\" = \""];
+ if (quoteEqualsQuoteRange.length && NSMaxRange(quoteEqualsQuoteRange) < line.length - 1) {
+ if (lastComment) {
+ [outputStrings appendString:lastComment];
+ [outputStrings appendString:@"\n"];
+ }
NSString *stringNeedingLocalization = [line substringFromIndex:NSMaxRange(quoteEqualsQuoteRange)]; // chop off leading: "blah" = "
- stringNeedingLocalization = [stringNeedingLocalization substringToIndex:stringNeedingLocalization.length - 2]; // chop off trailing: ";
+ stringNeedingLocalization = [stringNeedingLocalization substringToIndex:stringNeedingLocalization.length - 2]; // chop off trailing: ";
if(translatedStrings) {
NSString *translation = [translatedStrings objectForKey:stringNeedingLocalization];
if(!translation) {
@@ -74,19 +74,19 @@ int main(int argc, const char *argv[])
else {
[outputStrings appendFormat:@"\"%@\" = \"%@\";\n\n", stringNeedingLocalization, stringNeedingLocalization];
}
-
- continue;
- }
- }
-
- NSLog(@"Warning: skipped garbage input line %lu, contents: \"%@\"", (unsigned long)lineCount, line);
- }
-
- if (outputStrings.length && ![outputStrings writeToFile:[NSString stringWithUTF8String:argv[inputFileIndex+1]] atomically:NO encoding:usedEncoding error:&error]) {
- fprintf(stderr, "Error writing %s: %s\n", argv[inputFileIndex+1], error.localizedDescription.UTF8String);
- exit (-1);
- }
- } [autoreleasePool release];
+
+ continue;
+ }
+ }
+
+ NSLog(@"Warning: skipped garbage input line %lu, contents: \"%@\"", (unsigned long) lineCount, line);
+ }
+
+ if (outputStrings.length && ![outputStrings writeToFile:[NSString stringWithUTF8String:argv[inputFileIndex + 1]] atomically:NO encoding:usedEncoding error:&error]) {
+ fprintf(stderr, "Error writing %s: %s\n", argv[inputFileIndex + 1], error.localizedDescription.UTF8String);
+ exit(-1);
+ }
+ }
}
NSDictionary *load_kv_pairs(NSString *input)