Revision: 4800
http://skim-app.svn.sourceforge.net/skim-app/?rev=4800&view=rev
Author: hofman
Date: 2008-10-15 17:27:43 +0000 (Wed, 15 Oct 2008)
Log Message:
-----------
replace if's by switch
Modified Paths:
--------------
trunk/SKPDFSynchronizer.m
Modified: trunk/SKPDFSynchronizer.m
===================================================================
--- trunk/SKPDFSynchronizer.m 2008-10-15 17:20:16 UTC (rev 4799)
+++ trunk/SKPDFSynchronizer.m 2008-10-15 17:27:43 UTC (rev 4800)
@@ -392,49 +392,58 @@
while ([self shouldKeepRunning] && [sc scanCharacter:&ch]) {
- if (ch == 'l') {
- if ([sc scanInt:&recordIndex] && [sc scanInt:&line]) {
- // we ignore the column
- [sc scanInt:NULL];
- record = [records recordForIndex:recordIndex];
- [record setFile:file];
- [record setLine:line];
- [[lines objectForKey:file] addObject:record];
- }
- } else if (ch == 'p') {
- // we ignore * and + modifiers
- [sc scanString:@"*" intoString:NULL] || [sc
scanString:@"+" intoString:NULL];
- if ([sc scanInt:&recordIndex] && [sc scanFloat:&x] &&
[sc scanFloat:&y]) {
- record = [records recordForIndex:recordIndex];
- [record setPageIndex:[pages count] - 1];
- [record setPoint:NSMakePoint(PDFSYNC_TO_PDF(x) +
pdfOffset.x, PDFSYNC_TO_PDF(y) + pdfOffset.y)];
- [[pages lastObject] addObject:record];
- }
- } else if (ch == 's') {
- // start of a new page, the scanned integer should
always equal [pages count]+1
- if ([sc scanInt:&pageIndex] == NO) pageIndex = [pages
count] + 1;
- while (pageIndex > (int)[pages count]) {
- array = [[NSMutableArray alloc] init];
- [pages addObject:array];
- [array release];
- }
- } else if (ch == '(') {
- // start of a new source file
- if ([sc scanUpToCharactersFromSet:[NSCharacterSet
newlineCharacterSet] intoString:&file]) {
- file = [self sourceFileForFileName:file
defaultExtension:SKPDFSynchronizerTexExtension removeQuotes:YES];
- [files addObject:file];
- if ([lines objectForKey:file] == nil) {
+ switch (ch) {
+ case 'l':
+ if ([sc scanInt:&recordIndex] && [sc
scanInt:&line]) {
+ // we ignore the column
+ [sc scanInt:NULL];
+ record = [records recordForIndex:recordIndex];
+ [record setFile:file];
+ [record setLine:line];
+ [[lines objectForKey:file] addObject:record];
+ }
+ break;
+ case 'p':
+ // we ignore * and + modifiers
+ [sc scanString:@"*" intoString:NULL] || [sc
scanString:@"+" intoString:NULL];
+ if ([sc scanInt:&recordIndex] && [sc scanFloat:&x]
&& [sc scanFloat:&y]) {
+ record = [records recordForIndex:recordIndex];
+ [record setPageIndex:[pages count] - 1];
+ [record setPoint:NSMakePoint(PDFSYNC_TO_PDF(x)
+ pdfOffset.x, PDFSYNC_TO_PDF(y) + pdfOffset.y)];
+ [[pages lastObject] addObject:record];
+ }
+ break;
+ case 's':
+ // start of a new page, the scanned integer should
always equal [pages count]+1
+ if ([sc scanInt:&pageIndex] == NO) pageIndex =
[pages count] + 1;
+ while (pageIndex > (int)[pages count]) {
array = [[NSMutableArray alloc] init];
- [lines setObject:array forKey:file];
+ [pages addObject:array];
[array release];
}
- }
- } else if (ch == ')') {
- // closing of a source file
- if ([files count]) {
- [files removeLastObject];
- file = [files lastObject];
- }
+ break;
+ case '(':
+ // start of a new source file
+ if ([sc scanUpToCharactersFromSet:[NSCharacterSet
newlineCharacterSet] intoString:&file]) {
+ file = [self sourceFileForFileName:file
defaultExtension:SKPDFSynchronizerTexExtension removeQuotes:YES];
+ [files addObject:file];
+ if ([lines objectForKey:file] == nil) {
+ array = [[NSMutableArray alloc] init];
+ [lines setObject:array forKey:file];
+ [array release];
+ }
+ }
+ break;
+ case ')':
+ // closing of a source file
+ if ([files count]) {
+ [files removeLastObject];
+ file = [files lastObject];
+ }
+ break;
+ default:
+ // shouldn't reach
+ break;
}
[sc scanUpToCharactersFromSet:[NSCharacterSet
newlineCharacterSet] intoString:NULL];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit