httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Erenkrantz <jerenkra...@ebuilt.com>
Subject Re: [PATCH] Make apr_table_elts const
Date Sun, 11 Nov 2001 09:12:37 GMT
On Sat, Nov 10, 2001 at 04:46:00PM -0800, Brian Pane wrote:
> All the current uses of apr_table_elts in Apache 2.0 are for
> const iterators, so the only change required to the httpd code
> is the replacement of "apr_array_header_t*" declarations with
> "const apr_array_header_t*" (the patch includes the diffs for
> all the affected files).

You missed a few files - namely mod_dav, mod_cgid, and proxy.
And, you didn't catch all of the instances of apr_table_entry_t 
now being const (some of them were being casted to 
apr_table_entry_t, so you didn't catch that they were losing 
constness?).  The patch below compiles without warnings and
should achieve your intended result.

This patch should catch all cases *except* for mod_isapi.c.  
It's 1AM (I've been up since 7AM for the GRE CS test yesterday)
and it's not in our code style and it's doing something odd, 
so there's no way I'm groking whatever the hell that file is 
doing tonight.  If you want a reason why all files should be in 
one code style, you've got one - analyzing code at 1AM.  =)
-- justin

Index: modules/dav/main/mod_dav.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/dav/main/mod_dav.c,v
retrieving revision 1.63
diff -u -r1.63 mod_dav.c
--- modules/dav/main/mod_dav.c	2001/11/02 19:25:50	1.63
+++ modules/dav/main/mod_dav.c	2001/11/11 08:47:37
@@ -1216,8 +1216,8 @@
                                             const apr_table_t *methods,
                                             ap_text_header *body)
 {
-    apr_array_header_t *arr;
-    apr_table_entry_t *elts;
+    const apr_array_header_t *arr;
+    const apr_table_entry_t *elts;
     ap_xml_elem *child;
     ap_xml_attr *attr;
     char *s;
@@ -1228,7 +1228,7 @@
     if (elem->first_child == NULL) {
         /* show all supported methods */
         arr = apr_table_elts(methods);
-        elts = (apr_table_entry_t *) arr->elts;
+        elts = (const apr_table_entry_t *) arr->elts;
 
         for (i = 0; i < arr->nelts; ++i) {
             if (elts[i].key == NULL)
@@ -1459,8 +1459,8 @@
     const char *dav_level;
     char *allow;
     char *s;
-    apr_array_header_t *arr;
-    apr_table_entry_t *elts;
+    const apr_array_header_t *arr;
+    const apr_table_entry_t *elts;
     apr_table_t *methods = apr_table_make(r->pool, 12);
     ap_text_header vsn_options = { 0 };
     ap_text_header body = { 0 };
@@ -1641,7 +1641,7 @@
 
     /* Generate the Allow header */
     arr = apr_table_elts(methods);
-    elts = (apr_table_entry_t *) arr->elts;
+    elts = (const apr_table_entry_t *) arr->elts;
     text_size = 0;
 
     /* first, compute total length */
Index: modules/filters/mod_include.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/filters/mod_include.c,v
retrieving revision 1.150
diff -u -r1.150 mod_include.c
--- modules/filters/mod_include.c	2001/09/19 06:25:07	1.150
+++ modules/filters/mod_include.c	2001/11/11 08:47:38
@@ -2601,8 +2601,8 @@
     if (ctx->flags & FLAG_PRINTING) {
         ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, 1);
         if ((tag == NULL) && (tag_val == NULL)) {
-            apr_array_header_t *arr = apr_table_elts(r->subprocess_env);
-            apr_table_entry_t *elts = (apr_table_entry_t *)arr->elts;
+            const apr_array_header_t *arr = apr_table_elts(r->subprocess_env);
+            const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts;
             int i;
             const char *key_text, *val_text;
             apr_size_t   k_len, v_len, t_wrt;
Index: modules/generators/mod_cgi.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgi.c,v
retrieving revision 1.106
diff -u -r1.106 mod_cgi.c
--- modules/generators/mod_cgi.c	2001/09/18 03:33:30	1.106
+++ modules/generators/mod_cgi.c	2001/11/11 08:47:38
@@ -257,8 +257,8 @@
 		  char *dbuf, const char *sbuf, apr_file_t *script_in, 
                   apr_file_t *script_err)
 {
-    apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in);
-    apr_table_entry_t *hdrs = (apr_table_entry_t *) hdrs_arr->elts;
+    const apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in);
+    const apr_table_entry_t *hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
     char argsbuffer[HUGE_STRING_LEN];
     apr_file_t *f = NULL;
     int i;
@@ -300,7 +300,7 @@
 
     apr_file_puts("%response\n", f);
     hdrs_arr = apr_table_elts(r->err_headers_out);
-    hdrs = (apr_table_entry_t *) hdrs_arr->elts;
+    hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
 
     for (i = 0; i < hdrs_arr->nelts; ++i) {
 	if (!hdrs[i].key)
Index: modules/generators/mod_cgid.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgid.c,v
retrieving revision 1.99
diff -u -r1.99 mod_cgid.c
--- modules/generators/mod_cgid.c	2001/10/12 21:39:40	1.99
+++ modules/generators/mod_cgid.c	2001/11/11 08:47:39
@@ -749,8 +749,8 @@
 static int log_script(request_rec *r, cgid_server_conf * conf, int ret, 
                   char *dbuf, const char *sbuf, apr_file_t *script_in, apr_file_t *script_err)

 { 
-    apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in); 
-    apr_table_entry_t *hdrs = (apr_table_entry_t *) hdrs_arr->elts; 
+    const apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in); 
+    const apr_table_entry_t *hdrs = (apr_table_entry_t *) hdrs_arr->elts; 
     char argsbuffer[HUGE_STRING_LEN]; 
     apr_file_t *f = NULL; 
     int i; 
@@ -793,7 +793,7 @@
 
     apr_file_puts("%response\n", f); 
     hdrs_arr = apr_table_elts(r->err_headers_out); 
-    hdrs = (apr_table_entry_t *) hdrs_arr->elts; 
+    hdrs = (const apr_table_entry_t *) hdrs_arr->elts; 
 
     for (i = 0; i < hdrs_arr->nelts; ++i) { 
         if (!hdrs[i].key) 
Index: modules/http/http_request.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_request.c,v
retrieving revision 1.117
diff -u -r1.117 http_request.c
--- modules/http/http_request.c	2001/10/30 19:21:41	1.117
+++ modules/http/http_request.c	2001/11/11 08:47:39
@@ -310,8 +310,8 @@
 
 static apr_table_t *rename_original_env(apr_pool_t *p, apr_table_t *t)
 {
-    apr_array_header_t *env_arr = apr_table_elts(t);
-    apr_table_entry_t *elts = (apr_table_entry_t *) env_arr->elts;
+    const apr_array_header_t *env_arr = apr_table_elts(t);
+    const apr_table_entry_t *elts = (const apr_table_entry_t *) env_arr->elts;
     apr_table_t *new = apr_table_make(p, env_arr->nalloc);
     int i;
 
Index: modules/mappers/mod_rewrite.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
retrieving revision 1.85
diff -u -r1.85 mod_rewrite.c
--- modules/mappers/mod_rewrite.c	2001/10/21 17:56:36	1.85
+++ modules/mappers/mod_rewrite.c	2001/11/11 08:47:39
@@ -3627,12 +3627,12 @@
 
 static char *lookup_header(request_rec *r, const char *name)
 {
-    apr_array_header_t *hdrs_arr;
-    apr_table_entry_t *hdrs;
+    const apr_array_header_t *hdrs_arr;
+    const apr_table_entry_t *hdrs;
     int i;
 
     hdrs_arr = apr_table_elts(r->headers_in);
-    hdrs = (apr_table_entry_t *)hdrs_arr->elts;
+    hdrs = (const apr_table_entry_t *)hdrs_arr->elts;
     for (i = 0; i < hdrs_arr->nelts; ++i) {
         if (hdrs[i].key == NULL) {
             continue;
Index: modules/metadata/mod_env.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_env.c,v
retrieving revision 1.25
diff -u -r1.25 mod_env.c
--- modules/metadata/mod_env.c	2001/10/21 01:17:11	1.25
+++ modules/metadata/mod_env.c	2001/11/11 08:47:39
@@ -92,8 +92,8 @@
     env_dir_config_rec *add = addv;
     env_dir_config_rec *res = apr_palloc(p, sizeof(*res));
 
-    apr_table_entry_t *elts;
-    apr_array_header_t *arr;
+    const apr_table_entry_t *elts;
+    const apr_array_header_t *arr;
 
     int i;
 
@@ -111,14 +111,14 @@
     res->unsetenv = NULL;
 
     arr = apr_table_elts(add->unsetenv);
-    elts = (apr_table_entry_t *)arr->elts;
+    elts = (const apr_table_entry_t *)arr->elts;
 
     for (i = 0; i < arr->nelts; ++i) {
         apr_table_unset(res->vars, elts[i].key);
     }
 
     arr = apr_table_elts(add->vars);
-    elts = (apr_table_entry_t *)arr->elts;
+    elts = (const apr_table_entry_t *)arr->elts;
 
     for (i = 0; i < arr->nelts; ++i) {
         apr_table_setn(res->vars, elts[i].key, elts[i].val);
Index: modules/metadata/mod_setenvif.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_setenvif.c,v
retrieving revision 1.30
diff -u -r1.30 mod_setenvif.c
--- modules/metadata/mod_setenvif.c	2001/06/12 17:06:01	1.30
+++ modules/metadata/mod_setenvif.c	2001/11/11 08:47:39
@@ -406,7 +406,7 @@
 {
     sei_cfg_rec *sconf;
     sei_entry *entries;
-    apr_table_entry_t *elts;
+    const apr_table_entry_t *elts;
     const char *val;
     int i, j;
     char *last_name;
@@ -459,8 +459,8 @@
                      * the headers_in until we find a match or run out of
                      * headers.
                      */
-                    apr_array_header_t *arr = apr_table_elts(r->headers_in);
-                    elts = (apr_table_entry_t *) arr->elts;
+                    const apr_array_header_t *arr = apr_table_elts(r->headers_in);
+                    elts = (const apr_table_entry_t *) arr->elts;
                     val = NULL;
                     for (j = 0; j < arr->nelts; ++j) {
                         if (!ap_regexec(b->pnamereg, elts[j].key, 0, NULL, 0)) { 
@@ -489,8 +489,8 @@
         }
 
         if (!ap_regexec(b->preg, val, 0, NULL, 0)) {
-	    apr_array_header_t *arr = apr_table_elts(b->features);
-            elts = (apr_table_entry_t *) arr->elts;
+	    const apr_array_header_t *arr = apr_table_elts(b->features);
+            elts = (const apr_table_entry_t *) arr->elts;
 
             for (j = 0; j < arr->nelts; ++j) {
                 if (!strcmp(elts[j].val, "!")) {
Index: modules/proxy/proxy_http.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
retrieving revision 1.106
diff -u -r1.106 proxy_http.c
--- modules/proxy/proxy_http.c	2001/11/05 23:06:55	1.106
+++ modules/proxy/proxy_http.c	2001/11/11 08:47:40
@@ -448,8 +448,8 @@
     char buffer[HUGE_STRING_LEN];
     char *buf;
     apr_bucket *e;
-    apr_array_header_t *headers_in_array;
-    apr_table_entry_t *headers_in;
+    const apr_array_header_t *headers_in_array;
+    const apr_table_entry_t *headers_in;
     int counter;
     /*
      * Send the HTTP/1.1 request to the remote server
@@ -551,7 +551,7 @@
 
     /* send request headers */
     headers_in_array = apr_table_elts(r->headers_in);
-    headers_in = (apr_table_entry_t *) headers_in_array->elts;
+    headers_in = (const apr_table_entry_t *) headers_in_array->elts;
     for (counter = 0; counter < headers_in_array->nelts; counter++) {
         if (headers_in[counter].key == NULL || headers_in[counter].val == NULL
 
Index: server/util_script.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/util_script.c,v
retrieving revision 1.65
diff -u -r1.65 util_script.c
--- server/util_script.c	2001/11/10 18:38:02	1.65
+++ server/util_script.c	2001/11/11 08:47:40
@@ -122,8 +122,8 @@
 
 AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t)
 {
-    apr_array_header_t *env_arr = apr_table_elts(t);
-    apr_table_entry_t *elts = (apr_table_entry_t *) env_arr->elts;
+    const apr_array_header_t *env_arr = apr_table_elts(t);
+    const apr_table_entry_t *elts = (const apr_table_entry_t *) env_arr->elts;
     char **env = (char **) apr_palloc(p, (env_arr->nelts + 2) * sizeof(char *));
     int i, j;
     char *tz;
@@ -169,8 +169,8 @@
     char *env_temp;
 #endif
     const char *host;
-    apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in);
-    apr_table_entry_t *hdrs = (apr_table_entry_t *) hdrs_arr->elts;
+    const apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in);
+    const apr_table_entry_t *hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
     int i;
     apr_port_t rport;
     apr_sockaddr_t *remotesa;
Index: srclib/apr/include/apr_tables.h
===================================================================
RCS file: /home/cvs/apr/include/apr_tables.h,v
retrieving revision 1.23
diff -u -r1.23 apr_tables.h
--- srclib/apr/include/apr_tables.h	2001/08/24 17:55:45	1.23
+++ srclib/apr/include/apr_tables.h	2001/11/11 08:47:40
@@ -137,7 +137,7 @@
  * @param t The table
  * @return An array containing the contents of the table
  */
-#define apr_table_elts(t) ((apr_array_header_t *)(t))
+#define apr_table_elts(t) ((const apr_array_header_t *)(t))
 
 /**
  * Determine if the table is empty


Mime
View raw message