diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-10-09 10:13:42 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-10-09 10:13:42 +0000 |
commit | 0e9df92aef86421374ca1756ff3cbfa4c386c822 (patch) | |
tree | 778ccf801f614de0da69c1d1e298c2783861b6d5 /Source/SPSQLParser.m | |
parent | 5759187115c2aaa2db5f528a02bee80ba0980c39 (diff) | |
download | sequelpro-0e9df92aef86421374ca1756ff3cbfa4c386c822.tar.gz sequelpro-0e9df92aef86421374ca1756ff3cbfa4c386c822.tar.bz2 sequelpro-0e9df92aef86421374ca1756ff3cbfa4c386c822.zip |
• fixed bug while parsing the CREATE TABLE syntax if a column name contains a '#' or '/*'
- this fixes issue 431
- furthermore if the parsing process fails for some other reasons, i.e. a table name is NULL or empty SP alerts the user about it instead of stalling
Diffstat (limited to 'Source/SPSQLParser.m')
-rw-r--r-- | Source/SPSQLParser.m | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/SPSQLParser.m b/Source/SPSQLParser.m index 0b968d0a..4484c4c2 100644 --- a/Source/SPSQLParser.m +++ b/Source/SPSQLParser.m @@ -42,6 +42,10 @@ TO_BUFFER_STATE to_scan_string (const char *); */ @implementation SPSQLParser : NSMutableString +- (void)setIgnoringCommentStrings:(BOOL)ignoringCommentStrings +{ + ignoreCommentStrings = ignoringCommentStrings; +} /* * Removes comments within the current string, trimming "#", "--[/s]", and "/* * /" style strings. @@ -554,11 +558,13 @@ TO_BUFFER_STATE to_scan_string (const char *); break; case '#': + if(ignoreCommentStrings) break; currentStringIndex = [self endIndexOfCommentOfType:SPHashComment startingAtIndex:currentStringIndex]; break; // For comments starting "/*", ensure the start syntax is valid before proceeding. case '/': + if(ignoreCommentStrings) break; if (stringLength < currentStringIndex + 1) break; if ((unichar)(long)(*charAtIndex)(self, @selector(charAtIndex:), currentStringIndex+1) != '*') break; currentStringIndex = [self endIndexOfCommentOfType:SPCStyleComment startingAtIndex:currentStringIndex]; @@ -642,11 +648,13 @@ TO_BUFFER_STATE to_scan_string (const char *); break; case '#': + if(ignoreCommentStrings) break; currentStringIndex = [self endIndexOfCommentOfType:SPHashComment startingAtIndex:currentStringIndex]; break; // For comments starting "/*", ensure the start syntax is valid before proceeding. case '/': + if(ignoreCommentStrings) break; if (stringLength < currentStringIndex + 1) break; if ((unichar)(long)(*charAtIndex)(self, @selector(charAtIndex:), currentStringIndex+1) != '*') break; currentStringIndex = [self endIndexOfCommentOfType:SPCStyleComment startingAtIndex:currentStringIndex]; @@ -849,12 +857,15 @@ TO_BUFFER_STATE to_scan_string (const char *); /* Required and primitive methods to allow subclassing class cluster */ #pragma mark - - (id) init { + if (self = [super init]) { string = [[NSMutableString string] retain]; } parsedToChar = '\0'; parsedToPosition = -1; charCacheEnd = -1; + ignoreCommentStrings = NO; + return self; } - (id) initWithBytes:(const void *)bytes length:(unsigned int)length encoding:(NSStringEncoding)encoding { |