]> granicus.if.org Git - php/commitdiff
Generalization work
authorZeev Suraski <zeev@php.net>
Sun, 29 Oct 2000 18:23:51 +0000 (18:23 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 29 Oct 2000 18:23:51 +0000 (18:23 +0000)
Zend/Makefile.am
Zend/ZendTS.dsp
Zend/zend_globals.h
Zend/zend_ini.h
Zend/zend_ini_parser.y
Zend/zend_ini_scanner.l

index ea35704a9f3fde8bab77d458bb74e1f5c47c7d86..9d7af2faa41019f820ec1326458614991a47e7e6 100644 (file)
@@ -42,13 +42,13 @@ zend_language_parser.c: $(srcdir)/zend_language_parser.y
 # INI parser/scanner rules
 
 zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
-       $(YACC) -p ini -v -d $(srcdir)/zend_ini_parser.y -o zend_ini_parser.c
+       $(YACC) -p ini_ -v -d $(srcdir)/zend_ini_parser.y -o zend_ini_parser.c
 
 zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
-       $(LEX) -Pini -o$@ -i $(srcdir)/zend_ini_scanner.l
+       $(LEX) -Pini_ -o$@ -i $(srcdir)/zend_ini_scanner.l
 
 zend_ini_scanner_cc.cc: $(srcdir)/zend_ini_scanner.l
-       $(LEX) -+ -B -i -S$(srcdir)/flex.skl -Pini -o$@ $(srcdir)/zend_ini_scanner.l
+       $(LEX) -+ -B -i -S$(srcdir)/flex.skl -Pini_ -o$@ $(srcdir)/zend_ini_scanner.l
 
 depend:
 
index ef7c49704c405741acd5adb0e5e26533dca9f47f..6f280803c912c2bcf710ba6a294d5d5ea7064018 100644 (file)
@@ -163,6 +163,14 @@ SOURCE=.\zend_ini.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\zend_ini_parser.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\zend_ini_scanner.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=".\zend_language_parser.c"\r
 # End Source File\r
 # Begin Source File\r
@@ -291,6 +299,14 @@ SOURCE=.\zend_ini.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\zend_ini_parser.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\zend_ini_scanner.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=".\zend_language_parser.h"\r
 # End Source File\r
 # Begin Source File\r
@@ -336,8 +352,8 @@ InputDir=.
 InputPath=.\zend_ini_parser.y\r
 \r
 BuildCmds= \\r
-       if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend_ini zend_ini_parser.y \\r
-       if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend_ini zend_ini_parser.y \\r
+       if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p ini_ zend_ini_parser.y \\r
+       if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p ini_ zend_ini_parser.y \\r
        \r
 \r
 "$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
@@ -354,8 +370,8 @@ InputDir=.
 InputPath=.\zend_ini_parser.y\r
 \r
 BuildCmds= \\r
-       if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend_ini zend_ini_parser.y \\r
-       if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend_ini zend_ini_parser.y \\r
+       if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p ini_ zend_ini_parser.y \\r
+       if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p ini_ zend_ini_parser.y \\r
        \r
 \r
 "$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
@@ -372,8 +388,8 @@ InputDir=.
 InputPath=.\zend_ini_parser.y\r
 \r
 BuildCmds= \\r
-       if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend_ini zend_ini_parser.y \\r
-       if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend_ini zend_ini_parser.y \\r
+       if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p ini_ zend_ini_parser.y \\r
+       if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p ini_ zend_ini_parser.y \\r
        \r
 \r
 "$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
@@ -461,7 +477,7 @@ SOURCE=.\zend_ini_scanner.l
 InputPath=.\zend_ini_scanner.l\r
 \r
 "zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
-       flex -+ -B -i -Sflex.skl -Pzend_ini -ozend_ini_scanner.cpp zend_ini_scanner.l\r
+       flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l\r
 \r
 # End Custom Build\r
 \r
@@ -471,7 +487,7 @@ InputPath=.\zend_ini_scanner.l
 InputPath=.\zend_ini_scanner.l\r
 \r
 "zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
-       flex -+ -B -i -Sflex.skl -Pzend_ini -ozend_ini_scanner.cpp zend_ini_scanner.l\r
+       flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l\r
 \r
 # End Custom Build\r
 \r
@@ -481,7 +497,7 @@ InputPath=.\zend_ini_scanner.l
 InputPath=.\zend_ini_scanner.l\r
 \r
 "zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
-       flex -+ -B -i -Sflex.skl -Pzend_ini -ozend_ini_scanner.cpp zend_ini_scanner.l\r
+       flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l\r
 \r
 # End Custom Build\r
 \r
index 7855ce6545f990dae54a2028b79885c0a0c49cff..283d026ba19b0b8f2426f795486fca16fb7d05a1 100644 (file)
@@ -40,6 +40,7 @@
 
 #ifdef __cplusplus
 class ZendFlexLexer;
+class ZendIniFlexLexer;
 #endif
 
 BEGIN_EXTERN_C()
@@ -107,12 +108,12 @@ struct _zend_compiler_globals {
        zend_bool unclean_shutdown;
 
        zend_llist open_files;
-#ifdef ZTS
-#ifdef __cplusplus
+#if defined(ZTS) && defined(__cplusplus)
        ZendFlexLexer *ZFL;
+       ZendIniFlexLexer *ini_scanner;
 #else
        void *ZFL;
-#endif
+       void *ini_parser;
 #endif
 };
 
index 6127d7ec0edb9e7f4a34603873d0d0f154964c04..df9d48559b5640ed1af27f6518db8af4dfc755e1 100644 (file)
@@ -156,4 +156,9 @@ ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
 #define ZEND_INI_STAGE_DEACTIVATE      (1<<3)
 #define ZEND_INI_STAGE_RUNTIME         (1<<4)
 
+/* INI parsing engine */
+int zend_parse_ini_file(zend_file_handle *fh, void (*zend_ini_parser_cb)(zval *arg1, zval *arg2, int callback_type));
+#define ZEND_INI_PARSER_ENTRY  1
+#define ZEND_INI_PARSER_SECTION        2
+
 #endif /* ZEND_INI_H */
index 0e5393bc9d0a99df1a66f21a24e4606892b833d1..b0f8319ceaf3aa73c340d3e05cdd562fd7895aff 100644 (file)
 #include "zend_API.h"
 #include "zend_ini.h"
 #include "zend_constants.h"
-#if 0
-#include "ext/standard/dl.h"
-#include "ext/standard/file.h"
-#include "ext/standard/php_browscap.h"
-#endif
+#include "zend_ini_scanner.h"
 #include "zend_extensions.h"
 
 
 //#include "win32/wfile.h"
 #endif
 
+int ini_lex(zval *ini_lval);
+
 #define YYSTYPE zval
 
+#define YYPARSE_PARAM zend_ini_parser_cb
+
+#define ZEND_INI_PARSER_CB ((void (*)(zval *arg1, zval *arg2, int callback_type)) zend_ini_parser_cb)
+
 #define PARSING_MODE_CFG               0
 #define PARSING_MODE_BROWSCAP  1
 #define PARSING_MODE_STANDALONE        2
@@ -57,314 +59,12 @@ static int parsing_mode;
 
 zval yylval;
 
-extern int cfglex(zval *cfglval);
-extern FILE *cfgin;
-extern int cfglineno;
+#ifndef ZTS
+extern int ini_lex(zval *ini_lval); */
+extern FILE *ini_in;
+extern int ini_lineno;
 extern void init_cfg_scanner(void);
-
-zval *cfg_get_entry(char *name, uint name_length)
-{
-       zval *tmp;
-
-       if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp)==SUCCESS) {
-               return tmp;
-       } else {
-               return NULL;
-       }
-}
-
-
-ZEND_API int cfg_get_long(char *varname,long *result)
-{
-       zval *tmp,var;
-       
-       if (zend_hash_find(&configuration_hash,varname,strlen(varname)+1,(void **) &tmp)==FAILURE) {
-               *result=(long)NULL;
-               return FAILURE;
-       }
-       var = *tmp;
-       zval_copy_ctor(&var);
-       convert_to_long(&var);
-       *result = var.value.lval;
-       return SUCCESS;
-}
-
-
-ZEND_API int cfg_get_double(char *varname,double *result)
-{
-       zval *tmp,var;
-       
-       if (zend_hash_find(&configuration_hash,varname,strlen(varname)+1,(void **) &tmp)==FAILURE) {
-               *result=(double)0;
-               return FAILURE;
-       }
-       var = *tmp;
-       zval_copy_ctor(&var);
-       convert_to_double(&var);
-       *result = var.value.dval;
-       return SUCCESS;
-}
-
-
-ZEND_API int cfg_get_string(char *varname, char **result)
-{
-       zval *tmp;
-
-       if (zend_hash_find(&configuration_hash,varname,strlen(varname)+1,(void **) &tmp)==FAILURE) {
-               *result=NULL;
-               return FAILURE;
-       }
-       *result = tmp->value.str.val;
-       return SUCCESS;
-}
-
-
-static void yyerror(char *str)
-{
-       char *error_buf;
-       int error_buf_len;
-
-       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, cfglineno);
-#ifdef PHP_WIN32
-       MessageBox(NULL, error_buf, "PHP Error", MB_OK|MB_TOPMOST|0x00200000L);
-#else
-       fprintf(stderr, "PHP:  %s", error_buf);
 #endif
