]> git.kaiwu.me - nginx.git/commitdiff
Fixed the "include" directive.
authorRuslan Ermilov <ru@nginx.com>
Tue, 28 Aug 2012 13:31:01 +0000 (13:31 +0000)
committerRuslan Ermilov <ru@nginx.com>
Tue, 28 Aug 2012 13:31:01 +0000 (13:31 +0000)
The "include" directive should be able to include multiple files if
given a filename mask.  Fixed this to work for "include" directives
inside the "map" or "types" blocks.  The "include" directive inside
the "geo" block is still not fixed.

src/core/ngx_conf_file.c
src/core/ngx_conf_file.h
src/http/modules/ngx_http_map_module.c
src/http/ngx_http_core_module.c

index 0aa659cd8bb2b6762d868d3b17fa3da7203b73ee..6da2dae809db085b6d040cdfe0026c41e39886e7 100644 (file)
@@ -12,7 +12,6 @@
 
 static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
 static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
-static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 static ngx_int_t ngx_conf_test_full_name(ngx_str_t *name);
 static void ngx_conf_flush_files(ngx_cycle_t *cycle);
 
@@ -731,7 +730,7 @@ ngx_conf_read_token(ngx_conf_t *cf)
 }
 
 
-static char *
+char *
 ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
     char        *rv;
index 41bacaa9875c3dd99e3cf91c37e5904f0ba1421b..64a9e8fc8d91d01287d686a5aa1a117381b8f9e5 100644 (file)
@@ -317,6 +317,7 @@ char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data);
 
 char *ngx_conf_param(ngx_conf_t *cf);
 char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
+char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 
 
 ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name,
index 54f9ec4459bbdf084fa575e991d8757ec5e858bd..371737b2eac96ec3a8a7103047e1e558c73e14db 100644 (file)
@@ -369,7 +369,7 @@ static char *
 ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
 {
     ngx_int_t                   rc, index;
-    ngx_str_t                  *value, file, name;
+    ngx_str_t                  *value, name;
     ngx_uint_t                  i, key;
     ngx_http_map_conf_ctx_t    *ctx;
     ngx_http_variable_value_t  *var, **vp;
@@ -391,15 +391,7 @@ ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
     }
 
     if (ngx_strcmp(value[0].data, "include") == 0) {
-        file = value[1];
-
-        if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) {
-            return NGX_CONF_ERROR;
-        }
-
-        ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
-
-        return ngx_conf_parse(cf, &file);
+        return ngx_conf_include(cf, dummy, conf);
     }
 
     if (value[1].data[0] == '$') {
index 8667ae9858ae9b0ace681283a1c11f9d460a7a48..5ab9453daf4af907675750f6d8bdcb861cf0cc3b 100644 (file)
@@ -3236,7 +3236,7 @@ ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
 {
     ngx_http_core_loc_conf_t *clcf = conf;
 
-    ngx_str_t       *value, *content_type, *old, file;
+    ngx_str_t       *value, *content_type, *old;
     ngx_uint_t       i, n, hash;
     ngx_hash_key_t  *type;
 
@@ -3249,15 +3249,8 @@ ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
                                " in \"include\" directive");
             return NGX_CONF_ERROR;
         }
-        file = value[1];
 
-        if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) {
-            return NGX_CONF_ERROR;
-        }
-
-        ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
-
-        return ngx_conf_parse(cf, &file);
+        return ngx_conf_include(cf, dummy, conf);
     }
 
     content_type = ngx_palloc(cf->pool, sizeof(ngx_str_t));