httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@engelschall.com (Ralf S. Engelschall)
Subject [PATCH] trivial enhancement to RewriteCond patterns
Date Mon, 28 Jul 1997 17:34:43 GMT

For a lot of mod_rewrite rulesets a rewrite condition like

   RewriteRule %{ENV:BLABLA}  ^$
and
   RewriteRule %{ENV:BLABLA}  !^$

is used to check if "BLABLA" is set. This is both complicated to read and has
bad performance. The above patch, which I want to commit to HEAD, makes just a
trivial enhancement to mod_rewrite, so now we can both write

   RewriteRule %{ENV:BLABLA}  =""
and
   RewriteRule %{ENV:BLABLA}  !=""

and which also is evaluated more performant.

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Index: mod_rewrite.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_rewrite.c,v
retrieving revision 1.41
diff -c -r1.41 mod_rewrite.c
*** mod_rewrite.c       1997/07/27 02:10:39     1.41
--- mod_rewrite.c       1997/07/28 17:29:20
***************
*** 1783,1789 ****
          rc = (compare_lexicography(input, p->pattern+1) == -1 ? 1 : 0);
      }
      else if (strlen(p->pattern) > 1 && *(p->pattern) == '=') {
!         rc = (strcmp(input, p->pattern+1) == 0 ? 1 : 0);
      }
      else {
          /* it is really a regexp pattern, so apply it */
--- 1783,1792 ----
          rc = (compare_lexicography(input, p->pattern+1) == -1 ? 1 : 0);
      }
      else if (strlen(p->pattern) > 1 && *(p->pattern) == '=') {
!         if (strcmp(p->pattern+1, "\"\"") == 0)
!             rc = (*input == '\0');
!         else
!             rc = (strcmp(input, p->pattern+1) == 0 ? 1 : 0);
      }
      else {
          /* it is really a regexp pattern, so apply it */


Mime
View raw message