-       efree(error_buf);
-}
-
-
-static void pvalue_config_destructor(zval *pvalue)
-{
-       if (pvalue->type == IS_STRING && pvalue->value.str.val != empty_string) {
-               free(pvalue->value.str.val);
-       }
-}
-
-
-static void pvalue_browscap_destructor(zval *pvalue)
-{
-       if (pvalue->type == IS_OBJECT || pvalue->type == IS_ARRAY) {
-               zend_hash_destroy(pvalue->value.obj.properties);
-               free(pvalue->value.obj.properties);
-       }
-}
-
-
-#if 0
-int php_init_config(void)
-{
-       PLS_FETCH();
-
-       if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) {
-               return FAILURE;
-       }
-
-#if USE_CONFIG_FILE
-       {
-               char *env_location,*default_location,*php_ini_search_path;
-               int safe_mode_state = PG(safe_mode);
-               char *open_basedir = PG(open_basedir);
-               char *opened_path;
-               int free_default_location=0;
-               
-               env_location = getenv("PHPRC");
-               if (!env_location) {
-                       env_location="";
-               }
-#ifdef PHP_WIN32
-               {
-                       if (php_ini_path) {
-                               default_location = php_ini_path;
-                       } else {
-                               default_location = (char *) malloc(512);
-                       
-                               if (!GetWindowsDirectory(default_location,255)) {
-                                       default_location[0]=0;
-                               }
-                               free_default_location=1;
-                       }
-               }
-#else
-               if (!php_ini_path) {
-                       default_location = CONFIGURATION_FILE_PATH;
-               } else {
-                       default_location = php_ini_path;
-               }
-#endif
-
-/* build a path */
-               php_ini_search_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1);
-
-               if (!php_ini_path) {
-#ifdef PHP_WIN32
-                       sprintf(php_ini_search_path,".;%s;%s",env_location,default_location);
-#else
-                       sprintf(php_ini_search_path,".:%s:%s",env_location,default_location);
-#endif
-               } else {
-                       /* if path was set via -c flag, only look there */
-                       strcpy(php_ini_search_path,default_location);
-               }
-               PG(safe_mode) = 0;
-               PG(open_basedir) = NULL;
-               cfgin = php_fopen_with_path("php.ini","r",php_ini_search_path,&opened_path);
-               free(php_ini_search_path);
-               if (free_default_location) {
-                       free(default_location);
-               }
-               PG(safe_mode) = safe_mode_state;
-               PG(open_basedir) = open_basedir;
-
-               if (!cfgin) {
-                       return SUCCESS;  /* having no configuration file is ok */
-               }
-
-               if (opened_path) {
-                       zval tmp;
-                       
-                       tmp.value.str.val = strdup(opened_path);
-                       tmp.value.str.len = strlen(opened_path);
-                       tmp.type = IS_STRING;
-                       zend_hash_update(&configuration_hash,"cfg_file_path",sizeof("cfg_file_path"),(void *) &tmp,sizeof(zval),NULL);
-#if DEBUG_CFG_PARSER
-                       php_printf("INI file opened at '%s'\n",opened_path);
-#endif
-                       efree(opened_path);
-               }
-                       
-               init_cfg_scanner();
-               active_hash_table = &configuration_hash;
-               parsing_mode = PARSING_MODE_CFG;
-               currently_parsed_filename = "php.ini";
-               yyparse();
-               fclose(cfgin);
-       }
-       
-#endif
-       
-       return SUCCESS;
-}
-
-
-PHP_MINIT_FUNCTION(browscap)
-{
-       char *browscap = INI_STR("browscap");
-
-       if (browscap) {
-               if (zend_hash_init(&browser_hash, 0, NULL, (dtor_func_t) pvalue_browscap_destructor, 1)==FAILURE) {
-                       return FAILURE;
-               }
-
-               cfgin = V_FOPEN(browscap, "r");
-               if (!cfgin) {
-                       php_error(E_WARNING,"Cannot open '%s' for reading", browscap);
-                       return FAILURE;
-               }
-               init_cfg_scanner();
-               active_hash_table = &browser_hash;
-               parsing_mode = PARSING_MODE_BROWSCAP;
-               currently_parsed_filename = browscap;
-               yyparse();
-               fclose(cfgin);
-       }
-
-       return SUCCESS;
-}
-
-/* {{{ proto void parse_ini_file(string filename)
-   Parse configuration file */
-ZEND_FUNCTION(parse_ini_file)
-{
-#ifdef ZTS
-       php_error(E_WARNING, "parse_ini_file() is not supported in multithreaded PHP");
-       RETURN_FALSE;
-#else
-       zval **filename;
-
-       if (ARG_COUNT(ht)!=1 || zend_get_parameters_ex(1, &filename)==FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_string_ex(filename);
-       cfgin = V_FOPEN((*filename)->value.str.val, "r");
-       if (!cfgin) {
-               php_error(E_WARNING,"Cannot open '%s' for reading", (*filename)->value.str.val);
-               return;
-       }
-       array_init(return_value);
-       init_cfg_scanner();
-       active_hash_table = return_value->value.ht;
-       parsing_mode = PARSING_MODE_STANDALONE;
-       currently_parsed_filename = (*filename)->value.str.val;
-       yyparse();
-       fclose(cfgin);
-#endif
-}
-/* }}} */
-
-
-int php_shutdown_config(void)
-{
-       zend_hash_destroy(&configuration_hash);
-       return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(browscap)
-{
-       if (INI_STR("browscap")) {
-               zend_hash_destroy(&browser_hash);
-       }
-       return SUCCESS;
-}
-
-#endif
-
-
-static void convert_browscap_pattern(zval *pattern)
-{
-       register int i,j;
-       char *t;
-
-       for (i=0; i<pattern->value.str.len; i++) {
-               if (pattern->value.str.val[i]=='*' || pattern->value.str.val[i]=='?' || pattern->value.str.val[i]=='.') {
-                       break;
-               }
-       }
-
-       if (i==pattern->value.str.len) { /* no wildcards */
-               pattern->value.str.val = zend_strndup(pattern->value.str.val, pattern->value.str.len);
-               return;
-       }
-
-       t = (char *) malloc(pattern->value.str.len*2);
-       
-       for (i=0,j=0; i<pattern->value.str.len; i++,j++) {
-               switch (pattern->value.str.val[i]) {
-                       case '?':
-                               t[j] = '.';
-                               break;
-                       case '*':
-                               t[j++] = '.';
-                               t[j] = '*';
-                               break;
-                       case '.':
-                               t[j++] = '\\';
-                               t[j] = '.';
-                               break;
-                       default:
-                               t[j] = pattern->value.str.val[i];
-                               break;
-               }
-       }
-       t[j]=0;
-       pattern->value.str.val = t;
-       pattern->value.str.len = j;
-}
-
 
 void do_cfg_op(char type, zval *result, zval *op1, zval *op2)
 {
@@ -425,6 +125,24 @@ void do_cfg_get_constant(zval *result, zval *name)
 }
 
 
+static void ini_error(char *str)
+{
+       char *error_buf;
+       int error_buf_len;
+
+       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());
+#ifdef PHP_WIN32
+       MessageBox(NULL, error_buf, "PHP Error", MB_OK|MB_TOPMOST|0x00200000L);
+#else
+       fprintf(stderr, "PHP:  %s", error_buf);
+#endif
+       efree(error_buf);
+}
+
+
 %}
 
 %pure_parser
