diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 7c641e024..2662e5f6e 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -61,6 +61,7 @@ static ngx_uint_t argument_number[] = { char * ngx_conf_param(ngx_conf_t *cf) { + char *rv; ngx_str_t *param; ngx_buf_t b; ngx_conf_file_t conf_file; @@ -82,13 +83,17 @@ ngx_conf_param(ngx_conf_t *cf) b.temporary = 1; conf_file.file.fd = NGX_INVALID_FILE; - conf_file.file.name.data = (u_char *) "command line"; - conf_file.line = 1; + conf_file.file.name.data = NULL; + conf_file.line = 0; cf->conf_file = &conf_file; cf->conf_file->buffer = &b; - return ngx_conf_parse(cf, NULL); + rv = ngx_conf_parse(cf, NULL); + + cf->conf_file = NULL; + + return rv; } @@ -973,6 +978,12 @@ ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err, return; } + if (cf->conf_file->file.fd == NGX_INVALID_FILE) { + ngx_log_error(level, cf->log, 0, "%*s in command line", + p - errstr, errstr); + return; + } + ngx_log_error(level, cf->log, 0, "%*s in %s:%ui", p - errstr, errstr, cf->conf_file->file.name.data, cf->conf_file->line);