summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2001-08-06 13:48:51 +0000
committerZeev Suraski <zeev@php.net>2001-08-06 13:48:51 +0000
commit609d58a4d6aa63dd7abaf2651cf40f4907b77c1e (patch)
tree25fe6f56401a13587ef407ebb1eb96898d348c96 /Zend
parenta35df189b8e6a580261e4cce0339b0f0d2a0d4c3 (diff)
downloadphp-git-609d58a4d6aa63dd7abaf2651cf40f4907b77c1e.tar.gz
Merge from branch - move to standard C scanners in thread safe mode
Diffstat (limited to 'Zend')
-rw-r--r--Zend/Makefile.am25
-rw-r--r--Zend/Zend.dsp4
-rw-r--r--Zend/Zend.m443
-rw-r--r--Zend/ZendTS.dsp16
-rw-r--r--Zend/flex.skl302
-rw-r--r--Zend/zend.c28
-rw-r--r--Zend/zend_globals.h14
-rw-r--r--Zend/zend_globals_macros.h21
-rw-r--r--Zend/zend_highlight.c4
-rw-r--r--Zend/zend_indent.c4
-rw-r--r--Zend/zend_ini.h5
-rw-r--r--Zend/zend_ini_parser.y31
-rw-r--r--Zend/zend_ini_scanner.h2
-rw-r--r--Zend/zend_ini_scanner.l28
-rw-r--r--Zend/zend_language_scanner.h4
-rw-r--r--Zend/zend_language_scanner.l80
16 files changed, 355 insertions, 256 deletions
diff --git a/Zend/Makefile.am b/Zend/Makefile.am
index 11157ef7ca..89c7a59a60 100644
--- a/Zend/Makefile.am
+++ b/Zend/Makefile.am
@@ -3,15 +3,11 @@
#CLEANFILES = zend_language_parser.c zend_language_parser.h zend_language_scanner.c zend_language_parser.output zend_ini_parser.c zend_ini_parser.h zend_ini_scanner.c zend_ini_parser.output
AUTOMAKE_OPTIONS=foreign
-EXTRA_LTLIBRARIES=libZend_cc.la libZend_c.la
-noinst_LTLIBRARIES=$(ZEND_SCANNER) libZend.la
-
-libZend_cc_la_SOURCES=zend_language_scanner_cc.cc zend_ini_scanner_cc.cc
-libZend_c_la_SOURCES=zend_language_scanner.c zend_ini_scanner.c
+noinst_LTLIBRARIES=libZend.la
libZend_la_SOURCES=\
- zend_language_parser.y \
- zend_ini_parser.y \
+ zend_language_parser.y zend_language_scanner.l \
+ zend_ini_parser.y zend_ini_scanner.l \
zend_alloc.c zend_compile.c zend_constants.c zend_dynamic_array.c \
zend_execute.c zend_execute_API.c zend_highlight.c zend_llist.c \
zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \
@@ -19,23 +15,18 @@ libZend_la_SOURCES=\
zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
zend_ini.c
-libZend_la_LIBADD = $(ZEND_SCANNER)
libZend_la_LDFLAGS = @EXTRA_LIBS@
-libZend_la_DEPENDENCIES = $(ZEND_SCANNER)
# automake isn't too clever about "non-standard" use of lex and yacc
-$(libZend_la_OBJECTS) zend_language_scanner.lo zend_language_scanner_cc.lo: zend_language_parser.h
+$(libZend_la_OBJECTS): zend_language_parser.h
-zend_ini_scanner.lo zend_ini_scanner_cc.lo: zend_ini_parser.h
+zend_ini_scanner.lo: zend_ini_parser.h
# Language parser/scanner rules
zend_language_scanner.c: $(srcdir)/zend_language_scanner.l
- $(LEX) -Pzend -o$@ -i $(srcdir)/zend_language_scanner.l
-
-zend_language_scanner_cc.cc: $(srcdir)/zend_language_scanner.l
- $(LEX) -+ -B -i -S$(srcdir)/flex.skl -Pzend -o$@ $(srcdir)/zend_language_scanner.l
+ $(LEX) -Pzend -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_language_scanner.l
zend_language_parser.h: zend_language_parser.c
zend_language_parser.c: $(srcdir)/zend_language_parser.y
@@ -47,10 +38,8 @@ zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
$(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_ -S$(srcdir)/flex.skl -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
zend_ini_parser.h: zend_ini_parser.c
depend:
diff --git a/Zend/Zend.dsp b/Zend/Zend.dsp
index e2a8fe6611..6184c60d57 100644
--- a/Zend/Zend.dsp
+++ b/Zend/Zend.dsp
@@ -405,6 +405,10 @@ BuildCmds= \
# PROP Default_Filter "l"
# Begin Source File
+SOURCE=.\flex.skl
+# End Source File
+# Begin Source File
+
SOURCE=.\zend_ini_scanner.l
!IF "$(CFG)" == "Zend - Win32 Release"
diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
index 9cffb9ad3a..e1d4db9841 100644
--- a/Zend/Zend.m4
+++ b/Zend/Zend.m4
@@ -70,8 +70,6 @@ AC_CHECK_FUNCS(finite isfinite isinf isnan)
ZEND_FP_EXCEPT
-AC_SUBST(ZEND_SCANNER)
-
])
@@ -153,15 +151,10 @@ test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
if test "$ZEND_EXPERIMENTAL_ZTS" = "yes"; then
AC_DEFINE(ZTS,1,[ ])
- ZEND_SCANNER_TYPE=cc
- CPPFLAGS="$CPPFLAGS -I../TSRM"
+ CFLAGS="$CFLAGS -DZTS"
LIBZEND_CPLUSPLUS_CHECKS
-else
- ZEND_SCANNER_TYPE=c
fi
-ZEND_SCANNER="libZend_${ZEND_SCANNER_TYPE}.la"
-
if test "$ZEND_MEMORY_LIMIT" = "yes"; then
AC_DEFINE(MEMORY_LIMIT, 1, [Memory limit])
else
@@ -186,39 +179,5 @@ AC_SUBST(INLINE_CFLAGS)
AC_DEFUN(LIBZEND_CPLUSPLUS_CHECKS,[
-dnl extra check to avoid C++ preprocessor testing if in non-ZTS mode
-
-if test "$ZEND_EXPERIMENTAL_ZTS" = "yes"; then
-AC_PROG_CXX
-AC_PROG_CXXCPP
-AC_LANG_CPLUSPLUS
-AC_CHECK_HEADER(stdiostream.h, [ AC_DEFINE(HAVE_STDIOSTREAM_H, [], Whether you have stdiostream.h) ])
-
-AC_CHECK_LIB(C, cin)
-AC_CHECK_LIB(g++, cin)
-AC_CHECK_LIB(stdc++, cin)
-dnl Digital Unix 4.0
-AC_CHECK_LIB(cxx, cin)
-AC_CHECK_LIB(cxxstd, __array_delete)
-
-AC_CACHE_CHECK(for class istdiostream,ac_cv_class_istdiostream,[
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <unistd.h>
-#include <fstream.h>
-#include <stdiostream.h>
-],[
-istdiostream *foo = new istdiostream((FILE *) 0);
-],[
- ac_cv_class_istdiostream=yes
-],[
- ac_cv_class_istdiostream=no
-])
-])
- if test "$ac_cv_class_istdiostream" = "yes"; then
- AC_DEFINE(HAVE_CLASS_ISTDIOSTREAM, 1, [Whether you have class istdiostream])
- fi
-AC_LANG_C
-fi
])
diff --git a/Zend/ZendTS.dsp b/Zend/ZendTS.dsp
index 0a1bfdd446..699601644d 100644
--- a/Zend/ZendTS.dsp
+++ b/Zend/ZendTS.dsp
@@ -192,7 +192,7 @@ SOURCE=.\zend_ini_parser.c
# End Source File
# Begin Source File
-SOURCE=.\zend_ini_scanner.cpp
+SOURCE=.\zend_ini_scanner.c
# End Source File
# Begin Source File
@@ -200,7 +200,7 @@ SOURCE=".\zend_language_parser.c"
# End Source File
# Begin Source File
-SOURCE=".\zend_language_scanner.cpp"
+SOURCE=.\zend_language_scanner.c
# End Source File
# Begin Source File
@@ -518,6 +518,10 @@ BuildCmds= \
# PROP Default_Filter "l"
# Begin Source File
+SOURCE=.\flex.skl
+# End Source File
+# Begin Source File
+
SOURCE=.\zend_ini_scanner.l
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
@@ -535,8 +539,8 @@ InputPath=.\zend_ini_scanner.l
# Begin Custom Build
InputPath=.\zend_ini_scanner.l
-"zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l
+"zend_ini_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ flex -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.c zend_ini_scanner.l
# End Custom Build
@@ -582,8 +586,8 @@ InputPath=".\zend_language_scanner.l"
# Begin Custom Build
InputPath=".\zend_language_scanner.l"
-"zend_language_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- flex -+ -B -i -Sflex.skl -Pzend -ozend_language_scanner.cpp zend_language_scanner.l
+"zend_language_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ flex -B -i -Sflex.skl -Pzend -ozend_language_scanner.c zend_language_scanner.l
# End Custom Build
diff --git a/Zend/flex.skl b/Zend/flex.skl
index fb60c3ec9f..d84fa3dd6a 100644
--- a/Zend/flex.skl
+++ b/Zend/flex.skl
@@ -62,6 +62,8 @@ class istream;
#define yyconst
#endif
+#undef YY_USE_PROTOS
+#define YY_USE_PROTOS
#ifdef YY_USE_PROTOS
#define YY_PROTO(proto) proto
@@ -96,7 +98,7 @@ class istream;
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
+#define YY_NEW_FILE yyrestart( yyin TSRMLS_CC )
#define YY_END_OF_BUFFER_CHAR 0
@@ -107,9 +109,9 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
extern int yyleng;
%-
-extern FILE *yyin, *yyout;
%*
+
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
@@ -140,7 +142,7 @@ extern FILE *yyin, *yyout;
} \
while ( 0 )
-#define unput(c) yyunput( c, yytext_ptr )
+#define unput(c) yyunput( c, yytext_ptr TSRMLS_CC )
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
@@ -211,7 +213,7 @@ struct yy_buffer_state
};
%- Standard (non-C++) definition
-static YY_BUFFER_STATE yy_current_buffer = 0;
+#define yy_current_buffer SCNG(current_buffer)
%*
/* We provide macros for accessing buffer states in case in the
@@ -227,32 +229,44 @@ static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
int yyleng;
/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
+#define yy_c_buf_p SCNG(c_buf_p)
+#define yy_init SCNG(init)
+#define yy_start SCNG(start)
+
+#ifdef ZTS
+#define TSRMLS_D void ***tsrm_ls
+#define TSRMLS_DC , TSRMLS_D
+#define TSRMLS_C tsrm_ls
+#define TSRMLS_CC , TSRMLS_C
+#else
+#define TSRMLS_D
+#define TSRMLS_DC
+#define TSRMLS_C
+#define TSRMLS_CC
+#endif
/* Flag which is used to allow yywrap()'s to do buffer switches
* instead of setting up a fresh yyin. A bit of a hack ...
*/
static int yy_did_buffer_switch_on_eof;
-void yyrestart YY_PROTO(( FILE *input_file ));
+void yyrestart YY_PROTO(( FILE *input_file TSRMLS_DC ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer TSRMLS_DC ));
+void yy_load_buffer_state YY_PROTO(( TSRMLS_D ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size TSRMLS_DC ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b TSRMLS_DC ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file TSRMLS_DC ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b TSRMLS_DC ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer TSRMLS_CC )
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size TSRMLS_DC ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str TSRMLS_DC ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len TSRMLS_DC ));
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
%*
static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
@@ -264,28 +278,42 @@ static void yy_flex_free YY_PROTO(( void * ));
#define yy_set_interactive(is_interactive) \
{ \
if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer = yy_create_buffer( SCNG(yyin), YY_BUF_SIZE TSRMLS_CC ); \
yy_current_buffer->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer = yy_create_buffer( SCNG(yyin), YY_BUF_SIZE TSRMLS_CC ); \
yy_current_buffer->yy_at_bol = at_bol; \
}
#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
+#ifdef ZTS
+#undef yyleng
+#define yyleng SCNG(yy_leng)
+#undef yytext
+#define yytext SCNG(yy_text)
+#undef yytext_ptr
+#define yytext_ptr SCNG(yy_text)
+#endif
+
%- Standard (non-C++) definition
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
+static yy_state_type yy_get_previous_state YY_PROTO(( TSRMLS_D ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state TSRMLS_DC ));
+static int yy_get_next_buffer YY_PROTO(( TSRMLS_D ));
static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
%*
+#undef TSRMLS_D
+#undef TSRMLS_DC
+#undef TSRMLS_C
+#undef TSRMLS_CC
+
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
@@ -313,7 +341,7 @@ extern int yywrap YY_PROTO(( void ));
%-
#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+static void yyunput YY_PROTO(( int c, char *buf_ptr TSRMLS_DC ));
#endif
%*
@@ -328,9 +356,9 @@ static int yy_flex_strlen YY_PROTO(( yyconst char * ));
#ifndef YY_NO_INPUT
%- Standard (non-C++) definition
#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
+static int 3 YY_PROTO(( TSRMLS_D ));
#else
-static int input YY_PROTO(( void ));
+static int input YY_PROTO(( TSRMLS_D ));
#endif
%*
#endif
@@ -340,10 +368,10 @@ static int yy_start_stack_ptr = 0;
static int yy_start_stack_depth = 0;
static int *yy_start_stack = 0;
#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
+static void yy_push_state YY_PROTO(( int new_state TSRMLS_DC ));
#endif
#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
+static void yy_pop_state YY_PROTO(( TSRMLS_D ));
#endif
#ifndef YY_NO_TOP_STATE
static int yy_top_state YY_PROTO(( void ));
@@ -382,7 +410,7 @@ YY_MALLOC_DECL
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO (void) fwrite( yytext, yyleng, 1, SCNG(yyout) )
%+ C++ definition
#define ECHO LexerOutput( yytext, yyleng )
%*
@@ -422,6 +450,7 @@ YY_MALLOC_DECL
%*
#endif
+
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
@@ -466,25 +495,25 @@ YY_DECL
if ( ! yy_start )
yy_start = 1; /* first start state */
- if ( ! yyin )
+ if ( ! SCNG(yyin) )
%-
- yyin = stdin;
+ SCNG(yyin) = stdin;
%+
- yyin = &cin;
+ SCNG(yyin) = &cin;
%*
- if ( ! yyout )
+ if ( ! SCNG(yyout) )
%-
- yyout = stdout;
+ SCNG(yyout) = stdout;
%+
- yyout = &cout;
+ SCNG(yyout) = &cout;
%*
if ( ! yy_current_buffer )
yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
+ yy_create_buffer( SCNG(yyin), YY_BUF_SIZE TSRMLS_CC );
- yy_load_buffer_state();
+ yy_load_buffer_state(TSRMLS_C);
}
while ( 1 ) /* loops until end-of-file is reached */
@@ -554,7 +583,7 @@ do_action: /* This label is used only to access EOF actions. */
yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state(TSRMLS_C);
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
@@ -565,7 +594,7 @@ do_action: /* This label is used only to access EOF actions. */
* will run more slowly).
*/
- yy_next_state = yy_try_NUL_trans( yy_current_state );
+ yy_next_state = yy_try_NUL_trans( yy_current_state TSRMLS_CC );
yy_bp = yytext_ptr + YY_MORE_ADJ;
@@ -584,7 +613,7 @@ do_action: /* This label is used only to access EOF actions. */
}
}
- else switch ( yy_get_next_buffer() )
+ else switch ( yy_get_next_buffer(TSRMLS_C) )
{
case EOB_ACT_END_OF_FILE:
{
@@ -619,7 +648,7 @@ do_action: /* This label is used only to access EOF actions. */
yy_c_buf_p =
yytext_ptr + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state(TSRMLS_C);
yy_cp = yy_c_buf_p;
yy_bp = yytext_ptr + YY_MORE_ADJ;
@@ -629,7 +658,7 @@ do_action: /* This label is used only to access EOF actions. */
yy_c_buf_p =
&yy_current_buffer->yy_ch_buf[yy_n_chars];
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state(TSRMLS_C);
yy_cp = yy_c_buf_p;
yy_bp = yytext_ptr + YY_MORE_ADJ;
@@ -648,8 +677,8 @@ do_action: /* This label is used only to access EOF actions. */
%+
yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
{
- yyin = arg_yyin;
- yyout = arg_yyout;
+ SCNG(yyin) = arg_yyin;
+ SCNG(yyout) = arg_yyout;
yy_c_buf_p = 0;
yy_init = 1;
yy_start = 0;
@@ -678,49 +707,49 @@ yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
yyFlexLexer::~yyFlexLexer()
{
delete yy_state_buf;
- yy_delete_buffer( yy_current_buffer );
+ yy_delete_buffer( yy_current_buffer TSRMLS_CC );
}
void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
{
if ( new_in )
{
- yy_delete_buffer( yy_current_buffer );
- yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
+ yy_delete_buffer( SCNG(yy_current_buffer TSRMLS_CC ) );
+ yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE TSRMLS_CC ) TSRMLS_CC );
}
if ( new_out )
- yyout = new_out;
+ SCNG(yyout) = new_out;
}
int yyFlexLexer::LexerInput( char* buf, int max_size )
{
- if ( yyin->eof() || yyin->fail() )
+ if ( SCNG(yyin)->eof() || SCNG(yyin)->fail() )
return 0;
if (yy_current_buffer->yy_is_interactive) {
- yyin->get( buf[0] );
+ SCNG(yyin)->get( buf[0] );
- if ( yyin->eof() )
+ if ( SCNG(yyin)->eof() )
return 0;
- if ( yyin->bad() )
+ if ( SCNG(yyin)->bad() )
return -1;
return 1;
} else {
- (void) yyin->read( buf, max_size );
+ (void) SCNG(yyin)->read( buf, max_size );
- if ( yyin->bad() )
+ if ( SCNG(yyin)->bad() )
return -1;
else
- return yyin->gcount();
+ return SCNG(yyin)->gcount();
}
}
void yyFlexLexer::LexerOutput( const char* buf, int size )
{
- (void) yyout->write( buf, size );
+ (void) SCNG(yyout)->write( buf, size );
}
%*
@@ -733,9 +762,9 @@ void yyFlexLexer::LexerOutput( const char* buf, int size )
*/
%-
-static int yy_get_next_buffer()
+static int yy_get_next_buffer(TSRMLS_D)
%+
-int yyFlexLexer::yy_get_next_buffer()
+int yyFlexLexer::yy_get_next_buffer(TSRMLS_D)
%*
{
register char *dest = yy_current_buffer->yy_ch_buf;
@@ -842,7 +871,7 @@ int yyFlexLexer::yy_get_next_buffer()
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
+ yyrestart( SCNG(yyin) TSRMLS_CC );
}
else
@@ -869,9 +898,9 @@ int yyFlexLexer::yy_get_next_buffer()
/* yy_get_previous_state - get the state just before the EOB char was reached */
%-
-static yy_state_type yy_get_previous_state()
+static yy_state_type yy_get_previous_state(TSRMLS_D)
%+
-yy_state_type yyFlexLexer::yy_get_previous_state()
+yy_state_type yyFlexLexer::yy_get_previous_state(TSRMLS_D)
%*
{
register yy_state_type yy_current_state;
@@ -896,13 +925,16 @@ yy_state_type yyFlexLexer::yy_get_previous_state()
%-
#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state TSRMLS_DC )
#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
+static yy_state_type yy_try_NUL_trans( yy_current_state TSRMLS_CC )
yy_state_type yy_current_state;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
-yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
+yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state TSRMLS_DC )
%*
{
register int yy_is_jam;
@@ -915,14 +947,17 @@ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
%-
#ifndef YY_NO_UNPUT
#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
+static void yyunput( int c, register char *yy_bp TSRMLS_DC )
#else
-static void yyunput( c, yy_bp )
+static void yyunput( c, yy_bp TSRMLS_CC )
int c;
register char *yy_bp;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
-void yyFlexLexer::yyunput( int c, register char* yy_bp )
+void yyFlexLexer::yyunput( int c, register char* yy_bp TSRMLS_DC )
%*
{
register char *yy_cp = yy_c_buf_p;
@@ -966,12 +1001,15 @@ void yyFlexLexer::yyunput( int c, register char* yy_bp )
%-
#ifdef __cplusplus
-static int yyinput()
+static int yyinput(TSRMLS_D)
#else
-static int input()
+static int input(TSRMLS_C)
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
-int yyFlexLexer::yyinput()
+int yyFlexLexer::yyinput(TSRMLS_D)
%*
{
int c;
@@ -993,7 +1031,7 @@ int yyFlexLexer::yyinput()
int offset = yy_c_buf_p - yytext_ptr;
++yy_c_buf_p;
- switch ( yy_get_next_buffer() )
+ switch ( yy_get_next_buffer(TSRMLS_C) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
@@ -1007,7 +1045,7 @@ int yyFlexLexer::yyinput()
*/
/* Reset buffer status. */
- yyrestart( yyin );
+ yyrestart( SCNG(yyin) TSRMLS_CC );
/* fall through */
@@ -1019,9 +1057,9 @@ int yyFlexLexer::yyinput()
if ( ! yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
#ifdef __cplusplus
- return yyinput();
+ return yyinput(TSRMLS_C);
#else
- return input();
+ return input(TSRMLS_C);
#endif
}
@@ -1044,32 +1082,35 @@ int yyFlexLexer::yyinput()
%-
#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
+void yyrestart( FILE *input_file TSRMLS_DC )
#else
-void yyrestart( input_file )
+void yyrestart( input_file TSRMLS_CC )
FILE *input_file;
#endif
%+
-void yyFlexLexer::yyrestart( istream* input_file )
+void yyFlexLexer::yyrestart( istream* input_file TSRMLS_DC )
%*
{
if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+ yy_current_buffer = yy_create_buffer( SCNG(yyin), YY_BUF_SIZE TSRMLS_CC );
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
+ yy_init_buffer( yy_current_buffer, input_file TSRMLS_CC );
+ yy_load_buffer_state(TSRMLS_C);
}
%-
#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer TSRMLS_DC)
#else
-void yy_switch_to_buffer( new_buffer )
+void yy_switch_to_buffer( new_buffer TSRMLS_CC)
YY_BUFFER_STATE new_buffer;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
-void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer TSRMLS_DC )
%*
{
if ( yy_current_buffer == new_buffer )
@@ -1084,7 +1125,7 @@ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
}
yy_current_buffer = new_buffer;
- yy_load_buffer_state();
+ yy_load_buffer_state(TSRMLS_C);
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
@@ -1097,9 +1138,12 @@ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
%-
#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
+void yy_load_buffer_state( TSRMLS_D )
#else
-void yy_load_buffer_state()
+void yy_load_buffer_state(TSRMLS_C)
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
void yyFlexLexer::yy_load_buffer_state()
@@ -1107,21 +1151,24 @@ void yyFlexLexer::yy_load_buffer_state()
{
yy_n_chars = yy_current_buffer->yy_n_chars;
yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
+ SCNG(yyin) = yy_current_buffer->yy_input_file;
yy_hold_char = *yy_c_buf_p;
}
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size TSRMLS_DC )
#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
+YY_BUFFER_STATE yy_create_buffer( file, size TSRMLS_CC )
FILE *file;
int size;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
-YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
+YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size TSRMLS_DC )
%*
{
YY_BUFFER_STATE b;
@@ -1141,7 +1188,7 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
b->yy_is_our_buffer = 1;
- yy_init_buffer( b, file );
+ yy_init_buffer( b, file TSRMLS_CC );
return b;
}
@@ -1149,13 +1196,16 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
%-
#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
+void yy_delete_buffer( YY_BUFFER_STATE b TSRMLS_DC )
#else
-void yy_delete_buffer( b )
+void yy_delete_buffer( b TSRMLS_CC )
YY_BUFFER_STATE b;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
-void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
+void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b TSRMLS_DC )
%*
{
if ( ! b )
@@ -1179,20 +1229,23 @@ extern int isatty YY_PROTO(( int ));
#endif
#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file TSRMLS_DC )
#else
-void yy_init_buffer( b, file )
+void yy_init_buffer( b, file TSRMLS_CC )
YY_BUFFER_STATE b;
FILE *file;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
extern "C" int isatty YY_PROTO(( int ));
-void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
+void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file TSRMLS_DC )
%*
{
- yy_flush_buffer( b );
+ yy_flush_buffer( b TSRMLS_CC );
b->yy_input_file = file;
b->yy_fill_buffer = 1;
@@ -1215,14 +1268,17 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
%-
#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
+void yy_flush_buffer( YY_BUFFER_STATE b TSRMLS_DC )
#else
-void yy_flush_buffer( b )
+void yy_flush_buffer( b TSRMLS_CC )
YY_BUFFER_STATE b;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
-void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
+void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b TSRMLS_DC )
%*
{
if ( ! b )
@@ -1243,7 +1299,7 @@ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == yy_current_buffer )
- yy_load_buffer_state();
+ yy_load_buffer_state(TSRMLS_C);
}
%*
@@ -1251,11 +1307,14 @@ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
#ifndef YY_NO_SCAN_BUFFER
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size TSRMLS_DC )
#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
+YY_BUFFER_STATE yy_scan_buffer( base, size TSRMLS_CC )
char *base;
yy_size_t size;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
{
YY_BUFFER_STATE b;
@@ -1280,7 +1339,7 @@ yy_size_t size;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- yy_switch_to_buffer( b );
+ yy_switch_to_buffer( b TSRMLS_CC );
return b;
}
@@ -1291,17 +1350,20 @@ yy_size_t size;
#ifndef YY_NO_SCAN_STRING
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str TSRMLS_DC )
#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
+YY_BUFFER_STATE yy_scan_string( yy_str TSRMLS_CC )
yyconst char *yy_str;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
{
int len;
for ( len = 0; yy_str[len]; ++len )
;
- return yy_scan_bytes( yy_str, len );
+ return yy_scan_bytes( yy_str, len TSRMLS_CC );
}
%*
#endif
@@ -1310,11 +1372,14 @@ yyconst char *yy_str;
#ifndef YY_NO_SCAN_BYTES
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len TSRMLS_DC )
#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+YY_BUFFER_STATE yy_scan_bytes( bytes, len TSRMLS_CC )
yyconst char *bytes;
int len;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
{
YY_BUFFER_STATE b;
@@ -1333,7 +1398,7 @@ int len;
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
- b = yy_scan_buffer( buf, n );
+ b = yy_scan_buffer( buf, n TSRMLS_CC);
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
@@ -1351,13 +1416,16 @@ int len;
#ifndef YY_NO_PUSH_STATE
%-
#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
+static void yy_push_state( int new_state TSRMLS_DC )
#else
-static void yy_push_state( new_state )
+static void yy_push_state( new_state TSRMLS_CC )
int new_state;
+#ifdef ZTS
+void ***tsrm_ls;
+#endif
#endif
%+
-void yyFlexLexer::yy_push_state( int new_state )
+void yyFlexLexer::yy_push_state( int new_state TSRMLS_DC )
%*
{
if ( yy_start_stack_ptr >= yy_start_stack_depth )
@@ -1388,9 +1456,9 @@ void yyFlexLexer::yy_push_state( int new_state )
#ifndef YY_NO_POP_STATE
%-
-static void yy_pop_state()
+static void yy_pop_state(TSRMLS_D)
%+
-void yyFlexLexer::yy_pop_state()
+void yyFlexLexer::yy_pop_state(TSRMLS_D)
%*
{
if ( --yy_start_stack_ptr < 0 )
diff --git a/Zend/zend.c b/Zend/zend.c
index abd8b49477..be0901c540 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -320,6 +320,12 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS
}
+static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC)
+{
+ zend_copy_ini_directives(TSRMLS_C);
+ zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP TSRMLS_CC);
+}
+
#endif
@@ -340,13 +346,14 @@ static void alloc_globals_dtor(zend_alloc_globals *alloc_globals_p TSRMLS_DC)
#include <floatingpoint.h>
#endif
-#ifdef ZTS
-static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC)
+
+static void scanner_globals_ctor(zend_scanner_globals *scanner_globals_p TSRMLS_DC)
{
- zend_copy_ini_directives(TSRMLS_C);
- zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP TSRMLS_CC);
+ scanner_globals_p->c_buf_p = (char *) 0;
+ scanner_globals_p->init = 1;
+ scanner_globals_p->start = 0;
+ scanner_globals_p->current_buffer = NULL;
}
-#endif
int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions)
@@ -355,6 +362,13 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
zend_compiler_globals *compiler_globals;
zend_executor_globals *executor_globals;
void ***tsrm_ls;
+#ifdef ZTS
+ extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
+ extern ZEND_API ts_rsrc_id language_scanner_globals_id;
+#else
+ extern zend_scanner_globals ini_scanner_globals;
+ extern zend_scanner_globals language_scanner_globals;
+#endif
ts_allocate_id(&alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
#else
@@ -406,6 +420,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
global_constants_table = NULL;
ts_allocate_id(&compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
ts_allocate_id(&executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
+ ts_allocate_id(&language_scanner_globals_id, sizeof(zend_scanner_globals), (ts_allocate_ctor) scanner_globals_ctor, NULL);
+ ts_allocate_id(&ini_scanner_globals_id, sizeof(zend_scanner_globals), (ts_allocate_ctor) scanner_globals_ctor, NULL);
compiler_globals = ts_resource(compiler_globals_id);
executor_globals = ts_resource(executor_globals_id);
tsrm_ls = ts_resource_ex(0, NULL);
@@ -415,6 +431,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
zend_startup_constants(tsrm_ls);
GLOBAL_CONSTANTS_TABLE = EG(zend_constants);
#else
+ scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC);
+ scanner_globals_ctor(&language_scanner_globals TSRMLS_CC);
zend_startup_constants();
zend_set_default_compile_time_values(TSRMLS_C);
EG(user_error_handler) = NULL;
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index 964f61ec2b..f010adf338 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -119,6 +119,8 @@ struct _zend_compiler_globals {
void *ini_parser;
#endif
+ struct _zend_ini_parser_param *ini_parser_param;
+
int interactive;
};
@@ -225,4 +227,16 @@ struct _zend_alloc_globals {
#endif
};
+
+struct _zend_scanner_globals {
+ FILE *yyin;
+ FILE *yyout;
+ int yy_leng;
+ char *yy_text;
+ struct yy_buffer_state *current_buffer;
+ char *c_buf_p;
+ int init;
+ int start;
+};
+
#endif /* ZEND_GLOBALS_H */
diff --git a/Zend/zend_globals_macros.h b/Zend/zend_globals_macros.h
index e6c1343e9e..232bec1cf6 100644
--- a/Zend/zend_globals_macros.h
+++ b/Zend/zend_globals_macros.h
@@ -24,6 +24,7 @@
typedef struct _zend_compiler_globals zend_compiler_globals;
typedef struct _zend_executor_globals zend_executor_globals;
typedef struct _zend_alloc_globals zend_alloc_globals;
+typedef struct _zend_scanner_globals zend_scanner_globals;
/* Compiler */
#ifdef ZTS
@@ -56,6 +57,26 @@ extern ZEND_API zend_alloc_globals alloc_globals;
#endif
+/* Language Scanner */
+#ifdef ZTS
+# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_scanner_globals *, v)
+extern ZEND_API ts_rsrc_id language_scanner_globals_id;
+#else
+# define LANG_SCNG(v) (language_scanner_globals.v)
+extern ZEND_API zend_scanner_globals language_scanner_globals;
+#endif
+
+
+/* INI Scanner */
+#ifdef ZTS
+# define INI_SCNG(v) TSRMG(ini_scanner_globals_id, zend_scanner_globals *, v)
+extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
+#else
+# define INI_SCNG(v) (ini_scanner_globals.v)
+extern ZEND_API zend_scanner_globals ini_scanner_globals;
+#endif
+
+
/* For limited downwards source compatibility */
#define CLS_FETCH()
#define ELS_FETCH()
diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c
index c8af224c60..5fde390a7a 100644
--- a/Zend/zend_highlight.c
+++ b/Zend/zend_highlight.c
@@ -29,8 +29,8 @@
extern char *zendtext;
extern int zendleng;
#else
-#define zendtext ((char *) zend_get_zendtext(TSRMLS_C))
-#define zendleng zend_get_zendleng(TSRMLS_C)
+#define zendtext LANG_SCNG(yy_text)
+#define zendleng LANG_SCNG(yy_leng)
#endif
ZEND_API void zend_html_putc(char c)
diff --git a/Zend/zend_indent.c b/Zend/zend_indent.c
index ff9d41f0a4..eb29b5395c 100644
--- a/Zend/zend_indent.c
+++ b/Zend/zend_indent.c
@@ -30,8 +30,8 @@
extern char *zendtext;
extern int zendleng;
#else
-#define zendtext ((char *) zend_get_zendtext(TSRMLS_C))
-#define zendleng zend_get_zendleng(TSRMLS_C)
+#define zendtext LANG_SCNG(yy_text)
+#define zendleng LANG_SCNG(yy_leng)
#endif
diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h
index 16896792d6..47a13091d4 100644
--- a/Zend/zend_ini.h
+++ b/Zend/zend_ini.h
@@ -191,4 +191,9 @@ int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_
#define ZEND_INI_PARSER_ENTRY 1
#define ZEND_INI_PARSER_SECTION 2
+typedef struct _zend_ini_parser_param {
+ zend_ini_parser_cb_t ini_parser_cb;
+ void *arg;
+} zend_ini_parser_param;
+
#endif /* ZEND_INI_H */
diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y
index d673316fe8..ea7f6dc0c3 100644
--- a/Zend/zend_ini_parser.y
+++ b/Zend/zend_ini_parser.y
@@ -35,25 +35,27 @@
#include <winbase.h>
#endif
-
-typedef struct _zend_ini_parser_param {
- zend_ini_parser_cb_t ini_parser_cb;
- void *arg;
-} zend_ini_parser_param;
-
#define YYSTYPE zval
-#define YYPARSE_PARAM ini_parser_param
-#define ZEND_INI_PARSER_CB ((zend_ini_parser_param *) ini_parser_param)->ini_parser_cb
-#define ZEND_INI_PARSER_ARG ((zend_ini_parser_param *) ini_parser_param)->arg
+#ifdef ZTS
+#define YYPARSE_PARAM tsrm_ls
+#define YYLEX_PARAM tsrm_ls
+#endif
+
+#define ZEND_INI_PARSER_CB (CG(ini_parser_param))->ini_parser_cb
+#define ZEND_INI_PARSER_ARG (CG(ini_parser_param))->arg
-int ini_lex(zval *ini_lval);
-int ini_parse(void *ini_parser_param);
+int ini_lex(zval *ini_lval TSRMLS_DC);
+#ifdef ZTS
+int ini_parse(void *arg);
+#else
+int ini_parse(void);
+#endif
zval yylval;
#ifndef ZTS
-extern int ini_lex(zval *ini_lval);
+extern int ini_lex(zval *ini_lval TSRMLS_DC);
extern FILE *ini_in;
extern int ini_lineno;
extern void init_cfg_scanner(void);
@@ -147,19 +149,20 @@ static void ini_error(char *str)
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;
+ zend_ini_parser_param ini_parser_param;
TSRMLS_FETCH();
ini_parser_param.ini_parser_cb = ini_parser_cb;
ini_parser_param.arg = arg;
+ CG(ini_parser_param) = &ini_parser_param;
if (zend_ini_open_file_for_scanning(fh TSRMLS_CC)==FAILURE) {
return FAILURE;
}
CG(ini_parser_unbuffered_errors) = unbuffered_errors;
- retval = ini_parse(&ini_parser_param);
+ retval = ini_parse(TSRMLS_C);
zend_ini_close_file(fh TSRMLS_CC);
diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h
index 4b2e824d68..1be587fa40 100644
--- a/Zend/zend_ini_scanner.h
+++ b/Zend/zend_ini_scanner.h
@@ -18,7 +18,7 @@ int zend_ini_scanner_get_lineno(TSRMLS_D);
char *zend_ini_scanner_get_filename(TSRMLS_D);
int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC);
void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC);
-int ini_lex(zval *ini_lval);
+int ini_lex(zval *ini_lval TSRMLS_DC);
END_EXTERN_C()
#endif /* _ZEND_INI_SCANNER_H */
diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l
index de981e2cb0..1a19c17133 100644
--- a/Zend/zend_ini_scanner.l
+++ b/Zend/zend_ini_scanner.l
@@ -22,7 +22,7 @@
#include "zend_ini_parser.h"
#include "zend_ini_scanner.h"
-#ifdef ZTS
+#ifdef __cplusplus
# ifdef HAVE_STDIOSTR_H
# include <stdiostr.h>
# endif
@@ -39,16 +39,22 @@
#undef YYSTYPE
#define YYSTYPE zval
-#ifdef ZTS
-#define YY_DECL int ZendIniFlexLexer::lex_scan(zval *ini_lval)
+#ifdef __cplusplus
+#define YY_DECL int ZendIniFlexLexer::lex_scan(zval *ini_lval TSRMLS_DC)
#else
-#define YY_DECL int ini_lex(zval *ini_lval)
+#define YY_DECL int ini_lex(zval *ini_lval TSRMLS_DC)
#endif
-#include "zend_istdiostream.h"
+/* Globals Macros */
+#define SCNG INI_SCNG
+#ifdef ZTS
+ZEND_API ts_rsrc_id ini_scanner_globals_id;
+#else
+ZEND_API zend_scanner_globals ini_scanner_globals;
+#endif
-#ifndef ZTS
+#ifndef __cplusplus
static char *ini_filename;
void init_ini_scanner()
@@ -57,7 +63,7 @@ void init_ini_scanner()
}
-int zend_ini_scanner_get_lineno()
+int zend_ini_scanner_get_lineno(TSRMLS_D)
{
return ini_lineno;
}
@@ -119,7 +125,7 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC)
return FAILURE;
}
-#ifdef ZTS
+#ifdef __cplusplus
if (!fp) {
return FAILURE;
}
@@ -132,7 +138,7 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC)
#else
init_ini_scanner();
yyin = fp;
- yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
+ yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE TSRMLS_CC) TSRMLS_CC);
ini_filename = fh->filename;
#endif
return SUCCESS;
@@ -145,7 +151,7 @@ void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC)
case ZEND_HANDLE_FP:
fclose(fh->handle.fp);
break;
-#ifdef ZTS
+#ifdef __cplusplus
case ZEND_HANDLE_STDIOSTREAM: {
TSRMLS_FETCH();
delete CG(ini_scanner);
@@ -278,6 +284,6 @@ NEWLINE ("\r"|"\n"|"\r\n")
}
<<EOF>> {
- yy_delete_buffer(YY_CURRENT_BUFFER);
+ yy_delete_buffer(YY_CURRENT_BUFFER TSRMLS_CC);
yyterminate();
}
diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h
index f3b478d06b..b8819a350b 100644
--- a/Zend/zend_language_scanner.h
+++ b/Zend/zend_language_scanner.h
@@ -21,7 +21,7 @@
#ifndef ZEND_SCANNER_H
#define ZEND_SCANNER_H
-#ifdef ZTS
+#ifdef __cplusplus
class ZendFlexLexer : public yyFlexLexer
{
public:
@@ -34,7 +34,7 @@ public:
typedef struct _zend_lex_state {
-#ifndef ZTS
+#ifndef __cplusplus
YY_BUFFER_STATE buffer_state;
int state;
FILE *in;
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 9b19423fc2..37be5e7994 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -49,7 +49,7 @@
#include "zend_variables.h"
#include "zend_operators.h"
-#ifdef ZTS
+#ifdef __cplusplus
# include <fstream.h>
# ifdef HAVE_STDIOSTR_H
# include <stdiostr.h>
@@ -72,7 +72,7 @@
# include <unistd.h>
#endif
-#ifdef ZTS
+#ifdef __cplusplus
#define YY_DECL int ZendFlexLexer::lex_scan(zval *zendlval TSRMLS_DC)
#else
#define YY_DECL int lex_scan(zval *zendlval TSRMLS_DC)
@@ -86,7 +86,15 @@
# define MY_INPUT input
#endif
-#include "zend_istdiostream.h"
+
+/* Globals Macros */
+#define SCNG LANG_SCNG
+#ifdef ZTS
+ZEND_API ts_rsrc_id language_scanner_globals_id;
+#else
+ZEND_API zend_scanner_globals language_scanner_globals;
+#endif
+
#define YY_FATAL_ERROR zend_fatal_scanner_error
@@ -141,7 +149,7 @@ END_EXTERN_C()
static inline void save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
{
-#ifndef ZTS
+#ifndef __cplusplus
memcpy(&lex_state->buffer_state,&YY_CURRENT_BUFFER,sizeof(YY_BUFFER_STATE));
lex_state->in = yyin;
lex_state->state = YYSTATE;
@@ -155,16 +163,16 @@ static inline void save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
static inline void restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
{
-#ifndef ZTS
+#ifndef __cplusplus
YY_BUFFER_STATE original_buffer_state = YY_CURRENT_BUFFER;
if (lex_state->buffer_state) {
- yy_switch_to_buffer(lex_state->buffer_state);
+ yy_switch_to_buffer(lex_state->buffer_state TSRMLS_CC);
} else {
YY_CURRENT_BUFFER = NULL;
}
- yy_delete_buffer(original_buffer_state);
+ yy_delete_buffer(original_buffer_state TSRMLS_CC);
yyin = lex_state->in;
BEGIN(lex_state->state);
#else
@@ -190,7 +198,7 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh)
* which doesn't really contain open files, but references to their names/paths
*/
break;
-#ifdef ZTS
+#ifdef __cplusplus
case ZEND_HANDLE_FSTREAM:
delete ((ifstream *) fh->handle.is);
break;
@@ -220,7 +228,7 @@ int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2)
case ZEND_HANDLE_FP:
return fh1->handle.fp==fh2->handle.fp;
break;
-#ifdef ZTS
+#ifdef __cplusplus
case ZEND_HANDLE_FSTREAM:
case ZEND_HANDLE_STDIOSTREAM:
return fh1->handle.is==fh2->handle.is;
@@ -241,7 +249,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
{
char *file_path=NULL;
-#ifndef ZTS
+#ifndef __cplusplus
switch (file_handle->type) {
case ZEND_HANDLE_FILENAME:
file_handle->handle.fp = zend_fopen(file_handle->filename, &file_handle->opened_path);
@@ -263,7 +271,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
}
/* Reset the scanner for scanning the new file */
yyin = file_handle->handle.fp;
- yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
+ yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE TSRMLS_CC) TSRMLS_CC);
BEGIN(INITIAL);
#else
switch (file_handle->type) {
@@ -409,20 +417,20 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
return retval;
}
-#ifndef ZTS
-static inline int prepare_string_for_scanning(zval *str, char *filename)
+#ifndef __cplusplus
+static inline int prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC)
#else
static inline int prepare_string_for_scanning(zval *str, istrstream **input_stream, char *filename TSRMLS_DC)
#endif
{
-#ifndef ZTS
+#ifndef __cplusplus
/* enforce two trailing NULLs for flex... */
STR_REALLOC(str->value.str.val, str->value.str.len+2);
str->value.str.val[str->value.str.len+1]=0;
yyin=NULL;
- yy_scan_buffer(str->value.str.val, str->value.str.len+2);
+ yy_scan_buffer(str->value.str.val, str->value.str.len+2 TSRMLS_CC);
#else
*input_stream = new istrstream(str->value.str.val, str->value.str.len);
CG(ZFL) = new ZendFlexLexer;
@@ -444,7 +452,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
zval tmp;
int compiler_result;
zend_bool original_in_compilation = CG(in_compilation);
-#ifdef ZTS
+#ifdef __cplusplus
istrstream *input_stream;
#endif
@@ -461,8 +469,8 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
source_string = &tmp;
save_lexical_state(&original_lex_state TSRMLS_CC);
-#ifndef ZTS
- if (prepare_string_for_scanning(source_string, filename)==FAILURE) {
+#ifndef __cplusplus
+ if (prepare_string_for_scanning(source_string, filename TSRMLS_CC)==FAILURE) {
#else
if (prepare_string_for_scanning(source_string, &input_stream, filename TSRMLS_CC)==FAILURE) {
#endif
@@ -471,7 +479,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
} else {
init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);
CG(active_op_array) = op_array;
-#ifndef ZTS
+#ifndef __cplusplus
BEGIN(ST_IN_SCRIPTING);
#else
CG(ZFL)->BeginState(ST_IN_SCRIPTING);
@@ -490,7 +498,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
}
restore_lexical_state(&original_lex_state TSRMLS_CC);
}
-#ifdef ZTS
+#ifdef __cplusplus
delete input_stream;
#endif
zval_dtor(&tmp);
@@ -524,15 +532,15 @@ int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_
{
zend_lex_state original_lex_state;
zval tmp = *str;
-#ifdef ZTS
+#ifdef __cplusplus
istrstream *input_stream;
#endif
str = &tmp;
zval_copy_ctor(str);
save_lexical_state(&original_lex_state TSRMLS_CC);
-#ifndef ZTS
- if (prepare_string_for_scanning(str, str_name)==FAILURE) {
+#ifndef __cplusplus
+ if (prepare_string_for_scanning(str, str_name TSRMLS_CC)==FAILURE) {
#else
if (prepare_string_for_scanning(str, &input_stream, str_name TSRMLS_CC)==FAILURE) {
#endif
@@ -540,7 +548,7 @@ int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_
}
zend_highlight(syntax_highlighter_ini TSRMLS_CC);
restore_lexical_state(&original_lex_state TSRMLS_CC);
-#ifdef ZTS
+#ifdef __cplusplus
delete input_stream;
#endif
zval_dtor(str);
@@ -548,7 +556,7 @@ int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_
}
END_EXTERN_C()
-#ifdef ZTS
+#ifdef __cplusplus
BEGIN_EXTERN_C()
int lex_scan(zval *zendlval TSRMLS_DC)
{
@@ -731,12 +739,12 @@ NEWLINE ("\r"|"\n"|"\r\n")
}
<ST_IN_SCRIPTING,ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"->" {
- yy_push_state(ST_LOOKING_FOR_PROPERTY);
+ yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
return T_OBJECT_OPERATOR;
}
<ST_LOOKING_FOR_PROPERTY>{LABEL} {
- yy_pop_state();
+ yy_pop_state(TSRMLS_C);
zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
@@ -745,7 +753,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} {
yyless(0);
- yy_pop_state();
+ yy_pop_state(TSRMLS_C);
}
<ST_IN_SCRIPTING>"::" {
@@ -954,13 +962,13 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_IN_SCRIPTING>"{" {
- yy_push_state(ST_IN_SCRIPTING);
+ yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
return '{';
}
<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"${" {
- yy_push_state(ST_LOOKING_FOR_VARNAME);
+ yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC);
return T_DOLLAR_OPEN_CURLY_BRACES;
}
@@ -968,7 +976,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_IN_SCRIPTING>"}" {
/* This is a temporary fix which is dependant on flex and it's implementation */
if (yy_start_stack_ptr) {
- yy_pop_state();
+ yy_pop_state(TSRMLS_C);
}
return '}';
}
@@ -978,16 +986,16 @@ NEWLINE ("\r"|"\n"|"\r\n")
zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
- yy_pop_state();
- yy_push_state(ST_IN_SCRIPTING);
+ yy_pop_state(TSRMLS_C);
+ yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
return T_STRING_VARNAME;
}
<ST_LOOKING_FOR_VARNAME>{ANY_CHAR} {
yyless(0);
- yy_pop_state();
- yy_push_state(ST_IN_SCRIPTING);
+ yy_pop_state(TSRMLS_C);
+ yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
}
@@ -1488,7 +1496,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"{$" {
zendlval->value.lval = (long) yytext[0];
- yy_push_state(ST_IN_SCRIPTING);
+ yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
yyless(1);
return T_CURLY_OPEN;
}