OSDN Git Service

Fix MinGW-Bug 3212246.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Tue, 15 Mar 2011 20:28:38 +0000 (20:28 +0000)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Tue, 15 Mar 2011 20:28:38 +0000 (20:28 +0000)
ChangeLog
src/keyword.c

index 00cbfc2..f709589 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-03-15  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Fix MinGW-Bug 3212246.
+
+       * src/keyword.c (has_keyword): Avoid incrementing the comparison
+       pointers when a significant character in one string is not matched in
+       the other; previously the pointers were left pointing one character to
+       the right of the mismatch, and this was overlooked if the mismatch
+       occurred at the rightmost character in both strings.
+
 2011-03-12  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        mingw-get-0.2-mingw32-alpha-1 released.
index a762645..7e90318 100644 (file)
@@ -50,12 +50,13 @@ int has_keyword( const char *lookup, const char *in_list )
        * unchecked section of "in_list"...
        */
       const char *inspect = lookup;
-      while( *inspect && ! isspace( *in_list ) && (*inspect++ == *in_list++) )
-       /*
-        * ...advancing pointers to both, with no further action,
+      while( *inspect && ! isspace( *in_list ) && (*inspect == *in_list) )
+      {
+       /* ...advancing pointers to both, with no further action,
         * until we find a mismatch.
         */
-       ;
+       ++inspect; ++in_list;
+      }
 
       /* If the mismatch coincides with the terminating NUL for "lookup",
        * AND we've simultaneously encountered a keyword separator, or the
@@ -69,7 +70,10 @@ int has_keyword( const char *lookup, const char *in_list )
 
       /* Otherwise, we have not yet found a match...
        * Step over any remaining non-white-space characters in the current
-       * "in_list" entry, and also the following space character if any...
+       * "in_list" entry, and also the first of any following space characters.
+       * (Note that we don't need to explicitly skip over any additional space
+       * characters preceding the next list entry, if any, since they will be
+       * implicitly skipped in the outer loop).
        */
       while( *in_list && ! isspace( *in_list++ ) )
        /*