diff options
author | rowanbeentje <rowan@beent.je> | 2011-04-10 22:12:34 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2011-04-10 22:12:34 +0000 |
commit | b532634ab35447fea0b89123468b2d63869abc99 (patch) | |
tree | 5d215b88878ac953614970385a2a60dfc0e192ae /Source/SPSQLParser.m | |
parent | 0930c6b49fa7988cb14bdd5fe81c71d5d27f1936 (diff) | |
download | sequelpro-b532634ab35447fea0b89123468b2d63869abc99.tar.gz sequelpro-b532634ab35447fea0b89123468b2d63869abc99.tar.bz2 sequelpro-b532634ab35447fea0b89123468b2d63869abc99.zip |
- Fix a bug when standardising line endings, addressing multiple CRLFs - this fixes Issue #1024
Diffstat (limited to 'Source/SPSQLParser.m')
-rw-r--r-- | Source/SPSQLParser.m | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Source/SPSQLParser.m b/Source/SPSQLParser.m index 6485fc85..458d4e25 100644 --- a/Source/SPSQLParser.m +++ b/Source/SPSQLParser.m @@ -280,12 +280,14 @@ TO_BUFFER_STATE to_scan_string (const char *); } } - if ([carriageReturnPositions count]) { + // If any CRs were found, iterate over them backwards, converting to LFs by replacing or subtracting as appropriate + NSUInteger carriageReturnCount = [carriageReturnPositions count]; + if (carriageReturnCount) { NSMutableString *normalisedString = [NSMutableString stringWithString:queryString]; BOOL isCRLF; NSUInteger CRLocation; - for (NSNumber *position in carriageReturnPositions) { - CRLocation = [position unsignedIntegerValue]; + while ( carriageReturnCount-- ) { + CRLocation = [[carriageReturnPositions objectAtIndex:carriageReturnCount] unsignedIntegerValue]; // Check whether it's a CRLF or just a CR isCRLF = NO; |