I'll take a go at it this weekend, I think. Not certain I'll have time, but I think I will.

On Sep 16, 2010, at 2:58 PM, William A. Rowe Jr. wrote:

This is the second feature change to mod_rewrite this week.

If anyone can volunteer to update the mod_rewrite.xml that would be fantastic!
If not I'll update the docs sometime later next week.

-------- Original Message --------
Subject: svn commit: r997878 - /httpd/httpd/trunk/modules/mappers/ mod_rewrite.c
Date: Thu, 16 Sep 2010 18:57:23 -0000
From: [email protected]
Reply-To: [email protected]
To: [email protected]

Author: wrowe
Date: Thu Sep 16 18:57:23 2010
New Revision: 997878

URL: http://svn.apache.org/viewvc?rev=997878&view=rev
Log:
Introduce integer comparison support in RewriteCond

The operators -gt, -ge, -eq, -le, -lt and -ne follow the bash test' semantics for comparing the integer values of the lhs and rhs expressions, as opposed
to the string evaluations performed by > >= = <= and <.

Note that -lt and -le overlap the existing -l test, and could be confused in expresions such as -ltestfile - to avoid this conflict use -L or -h in place
of the legacy -l file symlink test operator.


Modified:
   httpd/httpd/trunk/modules/mappers/mod_rewrite.c

Modified: httpd/httpd/trunk/modules/mappers/mod_rewrite.c
URL:
http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_rewrite.c?rev=997878&r1=997877&r2=997878&view=diff
= = = = = = = = ======================================================================
--- httpd/httpd/trunk/modules/mappers/mod_rewrite.c (original)
+++ httpd/httpd/trunk/modules/mappers/mod_rewrite.c Thu Sep 16 18:57:23 2010
@@ -264,7 +264,12 @@ typedef enum {
    CONDPAT_STR_LE,
    CONDPAT_STR_EQ,
    CONDPAT_STR_GT,
-    CONDPAT_STR_GE
+    CONDPAT_STR_GE,
+    CONDPAT_INT_LT,
+    CONDPAT_INT_LE,
+    CONDPAT_INT_EQ,
+    CONDPAT_INT_GT,
+    CONDPAT_INT_GE
} pattern_type;

typedef struct {
@@ -3178,12 +3183,32 @@ static const char *cmd_rewritecond(cmd_p
            case 'f': newcond->ptype = CONDPAT_FILE_EXISTS; break;
            case 's': newcond->ptype = CONDPAT_FILE_SIZE;   break;
            case 'd': newcond->ptype = CONDPAT_FILE_DIR;    break;
-            case 'l': newcond->ptype = CONDPAT_FILE_LINK;   break;
            case 'x': newcond->ptype = CONDPAT_FILE_XBIT;   break;
            case 'h': newcond->ptype = CONDPAT_FILE_LINK;   break;
            case 'L': newcond->ptype = CONDPAT_FILE_LINK;   break;
            case 'U': newcond->ptype = CONDPAT_LU_URL;      break;
            case 'F': newcond->ptype = CONDPAT_LU_FILE;     break;
+            case 'l': if (a2[2] == 't')
+                          a2 += 3, newcond->ptype = CONDPAT_INT_LT;
+                      else if (a2[2] == 'e')
+                          a2 += 3, newcond->ptype = CONDPAT_INT_LE;
+                      else /* Historical; prefer -L or -h instead */
+                          newcond->ptype = CONDPAT_FILE_LINK;
+                      break;
+            case 'g': if (a2[2] == 't')
+                          a2 += 3, newcond->ptype = CONDPAT_INT_GT;
+                      else if (a2[2] == 'e')
+                          a2 += 3, newcond->ptype = CONDPAT_INT_GE;
+                      break;
+            case 'e': if (a2[2] == 'q')
+                          a2 += 3, newcond->ptype = CONDPAT_INT_EQ;
+                      break;
+            case 'n': if (a2[2] == 'e') {
+                          /* Inversion, ensure !-ne == -eq */
+                          a2 += 3, newcond->ptype = CONDPAT_INT_EQ;
+                          newcond->flags ^= CONDFLAG_NOTMATCH;
+                      }
+                      break;
            }
        }
        else {
@@ -3706,6 +3731,14 @@ test_str_l:
        }
        break;

+ case CONDPAT_INT_GE: rc = (atoi(input) >= atoi(p->pattern)); break; + case CONDPAT_INT_GT: rc = (atoi(input) > atoi(p->pattern)); break;
+
+ case CONDPAT_INT_LE: rc = (atoi(input) <= atoi(p->pattern)); break; + case CONDPAT_INT_LT: rc = (atoi(input) < atoi(p->pattern)); break;
+
+ case CONDPAT_INT_EQ: rc = (atoi(input) == atoi(p->pattern)); break;
+
    default:
        /* it is really a regexp pattern, so apply it */
rc = !ap_regexec(p->regexp, input, AP_MAX_REG_MATCH, regmatch, 0);




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


--
Rich Bowen
[email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to