diff options
author | Zeev Suraski <zeev@php.net> | 2000-10-30 23:19:48 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2000-10-30 23:19:48 +0000 |
commit | 9596255da8e5e82221fe0ce1daee5865de3af0f4 (patch) | |
tree | 0976de0f50b5eedac0bd3cc6f1c480e7a59e11dd /Zend | |
parent | ea6985a225f060b0923fcc97cc65fada878565cf (diff) | |
download | php-git-9596255da8e5e82221fe0ce1daee5865de3af0f4.tar.gz |
Final touches on the INI parser
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend_globals.h | 2 | ||||
-rw-r--r-- | Zend/zend_ini.h | 2 | ||||
-rw-r--r-- | Zend/zend_ini_parser.y | 16 | ||||
-rw-r--r-- | Zend/zend_ini_scanner.h | 3 | ||||
-rw-r--r-- | Zend/zend_ini_scanner.l | 21 |
5 files changed, 37 insertions, 7 deletions
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 283d026ba1..821a606a42 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -107,6 +107,8 @@ struct _zend_compiler_globals { zend_bool unclean_shutdown; + zend_bool ini_parser_unbuffered_errors; + zend_llist open_files; #if defined(ZTS) && defined(__cplusplus) ZendFlexLexer *ZFL; diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 44628a8277..3411eef40e 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -158,7 +158,7 @@ ZEND_API ZEND_INI_MH(OnUpdateStringUnempty); /* INI parsing engine */ typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, int callback_type, void *arg); -int zend_parse_ini_file(zend_file_handle *fh, zend_ini_parser_cb_t ini_parser_cb, void *arg); +int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg); #define ZEND_INI_PARSER_ENTRY 1 #define ZEND_INI_PARSER_SECTION 2 diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index a8c4687be6..1d87a3d937 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -59,7 +59,6 @@ extern HashTable browser_hash; ZEND_API extern char *php_ini_path; static HashTable *active_hash_table; static zval *current_section; -static char *currently_parsed_filename; static int parsing_mode; @@ -135,24 +134,32 @@ static void ini_error(char *str) { char *error_buf; int error_buf_len; + char *currently_parsed_filename = zend_ini_scanner_get_filename(); + CLS_FETCH(); error_buf_len = 128+strlen(currently_parsed_filename); /* should be more than enough */ error_buf = (char *) emalloc(error_buf_len); sprintf(error_buf, "Error parsing %s on line %d\n", currently_parsed_filename, zend_ini_scanner_get_lineno()); + + if (CG(ini_parser_unbuffered_errors)) { #ifdef PHP_WIN32 - MessageBox(NULL, error_buf, "PHP Error", MB_OK|MB_TOPMOST|0x00200000L); + MessageBox(NULL, error_buf, "PHP Error", MB_OK|MB_TOPMOST|0x00200000L); #else - fprintf(stderr, "PHP: %s", error_buf); + fprintf(stderr, "PHP: %s", error_buf); #endif + } else { + zend_error(E_CORE_WARNING, error_buf); + } efree(error_buf); } -int zend_parse_ini_file(zend_file_handle *fh, zend_ini_parser_cb_t ini_parser_cb, void *arg) +int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg) { zend_ini_parser_param ini_parser_param; int retval; + CLS_FETCH(); ini_parser_param.ini_parser_cb = ini_parser_cb; ini_parser_param.arg = arg; @@ -161,6 +168,7 @@ int zend_parse_ini_file(zend_file_handle *fh, zend_ini_parser_cb_t ini_parser_cb return FAILURE; } + CG(ini_parser_unbuffered_errors) = unbuffered_errors; retval = ini_parse(&ini_parser_param); zend_ini_close_file(fh); diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h index 9131216108..81389cc11f 100644 --- a/Zend/zend_ini_scanner.h +++ b/Zend/zend_ini_scanner.h @@ -8,11 +8,14 @@ public: virtual ~ZendIniFlexLexer(); int lex_scan(zval *zendlval); void BeginState(int state); + + char *filename; }; #endif /* ZTS && __cplusplus */ BEGIN_EXTERN_C() int zend_ini_scanner_get_lineno(); +char *zend_ini_scanner_get_filename(); int zend_ini_open_file_for_scanning(zend_file_handle *fh); void zend_ini_close_file(zend_file_handle *fh); int ini_lex(zval *ini_lval); diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index 1356005b2a..dcb0998f68 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -46,6 +46,8 @@ #endif #ifndef ZTS +static char *ini_filename; + void init_ini_scanner() { ini_lineno=1; @@ -57,6 +59,12 @@ int zend_ini_scanner_get_lineno() return ini_lineno; } + +char *zend_ini_scanner_get_filename() +{ + return ini_filename; +} + #else /* ZTS */ int zend_ini_scanner_get_lineno() @@ -66,6 +74,13 @@ int zend_ini_scanner_get_lineno() return CG(ini_scanner)->lineno(); } +char *zend_ini_scanner_get_filename() +{ + CLS_FETCH(); + + return CG(ini_scanner)->filename; +} + int ini_lex(zval *ini_lval) { CLS_FETCH(); @@ -115,10 +130,12 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh) CG(ini_scanner) = new ZendIniFlexLexer; CG(ini_scanner)->switch_streams(fh->handle.is, &cout); + CG(ini_scanner)->filename = fh->filename; #else init_ini_scanner(); yyin = fp; yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + ini_filename = fh->filename; #endif return SUCCESS; } @@ -130,13 +147,13 @@ void zend_ini_close_file(zend_file_handle *fh) case ZEND_HANDLE_FP: fclose(fh->handle.fp); break; +#ifdef ZTS case ZEND_HANDLE_STDIOSTREAM: { CLS_FETCH(); -#ifdef ZTS delete CG(ini_scanner); -#endif } break; +#endif } } |