@@ -433,11 +151,6 @@ void do_cfg_get_constant(zval *result, zval *name)
 %token SECTION
 %token CFG_TRUE
 %token CFG_FALSE
-%token EXTENSION
-%token T_ZEND_EXTENSION
-%token T_ZEND_EXTENSION_TS
-%token T_ZEND_EXTENSION_DEBUG
-%token T_ZEND_EXTENSION_DEBUG_TS
 %left '|' '&'
 %right '~' '!'
 
@@ -453,121 +166,14 @@ statement:
 #if DEBUG_CFG_PARSER
                        printf("'%s' = '%s'\n",$1.value.str.val,$3.value.str.val);
 #endif
-                       $3.type = IS_STRING;
-                       switch (parsing_mode) {
-                               case PARSING_MODE_CFG:
-                                       zend_hash_update(active_hash_table, $1.value.str.val, $1.value.str.len+1, &$3, sizeof(zval), NULL);
-                                       if (active_hash_table == &configuration_hash) {
-                                               zend_alter_ini_entry($1.value.str.val, $1.value.str.len+1, $3.value.str.val, $3.value.str.len+1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_STARTUP);
-                                       }
-                                       break;
-                               case PARSING_MODE_BROWSCAP:
-                                       if (current_section) {
-                                               zval *new_property;
-                                               char *new_key;
-
-                                               new_property = (zval *) malloc(sizeof(zval));
-                                               INIT_PZVAL(new_property);
-                                               new_property->value.str.val = $3.value.str.val;
-                                               new_property->value.str.len = $3.value.str.len;
-                                               new_property->type = IS_STRING;
-                                               
-                                               new_key = zend_strndup($1.value.str.val, $1.value.str.len);
-                                               zend_str_tolower(new_key,$1.value.str.len);
-                                               zend_hash_update(current_section->value.obj.properties, new_key, $1.value.str.len+1, &new_property, sizeof(zval *), NULL);
-                                               free(new_key);
-                                       }
-                                       break;
-                               case PARSING_MODE_STANDALONE: {
-                                               zval *entry;
-
-                                               MAKE_STD_ZVAL(entry);
-                                               entry->value.str.val = estrndup($3.value.str.val, $3.value.str.len);
-                                               entry->value.str.len = $3.value.str.len;
-                                               entry->type = IS_STRING;
-                                               zend_hash_update(active_hash_table, $1.value.str.val, $1.value.str.len+1, &entry, sizeof(zval *), NULL);
-                                               pvalue_config_destructor(&$3);
-                                       }
-                                       break;
-                       }               
-                       free($1.value.str.val);
-               }
-       |       TC_STRING { free($1.value.str.val); }
-       |       EXTENSION '=' cfg_string {
-                       if (parsing_mode==PARSING_MODE_CFG) {
-                               zval dummy;
-
-#if DEBUG_CFG_PARSER
-                               printf("Loading '%s'\n",$3.value.str.val);
-#endif
-                               php_dl(&$3,MODULE_PERSISTENT,&dummy);
-                       }
-               }
-       |       T_ZEND_EXTENSION '=' cfg_string {
-                       if (parsing_mode==PARSING_MODE_CFG) {
-#if !defined(ZTS) && !ZEND_DEBUG
-                               zend_load_extension($3.value.str.val);
-#endif
-                               free($3.value.str.val);
-                       }
-               }
-       |       T_ZEND_EXTENSION_TS '=' cfg_string { 
-                       if (parsing_mode==PARSING_MODE_CFG) {
-#if defined(ZTS) && !ZEND_DEBUG
-                               zend_load_extension($3.value.str.val);
-#endif
-                               free($3.value.str.val);
-                       }
-               }
-       |       T_ZEND_EXTENSION_DEBUG '=' cfg_string { 
-                       if (parsing_mode==PARSING_MODE_CFG) {
-#if !defined(ZTS) && ZEND_DEBUG
-                               zend_load_extension($3.value.str.val);
-#endif
-                               free($3.value.str.val);
-                       }
-               }
-       |       T_ZEND_EXTENSION_DEBUG_TS '=' cfg_string { 
-                       if (parsing_mode==PARSING_MODE_CFG) {
-#if defined(ZTS) && ZEND_DEBUG
-                               zend_load_extension($3.value.str.val);
-#endif
-                               free($3.value.str.val);
-                       }
-               }
-       |       SECTION { 
-                       if (parsing_mode==PARSING_MODE_BROWSCAP) {
-                               zval *processed;
-
-                               /*printf("'%s' (%d)\n",$1.value.str.val,$1.value.str.len+1);*/
-                               current_section = (zval *) malloc(sizeof(zval));
-                               INIT_PZVAL(current_section);
-                               processed = (zval *) malloc(sizeof(zval));
-                               INIT_PZVAL(processed);
-
-                               current_section->value.obj.ce = &zend_standard_class_def;
-                               current_section->value.obj.properties = (HashTable *) malloc(sizeof(HashTable));
-                               current_section->type = IS_OBJECT;
-                               zend_hash_init(current_section->value.obj.properties, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1);
-                               zend_hash_update(active_hash_table, $1.value.str.val, $1.value.str.len+1, (void *) &current_section, sizeof(zval *), NULL);
-
-                               processed->value.str.val = $1.value.str.val;
-                               processed->value.str.len = $1.value.str.len;
-                               processed->type = IS_STRING;
-                               convert_browscap_pattern(processed);
-                               zend_hash_update(current_section->value.obj.properties, "browser_name_pattern", sizeof("browser_name_pattern"), (void *) &processed, sizeof(zval *), NULL);
-                       }
-                       free($1.value.str.val);
+                       ZEND_INI_PARSER_CB(&$1, &$3, ZEND_INI_PARSER_ENTRY);
                }
