Commit 9bde43a3 authored by Stefan Fritsch's avatar Stefan Fritsch
Browse files

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/trunk@1212883 13f79535-47bb-0310-9956-ffa450edef68
parent c65b02d8
Loading
Loading
Loading
Loading
+3 −0
Changes for docs/manual/expr.xml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -374,6 +374,9 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
    <tr><td><code>-f</code></td>
        <td>The argument is treated as a filename.
            True if the file exists and is regular file</td><td>yes</td></tr>
    <tr><td><code>-s</code></td>
        <td>The argument is treated as a filename.
            True if the file exists and is not empty</td><td>yes</td></tr>
    <tr><td><code>-L</code></td>
        <td>The argument is treated as a filename.
            True if the file exists and is symlink</td><td>yes</td></tr>
+13 −3
Changes for server/util_expr_eval.c: 13 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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;
}