Mercurial > hg > nginx-vendor-0-5
comparison src/core/ngx_conf_file.c @ 288:0b1cc3960e27 NGINX_0_5_14
nginx 0.5.14
*) Bugfix: nginx ignored superfluous closing "}" in the end of
configuration file.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Fri, 23 Feb 2007 00:00:00 +0300 |
parents | 5bef04fc3fd5 |
children | 94e16de3c33f |
comparison
equal
deleted
inserted
replaced
287:eaccdcfdfe41 | 288:0b1cc3960e27 |
---|---|
139 * NGX_CONF_BLOCK_DONE the "}" was found | 139 * NGX_CONF_BLOCK_DONE the "}" was found |
140 * NGX_CONF_FILE_DONE the configuration file is done | 140 * NGX_CONF_FILE_DONE the configuration file is done |
141 */ | 141 */ |
142 | 142 |
143 if (rc == NGX_ERROR) { | 143 if (rc == NGX_ERROR) { |
144 break; | 144 goto done; |
145 } | 145 } |
146 | 146 |
147 if (rc == NGX_CONF_BLOCK_DONE) { | 147 if (rc == NGX_CONF_BLOCK_DONE) { |
148 if (!block) { | |
149 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "unexpected \"}\""); | |
150 goto failed; | |
151 } | |
152 | |
148 block = 0; | 153 block = 0; |
149 } | 154 } |
150 | 155 |
151 if (rc == NGX_CONF_FILE_DONE && block) { | 156 if (rc == NGX_CONF_FILE_DONE && block) { |
152 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 157 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
153 "unexpected end of file in %s:%ui, expecting \"}\"", | 158 "unexpected end of file, expecting \"}\""); |
154 cf->conf_file->file.name.data, | 159 goto failed; |
155 cf->conf_file->line); | |
156 rc = NGX_ERROR; | |
157 break; | |
158 } | 160 } |
159 | 161 |
160 if (rc != NGX_OK && rc != NGX_CONF_BLOCK_START) { | 162 if (rc != NGX_OK && rc != NGX_CONF_BLOCK_START) { |
161 break; | 163 goto done; |
162 } | 164 } |
163 | 165 |
164 if (cf->handler) { | 166 if (cf->handler) { |
165 | 167 |
166 /* | 168 /* |
172 if (rv == NGX_CONF_OK) { | 174 if (rv == NGX_CONF_OK) { |
173 continue; | 175 continue; |
174 } | 176 } |
175 | 177 |
176 if (rv == NGX_CONF_ERROR) { | 178 if (rv == NGX_CONF_ERROR) { |
177 rc = NGX_ERROR; | 179 goto failed; |
178 break; | 180 } |
179 } | 181 |
180 | 182 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, rv); |
181 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 183 |
182 "%s in %s:%ui", | 184 goto failed; |
183 rv, cf->conf_file->file.name.data, | |
184 cf->conf_file->line); | |
185 rc = NGX_ERROR; | |
186 break; | |
187 } | 185 } |
188 | 186 |
189 | 187 |
190 rc = ngx_conf_handler(cf, rc); | 188 rc = ngx_conf_handler(cf, rc); |
191 | 189 |
192 if (rc == NGX_ERROR) { | 190 if (rc == NGX_ERROR) { |
193 break; | 191 goto failed; |
194 } | 192 } |
195 } | 193 } |
196 | 194 |
195 failed: | |
196 | |
197 rc = NGX_ERROR; | |
198 | |
199 done: | |
197 | 200 |
198 if (filename) { | 201 if (filename) { |
199 ngx_free(cf->conf_file->buffer->start); | 202 ngx_free(cf->conf_file->buffer->start); |
200 | 203 |
201 cf->conf_file = prev; | 204 cf->conf_file = prev; |
265 | 268 |
266 goto not_allowed; | 269 goto not_allowed; |
267 } | 270 } |
268 | 271 |
269 if (!(cmd->type & NGX_CONF_BLOCK) && last != NGX_OK) { | 272 if (!(cmd->type & NGX_CONF_BLOCK) && last != NGX_OK) { |
270 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 273 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
271 "directive \"%s\" in %s:%ui " | 274 "directive \"%s\" is not terminated by \";\"", |
272 "is not terminated by \";\"", | 275 name->data); |
273 name->data, cf->conf_file->file.name.data, | |
274 cf->conf_file->line); | |
275 return NGX_ERROR; | 276 return NGX_ERROR; |
276 } | 277 } |
277 | 278 |
278 if ((cmd->type & NGX_CONF_BLOCK) && last != NGX_CONF_BLOCK_START) { | 279 if ((cmd->type & NGX_CONF_BLOCK) && last != NGX_CONF_BLOCK_START) { |
279 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 280 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
280 "directive \"%s\" in %s:%ui " | 281 "directive \"%s\" has no opening \"{\"", |
281 "has not the opening \"{\"", | 282 name->data); |
282 name->data, cf->conf_file->file.name.data, | |
283 cf->conf_file->line); | |
284 return NGX_ERROR; | 283 return NGX_ERROR; |
285 } | 284 } |
286 | 285 |
287 /* is the directive's argument count right ? */ | 286 /* is the directive's argument count right ? */ |
288 | 287 |
342 | 341 |
343 if (rv == NGX_CONF_ERROR) { | 342 if (rv == NGX_CONF_ERROR) { |
344 return NGX_ERROR; | 343 return NGX_ERROR; |
345 } | 344 } |
346 | 345 |
347 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 346 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
348 "the \"%s\" directive %s in %s:%ui", | 347 "the \"%s\" directive %s", name->data, rv); |
349 name->data, rv, cf->conf_file->file.name.data, | |
350 cf->conf_file->line); | |
351 | 348 |
352 return NGX_ERROR; | 349 return NGX_ERROR; |
353 } | 350 } |
354 } | 351 } |
355 | 352 |
356 if (multi == 0) { | 353 if (multi == 0) { |
357 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 354 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
358 "unknown directive \"%s\" in %s:%ui", | 355 "unknown directive \"%s\"", name->data); |
359 name->data, cf->conf_file->file.name.data, | |
360 cf->conf_file->line); | |
361 | 356 |
362 return NGX_ERROR; | 357 return NGX_ERROR; |
363 } | 358 } |
364 | 359 |
365 not_allowed: | 360 not_allowed: |
366 | 361 |
367 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 362 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
368 "directive \"%s\" in %s:%ui " | 363 "directive \"%s\" is not allowed here", name->data); |
369 "is not allowed here", | |
370 name->data, cf->conf_file->file.name.data, | |
371 cf->conf_file->line); | |
372 return NGX_ERROR; | 364 return NGX_ERROR; |
373 | 365 |
374 invalid: | 366 invalid: |
375 | 367 |
376 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 368 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
377 "invalid number arguments in " | 369 "invalid number arguments in directive \"%s\"", |
378 "directive \"%s\" in %s:%ui", | 370 name->data); |
379 name->data, cf->conf_file->file.name.data, | |
380 cf->conf_file->line); | |
381 | 371 |
382 return NGX_ERROR; | 372 return NGX_ERROR; |
383 } | 373 } |
384 | 374 |
385 | 375 |
410 if (b->pos >= b->last) { | 400 if (b->pos >= b->last) { |
411 if (cf->conf_file->file.offset | 401 if (cf->conf_file->file.offset |
412 >= ngx_file_size(&cf->conf_file->file.info)) | 402 >= ngx_file_size(&cf->conf_file->file.info)) |
413 { | 403 { |
414 if (cf->args->nelts > 0) { | 404 if (cf->args->nelts > 0) { |
415 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 405 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
416 "unexpected end of file in %s:%ui, " | 406 "unexpected end of file, " |
417 "expecting \";\" or \"}\"", | 407 "expecting \";\" or \"}\""); |
418 cf->conf_file->file.name.data, | |
419 cf->conf_file->line); | |
420 return NGX_ERROR; | 408 return NGX_ERROR; |
421 } | 409 } |
422 | 410 |
423 return NGX_CONF_FILE_DONE; | 411 return NGX_CONF_FILE_DONE; |
424 } | 412 } |
478 if (ch == ')') { | 466 if (ch == ')') { |
479 last_space = 1; | 467 last_space = 1; |
480 need_space = 0; | 468 need_space = 0; |
481 | 469 |
482 } else { | 470 } else { |
483 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 471 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
484 "unexpected \"%c\" in %s:%ui", | 472 "unexpected \"%c\"", ch); |
485 ch, cf->conf_file->file.name.data, | |
486 cf->conf_file->line); | |
487 | |
488 return NGX_ERROR; | 473 return NGX_ERROR; |
489 } | 474 } |
490 } | 475 } |
491 | 476 |
492 if (last_space) { | 477 if (last_space) { |
499 switch (ch) { | 484 switch (ch) { |
500 | 485 |
501 case ';': | 486 case ';': |
502 case '{': | 487 case '{': |
503 if (cf->args->nelts == 0) { | 488 if (cf->args->nelts == 0) { |
504 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 489 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
505 "unexpected \"%c\" in %s:%ui", | 490 "unexpected \"%c\"", ch); |
506 ch, cf->conf_file->file.name.data, | |
507 cf->conf_file->line); | |
508 return NGX_ERROR; | 491 return NGX_ERROR; |
509 } | 492 } |
510 | 493 |
511 if (ch == '{') { | 494 if (ch == '{') { |
512 return NGX_CONF_BLOCK_START; | 495 return NGX_CONF_BLOCK_START; |
514 | 497 |
515 return NGX_OK; | 498 return NGX_OK; |
516 | 499 |
517 case '}': | 500 case '}': |
518 if (cf->args->nelts != 0) { | 501 if (cf->args->nelts != 0) { |
519 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 502 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
520 "unexpected \"}\" in %s:%ui", | 503 "unexpected \"}\""); |
521 cf->conf_file->file.name.data, | |
522 cf->conf_file->line); | |
523 return NGX_ERROR; | 504 return NGX_ERROR; |
524 } | 505 } |
525 | 506 |
526 return NGX_CONF_BLOCK_DONE; | 507 return NGX_CONF_BLOCK_DONE; |
527 | 508 |