From: André Malo Date: Mon, 28 Jul 2003 21:59:43 +0000 (+0000) Subject: cleanup splitout_queryargs function. X-Git-Tag: pre_ajp_proxy~1337 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30ee44124881eab2fa5fd7388aa0a660e917106a;p=apache cleanup splitout_queryargs function. - don't compute strlen more than one time - use ap_strchr instead of strchr git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@100828 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index a27e538413..7b101e9475 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -661,7 +661,6 @@ static char *escape_absolute_uri(apr_pool_t *p, char *uri, unsigned scheme) static void splitout_queryargs(request_rec *r, int qsappend) { char *q; - char *olduri; /* don't touch, unless it's an http or mailto URL. * See RFC 1738 and RFC 2368. @@ -673,8 +672,11 @@ static void splitout_queryargs(request_rec *r, int qsappend) return; } - q = strchr(r->filename, '?'); + q = ap_strchr(r->filename, '?'); if (q != NULL) { + char *olduri; + apr_size_t len; + olduri = apr_pstrdup(r->pool, r->filename); *q++ = '\0'; if (qsappend) { @@ -683,18 +685,17 @@ static void splitout_queryargs(request_rec *r, int qsappend) else { r->args = apr_pstrdup(r->pool, q); } - if (strlen(r->args) == 0) { + + len = strlen(r->args); + if (!len) { r->args = NULL; - rewritelog(r, 3, "split uri=%s -> uri=%s, args=", olduri, - r->filename); } - else { - if (r->args[strlen(r->args)-1] == '&') { - r->args[strlen(r->args)-1] = '\0'; - } - rewritelog(r, 3, "split uri=%s -> uri=%s, args=%s", olduri, - r->filename, r->args); + else if (r->args[len-1] == '&') { + r->args[len-1] = '\0'; } + + rewritelog(r, 3, "split uri=%s -> uri=%s, args=%s", olduri, + r->filename, r->args ? r->args : ""); } return; @@ -758,6 +759,7 @@ static void reduce_uri(request_rec *r) r->filename = apr_pstrdup(r->pool, url); } } + return; }