From: Brian Pane Date: Mon, 29 Apr 2002 07:20:46 +0000 (+0000) Subject: Updated ap_getword_white() to use the same coding style X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=248de03fa2490d6972bb06102fc62caeeabe39b7;p=apache Updated ap_getword_white() to use the same coding style (and optimizations) as ap_getword() git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94854 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/util.c b/server/util.c index 22a7db7d41..4544551e15 100644 --- a/server/util.c +++ b/server/util.c @@ -675,29 +675,24 @@ AP_DECLARE(char *) ap_getword_white_nc(apr_pool_t *atrans, char **line) AP_DECLARE(char *) ap_getword_white(apr_pool_t *atrans, const char **line) { - int pos = -1, x; + const char *pos = *line; + int len; char *res; - for (x = 0; (*line)[x]; x++) { - if (apr_isspace((*line)[x])) { - pos = x; - break; - } - } - - if (pos == -1) { - res = apr_pstrdup(atrans, *line); - *line += strlen(*line); - return res; + while (!apr_isspace(*pos) && *pos) { + ++pos; } - res = apr_palloc(atrans, pos + 1); - apr_cpystrn(res, *line, pos + 1); + len = pos - *line; + res = (char *)apr_palloc(atrans, len + 1); + memcpy(res, *line, len); + res[len] = 0; - while (apr_isspace((*line)[pos])) - ++pos; + while (apr_isspace(*pos)) { + ++pos; + } - *line += pos; + *line = pos; return res; }