Skip to content

Commit 54d93ce

Browse files
committed
Clean up code
Remove warnings Uses runTask
1 parent 7222c82 commit 54d93ce

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

src/Common.m

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,15 @@
7070
// Set up preferences
7171
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
7272

73+
NSMutableDictionary *env = [NSMutableDictionary dictionaryWithDictionary:
74+
[[NSProcessInfo processInfo] environment]];
75+
7376
// Try to find highlight location
7477
NSString *highlightPath = [defaults valueForKey:@"pathHL"];
7578
if (highlightPath == nil) {
7679
NSUserDefaults *userDefaults = [[NSUserDefaults alloc] init];
77-
NSTask *task = [[NSTask alloc] init];
78-
[task setLaunchPath:@"/bin/bash"];
79-
[task setArguments:@[@"-l", @"-c", @"which highlight"]];
80-
NSPipe *pipe;
81-
pipe = [NSPipe pipe];
82-
[task setStandardOutput: pipe];
83-
NSFileHandle *file;
84-
file = [pipe fileHandleForReading];
85-
[task launch];
86-
NSData *data;
87-
data = [file readDataToEndOfFile];
88-
[task waitUntilExit];
80+
NSData* data = runTask(@"which highlight", env, status);
8981
highlightPath = [[[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease] stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
90-
[task release];
91-
[file closeFile];
9282
if (![highlightPath hasPrefix: @"/"] || ![highlightPath hasSuffix: @"highlight"]) { // fallback on default
9383
highlightPath = @"/opt/local/bin/highlight";
9484
}
@@ -99,8 +89,6 @@
9989
[userDefaults release];
10090
}
10191

102-
NSMutableDictionary *env = [NSMutableDictionary dictionaryWithDictionary:
103-
[[NSProcessInfo processInfo] environment]];
10492
[env addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
10593
#ifdef DEBUG
10694
@"1", @"qlcc_debug",

src/GeneratePreviewForURL.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
5151
//kUTTypePlainText,
5252
kUTTypeHTML,
5353
properties);
54-
54+
#ifndef DEBUG
5555
done:
56+
#endif
5657
n8log(@"Finished preview in %.3f sec", -[startDate timeIntervalSinceNow] );
5758
[pool release];
5859
return noErr;

src/GenerateThumbnailForURL.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@
9090
}
9191
[webView release];
9292

93+
#ifndef DEBUG
9394
done:
95+
#endif
9496
#ifdef DEBUG
9597
n8log(@"Finished thumbnail after %.3f sec\n\n", -[startDate timeIntervalSinceNow] );
9698
#endif

0 commit comments

Comments
 (0)