Mercurial > hg > nginx
comparison src/http/modules/ngx_http_rewrite_module.c @ 2547:912ce4113f21
now regex captures are per-request entities
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 06 Mar 2009 12:15:07 +0000 |
parents | 989176d3ffc5 |
children | c7d57b539248 2efa8d2fcde1 |
comparison
equal
deleted
inserted
replaced
2546:8b9861c2a32f | 2547:912ce4113f21 |
---|---|
10 | 10 |
11 | 11 |
12 typedef struct { | 12 typedef struct { |
13 ngx_array_t *codes; /* uintptr_t */ | 13 ngx_array_t *codes; /* uintptr_t */ |
14 | 14 |
15 ngx_uint_t captures; | |
16 ngx_uint_t stack_size; | 15 ngx_uint_t stack_size; |
17 | 16 |
18 ngx_flag_t log; | 17 ngx_flag_t log; |
19 ngx_flag_t uninitialized_variable_warn; | 18 ngx_flag_t uninitialized_variable_warn; |
20 } ngx_http_rewrite_loc_conf_t; | 19 } ngx_http_rewrite_loc_conf_t; |
155 rlcf->stack_size * sizeof(ngx_http_variable_value_t)); | 154 rlcf->stack_size * sizeof(ngx_http_variable_value_t)); |
156 if (e->sp == NULL) { | 155 if (e->sp == NULL) { |
157 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 156 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
158 } | 157 } |
159 | 158 |
160 if (rlcf->captures) { | |
161 e->captures = ngx_palloc(r->pool, rlcf->captures * sizeof(int)); | |
162 if (e->captures == NULL) { | |
163 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
164 } | |
165 | |
166 } else { | |
167 e->captures = NULL; | |
168 } | |
169 | |
170 e->ip = rlcf->codes->elts; | 159 e->ip = rlcf->codes->elts; |
171 e->request = r; | 160 e->request = r; |
172 e->quote = 1; | 161 e->quote = 1; |
173 e->log = rlcf->log; | 162 e->log = rlcf->log; |
174 e->status = NGX_DECLINED; | 163 e->status = NGX_DECLINED; |
434 regex->ncaptures = (ngx_uint_t) n; | 423 regex->ncaptures = (ngx_uint_t) n; |
435 } | 424 } |
436 | 425 |
437 if (regex->ncaptures) { | 426 if (regex->ncaptures) { |
438 regex->ncaptures = (regex->ncaptures + 1) * 3; | 427 regex->ncaptures = (regex->ncaptures + 1) * 3; |
439 | |
440 if (lcf->captures < regex->ncaptures) { | |
441 lcf->captures = regex->ncaptures; | |
442 } | |
443 } | 428 } |
444 | 429 |
445 regex_end = ngx_http_script_add_code(lcf->codes, | 430 regex_end = ngx_http_script_add_code(lcf->codes, |
446 sizeof(ngx_http_script_regex_end_code_t), | 431 sizeof(ngx_http_script_regex_end_code_t), |
447 ®ex); | 432 ®ex); |
616 if (rv != NGX_CONF_OK) { | 601 if (rv != NGX_CONF_OK) { |
617 return rv; | 602 return rv; |
618 } | 603 } |
619 | 604 |
620 | 605 |
621 if (lcf->captures < nlcf->captures) { | |
622 lcf->captures = nlcf->captures; | |
623 } | |
624 | |
625 | |
626 if (elts != lcf->codes->elts) { | 606 if (elts != lcf->codes->elts) { |
627 if_code = (ngx_http_script_if_code_t *) | 607 if_code = (ngx_http_script_if_code_t *) |
628 ((u_char *) if_code + ((u_char *) lcf->codes->elts - elts)); | 608 ((u_char *) if_code + ((u_char *) lcf->codes->elts - elts)); |
629 } | 609 } |
630 | 610 |
775 | 755 |
776 n = ngx_regex_capture_count(regex->regex); | 756 n = ngx_regex_capture_count(regex->regex); |
777 | 757 |
778 if (n) { | 758 if (n) { |
779 regex->ncaptures = (n + 1) * 3; | 759 regex->ncaptures = (n + 1) * 3; |
780 | |
781 if (lcf->captures < regex->ncaptures) { | |
782 lcf->captures = regex->ncaptures; | |
783 } | |
784 } | 760 } |
785 | 761 |
786 return NGX_CONF_OK; | 762 return NGX_CONF_OK; |
787 } | 763 } |
788 | 764 |