Use for loops instead of while.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 6 Sep 2014 23:09:51 +0000 (01:09 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 6 Sep 2014 23:09:51 +0000 (01:09 +0200)
src/util.c

index 92d5d26..e42fc57 100644 (file)
@@ -648,17 +648,13 @@ static gboolean match_list(const char *pattern, int patlen, const char *subject)
     int endlen;
     const char *end, *s;
 
-    end    = pattern;
-    endlen = patlen;
     /* finde the next none escaped '}' */
-    while (endlen > 0 && *end != '}') {
+    for (end = pattern, endlen = patlen; endlen > 0 && *end != '}'; end++, endlen--) {
         /* if escape char - move pointer one additional step */
         if (*end == '\\') {
             end++;
             endlen--;
         }
-        end++;
-        endlen--;
     }
 
     if (!*end) {
@@ -701,14 +697,12 @@ static gboolean match_list(const char *pattern, int patlen, const char *subject)
                     /* this item of the list does not match - move forward to
                      * the next none escaped ',' or '}' */
                     s = subject;
-                    while (*pattern != ',' && *pattern != '}') {
+                    for (s = subject; *pattern != ',' && *pattern != '}'; pattern++, patlen--) {
                         /* if escape char is found - skip next char */
                         if (*pattern == '\\') {
                             pattern++;
                             patlen--;
                         }
-                        pattern++;
-                        patlen--;
                     }
                     /* found ',' skip over it to check the next list item */
                     if (*pattern == ',') {