From: Alan T. DeKok Date: Wed, 31 Aug 2016 14:12:57 +0000 (-0400) Subject: hoist check for backslash to near the top of the loop X-Git-Tag: release_3_0_12~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=360a19238b61045fd9f22bdbb3ebcbf71c5177a0;p=thirdparty%2Ffreeradius-server.git hoist check for backslash to near the top of the loop --- diff --git a/src/lib/token.c b/src/lib/token.c index edbacc4ef90..0ef4065c87d 100644 --- a/src/lib/token.c +++ b/src/lib/token.c @@ -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;