captures in regex location

Igor Sysoev is at rambler-co.ru
Sat Mar 7 14:53:54 MSK 2009


On Sat, Mar 07, 2009 at 02:22:43PM +0300, Vladimir Sopot wrote:

> Вроде вот так -

Дополнительный патч.


-- 
Игорь Сысоев
http://sysoev.ru
-------------- next part --------------
Index: src/http/ngx_http_request.c
===================================================================
--- src/http/ngx_http_request.c	(revision 1871)
+++ src/http/ngx_http_request.c	(working copy)
@@ -1611,6 +1611,7 @@
 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len)
 {
     u_char                    *server;
+    size_t                     clen;
     ngx_uint_t                 hash;
     ngx_http_virtual_names_t  *vn;
     ngx_http_core_loc_conf_t  *clcf;
@@ -1653,7 +1654,7 @@
         name.len = len;
         name.data = server;
 
-        len = 0;
+        clen = 0;
 
         sn = vn->regex;
 
@@ -1661,9 +1662,9 @@
 
             if (sn[i].captures && r->captures == NULL) {
 
-                len = (NGX_HTTP_MAX_CAPTURES + 1) * 3 * sizeof(int);
+                clen = (NGX_HTTP_MAX_CAPTURES + 1) * 3 * sizeof(int);
 
-                r->captures = ngx_palloc(r->pool, len);
+                r->captures = ngx_palloc(r->pool, clen);
                 if (r->captures == NULL) {
                     return NGX_ERROR;
                 }
@@ -1679,7 +1680,7 @@
                 }
             }
 
-            n = ngx_regex_exec(sn[i].regex, &name, r->captures, len);
+            n = ngx_regex_exec(sn[i].regex, &name, r->captures, clen);
 
             if (n == NGX_REGEX_NO_MATCHED) {
                 continue;
@@ -1697,7 +1698,7 @@
 
             cscf = sn[i].core_srv_conf;
 
-            r->ncaptures = len;
+            r->ncaptures = clen;
             r->captures_data = server;
 
             goto found;


More information about the nginx-ru mailing list