httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <...@manyfish.co.uk>
Subject Re: cvs commit: httpd-2.0/modules/dav/main util.c
Date Thu, 24 Apr 2003 09:47:40 GMT
On Tue, Apr 22, 2003 at 09:52:47PM -0000, Justin Erenkrantz wrote:
> jerenkrantz    2003/04/22 14:52:46
> 
>   Modified:    modules/dav/main util.c
>   Log:
>   Fix a typo in the weak entity check.  The prefix is W/" not "W/.

This code can be simplified to avoid the strdups:

Index: modules/dav/main/util.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/dav/main/util.c,v
retrieving revision 1.48
diff -u -r1.48 util.c
--- modules/dav/main/util.c	22 Apr 2003 21:52:46 -0000	1.48
+++ modules/dav/main/util.c	24 Apr 2003 09:45:11 -0000
@@ -1072,33 +1072,18 @@
             switch(state_list->type) {
             case dav_if_etag:
             {
-                const char *given_etag, *current_etag;
-                char *new_etag;
+                const char *given_etag = state_list->etag;
+                const char *current_etag = etag;
                 int mismatch;
 
                 /* Do a weak entity comparison function as defined in
                  * RFC 2616 13.3.3.
                  */
-                if (state_list->etag[0] == 'W' &&
-                    state_list->etag[1] == '/' &&
-                    state_list->etag[2] == '"') {
-                    new_etag = apr_pstrdup(p, state_list->etag);
-                    new_etag += 2;
-                    given_etag = new_etag;
-                }
-                else {
-                    given_etag = state_list->etag;
-                }
-                if (etag[0] == 'W' &&
-                    etag[1] == '/' &&
-                    etag[2] == '"') {
-                    new_etag = apr_pstrdup(p, etag);
-                    new_etag += 2;
-                    current_etag = new_etag;
-                }
-                else {
-                    current_etag = etag;
-                }
+                if (given_etag[0] == 'W' && given_etag[1] == '/')
+                    given_etag += 2;
+
+                if (current_etag[0] == 'W' && current_etag[1] == '/')
+                    current_etag += 2;
 
                 mismatch = strcmp(given_etag, current_etag);
 

Mime
View raw message