Revision: 6886
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6886&view=rev
Author:   hofman
Date:     2010-11-26 00:11:31 +0000 (Fri, 26 Nov 2010)

Log Message:
-----------
fix resolving selection specifier from non-character specifiers

Modified Paths:
--------------
    trunk/PDFSelection_SKExtensions.m

Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m   2010-11-25 23:42:00 UTC (rev 6885)
+++ trunk/PDFSelection_SKExtensions.m   2010-11-26 00:11:31 UTC (rev 6886)
@@ -247,13 +247,18 @@
 static inline NSRange rangeOfSubstringOfStringAtIndex(NSString *string, 
NSArray *substrings, NSUInteger anIndex) {
     NSUInteger length = [string length];
     NSRange range = NSMakeRange(0, 0);
+    NSUInteger i, iMax = [substrings count];
     
-    if (anIndex >= [substrings count])
+    if (anIndex >= iMax)
         return NSMakeRange(NSNotFound, 0);
-    for (NSString *substring in substrings) {
+    for (i = 0; i <= anIndex; i++) {
+        NSString *substring = [substrings objectAtIndex:i]; 
         NSRange searchRange = NSMakeRange(NSMaxRange(range), length - 
NSMaxRange(range));
-        if ([substring length] == 0)
+        if ([substring length] == 0) {
+            if (i == anIndex)
+                return NSMakeRange(NSNotFound, 0);
             continue;
+        }
         range = [string rangeOfString:substring options:NSLiteralSearch 
range:searchRange];
         if (range.location == NSNotFound)
             return NSMakeRange(NSNotFound, 0);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to