comparison src/http/modules/ngx_http_ssi_filter_module.c @ 3325:42c16d8bddbe

regex named captures
author Igor Sysoev <igor@sysoev.ru>
date Mon, 16 Nov 2009 12:19:02 +0000
parents be47fe127f8c
children 6b8e5c882e47
comparison
equal deleted inserted replaced
3324:616da2ea901f 3325:42c16d8bddbe
2448 rc = ngx_strncmp(left.data, right.data, right.len); 2448 rc = ngx_strncmp(left.data, right.data, right.len);
2449 } 2449 }
2450 2450
2451 } else { 2451 } else {
2452 #if (NGX_PCRE) 2452 #if (NGX_PCRE)
2453 ngx_str_t err; 2453 ngx_regex_compile_t rgc;
2454 ngx_regex_t *regex; 2454 u_char errstr[NGX_MAX_CONF_ERRSTR];
2455 u_char errstr[NGX_MAX_CONF_ERRSTR];
2456
2457 err.len = NGX_MAX_CONF_ERRSTR;
2458 err.data = errstr;
2459 2455
2460 right.data[right.len] = '\0'; 2456 right.data[right.len] = '\0';
2461 2457
2462 regex = ngx_regex_compile(&right, 0, r->pool, &err); 2458 ngx_memzero(&rgc, sizeof(ngx_regex_compile_t));
2463 2459
2464 if (regex == NULL) { 2460 rgc.pattern = right;
2465 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%s", err.data); 2461 rgc.pool = r->pool;
2462 rgc.err.len = NGX_MAX_CONF_ERRSTR;
2463 rgc.err.data = errstr;
2464
2465 if (ngx_regex_compile(&rgc) != NGX_OK) {
2466 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%V", &rgc.err);
2466 return NGX_HTTP_SSI_ERROR; 2467 return NGX_HTTP_SSI_ERROR;
2467 } 2468 }
2468 2469
2469 rc = ngx_regex_exec(regex, &left, NULL, 0); 2470 rc = ngx_regex_exec(rgc.regex, &left, NULL, 0);
2470 2471
2471 if (rc < NGX_REGEX_NO_MATCHED) { 2472 if (rc < NGX_REGEX_NO_MATCHED) {
2472 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 2473 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
2473 ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"", 2474 ngx_regex_exec_n " failed: %i on \"%V\" using \"%V\"",
2474 rc, &left, &right); 2475 rc, &left, &right);
2475 return NGX_HTTP_SSI_ERROR; 2476 return NGX_HTTP_SSI_ERROR;
2476 } 2477 }
2477 #else 2478 #else
2478 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 2479 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,