+       |       TC_STRING { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_ENTRY); }
+       |       SECTION { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_SECTION); }
        |       '\n'
 ;
 
 
-cfg_string:
-               TC_STRING { $$ = $1; }
-       |       TC_ENCAPSULATED_STRING { $$ = $1; }
-;
-
 string_or_value:
                expr { $$ = $1; }
        |       TC_ENCAPSULATED_STRING { $$ = $1; }
index 7a942109e104efa1082559c4e59f4d902e4f68b3..6f1880d9d9af9a478d9a27767e31c11aa994ed0d 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "zend.h"
+#include "zend_globals.h"
 #include "zend_ini_parser.h"
 #include "zend_ini_scanner.h"
 
 #define YYSTYPE zval
 
 #ifdef ZTS
-#define YY_DECL int ZendIniFlexLexer::lex_scan(zval *inilval CLS_DC)
+#define YY_DECL int ZendIniFlexLexer::lex_scan(zval *ini_lval)
 #else
-#define YY_DECL int ini_lex_scan(zval *inilval CLS_DC)
+#define YY_DECL int ini_lex(zval *ini_lval)
 #endif
 
 #ifndef ZTS
 void init_cfg_scanner()
 {
-       inilineno=1;
+       ini_lineno=1;
 }
-#endif
 
 
-%}
+int zend_ini_scanner_get_lineno()
+{
+       return ini_lineno;
+}
 
