]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
hoist check for backslash to near the top of the loop
authorAlan T. DeKok <aland@freeradius.org>
Wed, 31 Aug 2016 14:12:57 +0000 (10:12 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 31 Aug 2016 14:26:27 +0000 (10:26 -0400)
src/lib/token.c

index edbacc4ef90c6e40b6968dbff994ead02af40dfb..0ef4065c87d91409c2e633a02e8b1c5d19d1935c 100644 (file)
@@ -267,7 +267,12 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok,
                        break;
                }
 
-               if (unescape && (*p == '\\')) {
+               if (*p != '\\') {
+                       *s++ = *p++;
+                       continue;
+               }
+
+               if (unescape) {
                        p++;
 
                        switch (*p) {
@@ -294,15 +299,13 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok,
                                        break;
                        }
                        p++;
-                       continue;
-               }
 
-               /*
-                *      Deal with quotes and escapes, but don't mash
-                *      escaped characters into their non-escaped
-                *      equivalent.
-                */
-               if (!unescape && (*p == '\\')) {
+               } else {
+                       /*
+                        *      Deal with quotes and escapes, but don't mash
+                        *      escaped characters into their non-escaped
+                        *      equivalent.
+                        */
                        if (!p[1]) continue; /* force end of string */
 
                        if (p[1] == quote) { /* convert '\'' --> ' */
@@ -311,10 +314,7 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok,
                                *(s++) = *(p++);
                        }
                        *(s++) = *(p++);
-                       continue;
                }
-
-               *s++ = *p++;
        }
 
        *s++ = 0;