From: Stefan Fritsch Date: Sat, 10 Dec 2011 21:27:22 +0000 (+0000) Subject: Merge r1212883: X-Git-Tag: 2.3.16~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=923b96d02fb4c7483bde94a93a763a2386940c18;p=apache Merge r1212883: Fix names of unary operators like '-s' being compared case insensitively. Improve error message if op or function is not found. Document '-s' operator. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1212884 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/expr.xml b/docs/manual/expr.xml index 9b18d7faf7..bdb3e687bd 100644 --- a/docs/manual/expr.xml +++ b/docs/manual/expr.xml @@ -374,6 +374,9 @@ listfunction ::= listfuncname "(" word ")" -f The argument is treated as a filename. True if the file exists and is regular fileyes + -s + The argument is treated as a filename. + True if the file exists and is not emptyyes -L The argument is treated as a filename. True if the file exists and is symlinkyes diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index ee34375f1f..abf3bdb472 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -1636,7 +1636,12 @@ static int core_expr_lookup(ap_expr_lookup_parms *parms) ap_assert(0); } while (prov->func) { - if (strcasecmp(prov->name, parms->name) == 0) { + int match; + if (parms->type == AP_EXPR_FUNC_OP_UNARY) + match = !strcmp(prov->name, parms->name); + else + match = !strcasecmp(prov->name, parms->name); + if (match) { if ((parms->flags & AP_EXPR_FLAG_RESTRICTED) && prov->restricted) { *parms->err = @@ -1668,6 +1673,7 @@ static int core_expr_lookup(ap_expr_lookup_parms *parms) static int expr_lookup_not_found(ap_expr_lookup_parms *parms) { const char *type; + const char *prefix = ""; switch (parms->type) { case AP_EXPR_FUNC_VAR: @@ -1689,8 +1695,12 @@ static int expr_lookup_not_found(ap_expr_lookup_parms *parms) *parms->err = "Inavalid expression type in expr_lookup"; return !OK; } - *parms->err = apr_psprintf(parms->ptemp, "%s '%s' does not exist", type, - parms->name); + if ( parms->type == AP_EXPR_FUNC_OP_UNARY + || parms->type == AP_EXPR_FUNC_OP_BINARY) { + prefix = "-"; + } + *parms->err = apr_psprintf(parms->ptemp, "%s '%s%s' does not exist", type, + prefix, parms->name); return !OK; }