#ifdef ZTS
#include <fstream.h>
+#include <strstrea.h>
#endif
#include "zend.h"
BEGIN(INITIAL);
zend_set_compiled_filename(file_handle->filename);
- return SUCCESS;
#else
ifstream *input_file = new ifstream(file_handle->filename);
CG(ZFL) = new ZendFlexLexer;
CG(ZFL)->switch_streams(input_file, &cout);
- return SUCCESS;
#endif
+ return SUCCESS;
}
END_EXTERN_C()
}
-static inline int prepare_string_for_scanning(zval *str)
+static inline int prepare_string_for_scanning(zval *str CLS_DC)
{
#ifndef ZTS
/* enforce two trailing NULLs for flex... */
str->value.str.val = (char *) erealloc(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);
+#else
+ istrstream *input_stream = new istrstream(str->value.str.val, str->value.str.len);
+ CG(ZFL) = new ZendFlexLexer;
+
+ CG(ZFL)->switch_streams(input_stream, &cout);
#endif
return SUCCESS;
}
zend_op_array *compile_string(zval *source_string CLS_DC)
{
-#ifndef ZTS
zend_lex_state original_lex_state;
zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));
zend_op_array *original_active_op_array = CG(active_op_array);
init_op_array(op_array, INITIAL_OP_ARRAY_SIZE);
save_lexical_state(&original_lex_state CLS_CC);
- if (prepare_string_for_scanning(source_string)==FAILURE) {
+ if (prepare_string_for_scanning(source_string CLS_CC)==FAILURE) {
destroy_op_array(op_array);
efree(op_array);
retval = NULL;
} else {
CG(active_op_array) = op_array;
+#ifndef ZTS
BEGIN(IN_SCRIPTING);
+#else
+ CG(ZFL)->BeginState(IN_SCRIPTING);
+#endif
if (zendparse(CLS_C)==1) {
retval = NULL;
} else {
zval_dtor(&tmp);
return retval;
-#else
- return NULL;
-#endif
}
str = &tmp;
zval_copy_ctor(str);
save_lexical_state(&original_lex_state CLS_CC);
- if (prepare_string_for_scanning(str)==FAILURE) {
+ if (prepare_string_for_scanning(str CLS_CC)==FAILURE) {
return FAILURE;
}
zend_highlight(syntax_highlighter_ini);
}
+void ZendFlexLexer::BeginState(int state)
+{
+ BEGIN(state);
+}
+
+
int yyFlexLexer::yylex()
{
fprintf(stderr, "Error: yyFlexLexer::yylex() called\n");