From: Alan T. DeKok Date: Wed, 31 Aug 2016 14:02:49 +0000 (-0400) Subject: hoist unquoted case to top of the loop X-Git-Tag: release_3_0_12~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c7e5a527d2b9d11f1b0dfc0555d0f93bf7745af;p=thirdparty%2Ffreeradius-server.git hoist unquoted case to top of the loop --- diff --git a/src/lib/token.c b/src/lib/token.c index b7f50409e14..85e70806c5c 100644 --- a/src/lib/token.c +++ b/src/lib/token.c @@ -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++; }