aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPAppController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2011-03-01 21:09:08 +0000
committerstuconnolly <stuart02@gmail.com>2011-03-01 21:09:08 +0000
commit64919b03fa59c8d93c81a8e3893934c04a3cac91 (patch)
treea73f3db993975d4fb6963730450bae0655b12a09 /Source/SPAppController.m
parentcd09dcd69813400b098b9f019a558efb11e6c8b2 (diff)
downloadsequelpro-64919b03fa59c8d93c81a8e3893934c04a3cac91.tar.gz
sequelpro-64919b03fa59c8d93c81a8e3893934c04a3cac91.tar.bz2
sequelpro-64919b03fa59c8d93c81a8e3893934c04a3cac91.zip
Fix compiler warnings.
Diffstat (limited to 'Source/SPAppController.m')
-rw-r--r--Source/SPAppController.m129
1 files changed, 61 insertions, 68 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index f7514928..c0209fca 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -838,84 +838,77 @@ YY_BUFFER_STATE yy_scan_string (const char *);
*/
- (NSString*)doSQLSyntaxHighlightForString:(NSString*)sqlText cssLike:(BOOL)cssLike
{
+ NSMutableString *sqlHTML = [[[NSMutableString alloc] initWithCapacity:[sqlText length]] autorelease];
+
+ NSString *tokenColor;
+ NSString *cssId;
+ size_t token;
+ NSRange tokenRange;
+
+ // initialise flex
+ yyuoffset = 0; yyuleng = 0;
+ yy_switch_to_buffer(yy_scan_string([sqlText UTF8String]));
+ BOOL skipFontTag;
+
+ while ((token=yylex())) {
+ skipFontTag = NO;
+ switch (token) {
+ case SPT_SINGLE_QUOTED_TEXT:
+ case SPT_DOUBLE_QUOTED_TEXT:
+ tokenColor = @"#A7221C";
+ cssId = @"sp_sql_quoted";
+ break;
+ case SPT_BACKTICK_QUOTED_TEXT:
+ tokenColor = @"#001892";
+ cssId = @"sp_sql_backtick";
+ break;
+ case SPT_RESERVED_WORD:
+ tokenColor = @"#0041F6";
+ cssId = @"sp_sql_keyword";
+ break;
+ case SPT_NUMERIC:
+ tokenColor = @"#67350F";
+ cssId = @"sp_sql_numeric";
+ break;
+ case SPT_COMMENT:
+ tokenColor = @"#265C10";
+ cssId = @"sp_sql_comment";
+ break;
+ case SPT_VARIABLE:
+ tokenColor = @"#6C6C6C";
+ cssId = @"sp_sql_variable";
+ break;
+ case SPT_WHITESPACE:
+ skipFontTag = YES;
+ cssId = @"";
+ break;
+ default:
+ skipFontTag = YES;
+ cssId = @"";
+ }
- NSMutableString *sqlHTML = [[[NSMutableString alloc] initWithCapacity:[sqlText length]] autorelease];
-
- NSRange textRange = NSMakeRange(0, [sqlText length]);
- NSString *tokenColor;
- NSString *cssId;
- size_t token;
- NSRange tokenRange;
-
- // initialise flex
- yyuoffset = 0; yyuleng = 0;
- yy_switch_to_buffer(yy_scan_string([sqlText UTF8String]));
- BOOL skipFontTag;
-
- while (token=yylex()){
- skipFontTag = NO;
- switch (token) {
- case SPT_SINGLE_QUOTED_TEXT:
- case SPT_DOUBLE_QUOTED_TEXT:
- tokenColor = @"#A7221C";
- cssId = @"sp_sql_quoted";
- break;
- case SPT_BACKTICK_QUOTED_TEXT:
- tokenColor = @"#001892";
- cssId = @"sp_sql_backtick";
- break;
- case SPT_RESERVED_WORD:
- tokenColor = @"#0041F6";
- cssId = @"sp_sql_keyword";
- break;
- case SPT_NUMERIC:
- tokenColor = @"#67350F";
- cssId = @"sp_sql_numeric";
- break;
- case SPT_COMMENT:
- tokenColor = @"#265C10";
- cssId = @"sp_sql_comment";
- break;
- case SPT_VARIABLE:
- tokenColor = @"#6C6C6C";
- cssId = @"sp_sql_variable";
- break;
- case SPT_WHITESPACE:
- skipFontTag = YES;
- cssId = @"";
- break;
- default:
- skipFontTag = YES;
- cssId = @"";
- }
-
- tokenRange = NSMakeRange(yyuoffset, yyuleng);
-
- if(skipFontTag)
- [sqlHTML appendString:[[sqlText substringWithRange:tokenRange] HTMLEscapeString]];
- else {
- if(cssLike)
- [sqlHTML appendFormat:@"<span class=\"%@\">%@</span>", cssId, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]];
- else
- [sqlHTML appendFormat:@"<font color=%@>%@</font>", tokenColor, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]];
- }
+ tokenRange = NSMakeRange(yyuoffset, yyuleng);
+ if(skipFontTag)
+ [sqlHTML appendString:[[sqlText substringWithRange:tokenRange] HTMLEscapeString]];
+ else {
+ if(cssLike)
+ [sqlHTML appendFormat:@"<span class=\"%@\">%@</span>", cssId, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]];
+ else
+ [sqlHTML appendFormat:@"<font color=%@>%@</font>", tokenColor, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]];
}
- // Wrap lines, and replace tabs with spaces
- [sqlHTML replaceOccurrencesOfString:@"\n" withString:@"<br>" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])];
- [sqlHTML replaceOccurrencesOfString:@"\t" withString:@"&nbsp;&nbsp;&nbsp;&nbsp;" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])];
+ }
- if(sqlHTML)
- return sqlHTML;
- else
- return @"";
+ // Wrap lines, and replace tabs with spaces
+ [sqlHTML replaceOccurrencesOfString:@"\n" withString:@"<br>" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])];
+ [sqlHTML replaceOccurrencesOfString:@"\t" withString:@"&nbsp;&nbsp;&nbsp;&nbsp;" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])];
+ return (sqlHTML) ? sqlHTML : @"";
}
- (IBAction)executeBundleItemForApp:(id)sender
{
-
NSInteger idx = [sender tag] - 1000000;
NSString *infoPath = nil;
NSArray *bundleItems = [[NSApp delegate] bundleItemsForScope:SPBundleScopeGeneral];