bash: Remove short option completions for branch/checkout/diff.
[gitweb.git] / xdiff / xutils.c
index f7bdd395ad1f69067654a754b4d60fcc7c359275..1b899f32c4b7c3f00c5310a161d0d9afd459f002 100644 (file)
@@ -191,36 +191,30 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
        int i1, i2;
 
        if (flags & XDF_IGNORE_WHITESPACE) {
-               for (i1 = i2 = 0; i1 < s1 && i2 < s2; i1++, i2++) {
+               for (i1 = i2 = 0; i1 < s1 && i2 < s2; ) {
                        if (isspace(l1[i1]))
                                while (isspace(l1[i1]) && i1 < s1)
                                        i1++;
-                       else if (isspace(l2[i2]))
+                       if (isspace(l2[i2]))
                                while (isspace(l2[i2]) && i2 < s2)
                                        i2++;
-                       else if (l1[i1] != l2[i2])
-                               return l2[i2] - l1[i1];
+                       if (i1 < s1 && i2 < s2 && l1[i1++] != l2[i2++])
+                               return 0;
                }
-               if (i1 >= s1)
-                       return 1;
-               else if (i2 >= s2)
-                       return -1;
+               return (i1 >= s1 && i2 >= s2);
        } else if (flags & XDF_IGNORE_WHITESPACE_CHANGE) {
-               for (i1 = i2 = 0; i1 < s1 && i2 < s2; i1++, i2++) {
+               for (i1 = i2 = 0; i1 < s1 && i2 < s2; ) {
                        if (isspace(l1[i1])) {
                                if (!isspace(l2[i2]))
-                                       return -1;
+                                       return 0;
                                while (isspace(l1[i1]) && i1 < s1)
                                        i1++;
                                while (isspace(l2[i2]) && i2 < s2)
                                        i2++;
-                       } else if (l1[i1] != l2[i2])
-                               return l2[i2] - l1[i1];
+                       } else if (l1[i1++] != l2[i2++])
+                               return 0;
                }
-               if (i1 >= s1)
-                       return 1;
-               else if (i2 >= s2)
-                       return -1;
+               return (i1 >= s1 && i2 >= s2);
        } else
                return s1 == s2 && !memcmp(l1, l2, s1);
 
@@ -233,9 +227,11 @@ unsigned long xdl_hash_record(char const **data, char const *top, long flags) {
 
        for (; ptr < top && *ptr != '\n'; ptr++) {
                if (isspace(*ptr) && (flags & XDF_WHITESPACE_FLAGS)) {
-                       while (ptr < top && isspace(*ptr) && ptr[1] != '\n')
+                       while (ptr + 1 < top && isspace(ptr[1])
+                                       && ptr[1] != '\n')
                                ptr++;
-                       if (flags & XDF_IGNORE_WHITESPACE_CHANGE) {
+                       if (flags & XDF_IGNORE_WHITESPACE_CHANGE
+                                       && ptr[1] != '\n') {
                                ha += (ha << 5);
                                ha ^= (unsigned long) ' ';
                        }