]> granicus.if.org Git - apache/commitdiff
Merge r1212883:
authorStefan Fritsch <sf@apache.org>
Sat, 10 Dec 2011 21:27:22 +0000 (21:27 +0000)
committerStefan Fritsch <sf@apache.org>
Sat, 10 Dec 2011 21:27:22 +0000 (21:27 +0000)
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

docs/manual/expr.xml
server/util_expr_eval.c

index 9b18d7faf7e56065c4e044b46433027d6c2ecee1..bdb3e687bd31be5429dcfb8aeb6e549e7e30f9ab 100644 (file)
@@ -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>
index ee34375f1f56b8b50c60060da8bf7e286a2aa27f..abf3bdb472027440b54c149f4a71321276e477b5 100644 (file)
@@ -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;
 }