Gentoo Archives: gentoo-commits

From: "Thomas Sachau (tommy)" <tommy@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in www-servers/lighttpd/files: lighttpd-1.4.24-mod_rewrite-without-pcre.patch
Date: Thu, 05 Nov 2009 18:19:56
Message-Id: E1N66vj-0004BS-7h@stork.gentoo.org
1 tommy 09/11/05 18:19:31
2
3 Added: lighttpd-1.4.24-mod_rewrite-without-pcre.patch
4 Log:
5 Dont build mod_rewrite with disabled pcre USE flag, fixes bug 291183
6 (Portage version: 2.2_rc48-r1/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 www-servers/lighttpd/files/lighttpd-1.4.24-mod_rewrite-without-pcre.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/www-servers/lighttpd/files/lighttpd-1.4.24-mod_rewrite-without-pcre.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/www-servers/lighttpd/files/lighttpd-1.4.24-mod_rewrite-without-pcre.patch?rev=1.1&content-type=text/plain
13
14 Index: lighttpd-1.4.24-mod_rewrite-without-pcre.patch
15 ===================================================================
16 --- src/mod_rewrite.c (revision 2682)
17 +++ src/mod_rewrite.c (revision 2683)
18 @@ -9,10 +9,9 @@
19 #include <stdlib.h>
20 #include <string.h>
21
22 -typedef struct {
23 #ifdef HAVE_PCRE_H
24 +typedef struct {
25 pcre *key;
26 -#endif
27
28 buffer *value;
29
30 @@ -70,7 +69,6 @@
31 }
32
33 static int rewrite_rule_buffer_append(rewrite_rule_buffer *kvb, buffer *key, buffer *value, int once) {
34 -#ifdef HAVE_PCRE_H
35 size_t i;
36 const char *errptr;
37 int erroff;
38 @@ -109,18 +107,9 @@
39 kvb->used++;
40
41 return 0;
42 -#else
43 - UNUSED(kvb);
44 - UNUSED(value);
45 - UNUSED(once);
46 - UNUSED(key);
47 -
48 - return -1;
49 -#endif
50 }
51
52 static void rewrite_rule_buffer_free(rewrite_rule_buffer *kvb) {
53 -#ifdef HAVE_PCRE_H
54 size_t i;
55
56 for (i = 0; i < kvb->size; i++) {
57 @@ -130,7 +119,6 @@
58 }
59
60 if (kvb->ptr) free(kvb->ptr);
61 -#endif
62
63 free(kvb);
64 }
65 @@ -201,24 +189,29 @@
66 ((data_string *)(da->value->data[j]))->key,
67 ((data_string *)(da->value->data[j]))->value,
68 once)) {
69 -#ifdef HAVE_PCRE_H
70 log_error_write(srv, __FILE__, __LINE__, "sb",
71 "pcre-compile failed for", da->value->data[j]->key);
72 -#else
73 - log_error_write(srv, __FILE__, __LINE__, "s",
74 - "pcre support is missing, please install libpcre and the headers");
75 -#endif
76 }
77 }
78 }
79
80 return 0;
81 }
82 +#else
83 +static int parse_config_entry(server *srv, array *ca, const char *option) {
84 + static int logged_message = 0;
85 + if (logged_message) return 0;
86 + if (NULL != array_get_element(ca, option)) {
87 + logged_message = 1;
88 + log_error_write(srv, __FILE__, __LINE__, "s",
89 + "pcre support is missing, please install libpcre and the headers");
90 + }
91 + return 0;
92 +}
93 +#endif
94
95 SETDEFAULTS_FUNC(mod_rewrite_set_defaults) {
96 - plugin_data *p = p_d;
97 size_t i = 0;
98 -
99 config_values_t cv[] = {
100 { "url.rewrite-repeat", NULL, T_CONFIG_LOCAL, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
101 { "url.rewrite-once", NULL, T_CONFIG_LOCAL, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
102 @@ -243,33 +236,37 @@
103 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
104 };
105
106 +#ifdef HAVE_PCRE_H
107 + plugin_data *p = p_d;
108 +
109 if (!p) return HANDLER_ERROR;
110
111 /* 0 */
112 p->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
113 +#else
114 + UNUSED(p_d);
115 +#endif
116
117 for (i = 0; i < srv->config_context->used; i++) {
118 - plugin_config *s;
119 array *ca;
120 +#ifdef HAVE_PCRE_H
121 + plugin_config *s;
122
123 s = calloc(1, sizeof(plugin_config));
124 s->rewrite = rewrite_rule_buffer_init();
125 s->rewrite_NF = rewrite_rule_buffer_init();
126 -
127 - cv[0].destination = s->rewrite;
128 - cv[1].destination = s->rewrite;
129 - cv[2].destination = s->rewrite_NF;
130 - cv[3].destination = s->rewrite_NF;
131 - cv[4].destination = s->rewrite;
132 - cv[5].destination = s->rewrite;
133 -
134 p->config_storage[i] = s;
135 +#endif
136 +
137 ca = ((data_config *)srv->config_context->data[i])->value;
138
139 if (0 != config_insert_values_global(srv, ca, cv)) {
140 return HANDLER_ERROR;
141 }
142
143 +#ifndef HAVE_PCRE_H
144 +# define parse_config_entry(srv, ca, x, option, y) parse_config_entry(srv, ca, option)
145 +#endif
146 parse_config_entry(srv, ca, s->rewrite, "url.rewrite-once", 1);
147 parse_config_entry(srv, ca, s->rewrite, "url.rewrite-final", 1);
148 parse_config_entry(srv, ca, s->rewrite_NF, "url.rewrite-if-not-file", 1);
149 @@ -280,7 +277,9 @@
150
151 return HANDLER_GO_ON;
152 }
153 +
154 #ifdef HAVE_PCRE_H
155 +
156 #define PATCH(x) \
157 p->conf.x = s->x;
158 static int mod_rewrite_patch_connection(server *srv, connection *con, plugin_data *p) {
159 @@ -330,7 +329,7 @@
160
161 return 0;
162 }
163 -#endif
164 +
165 URIHANDLER_FUNC(mod_rewrite_con_reset) {
166 plugin_data *p = p_d;
167
168 @@ -345,7 +344,6 @@
169 }
170
171 static int process_rewrite_rules(server *srv, connection *con, plugin_data *p, rewrite_rule_buffer *kvb) {
172 -#ifdef HAVE_PCRE_H
173 size_t i;
174 handler_ctx *hctx;
175
176 @@ -444,19 +442,11 @@
177 }
178 #undef N
179 }
180 -#else
181 - UNUSED(srv);
182 - UNUSED(con);
183 - UNUSED(p);
184 - UNUSED(hctx);
185 - UNUSED(kvb);
186 -#endif
187
188 return HANDLER_GO_ON;
189 }
190
191 URIHANDLER_FUNC(mod_rewrite_physical) {
192 -#ifdef HAVE_PCRE_H
193 plugin_data *p = p_d;
194 handler_t r;
195 stat_cache_entry *sce;
196 @@ -480,17 +470,11 @@
197 default:
198 return r;
199 }
200 -#else
201 - UNUSED(srv);
202 - UNUSED(con);
203 - UNUSED(p_d);
204 -#endif
205
206 return HANDLER_GO_ON;
207 }
208
209 URIHANDLER_FUNC(mod_rewrite_uri_handler) {
210 -#ifdef HAVE_PCRE_H
211 plugin_data *p = p_d;
212
213 mod_rewrite_patch_connection(srv, con, p);
214 @@ -498,29 +482,27 @@
215 if (!p->conf.rewrite) return HANDLER_GO_ON;
216
217 return process_rewrite_rules(srv, con, p, p->conf.rewrite);
218 -#else
219 - UNUSED(srv);
220 - UNUSED(con);
221 - UNUSED(p_d);
222 -#endif
223
224 return HANDLER_GO_ON;
225 }
226 +#endif
227
228 int mod_rewrite_plugin_init(plugin *p);
229 int mod_rewrite_plugin_init(plugin *p) {
230 p->version = LIGHTTPD_VERSION_ID;
231 p->name = buffer_init_string("rewrite");
232
233 +#ifdef HAVE_PCRE_H
234 p->init = mod_rewrite_init;
235 /* it has to stay _raw as we are matching on uri + querystring
236 */
237
238 p->handle_uri_raw = mod_rewrite_uri_handler;
239 p->handle_physical = mod_rewrite_physical;
240 - p->set_defaults = mod_rewrite_set_defaults;
241 p->cleanup = mod_rewrite_free;
242 p->connection_reset = mod_rewrite_con_reset;
243 +#endif
244 + p->set_defaults = mod_rewrite_set_defaults;
245
246 p->data = NULL;