hoist unquoted case to top of the loop
authorAlan T. DeKok <aland@freeradius.org>
Wed, 31 Aug 2016 14:02:49 +0000 (10:02 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 31 Aug 2016 14:26:27 +0000 (10:26 -0400)
src/lib/token.c

index b7f5040..85e7080 100644 (file)
@@ -231,6 +231,33 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok,
        s = buf;
 
        while (*p && buflen-- > 1) {
+               /*
+                *      We're looking for strings.  Stop on spaces, or
+                *      (if given a token list), on a token, or on a
+                *      comma.
+                */
+               if (!quote) {
+                       if (isspace((int) *p)) {
+                               break;
+                       }
+
+                       if (tok) {
+                               for (t = tokenlist; t->name; t++) {
+                                       if (TOKEN_MATCH(p, t->name)) {
+                                               *s++ = 0;
+                                               goto done;
+                                       }
+                               }
+                       }
+                       if (*p == ',') break;
+
+                       /*
+                        *      Copy the character over.
+                        */
+                       *s++ = *p++;
+                       continue;
+               }
+
                if (unescape && quote && (*p == '\\')) {
                        p++;
 
@@ -283,27 +310,6 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok,
                        p++;
                        break;
                }
-
-               /*
-                *      We're looking for strings.  Stop on spaces, or
-                *      (if given a token list), on a token, or on a
-                *      comma.
-                */
-               if (!quote) {
-                       if (isspace((int) *p)) {
-                               break;
-                       }
-
-                       if (tok) {
-                               for (t = tokenlist; t->name; t++) {
-                                       if (TOKEN_MATCH(p, t->name)) {
-                                               *s++ = 0;
-                                               goto done;
-                                       }
-                               }
-                       }
-                       if (*p == ',') break;
-               }
                *s++ = *p++;
        }