Revision: 2867
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2867&view=rev
Author:   hofman
Date:     2007-09-09 13:58:00 -0700 (Sun, 09 Sep 2007)

Log Message:
-----------
Ignore charactersToBeSkipped while scanning a single character.

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

Modified: trunk/NSScanner_SKExtensions.m
===================================================================
--- trunk/NSScanner_SKExtensions.m      2007-09-09 20:21:28 UTC (rev 2866)
+++ trunk/NSScanner_SKExtensions.m      2007-09-09 20:58:00 UTC (rev 2867)
@@ -42,21 +42,32 @@
 @implementation NSScanner (SKExtensions)
 
 - (BOOL)scanCharacter:(unichar *)ch {
-    if ([self isAtEnd])
-        return NO;
-    int location = [self scanLocation];
-    if (ch != NULL)
-        *ch = [[self string] characterAtIndex:location];
-    [self setScanLocation:location + 1];
-    return YES;
+    int location, length = [[self string] length];
+    unichar character;
+    BOOL success = NO;
+    for (location = [self scanLocation]; success == NO && location < length; 
location++) {
+        character = [[self string] characterAtIndex:location];
+        success = [[self charactersToBeSkipped] characterIsMember:character] 
== NO;
+    }
+    if (success) {
+        if (ch != NULL)
+            *ch = character;
+        [self setScanLocation:location];
+    }
+    return success;
 }
 
 - (BOOL)peekCharacter:(unichar *)ch {
-    if ([self isAtEnd])
-        return NO;
-    if (ch != NULL)
-        *ch = [[self string] characterAtIndex:[self scanLocation]];
-    return YES;
+    int location, length = [[self string] length];
+    unichar character;
+    BOOL success = NO;
+    for (location = [self scanLocation]; success == NO && location < length; 
location++) {
+        character = [[self string] characterAtIndex:location];
+        success = [[self charactersToBeSkipped] characterIsMember:character] 
== NO;
+    }
+    if (success && ch != NULL)
+        *ch = character;
+    return success;
 }
 
 @end


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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to