-%option noyywrap
-%option yylineno
+#else /* ZTS */
 
-%%
+int zend_ini_scanner_get_lineno()
+{
+       CLS_FETCH();
 
-<INITIAL>"extension" {
-#if    0
-       printf("found extension\n");
-#endif
-       return EXTENSION;
+       return CG(ini_scanner)->lineno();
 }
 
+int ini_lex(zval *ini_lval)
+{
+       CLS_FETCH();
 
-<INITIAL>"zend_extension" {
-       return T_ZEND_EXTENSION;
+       return CG(ini_scanner)->lex_scan(ini_lval);
 }
 
-
-<INITIAL>"zend_extension_ts" {
-       return T_ZEND_EXTENSION_TS;
-}
+#endif
 
 
-<INITIAL>"zend_extension_debug" {
-       return T_ZEND_EXTENSION_DEBUG;
-}
+%}
 
+%option noyywrap
+%option yylineno
 
-<INITIAL>"zend_extension_debug_ts" {
-       return T_ZEND_EXTENSION_DEBUG_TS;
-}
+%%
 
 
 <INITIAL>[ ]*("true"|"on"|"yes")[ ]* {
-       inilval->value.str.val = zend_strndup("1",1);
-       inilval->value.str.len = 1;
-       inilval->type = IS_STRING;
+       ini_lval->value.str.val = zend_strndup("1",1);
+       ini_lval->value.str.len = 1;
+       ini_lval->type = IS_STRING;
        return CFG_TRUE;
 }
 
 
 <INITIAL>[ ]*("false"|"off"|"no"|"none")[ ]* {
-       inilval->value.str.val = zend_strndup("",0);
-       inilval->value.str.len = 0;
-       inilval->type = IS_STRING;
+       ini_lval->value.str.val = zend_strndup("",0);
+       ini_lval->value.str.len = 0;
+       ini_lval->type = IS_STRING;
        return CFG_FALSE;
 }
 
@@ -101,9 +98,9 @@ void init_cfg_scanner()
        yytext++;
        yyleng--;
 
-       inilval->value.str.val = zend_strndup(yytext,yyleng);
-       inilval->value.str.len = yyleng;
-       inilval->type = IS_STRING;
+       ini_lval->value.str.val = zend_strndup(yytext,yyleng);
+       ini_lval->value.str.len = yyleng;
+       ini_lval->type = IS_STRING;
        return SECTION;
 }
 
@@ -117,9 +114,9 @@ void init_cfg_scanner()
        /* eat leading " */
        yytext++;
 
-       inilval->value.str.val = zend_strndup(yytext, yyleng - 2);
-       inilval->value.str.len = yyleng - 2;
-       inilval->type = IS_STRING;
+       ini_lval->value.str.val = zend_strndup(yytext, yyleng - 2);
+       ini_lval->value.str.len = yyleng - 2;
+       ini_lval->type = IS_STRING;
        return TC_ENCAPSULATED_STRING;
 }
 
@@ -151,9 +148,9 @@ void init_cfg_scanner()
                }
        }
        if (yyleng!=0) {
-               inilval->value.str.val = zend_strndup(yytext,yyleng);
-               inilval->value.str.len = yyleng;
-               inilval->type = IS_STRING;
+               ini_lval->value.str.val = zend_strndup(yytext,yyleng);
+               ini_lval->value.str.len = yyleng;
+               ini_lval->type = IS_STRING;
                return TC_STRING;
        } else {
                /* whitespace */