Browse Source

- Rewrite scanner to be based on re2c instead of flex

The full patch is available as:
  http://php.net/~helly/php-re2c-5.3-20080316.diff.txt
  This is against php-re2c repository version 98
  An older patch against version 97 is available under:
  http://php.net/~helly/php-re2c-97-20080316.diff.txt
PECL
Marcus Boerger 18 years ago
parent
commit
af316021e8
  1. 4
      Makefile.frag
  2. 1
      NEWS
  3. 186
      Zend/FlexLexer.h
  4. 6
      Zend/Makefile.am
  5. 15
      Zend/Zend.m4
  6. 1
      Zend/configure.in
  7. 1648
      Zend/flex.skl
  8. 7
      Zend/tests/bug42767.phpt
  9. 35
      Zend/zend.c
  10. 63
      Zend/zend_compile.c
  11. 8
      Zend/zend_compile.h
  12. 82
      Zend/zend_globals.h
  13. 11
      Zend/zend_globals_macros.h
  14. 22
      Zend/zend_highlight.c
  15. 2
      Zend/zend_ini_parser.y
  16. 1
      Zend/zend_ini_scanner.h
  17. 217
      Zend/zend_ini_scanner.l
  18. 28
      Zend/zend_language_scanner.h
  19. 740
      Zend/zend_language_scanner.l
  20. 11
      Zend/zend_stack.c
  21. 310
      Zend/zend_stream.c
  22. 63
      Zend/zend_stream.h
  23. 2
      Zend/zend_strtod.c
  24. 2
      Zend/zend_vm_def.h
  25. 8
      Zend/zend_vm_execute.h
  26. 71
      acinclude.m4
  27. 31
      configure.in
  28. 2
      ext/spl/php_spl.c
  29. 8
      ext/standard/tests/strings/006.phpt
  30. 6
      ext/standard/tests/strings/007.phpt
  31. 17
      ext/standard/tests/strings/highlight_file.phpt
  32. 2
      ext/standard/tests/strings/strip_tags_basic1.phpt
  33. 2
      ext/standard/tests/strings/strip_tags_basic2.phpt
  34. 2
      ext/standard/tests/strings/strip_tags_error.phpt
  35. 2
      ext/standard/tests/strings/strip_tags_variation1.phpt
  36. 2
      ext/standard/tests/strings/strip_tags_variation10.phpt
  37. 2
      ext/standard/tests/strings/strip_tags_variation2.phpt
  38. 2
      ext/standard/tests/strings/strip_tags_variation3.phpt
  39. 2
      ext/standard/tests/strings/strip_tags_variation4.phpt
  40. 2
      ext/standard/tests/strings/strip_tags_variation5.phpt
  41. 2
      ext/standard/tests/strings/strip_tags_variation6.phpt
  42. 2
      ext/standard/tests/strings/strip_tags_variation7.phpt
  43. 2
      ext/standard/tests/strings/strip_tags_variation8.phpt
  44. 2
      ext/standard/tests/strings/strip_tags_variation9.phpt
  45. 4
      ext/tokenizer/Makefile.frag
  46. 13
      ext/tokenizer/tests/token_get_all_variation14.phpt
  47. 62
      ext/tokenizer/tokenizer.c
  48. 48
      main/main.c
  49. 8
      sapi/apache/mod_php5.c
  50. 8
      sapi/apache_hooks/mod_php5.c
  51. 6
      sapi/cgi/cgi_main.c
  52. 4
      sapi/cgi/tests/007.phpt
  53. 5
      sapi/cli/php_cli.c
  54. 23
      sapi/cli/tests/010.phpt
  55. 105
      sapi/cli/tests/016.phpt
  56. 106
      sapi/cli/tests/017.phpt
  57. 6
      sapi/tests/test003.phpt
  58. 6
      sapi/tests/test004.phpt
  59. 6
      win32/build/config.w32

4
Makefile.frag

@ -7,7 +7,7 @@ $(builddir)/zend_language_scanner.lo: $(srcdir)/zend_language_parser.h
$(builddir)/zend_ini_scanner.lo: $(srcdir)/zend_ini_parser.h
$(srcdir)/zend_language_scanner.c: $(srcdir)/zend_language_scanner.l
@$(LEX) -Pzend -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_language_scanner.l
$(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt $(srcdir)/zend_language_scanner_defs.h -o$@ $(srcdir)/zend_language_scanner.l
$(srcdir)/zend_language_parser.h: $(srcdir)/zend_language_parser.c
$(srcdir)/zend_language_parser.c: $(srcdir)/zend_language_parser.y
@ -18,6 +18,6 @@ $(srcdir)/zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
@$(YACC) -p ini_ -v -d $(srcdir)/zend_ini_parser.y -o $@
$(srcdir)/zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
@$(LEX) -Pini_ -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_ini_scanner.l
$(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt $(srcdir)/zend_ini_scanner_defs.h -o$@ $(srcdir)/zend_ini_scanner.l
$(builddir)/zend_indent.lo $(builddir)/zend_highlight.lo $(builddir)/zend_compile.lo: $(srcdir)/zend_language_parser.h

1
NEWS

@ -79,6 +79,7 @@ PHP NEWS
- Added PREG_BAD_UTF8_OFFSET_ERROR constant. (Nuno)
- Improved PHP runtime speed and memory usage:
. Replaced flex based scanner with re2c based scanner. (Marcus, Nuno, Scott)
. Added garbage collector. (David Wang, Dmitry).
. Improved PHP binary size and startup speed with GCC4 visibility control.
(Nuno)

186
Zend/FlexLexer.h

@ -1,186 +0,0 @@
// $Header$
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
// by flex
// Copyright (c) 1993 The Regents of the University of California.
// All rights reserved.
//
// This code is derived from software contributed to Berkeley by
// Kent Williams and Tom Epperly.
//
// Redistribution and use in source and binary forms with or without
// modification are permitted provided that: (1) source distributions retain
// this entire copyright notice and comment, and (2) distributions including
// binaries display the following acknowledgement: ``This product includes
// software developed by the University of California, Berkeley and its
// contributors'' in the documentation or other materials provided with the
// distribution and in all advertising materials mentioning features or use
// of this software. Neither the name of the University nor the names of
// its contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// This file defines FlexLexer, an abstract class which specifies the
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
// which defines a particular lexer class.
//
// If you want to create multiple lexer classes, you use the -P flag
// to rename each yyFlexLexer to some other xxFlexLexer. You then
// include <FlexLexer.h> in your other sources once per lexer class:
//
// #undef yyFlexLexer
// #define yyFlexLexer xxFlexLexer
// #include <FlexLexer.h>
//
// #undef yyFlexLexer
// #define yyFlexLexer zzFlexLexer
// #include <FlexLexer.h>
// ...
#ifndef FLEXLEXER_H
// Never included before - need to define base class.
#define FLEXLEXER_H
#include <iostream.h>
extern "C++" {
struct yy_buffer_state;
typedef int yy_state_type;
class FlexLexer {
public:
virtual ~FlexLexer() { }
const char* YYText() { return yytext; }
int YYLeng() { return yyleng; }
virtual void
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
virtual struct yy_buffer_state*
yy_create_buffer( istream* s, int size ) = 0;
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
virtual void yyrestart( istream* s ) = 0;
virtual int yylex() = 0;
// Call yylex with new input/output sources.
int yylex( istream* new_in, ostream* new_out = 0 )
{
switch_streams( new_in, new_out );
return yylex();
}
// Switch to new input/output streams. A nil stream pointer
// indicates "keep the current one".
virtual void switch_streams( istream* new_in = 0,
ostream* new_out = 0 ) = 0;
int lineno() const { return yylineno; }
int debug() const { return yy_flex_debug; }
void set_debug( int flag ) { yy_flex_debug = flag; }
protected:
char* yytext;
int yyleng;
int yylineno; // only maintained if you use %option yylineno
int yy_flex_debug; // only has effect with -d or "%option debug"
};
}
#endif
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
// Either this is the first time through (yyFlexLexerOnce not defined),
// or this is a repeated include to define a different flavor of
// yyFlexLexer, as discussed in the flex man page.
#define yyFlexLexerOnce
class yyFlexLexer : public FlexLexer {
public:
// arg_yyin and arg_yyout default to the cin and cout, but we
// only make that assignment when initializing in yylex().
yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );
virtual ~yyFlexLexer();
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
struct yy_buffer_state* yy_create_buffer( istream* s, int size );
void yy_delete_buffer( struct yy_buffer_state* b );
void yyrestart( istream* s );
virtual int yylex();
virtual void switch_streams( istream* new_in, ostream* new_out );
protected:
virtual int LexerInput( char* buf, int max_size );
virtual void LexerOutput( const char* buf, int size );
virtual void LexerError( const char* msg );
void yyunput( int c, char* buf_ptr );
int yyinput();
void yy_load_buffer_state();
void yy_init_buffer( struct yy_buffer_state* b, istream* s );
void yy_flush_buffer( struct yy_buffer_state* b );
int yy_start_stack_ptr;
int yy_start_stack_depth;
int* yy_start_stack;
void yy_push_state( int new_state );
void yy_pop_state();
int yy_top_state();
yy_state_type yy_get_previous_state();
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
int yy_get_next_buffer();
istream* yyin; // input source for default LexerInput
ostream* yyout; // output sink for default LexerOutput
struct yy_buffer_state* yy_current_buffer;
// yy_hold_char holds the character lost when yytext is formed.
char yy_hold_char;
// Number of characters read into yy_ch_buf.
int yy_n_chars;
// Points to current character in buffer.
char* yy_c_buf_p;
int yy_init; // whether we need to initialize
int yy_start; // start state number
// Flag which is used to allow yywrap()'s to do buffer switches
// instead of setting up a fresh yyin. A bit of a hack ...
int yy_did_buffer_switch_on_eof;
// The following are not always needed, but may be depending
// on use of certain flex features (like REJECT or yymore()).
yy_state_type yy_last_accepting_state;
char* yy_last_accepting_cpos;
yy_state_type* yy_state_buf;
yy_state_type* yy_state_ptr;
char* yy_full_match;
int* yy_full_state;
int yy_full_lp;
int yy_lp;
int yy_looking_for_trail_begin;
int yy_more_flag;
int yy_more_len;
int yy_more_offset;
int yy_prev_more_offset;
};
#endif

6
Zend/Makefile.am

@ -17,7 +17,7 @@ libZend_la_SOURCES=\
zend_objects_API.c zend_ts_hash.c zend_stream.c \
zend_default_classes.c \
zend_iterators.c zend_interfaces.c zend_exceptions.c \
zend_strtod.c zend_multibyte.c
zend_strtod.c
libZend_la_LDFLAGS =
libZend_la_LIBADD = @ZEND_EXTRA_LIBS@
@ -31,7 +31,7 @@ zend_ini_scanner.lo: zend_ini_parser.h
# Language parser/scanner rules
zend_language_scanner.c: $(srcdir)/zend_language_scanner.l
$(LEX) -Pzend -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_language_scanner.l
$(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt $(srcdir)/zend_language_scanner_defs.h -o$@ $(srcdir)/zend_language_scanner.l
zend_language_parser.h: zend_language_parser.c
zend_language_parser.c: $(srcdir)/zend_language_parser.y
@ -43,7 +43,7 @@ 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_ -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_ini_scanner.l
$(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt $(srcdir)/zend_ini_scanner_defs.h -o$@ $(srcdir)/zend_ini_scanner.l
zend_ini_parser.h: zend_ini_parser.c

15
Zend/Zend.m4

@ -31,7 +31,6 @@ AC_DEFUN([LIBZEND_BASIC_CHECKS],[
AC_REQUIRE([AC_PROG_YACC])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CC_C_O])
AC_REQUIRE([AC_PROG_LEX])
AC_REQUIRE([AC_HEADER_STDC])
LIBZEND_BISON_CHECK
@ -155,13 +154,6 @@ AC_ARG_ENABLE(inline-optimization,
ZEND_INLINE_OPTIMIZATION=yes
])
AC_ARG_ENABLE(zend-multibyte,
[ --enable-zend-multibyte Compile with zend multibyte support], [
ZEND_MULTIBYTE=$enableval
],[
ZEND_MULTIBYTE=no
])
AC_MSG_CHECKING([virtual machine dispatch method])
AC_MSG_RESULT($PHP_ZEND_VM)
@ -174,9 +166,6 @@ AC_MSG_RESULT($ZEND_INLINE_OPTIMIZATION)
AC_MSG_CHECKING(whether to enable Zend debugging)
AC_MSG_RESULT($ZEND_DEBUG)
AC_MSG_CHECKING(whether to enable Zend multibyte)
AC_MSG_RESULT($ZEND_MULTIBYTE)
case $PHP_ZEND_VM in
SWITCH)
AC_DEFINE(ZEND_VM_KIND,ZEND_VM_KIND_SWITCH,[virtual machine dispatch method])
@ -211,10 +200,6 @@ if test "$ZEND_MAINTAINER_ZTS" = "yes"; then
LIBZEND_CPLUSPLUS_CHECKS
fi
if test "$ZEND_MULTIBYTE" = "yes"; then
AC_DEFINE(ZEND_MULTIBYTE, 1, [ ])
fi
changequote({,})
if test -n "$GCC" && test "$ZEND_INLINE_OPTIMIZATION" != "yes"; then
INLINE_CFLAGS=`echo $ac_n "$CFLAGS $ac_c" | sed s/-O[0-9s]*//`

1
Zend/configure.in

@ -7,7 +7,6 @@ AM_CONFIG_HEADER(zend_config.h)
AM_SANITY_CHECK
AM_MAINTAINER_MODE
AC_PROG_CC
AM_PROG_LEX
AM_PROG_CC_STDC
ZEND_VERSION=$VERSION
AC_ZEND_C_BIGENDIAN

1648
Zend/flex.skl
File diff suppressed because it is too large
View File

7
Zend/tests/bug42767.phpt

@ -1,5 +1,12 @@
--TEST--
Bug #42767 (highlight_string() truncates trailing comments)
--INI--
highlight.string = #DD0000
highlight.comment = #FF8000
highlight.keyword = #007700
highlight.bg = #FFFFFF
highlight.default = #0000BB
highlight.html = #000000
--FILE--
<?php
highlight_string('<?php /*some comment..');

35
Zend/zend.c

@ -91,9 +91,6 @@ ZEND_INI_BEGIN()
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
STD_ZEND_INI_BOOLEAN("zend.enable_gc", "1", ZEND_INI_ALL, OnUpdateGCEnabled, gc_enabled, zend_gc_globals, gc_globals)
STD_ZEND_INI_BOOLEAN("zend.ze1_compatibility_mode", "0", ZEND_INI_ALL, OnUpdateBool, ze1_compatibility_mode, zend_executor_globals, executor_globals)
#ifdef ZEND_MULTIBYTE
STD_ZEND_INI_BOOLEAN("detect_unicode", "1", ZEND_INI_ALL, OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals)
#endif
ZEND_INI_END()
@ -565,19 +562,15 @@ static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC) /* {{{ */
#include <floatingpoint.h>
#endif
static void scanner_globals_ctor(zend_scanner_globals *scanner_globals_p TSRMLS_DC) /* {{{ */
static void ini_scanner_globals_ctor(zend_ini_scanner_globals *scanner_globals_p TSRMLS_DC) /* {{{ */
{
memset(scanner_globals_p, 0, sizeof(*scanner_globals_p));
}
/* }}} */
static void php_scanner_globals_ctor(zend_php_scanner_globals *scanner_globals_p TSRMLS_DC) /* {{{ */
{
scanner_globals_p->c_buf_p = (char *) 0;
scanner_globals_p->init = 1;
scanner_globals_p->start = 0;
scanner_globals_p->current_buffer = NULL;
scanner_globals_p->yy_in = NULL;
scanner_globals_p->yy_out = NULL;
scanner_globals_p->_yy_more_flag = 0;
scanner_globals_p->_yy_more_len = 0;
scanner_globals_p->yy_start_stack_ptr = 0;
scanner_globals_p->yy_start_stack_depth = 0;
scanner_globals_p->yy_start_stack = 0;
memset(scanner_globals_p, 0, sizeof(*scanner_globals_p));
}
/* }}} */
@ -591,8 +584,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
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;
extern zend_ini_scanner_globals ini_scanner_globals;
extern zend_php_scanner_globals language_scanner_globals;
#endif
TSRMLS_FETCH();
@ -658,8 +651,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
#ifdef ZTS
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);
ts_allocate_id(&language_scanner_globals_id, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
ts_allocate_id(&ini_scanner_globals_id, sizeof(zend_ini_scanner_globals), (ts_allocate_ctor) ini_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);
@ -676,8 +669,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
zend_hash_destroy(executor_globals->zend_constants);
*executor_globals->zend_constants = *GLOBAL_CONSTANTS_TABLE;
#else
scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC);
scanner_globals_ctor(&language_scanner_globals TSRMLS_CC);
ini_scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC);
php_scanner_globals_ctor(&language_scanner_globals TSRMLS_CC);
zend_set_default_compile_time_values(TSRMLS_C);
EG(user_error_handler) = NULL;
EG(user_exception_handler) = NULL;

63
Zend/zend_compile.c

@ -28,10 +28,6 @@
#include "zend_exceptions.h"
#include "tsrm_virtual_cwd.h"
#ifdef ZEND_MULTIBYTE
#include "zend_multibyte.h"
#endif /* ZEND_MULTIBYTE */
ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC);
@ -77,7 +73,7 @@ static void build_runtime_defined_function_key(zval *result, char *name, int nam
uint char_pos_len;
char *filename;
char_pos_len = zend_sprintf(char_pos_buf, "%p", LANG_SCNG(_yy_last_accepting_cpos));
char_pos_len = zend_sprintf(char_pos_buf, "%p", LANG_SCNG(yy_text));
if (CG(active_op_array)->filename) {
filename = CG(active_op_array)->filename;
} else {
@ -86,14 +82,7 @@ static void build_runtime_defined_function_key(zval *result, char *name, int nam
/* NULL, name length, filename length, last accepting char position length */
result->value.str.len = 1+name_length+strlen(filename)+char_pos_len;
#ifdef ZEND_MULTIBYTE
/* must be binary safe */
result->value.str.val = (char *) safe_emalloc(result->value.str.len, 1, 1);
result->value.str.val[0] = '\0';
sprintf(result->value.str.val+1, "%s%s%s", name, filename, char_pos_buf);
#else
zend_spprintf(&result->value.str.val, 0, "%c%s%s%s", '\0', name, filename, char_pos_buf);
#endif /* ZEND_MULTIBYTE */
result->type = IS_STRING;
Z_SET_REFCOUNT_P(result, 1);
}
@ -144,15 +133,14 @@ void zend_init_compiler_data_structures(TSRMLS_D)
CG(current_import) = NULL;
init_compiler_declarables(TSRMLS_C);
zend_hash_apply(CG(auto_globals), (apply_func_t) zend_auto_global_arm TSRMLS_CC);
}
ZEND_API void file_handle_dtor(zend_file_handle *fh)
{
TSRMLS_FETCH();
#ifdef ZEND_MULTIBYTE
CG(script_encoding_list) = NULL;
CG(script_encoding_list_size) = 0;
CG(internal_encoding) = NULL;
CG(encoding_detector) = NULL;
CG(encoding_converter) = NULL;
CG(encoding_oddlen) = NULL;
#endif /* ZEND_MULTIBYTE */
zend_file_handle_dtor(fh TSRMLS_CC);
}
@ -162,7 +150,7 @@ void init_compiler(TSRMLS_D)
zend_init_compiler_data_structures(TSRMLS_C);
zend_init_rsrc_list(TSRMLS_C);
zend_hash_init(&CG(filenames_table), 5, NULL, (dtor_func_t) free_estring, 0);
zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_file_handle_dtor, 0);
zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) file_handle_dtor, 0);
CG(unclean_shutdown) = 0;
}
@ -178,12 +166,6 @@ void shutdown_compiler(TSRMLS_D)
zend_stack_destroy(&CG(list_stack));
zend_hash_destroy(&CG(filenames_table));
zend_llist_destroy(&CG(open_files));
#ifdef ZEND_MULTIBYTE
if (CG(script_encoding_list)) {
efree(CG(script_encoding_list));
}
#endif /* ZEND_MULTIBYTE */
}
@ -4322,33 +4304,12 @@ void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC)
if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "ticks", sizeof("ticks")-1)) {
convert_to_long(&val->u.constant);
CG(declarables).ticks = val->u.constant;
#ifdef ZEND_MULTIBYTE
} else if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) {
zend_encoding *new_encoding, *old_encoding;
zend_encoding_filter old_input_filter;
if (Z_TYPE(val->u.constant) == IS_CONSTANT) {
zend_error(E_COMPILE_ERROR, "Cannot use constants as encoding");
}
convert_to_string(&val->u.constant);
new_encoding = zend_multibyte_fetch_encoding(val->u.constant.value.str.val);
if (!new_encoding) {
zend_error(E_COMPILE_WARNING, "Unsupported encoding [%s]", val->u.constant.value.str.val);
} else {
old_input_filter = LANG_SCNG(input_filter);
old_encoding = LANG_SCNG(script_encoding);
zend_multibyte_set_filter(new_encoding TSRMLS_CC);
/* need to re-scan if input filter changed */
if (old_input_filter != LANG_SCNG(input_filter) ||
((old_input_filter == zend_multibyte_script_encoding_filter) &&
(new_encoding != old_encoding))) {
zend_multibyte_yyinput_again(old_input_filter, old_encoding TSRMLS_CC);
}
}
/* Do not generate any kind of warning for encoding declares */
/* zend_error(E_COMPILE_WARNING, "Declare encoding [%s] not supported", val->u.constant.value.str.val); */
efree(val->u.constant.value.str.val);
#endif /* ZEND_MULTIBYTE */
} else {
zend_error(E_COMPILE_WARNING, "Unsupported declare '%s'", var->u.constant.value.str.val);
zval_dtor(&val->u.constant);
}
zval_dtor(&var->u.constant);

8
Zend/zend_compile.h

@ -655,14 +655,6 @@ int zendlex(znode *zendlval TSRMLS_DC);
#define ZEND_CT (1<<0)
#define ZEND_RT (1<<1)
#define ZEND_HANDLE_FILENAME 0
#define ZEND_HANDLE_FD 1
#define ZEND_HANDLE_FP 2
#define ZEND_HANDLE_STDIOSTREAM 3
#define ZEND_HANDLE_FSTREAM 4
#define ZEND_HANDLE_STREAM 5
#define ZEND_FETCH_STANDARD 0
#define ZEND_FETCH_ADD_LOCK (1<<0)
#define ZEND_FETCH_MAKE_REF (1<<1)

82
Zend/zend_globals.h

@ -35,10 +35,6 @@
#include "zend_objects_API.h"
#include "zend_modules.h"
#ifdef ZEND_MULTIBYTE
#include "zend_multibyte.h"
#endif /* ZEND_MULTIBYTE */
/* Define ZTS if you want a thread-safe Zend */
/*#undef ZTS*/
@ -134,19 +130,6 @@ struct _zend_compiler_globals {
zval *current_namespace;
HashTable *current_import;
#ifdef ZEND_MULTIBYTE
zend_encoding **script_encoding_list;
int script_encoding_list_size;
zend_bool detect_unicode;
zend_encoding *internal_encoding;
/* multibyte utility functions */
zend_encoding_detector encoding_detector;
zend_encoding_converter encoding_converter;
zend_encoding_oddlen encoding_oddlen;
#endif /* ZEND_MULTIBYTE */
#ifdef ZTS
HashTable **static_members;
int last_static_member;
@ -251,47 +234,40 @@ struct _zend_executor_globals {
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
struct _zend_scanner_globals {
struct _zend_ini_scanner_globals {
zend_file_handle *yy_in;
zend_file_handle *yy_out;
int yy_leng;
char *yy_text;
struct yy_buffer_state *current_buffer;
char *c_buf_p;
int init;
int start;
unsigned int yy_leng;
unsigned char *yy_start;
unsigned char *yy_text;
unsigned char *yy_cursor;
unsigned char *yy_marker;
unsigned char *yy_limit;
int yy_state;
zend_stack state_stack;
char *filename;
int lineno;
char _yy_hold_char;
int yy_n_chars;
int _yy_did_buffer_switch_on_eof;
int _yy_last_accepting_state; /* Must be of the same type as yy_state_type,
* if for whatever reason it's no longer int!
*/
char *_yy_last_accepting_cpos;
int _yy_more_flag;
int _yy_more_len;
int yy_start_stack_ptr;
int yy_start_stack_depth;
int *yy_start_stack;
/* For ini scanner. Modes are: ZEND_INI_SCANNER_NORMAL, ZEND_INI_SCANNER_RAW */
/* Modes are: ZEND_INI_SCANNER_NORMAL, ZEND_INI_SCANNER_RAW */
int scanner_mode;
};
struct _zend_php_scanner_globals {
zend_file_handle *yy_in;
zend_file_handle *yy_out;
#ifdef ZEND_MULTIBYTE
/* original (unfiltered) script */
char *script_org;
int script_org_size;
/* filtered script */
char *script_filtered;
int script_filtered_size;
/* input/ouput filters */
zend_encoding_filter input_filter;
zend_encoding_filter output_filter;
zend_encoding *script_encoding;
zend_encoding *internal_encoding;
#endif /* ZEND_MULTIBYTE */
unsigned int yy_leng;
unsigned char *yy_start;
unsigned char *yy_text;
unsigned char *yy_cursor;
unsigned char *yy_marker;
unsigned char *yy_limit;
int yy_state;
zend_stack state_stack;
zend_llist used_state_stacks;
};
#endif /* ZEND_GLOBALS_H */

11
Zend/zend_globals_macros.h

@ -24,7 +24,8 @@
typedef struct _zend_compiler_globals zend_compiler_globals;
typedef struct _zend_executor_globals zend_executor_globals;
typedef struct _zend_scanner_globals zend_scanner_globals;
typedef struct _zend_php_scanner_globals zend_php_scanner_globals;
typedef struct _zend_ini_scanner_globals zend_ini_scanner_globals;
BEGIN_EXTERN_C()
@ -49,21 +50,21 @@ extern ZEND_API zend_executor_globals executor_globals;
/* Language Scanner */
#ifdef ZTS
# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_scanner_globals *, v)
# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_php_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;
extern ZEND_API zend_php_scanner_globals language_scanner_globals;
#endif
/* INI Scanner */
#ifdef ZTS
# define INI_SCNG(v) TSRMG(ini_scanner_globals_id, zend_scanner_globals *, v)
# define INI_SCNG(v) TSRMG(ini_scanner_globals_id, zend_ini_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;
extern ZEND_API zend_ini_scanner_globals ini_scanner_globals;
#endif
END_EXTERN_C()

22
Zend/zend_highlight.c

@ -58,17 +58,6 @@ ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC)
{
const char *ptr=s, *end=s+len;
#ifdef ZEND_MULTIBYTE
char *filtered;
int filtered_len;
if (LANG_SCNG(output_filter)) {
LANG_SCNG(output_filter)(&filtered, &filtered_len, s, len TSRMLS_CC);
ptr = filtered;
end = filtered + filtered_len;
}
#endif /* ZEND_MULTIBYTE */
while (ptr<end) {
if (*ptr==' ') {
do {
@ -78,16 +67,9 @@ ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC)
zend_html_putc(*ptr++);
}
}
#ifdef ZEND_MULTIBYTE
if (LANG_SCNG(output_filter)) {
efree(filtered);
}
#endif /* ZEND_MULTIBYTE */
}
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC)
{
zval token;
@ -180,7 +162,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
}
/* handler for trailing comments, see bug #42767 */
if (LANG_SCNG(yy_leng) && LANG_SCNG(_yy_more_len)) {
if (LANG_SCNG(yy_leng) && LANG_SCNG(yy_text) < LANG_SCNG(yy_limit)) {
if (last_color != syntax_highlighter_ini->highlight_comment) {
if (last_color != syntax_highlighter_ini->highlight_html) {
zend_printf("</span>");
@ -189,7 +171,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
zend_printf("<span style=\"color: %s\">", syntax_highlighter_ini->highlight_comment);
}
}
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(_yy_more_len) TSRMLS_CC);
zend_html_puts(LANG_SCNG(yy_text), (LANG_SCNG(yy_limit) - LANG_SCNG(yy_text)) TSRMLS_CC);
}
done:
if (last_color != syntax_highlighter_ini->highlight_html) {

2
Zend/zend_ini_parser.y

@ -204,7 +204,7 @@ ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_erro
CG(ini_parser_unbuffered_errors) = unbuffered_errors;
retval = ini_parse(TSRMLS_C);
zend_ini_close_file(fh TSRMLS_CC);
zend_file_handle_dtor(fh TSRMLS_CC);
shutdown_ini_scanner(TSRMLS_C);

1
Zend/zend_ini_scanner.h

@ -31,7 +31,6 @@ 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, int scanner_mode TSRMLS_DC);
int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC);
void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC);
int ini_lex(zval *ini_lval TSRMLS_DC);
void shutdown_ini_scanner(TSRMLS_D);
END_EXTERN_C()

217
Zend/zend_ini_scanner.l

@ -1,4 +1,3 @@
%{
/*
+----------------------------------------------------------------------+
| Zend Engine |
@ -15,18 +14,41 @@
+----------------------------------------------------------------------+
| Authors: Zeev Suraski <zeev@zend.com> |
| Jani Taskinen <jani@php.net> |
| Marcus Boerger <helly@php.net> |
| Nuno Lopes <nlopess@php.net> |
| Scott MacVicar <scottmac@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#define DEBUG_CFG_SCANNER 0
#define yyleng SCNG(yy_leng)
#define yytext SCNG(yy_text)
#define yytext_ptr SCNG(yy_text)
#define yyin SCNG(yy_in)
#define yyout SCNG(yy_out)
#if 0
# define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
#else
# define YYDEBUG(s, c)
#endif
#include "zend_ini_scanner_defs.h"
#define YYCTYPE unsigned char
#define YYFILL(n) { if (n == 1) return 0; }
#define YYCURSOR SCNG(yy_cursor)
#define YYLIMIT SCNG(yy_limit)
#define YYMARKER SCNG(yy_marker)
#define YYGETCONDITION() SCNG(yy_state)
#define YYSETCONDITION(s) SCNG(yy_state) = s
#define STATE(name) yyc##name
/* emulate flex constructs */
#define BEGIN(state) YYSETCONDITION(STATE(state))
#define YYSTATE YYGETCONDITION()
#define yytext ((char*)SCNG(yy_text))
#define yyleng SCNG(yy_leng)
#define yyless(x) YYCURSOR = yytext + x
/* #define yymore() goto yymore_restart */
/* How it works (for the core ini directives):
* ===========================================
@ -47,7 +69,7 @@
* 5. User defined ini files (like .htaccess for apache) are parsed for each request and
* stored in separate hash defined by SAPI.
*/
/* TODO: (ordered by importance :-)
* ===============================================================================
*
@ -58,41 +80,18 @@
*
*/
/* These are not needed when yymore() is not used */
/*
#define yy_last_accepting_state SCNG(_yy_last_accepting_state)
#define yy_last_accepting_cpos SCNG(_yy_last_accepting_cpos)
#define yy_more_flag SCNG(_yy_more_flag)
#define yy_more_len SCNG(_yy_more_len)
*/
%}
%x ST_DOUBLE_QUOTES
%x ST_OFFSET
%x ST_RAW
%x ST_SECTION_RAW
%x ST_SECTION_VALUE
%x ST_VALUE
%x ST_VARNAME
%option stack
%{
#include <errno.h>
#include "zend.h"
#include "zend_globals.h"
#include <zend_ini_parser.h>
#include "zend_ini_scanner.h"
#define YY_DECL int ini_lex(zval *ini_lval TSRMLS_DC)
/* 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;
ZEND_API zend_ini_scanner_globals ini_scanner_globals;
#endif
/* Eat trailing whitespace + extra char */
@ -105,7 +104,6 @@ ZEND_API zend_scanner_globals ini_scanner_globals;
yytext[yyleng - 1] == ' ') \
) { \
yyleng--; \
yytext[yyleng]=0; \
}
/* Eat trailing whitespace */
@ -122,7 +120,30 @@ ZEND_API zend_scanner_globals ini_scanner_globals;
return type; \
}
static char *ini_filename;
static void _yy_push_state(int new_state TSRMLS_DC)
{
zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION(), sizeof(int));
YYSETCONDITION(new_state);
}
#define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm)
static void yy_pop_state(TSRMLS_D)
{
int *stack_state;
zend_stack_top(&SCNG(state_stack), (void **) &stack_state);
YYSETCONDITION(*stack_state);
zend_stack_del_top(&SCNG(state_stack));
}
static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC)
{
YYCURSOR = (YYCTYPE*)str;
SCNG(yy_start) = YYCURSOR;
YYLIMIT = YYCURSOR + len;
}
#define ini_filename SCNG(filename)
/* {{{ init_ini_scanner()
*/
@ -130,9 +151,8 @@ static void init_ini_scanner(TSRMLS_D)
{
SCNG(lineno) = 1;
SCNG(scanner_mode) = ZEND_INI_SCANNER_NORMAL;
SCNG(yy_start_stack_ptr) = 0;
SCNG(yy_start_stack_depth) = 0;
SCNG(current_buffer) = NULL;
zend_stack_init(&SCNG(state_stack));
BEGIN(INITIAL);
}
/* }}} */
@ -140,11 +160,7 @@ static void init_ini_scanner(TSRMLS_D)
*/
void shutdown_ini_scanner(TSRMLS_D)
{
if (SCNG(yy_start_stack)) {
yy_flex_free(SCNG(yy_start_stack));
SCNG(yy_start_stack) = NULL;
}
yy_delete_buffer(SCNG(current_buffer) TSRMLS_CC);
zend_stack_destroy(&SCNG(state_stack));
if (ini_filename) {
free(ini_filename);
}
@ -171,14 +187,17 @@ char *zend_ini_scanner_get_filename(TSRMLS_D)
*/
int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRMLS_DC)
{
if (FAILURE == zend_stream_fixup(fh TSRMLS_CC)) {
char *buf;
size_t size;
if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE) {
return FAILURE;
}
init_ini_scanner(TSRMLS_C);
SCNG(scanner_mode) = scanner_mode;
yyin = fh;
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE TSRMLS_CC) TSRMLS_CC);
SCNG(yy_in) = fh;
yy_scan_buffer(buf, size TSRMLS_CC);
ini_filename = zend_strndup(fh->filename, strlen(fh->filename));
return SUCCESS;
}
@ -192,21 +211,13 @@ int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC)
init_ini_scanner(TSRMLS_C);
SCNG(scanner_mode) = scanner_mode;
yyin = NULL;
yy_scan_buffer(str, len + 2 TSRMLS_CC);
SCNG(yy_in) = NULL;
yy_scan_buffer(str, len TSRMLS_CC);
ini_filename = NULL;
return SUCCESS;
}
/* }}} */
/* {{{ zend_ini_close_file()
*/
void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC)
{
zend_stream_close(fh);
}
/* }}} */
/* {{{ zend_ini_escape_string()
*/
static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type TSRMLS_DC)
@ -267,7 +278,22 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty
}
/* }}} */
%}
int ini_lex(zval *ini_lval TSRMLS_DC)
{
restart:
SCNG(yy_text) = YYCURSOR;
/* yymore_restart: */
/* detect EOF */
if (YYCURSOR >= YYLIMIT) {
if (YYSTATE == STATE(ST_VALUE) || YYSTATE == STATE(ST_RAW)) {
BEGIN(INITIAL);
return 0;
}
return 0;
}
/*!re2c
LNUM [0-9]+
DNUM ([0-9]*[\.][0-9]+)|([0-9]+[\.][0-9]*)
@ -286,21 +312,12 @@ SECTION_RAW_CHARS [^\]\n\r]
SINGLE_QUOTED_CHARS [^']
RAW_VALUE_CHARS [^=\n\r;]
/* Allow using ${foobar} in sections, quoted strings and values */
LITERAL_DOLLAR ("$"([^a-zA-Z0-9{]|("\\"{ANY_CHAR})))
VALUE_CHARS ([^$= \t\n\r;&|~()!"']|{LITERAL_DOLLAR})
LITERAL_DOLLAR ("$"([^a-zA-Z0-9{\000]|("\\"{ANY_CHAR})))
VALUE_CHARS ([^$= \t\n\r;&|~()!"'\000]|{LITERAL_DOLLAR})
SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
/* " */
%option nounput
%option noyywrap
%option noyylineno
%option noyy_top_state
%option never-interactive
%%
<!*> := yyleng = YYCURSOR - SCNG(yy_text);
<INITIAL>"[" { /* Section start */
/* Enter section data lookup state */
@ -315,9 +332,8 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
<ST_VALUE,ST_SECTION_VALUE,ST_OFFSET>"'"{SINGLE_QUOTED_CHARS}+"'" { /* Raw string */
/* Eat leading and trailing single quotes */
if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
yytext++;
SCNG(yy_text)++;
yyleng = yyleng - 2;
yytext[yyleng] = 0;
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
@ -334,7 +350,7 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
/* Enter offset lookup state */
yy_push_state(ST_OFFSET TSRMLS_CC);
RETURN_TOKEN(TC_OFFSET, yytext, yyleng);
}
@ -369,7 +385,7 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
RETURN_TOKEN(TC_LABEL, yytext, yyleng);
}
<INITIAL>{TABS_AND_SPACES}*[=]{TABS_AND_SPACES}* { /* Start option value */
<INITIAL>{TABS_AND_SPACES}*[=]{TABS_AND_SPACES}* { /* Start option value */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
yy_push_state(ST_RAW TSRMLS_CC);
} else {
@ -381,9 +397,9 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
<ST_RAW>{RAW_VALUE_CHARS}+ { /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
/* Eat leading and trailing double quotes */
if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
yytext++;
SCNG(yy_text)++;
yyleng = yyleng - 2;
yytext[yyleng] = 0;
yytext[yyleng] = 0;
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
@ -415,7 +431,7 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
}
<ST_VALUE>[=] { /* Make = used in option value to trigger error */
yyless(yyleng - 1);
yyless(0);
BEGIN(INITIAL);
return END_OF_LINE;
}
@ -449,6 +465,7 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
<INITIAL,ST_RAW>{TABS_AND_SPACES}+ {
/* eat whitespace */
goto restart;
}
<INITIAL>{TABS_AND_SPACES}*{NEWLINE} {
@ -462,52 +479,14 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
return END_OF_LINE;
}
<ST_VALUE,ST_RAW><<EOF>> { /* End of option value (if EOF is reached before EOL */
<ST_VALUE,ST_RAW>[^] { /* End of option value (if EOF is reached before EOL */
BEGIN(INITIAL);
return END_OF_LINE;
return 0;
}
<<EOF>> {
#if DEBUG_CFG_SCANNER
while (YYSTATE != INITIAL) {
switch (YYSTATE) {
case INITIAL:
break;
case ST_DOUBLE_QUOTES:
fprintf(stderr, "ERROR: Unterminated ini option value double quotes\n");
break;
case ST_OFFSET:
fprintf(stderr, "ERROR: Unterminated ini option offset\n");
break;
case ST_RAW:
fprintf(stderr, "ERROR: Unterminated raw ini option value\n");
break;
case ST_SECTION_RAW:
fprintf(stderr, "ERROR: Unterminated raw ini section value\n");
break;
case ST_SECTION_VALUE:
fprintf(stderr, "ERROR: Unterminated ini section value\n");
break;
case ST_VALUE:
fprintf(stderr, "ERROR: Unterminated ini option value\n");
break;
case ST_VARNAME:
fprintf(stderr, "ERROR: Unterminated ini variable\n");
break;
<*>[^] {
return 0;
}
default:
fprintf(stderr, "BUG: Unknown state (%d)\n", YYSTATE);
break;
}
yy_pop_state(TSRMLS_C);
}
#endif
yyterminate();
*/
}

28
Zend/zend_language_scanner.h

@ -23,31 +23,21 @@
#define ZEND_SCANNER_H
typedef struct _zend_lex_state {
YY_BUFFER_STATE buffer_state;
int state;
unsigned int yy_leng;
unsigned char *yy_start;
unsigned char *yy_text;
unsigned char *yy_cursor;
unsigned char *yy_marker;
unsigned char *yy_limit;
int yy_state;
zend_stack state_stack;
zend_file_handle *in;
uint lineno;
char *filename;
#ifdef ZEND_MULTIBYTE
/* original (unfiltered) script */
char *script_org;
int script_org_size;
/* filtered script */
char *script_filtered;
int script_filtered_size;
/* input/ouput filters */
zend_encoding_filter input_filter;
zend_encoding_filter output_filter;
zend_encoding *script_encoding;
zend_encoding *internal_encoding;
#endif /* ZEND_MULTIBYTE */
} zend_lex_state;
void zend_fatal_scanner_error(char *);
BEGIN_EXTERN_C()
int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC);

740
Zend/zend_language_scanner.l
File diff suppressed because it is too large
View File

11
Zend/zend_stack.c

@ -94,15 +94,16 @@ ZEND_API int zend_stack_is_empty(zend_stack *stack)
ZEND_API int zend_stack_destroy(zend_stack *stack)
{
register int i;
for (i = 0; i < stack->top; i++) {
efree(stack->elements[i]);
}
int i;
if (stack->elements) {
for (i = 0; i < stack->top; i++) {
efree(stack->elements[i]);
}
efree(stack->elements);
}
return SUCCESS;
}

310
Zend/zend_stream.c

@ -5,7 +5,7 @@
| Copyright (c) 1998-2008 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
@ -13,6 +13,9 @@
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Wez Furlong <wez@thebrainroom.com> |
| Scott MacVicar <scottmac@php.net> |
| Nuno Lopes <nlopess@php.net> |
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
@ -22,26 +25,81 @@
#include "zend.h"
#include "zend_compile.h"
#include <sys/types.h>
#include <sys/stat.h>
#if HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
ZEND_DLIMPORT int isatty(int fd);
static size_t zend_stream_stdio_reader(void *handle, char *buf, size_t len TSRMLS_DC)
static size_t zend_stream_stdio_reader(void *handle, char *buf, size_t len TSRMLS_DC) /* {{{ */
{
return fread(buf, 1, len, (FILE*)handle);
}
} /* }}} */
static void zend_stream_stdio_closer(void *handle TSRMLS_DC)
static void zend_stream_stdio_closer(void *handle TSRMLS_DC) /* {{{ */
{
if ((FILE*)handle != stdin)
if (handle && (FILE*)handle != stdin) {
fclose((FILE*)handle);
}
}
} /* }}} */
static long zend_stream_stdio_fteller(void *handle TSRMLS_DC)
static size_t zend_stream_stdio_fsizer(void *handle TSRMLS_DC) /* {{{ */
{
return ftell((FILE*) handle);
}
struct stat buf;
if (handle && fstat(fileno((FILE*)handle), &buf) == 0) {
return buf.st_size;
}
return 0;
} /* }}} */
static void zend_stream_unmap(zend_stream *stream TSRMLS_DC) { /* {{{ */
#if HAVE_MMAP
if (stream->mmap.map) {
munmap(stream->mmap.map, stream->mmap.len);
} else
#endif
if (stream->mmap.buf) {
efree(stream->mmap.buf);
}
stream->mmap.len = 0;
stream->mmap.pos = 0;
stream->mmap.map = 0;
stream->mmap.buf = 0;
stream->handle = stream->mmap.old_handle;
} /* }}} */
static void zend_stream_mmap_closer(zend_stream *stream TSRMLS_DC) /* {{{ */
{
zend_stream_unmap(stream TSRMLS_CC);
if (stream->mmap.old_closer && stream->handle) {
stream->mmap.old_closer(stream->handle TSRMLS_CC);
}
} /* }}} */
static inline int zend_stream_is_mmap(zend_file_handle *file_handle) { /* {{{ */
return file_handle->type == ZEND_HANDLE_MAPPED;
} /* }}} */
static size_t zend_stream_fsize(zend_file_handle *file_handle TSRMLS_DC) /* {{{ */
{
struct stat buf;
if (zend_stream_is_mmap(file_handle)) {
return file_handle->handle.stream.mmap.len;
}
if (file_handle->type == ZEND_HANDLE_STREAM || file_handle->type == ZEND_HANDLE_MAPPED) {
return file_handle->handle.stream.fsizer(file_handle->handle.stream.handle TSRMLS_CC);
}
if (file_handle->handle.fp && fstat(fileno(file_handle->handle.fp), &buf) == 0) {
return buf.st_size;
}
return -1;
} /* }}} */
ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC)
ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /* {{{ */
{
if (zend_stream_open_function) {
return zend_stream_open_function(filename, handle TSRMLS_CC);
@ -51,56 +109,26 @@ ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSR
handle->handle.fp = zend_fopen(filename, &handle->opened_path);
handle->filename = (char *)filename;
handle->free_filename = 0;
memset(&handle->handle.stream.mmap, 0, sizeof(zend_mmap));
return (handle->handle.fp) ? SUCCESS : FAILURE;
}
} /* }}} */
ZEND_API int zend_stream_fixup(zend_file_handle *file_handle TSRMLS_DC)
static int zend_stream_getc(zend_file_handle *file_handle TSRMLS_DC) /* {{{ */
{
switch (file_handle->type) {
case ZEND_HANDLE_FILENAME:
if (FAILURE == zend_stream_open(file_handle->filename, file_handle TSRMLS_CC)) {
return FAILURE;
}
break;
case ZEND_HANDLE_FD:
file_handle->handle.fp = fdopen(file_handle->handle.fd, "rb");
file_handle->type = ZEND_HANDLE_FP;
break;
case ZEND_HANDLE_FP:
file_handle->handle.fp = file_handle->handle.fp;
break;
case ZEND_HANDLE_STREAM:
/* nothing to do */
return SUCCESS;
default:
return FAILURE;
}
if (file_handle->type == ZEND_HANDLE_FP) {
if (!file_handle->handle.fp) {
return FAILURE;
}
/* make compatible with stream */
file_handle->handle.stream.handle = file_handle->handle.fp;
file_handle->handle.stream.reader = zend_stream_stdio_reader;
file_handle->handle.stream.closer = zend_stream_stdio_closer;
file_handle->handle.stream.fteller = zend_stream_stdio_fteller;
char buf;
file_handle->handle.stream.interactive = isatty(fileno((FILE *)file_handle->handle.stream.handle));
if (file_handle->handle.stream.reader(file_handle->handle.stream.handle, &buf, sizeof(buf) TSRMLS_CC)) {
return (int)buf;
}
return SUCCESS;
}
return EOF;
} /* }}} */
ZEND_API size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC)
static size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC) /* {{{ */
{
if (file_handle->handle.stream.interactive) {
if (!zend_stream_is_mmap(file_handle) && file_handle->handle.stream.isatty) {
int c = '*';
size_t n;
size_t n;
#ifdef NETWARE
/*
@ -108,35 +136,181 @@ ZEND_API size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_
Ascii value 4 is actually EOT character which is not defined anywhere in the LibC
or else we can use instead of hardcoded 4.
*/
for ( n = 0; n < len && (c = zend_stream_getc( file_handle TSRMLS_CC)) != EOF && c != 4 && c != '\n'; ++n )
for (n = 0; n < len && (c = zend_stream_getc(file_handle TSRMLS_CC)) != EOF && c != 4 && c != '\n'; ++n) {
#else
for ( n = 0; n < len && (c = zend_stream_getc( file_handle TSRMLS_CC)) != EOF && c != '\n'; ++n )
for (n = 0; n < len && (c = zend_stream_getc(file_handle TSRMLS_CC)) != EOF && c != '\n'; ++n) {
#endif
buf[n] = (char) c;
if ( c == '\n' )
buf[n++] = (char) c;
buf[n] = (char)c;
}
if (c == '\n') {
buf[n++] = (char)c;
}
return n;
}
return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len TSRMLS_CC);
}
} /* }}} */
ZEND_API int zend_stream_getc(zend_file_handle *file_handle TSRMLS_DC)
ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len TSRMLS_DC) /* {{{ */
{
char buf;
size_t size;
if (file_handle->handle.stream.reader(file_handle->handle.stream.handle, &buf, sizeof(buf) TSRMLS_CC)) {
return (int)buf;
if (file_handle->type == ZEND_HANDLE_FILENAME) {
if (zend_stream_open(file_handle->filename, file_handle TSRMLS_CC) == FAILURE) {
return FAILURE;
}
}
return EOF;
}
ZEND_API int zend_stream_ferror(zend_file_handle *file_handle TSRMLS_DC)
switch (file_handle->type) {
case ZEND_HANDLE_FD:
file_handle->type = ZEND_HANDLE_FP;
file_handle->handle.fp = fdopen(file_handle->handle.fd, "rb");
/* no break; */
case ZEND_HANDLE_FP:
if (!file_handle->handle.fp) {
return FAILURE;
}
memset(&file_handle->handle.stream.mmap, 0, sizeof(zend_mmap));
file_handle->handle.stream.isatty = isatty(fileno((FILE *)file_handle->handle.stream.handle)) ? 1 : 0;
file_handle->handle.stream.reader = (zend_stream_reader_t)zend_stream_stdio_reader;
file_handle->handle.stream.closer = (zend_stream_closer_t)zend_stream_stdio_closer;
file_handle->handle.stream.fsizer = (zend_stream_fsizer_t)zend_stream_stdio_fsizer;
memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap));
/* no break; */
case ZEND_HANDLE_STREAM:
/* nothing to do */
break;
case ZEND_HANDLE_MAPPED:
file_handle->handle.stream.mmap.pos = 0;
*buf = file_handle->handle.stream.mmap.buf;
*len = file_handle->handle.stream.mmap.len;
return SUCCESS;
default:
return FAILURE;
}
size = zend_stream_fsize(file_handle TSRMLS_CC);
if (size == (size_t)-1) {
return FAILURE;
}
file_handle->type = ZEND_HANDLE_STREAM; /* we might still be _FP but we need fsize() work */
if (!file_handle->handle.stream.isatty && size) {
#if HAVE_MMAP
if (file_handle->handle.fp && size) {
/* *buf[size] is zeroed automatically by the kernel */
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
if (*buf != MAP_FAILED) {
file_handle->handle.stream.mmap.len = size;
file_handle->handle.stream.mmap.map = *buf;
file_handle->handle.stream.mmap.buf = *buf;
goto return_mapped;
}
}
#endif
file_handle->handle.stream.mmap.map = 0;
file_handle->handle.stream.mmap.buf = *buf = safe_emalloc(1, size, ZEND_MMAP_AHEAD);
file_handle->handle.stream.mmap.len = zend_stream_read(file_handle, *buf, size TSRMLS_CC);
} else {
size_t read, remain = 4*1024;
*buf = emalloc(remain);
size = 0;
while ((read = zend_stream_read(file_handle, *buf + size, remain TSRMLS_CC)) > 0) {
size += read;
remain -= read;
if (remain == 0) {
*buf = safe_erealloc(*buf, size, 2, 0);
remain = size;
}
}
file_handle->handle.stream.mmap.map = 0;
file_handle->handle.stream.mmap.buf = *buf;
file_handle->handle.stream.mmap.len = size;
if (size && remain < ZEND_MMAP_AHEAD) {
*buf = safe_erealloc(*buf, size, 1, ZEND_MMAP_AHEAD);
}
}
if (file_handle->handle.stream.mmap.len == 0) {
*buf = erealloc(*buf, ZEND_MMAP_AHEAD);
file_handle->handle.stream.mmap.buf = *buf;
}
if (ZEND_MMAP_AHEAD) {
memset(file_handle->handle.stream.mmap.buf + file_handle->handle.stream.mmap.len, 0, ZEND_MMAP_AHEAD);
}
return_mapped:
file_handle->type = ZEND_HANDLE_MAPPED;
file_handle->handle.stream.mmap.pos = 0;
file_handle->handle.stream.mmap.old_handle = file_handle->handle.stream.handle;
file_handle->handle.stream.mmap.old_closer = file_handle->handle.stream.closer;
file_handle->handle.stream.handle = &file_handle->handle.stream;
file_handle->handle.stream.closer = (zend_stream_closer_t)zend_stream_mmap_closer;
*buf = file_handle->handle.stream.mmap.buf;
*len = file_handle->handle.stream.mmap.len;
return SUCCESS;
} /* }}} */
ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC) /* {{{ */
{
return 0;
switch (fh->type) {
case ZEND_HANDLE_FD:
/* nothing to do */
break;
case ZEND_HANDLE_FP:
fclose(fh->handle.fp);
break;
case ZEND_HANDLE_STREAM:
case ZEND_HANDLE_MAPPED:
if (fh->handle.stream.closer && fh->handle.stream.handle) {
fh->handle.stream.closer(fh->handle.stream.handle TSRMLS_CC);
}
fh->handle.stream.handle = NULL;
break;
case ZEND_HANDLE_FILENAME:
/* We're only supposed to get here when destructing the used_files hash,
* which doesn't really contain open files, but references to their names/paths
*/
break;
}
if (fh->opened_path) {
efree(fh->opened_path);
fh->opened_path = NULL;
}
if (fh->free_filename && fh->filename) {
efree(fh->filename);
fh->filename = NULL;
}
}
/* }}} */
ZEND_API long zend_stream_ftell(zend_file_handle *file_handle TSRMLS_DC)
ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2) /* {{{ */
{
return file_handle->handle.stream.fteller(file_handle->handle.stream.handle TSRMLS_CC);
}
if (fh1->type != fh2->type) {
return 0;
}
switch (fh1->type) {
case ZEND_HANDLE_FD:
return fh1->handle.fd == fh2->handle.fd;
case ZEND_HANDLE_FP:
return fh1->handle.fp == fh2->handle.fp;
case ZEND_HANDLE_STREAM:
return fh1->handle.stream.handle == fh2->handle.stream.handle;
case ZEND_HANDLE_MAPPED:
return (fh1->handle.stream.handle == &fh1->handle.stream &&
fh2->handle.stream.handle == &fh2->handle.stream &&
fh1->handle.stream.mmap.old_handle == fh2->handle.stream.mmap.old_handle)
|| fh1->handle.stream.handle == fh2->handle.stream.handle;
default:
return 0;
}
return 0;
} /* }}} */

63
Zend/zend_stream.h

@ -5,7 +5,7 @@
| Copyright (c) 1998-2008 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
@ -13,6 +13,9 @@
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Wez Furlong <wez@thebrainroom.com> |
| Scott MacVicar <scottmac@php.net> |
| Nuno Lopes <nlopess@php.net> |
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
@ -24,41 +27,55 @@
/* Lightweight stream implementation for the ZE scanners.
* These functions are private to the engine.
* */
typedef size_t (*zend_stream_fsizer_t)(void* handle TSRMLS_DC);
typedef size_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len TSRMLS_DC);
typedef void (*zend_stream_closer_t)(void* handle TSRMLS_DC);
typedef size_t (*zend_stream_reader_t)(void *handle, char *buf, size_t len TSRMLS_DC);
typedef void (*zend_stream_closer_t)(void *handle TSRMLS_DC);
typedef long (*zend_stream_fteller_t)(void *handle TSRMLS_DC);
#define ZEND_MMAP_AHEAD 32
typedef enum {
ZEND_HANDLE_FILENAME,
ZEND_HANDLE_FD,
ZEND_HANDLE_FP,
ZEND_HANDLE_STREAM,
ZEND_HANDLE_MAPPED,
} zend_stream_type;
typedef struct _zend_mmap {
size_t len;
size_t pos;
void *map;
char *buf;
void *old_handle;
zend_stream_closer_t old_closer;
} zend_mmap;
typedef struct _zend_stream {
void *handle;
zend_stream_reader_t reader;
zend_stream_closer_t closer;
zend_stream_fteller_t fteller;
int interactive;
void *handle;
int isatty;
zend_mmap mmap;
zend_stream_reader_t reader;
zend_stream_fsizer_t fsizer;
zend_stream_closer_t closer;
} zend_stream;
typedef struct _zend_file_handle {
zend_uchar type;
char *filename;
char *opened_path;
zend_stream_type type;
char *filename;
char *opened_path;
union {
int fd;
FILE *fp;
zend_stream stream;
int fd;
FILE *fp;
zend_stream stream;
} handle;
zend_bool free_filename;
} zend_file_handle;
BEGIN_EXTERN_C()
ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC);
ZEND_API int zend_stream_ferror(zend_file_handle *file_handle TSRMLS_DC);
ZEND_API int zend_stream_getc(zend_file_handle *file_handle TSRMLS_DC);
ZEND_API size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC);
ZEND_API long zend_stream_ftell(zend_file_handle *file_handle TSRMLS_DC);
ZEND_API int zend_stream_fixup(zend_file_handle *file_handle TSRMLS_DC);
ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len TSRMLS_DC);
ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC);
ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
END_EXTERN_C()
#define zend_stream_close(handle) zend_file_handle_dtor((handle))
#endif

2
Zend/zend_strtod.c

@ -2628,7 +2628,7 @@ ZEND_API double zend_oct_strtod(const char *str, char **endptr)
s++;
while ((c = *s++)) {
if (c > '7') {
if (c < '0' || c > '7') {
/* break and return the current value if the number is not well-formed
* that's what Linux strtol() does
*/

2
Zend/zend_vm_def.h

@ -3075,7 +3075,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
} else {
zend_file_handle_dtor(&file_handle);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
failure_retval=1;
}
} else {

8
Zend/zend_vm_execute.h

@ -1684,7 +1684,7 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
} else {
zend_file_handle_dtor(&file_handle);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
failure_retval=1;
}
} else {
@ -4869,7 +4869,7 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
} else {
zend_file_handle_dtor(&file_handle);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
failure_retval=1;
}
} else {
@ -8085,7 +8085,7 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
} else {
zend_file_handle_dtor(&file_handle);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
failure_retval=1;
}
} else {
@ -21765,7 +21765,7 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
new_op_array = zend_compile_file(&file_handle, (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
} else {
zend_file_handle_dtor(&file_handle);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
failure_retval=1;
}
} else {

71
acinclude.m4

@ -2086,64 +2086,6 @@ AC_DEFUN([PHP_PROG_BISON], [
PHP_SUBST(YACC)
])
dnl
dnl PHP_PROG_LEX
dnl
dnl Search for (f)lex and check it's version
dnl
AC_DEFUN([PHP_PROG_LEX], [
dnl we only support certain flex versions
flex_version_list="2.5.4"
AC_PROG_LEX
if test "$LEX" = "flex"; then
dnl AC_DECL_YYTEXT is obsolete since autoconf 2.50 and merged into AC_PROG_LEX
dnl this is what causes that annoying "PHP_PROG_LEX is expanded from" warning with autoconf 2.50+
dnl it should be removed once we drop support of autoconf 2.13 (if ever)
AC_DECL_YYTEXT
:
fi
dnl ## Make flex scanners use const if they can, even if __STDC__ is not
dnl ## true, for compilers like Sun's that only set __STDC__ true in
dnl ## "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
AC_C_CONST
if test "$ac_cv_c_const" = "yes" ; then
LEX_CFLAGS="-DYY_USE_CONST"
fi
if test "$LEX" = "flex"; then
AC_CACHE_CHECK([for flex version], php_cv_flex_version, [
flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'`
php_cv_flex_version=invalid
for flex_check_version in $flex_version_list; do
if test "$flex_version" = "$flex_check_version"; then
php_cv_flex_version="$flex_check_version (ok)"
fi
done
])
else
flex_version=none
fi
case $php_cv_flex_version in
""|invalid[)]
if test -f "$abs_srcdir/Zend/zend_language_scanner.c" && test -f "$abs_srcdir/Zend/zend_ini_scanner.c"; then
AC_MSG_WARN([flex versions supported for regeneration of the Zend/PHP parsers: $flex_version_list (found: $flex_version)])
else
flex_msg="Supported flex versions are: $flex_version_list"
if test "$flex_version" = "none"; then
flex_msg="flex not found. flex is required to generate the Zend/PHP parsers! $flex_msg"
else
flex_msg="Found invalid flex version: $flex_version. $flex_msg"
fi
AC_MSG_ERROR([$flex_msg])
fi
LEX="exit 0;"
;;
esac
PHP_SUBST(LEX)
])
dnl
dnl PHP_PROG_RE2C
dnl
@ -2153,17 +2095,17 @@ AC_DEFUN([PHP_PROG_RE2C],[
AC_CHECK_PROG(RE2C, re2c, re2c)
if test -n "$RE2C"; then
AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
re2c_vernum=`re2c --vernum 2>/dev/null`
if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1200"; then
re2c_vernum=`$RE2C --vernum 2>/dev/null`
if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1302"; then
php_cv_re2c_version=invalid
else
php_cv_re2c_version="`re2c --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
fi
])
fi
case $php_cv_re2c_version in
""|invalid[)]
AC_MSG_WARN([You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.])
AC_MSG_WARN([You will need re2c 0.13.3 or later if you want to regenerate PHP parsers.])
RE2C="exit 0;"
;;
esac
@ -2710,11 +2652,6 @@ AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
# PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name>
*[)]
# Options that exist before PHP 6
if test "$PHP_MAJOR_VERSION" -lt "6"; then
case $arg_name in
enable-zend-multibyte[)] continue;;
esac
fi
is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
if eval test "x\$$is_arg_set" = "x"; then
PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS

31
configure.in

@ -161,10 +161,37 @@ dnl check for -R, etc. switch
PHP_RUNPATH_SWITCH
dnl Checks for some support/generator progs
PHP_PROG_RE2C
PHP_PROG_AWK
PHP_PROG_BISON
PHP_PROG_LEX
PHP_PROG_RE2C
PHP_ARG_ENABLE(re2c-cgoto, whether to enable computed goto gcc extension with re2c,
[ --enable-re2c-cgoto Enable -g flag to re2c to use computed goto gcc extension], no, no)
if test "$PHP_RE2C_CGOTO" = "no"; then
RE2C_FLAGS=""
else
AC_MSG_CHECKING([whether re2c -g works])
AC_TRY_COMPILE([],[
int main(int argc, const char **argv)
{
argc = argc;
argv = argv;
label1:
label2:
static void *adr[] = { &&label1, &&label2};
goto *adr[0];
return 0;
}
],[
RE2C_FLAGS=""
AC_MSG_RESULT([no])
],[
RE2C_FLAGS="-g"
AC_MSG_RESULT([yes])
])
fi
PHP_SUBST(RE2C_FLAGS)
dnl Platform-specific compile settings.
dnl -------------------------------------------------------------------------

2
ext/spl/php_spl.c

@ -238,7 +238,7 @@ static int spl_autoload(const char *class_name, const char * lc_name, int class_
zend_destroy_file_handle(&file_handle TSRMLS_CC);
} else {
new_op_array = NULL;
zend_file_handle_dtor(&file_handle);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
}
if (new_op_array) {
EG(return_value_ptr_ptr) = &result;

8
ext/standard/tests/strings/006.phpt

@ -8,12 +8,12 @@ $file = str_repeat("A", 1024);
var_dump(highlight_file($file, true));
var_dump(ob_get_contents());
echo "Done\n";
?>
===DONE===
--EXPECTF--
Warning: highlight_file(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' for highlighting in %s006.php on line %d
bool(false)
bool(false)
Done
===DONE===

6
ext/standard/tests/strings/007.phpt

@ -8,10 +8,10 @@ $file = str_repeat("A", 1024);
var_dump(php_strip_whitespace($file));
var_dump(ob_get_contents());
echo "Done\n";
?>
===DONE===
--EXPECTF--
Warning: php_strip_whitespace(AAAA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to open stream: File name too long in %s007.php on line %d
string(0) ""
bool(false)
Done
===DONE===

17
ext/standard/tests/strings/highlight_file.phpt

@ -7,6 +7,7 @@ highlight.keyword=#007700
highlight.bg=#FFFFFF
highlight.default=#0000BB
highlight.html=#000000
allow_url_include=1
--FILE--
<?php
@ -15,19 +16,9 @@ $filename = dirname(__FILE__)."/highlight_file.dat";
var_dump(highlight_file());
var_dump(highlight_file($filename));
$data = <<<DATA
<?php echo "test"; ?>
DATA;
var_dump(highlight_file('data:,<?php echo "test"; ?>'));
file_put_contents($filename, $data);
var_dump(highlight_file($filename));
$data = <<<DATA
<?php echo "test ?>
DATA;
file_put_contents($filename, $data);
var_dump(highlight_file($filename));
var_dump(highlight_file('data:,<?php echo "test ?>'));
$data = '
<?php
@ -58,7 +49,7 @@ bool(false)
</span>
</code>bool(true)
<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"test&nbsp;?&gt;</span>
<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #FF9900">"test&nbsp;?&gt;</span>
</span>
</code>bool(true)
<code><span style="color: #000000">

2
ext/standard/tests/strings/strip_tags_basic1.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : basic functionality - with default arguments
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_basic2.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : basic functionality - with all arguments
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_error.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : error conditions
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation1.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - unexpected values for 'str' argument
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation10.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - single quoted strings
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation2.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - unexpected values for 'allowable_tags'
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation3.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - unexpected values for both 'str' and 'allowable_tags'
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation4.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - invalid values for 'str' and valid 'allowable_tags'
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation5.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - heredoc strings
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation6.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - binary safe checking
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation7.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - invalid values for 'str' and 'allowable_tags'
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation8.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - valid value for 'str' and invalid values for 'allowable_tags'
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

2
ext/standard/tests/strings/strip_tags_variation9.phpt

@ -1,7 +1,7 @@
--TEST--
Test strip_tags() function : usage variations - double quoted strings
--INI--
set short_open_tag = on
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

4
ext/tokenizer/Makefile.frag

@ -1,2 +1,2 @@
$(top_srcdir)/Zend/zend_language_parser.h:
$(builddir)/tokenizer.lo: $(top_srcdir)/Zend/zend_language_parser.h
$(builddir)/tokenizer.lo: $(top_srcdir)/Zend/zend_language_parser.c $(top_srcdir)/Zend/zend_language_scanner.c

13
ext/tokenizer/tests/token_get_all_variation14.phpt

@ -266,22 +266,13 @@ echo "hello world"; ?>"
}
}
-- with invalid PHP tags and tokens --
array(2) {
array(1) {
[0]=>
array(3) {
[0]=>
int(311)
[1]=>
string(18) "<PDP display $a; "
[2]=>
int(1)
}
[1]=>
array(3) {
[0]=>
int(311)
[1]=>
string(1) "<"
string(19) "<PDP display $a; <"
[2]=>
int(1)
}

62
ext/tokenizer/tokenizer.c

@ -27,67 +27,9 @@
#include "ext/standard/info.h"
#include "php_tokenizer.h"
typedef struct yy_buffer_state *YY_BUFFER_STATE;
typedef unsigned int yy_size_t;
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
* shouldn't try reading from the input source any more. We might
* still have a bunch of tokens to match, though, because of
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
* (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
};
#include "zend.h"
#include "zend_language_scanner.h"
#include "zend_language_scanner_defs.h"
#include <zend_language_parser.h>
#define zendtext LANG_SCNG(yy_text)
@ -222,7 +164,7 @@ PHP_FUNCTION(token_get_all)
RETURN_EMPTY_STRING();
}
LANG_SCNG(start) = 1;
LANG_SCNG(yy_state) = yycINITIAL;
tokenize(return_value TSRMLS_CC);

48
main/main.c

@ -1055,15 +1055,26 @@ static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path
}
/* }}} */
static void stream_closer_for_zend(void *handle TSRMLS_DC) /* {{{ */
static void php_zend_stream_closer(void *handle TSRMLS_DC) /* {{{ */
{
php_stream_close((php_stream*)handle);
}
/* }}} */
static long stream_fteller_for_zend(void *handle TSRMLS_DC) /* {{{ */
static void php_zend_stream_mmap_closer(void *handle TSRMLS_DC) /* {{{ */
{
return (long)php_stream_tell((php_stream*)handle);
php_stream_mmap_unmap((php_stream*)handle);
php_zend_stream_closer(handle);
}
/* }}} */
static size_t php_zend_stream_fsizer(void *handle TSRMLS_DC) /* {{{ */
{
php_stream_statbuf ssb;
if (php_stream_stat((php_stream*)handle, &ssb) == 0) {
return ssb.sb.st_size;
}
return 0;
}
/* }}} */
@ -1075,19 +1086,30 @@ static int php_stream_open_for_zend(const char *filename, zend_file_handle *hand
PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode TSRMLS_DC) /* {{{ */
{
php_stream *stream;
stream = php_stream_open_wrapper((char *)filename, "rb", mode, &handle->opened_path);
char *p;
size_t len, mapped_len;
php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &handle->opened_path);
if (stream) {
handle->type = ZEND_HANDLE_STREAM;
handle->filename = (char*)filename;
handle->free_filename = 0;
handle->handle.stream.handle = stream;
handle->handle.stream.reader = (zend_stream_reader_t)_php_stream_read;
handle->handle.stream.closer = stream_closer_for_zend;
handle->handle.stream.fteller = stream_fteller_for_zend;
handle->handle.stream.interactive = 0;
handle->handle.stream.handle = stream;
handle->handle.stream.reader = (zend_stream_reader_t)_php_stream_read;
handle->handle.stream.fsizer = php_zend_stream_fsizer;
handle->handle.stream.isatty = 0;
/* can we mmap immeadiately? */
memset(&handle->handle.stream.mmap, 0, sizeof(handle->handle.stream.mmap));
len = php_zend_stream_fsizer(stream TSRMLS_CC) + ZEND_MMAP_AHEAD;
if (php_stream_mmap_possible(stream)
&& (p = php_stream_mmap_range(stream, 0, len, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped_len TSRMLS_CC)) != NULL) {
handle->handle.stream.closer = php_zend_stream_mmap_closer;
handle->handle.stream.mmap.buf = p;
handle->handle.stream.mmap.len = mapped_len;
handle->type = ZEND_HANDLE_MAPPED;
} else {
handle->handle.stream.closer = php_zend_stream_closer;
handle->type = ZEND_HANDLE_STREAM;
}
/* suppress warning if this stream is not explicitly closed */
php_stream_auto_cleanup(stream);
@ -1964,7 +1986,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
EG(exit_status) = 0;
if (php_handle_special_queries(TSRMLS_C)) {
zend_file_handle_dtor(primary_file);
zend_file_handle_dtor(primary_file TSRMLS_CC);
return 0;
}
#ifndef HAVE_BROKEN_GETCWD

8
sapi/apache/mod_php5.c

@ -26,10 +26,6 @@
#define SIGPIPE SIGINT
#endif
#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING)
#include "ext/mbstring/mbstring.h"
#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */
#undef shutdown
/* {{{ Prototypes
@ -589,10 +585,6 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
fh.free_filename = 0;
fh.type = ZEND_HANDLE_FILENAME;
#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING)
php_mb_set_zend_encoding(TSRMLS_C);
#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */
zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &fh);
return OK;
}

8
sapi/apache_hooks/mod_php5.c

@ -25,10 +25,6 @@
#define SIGPIPE SIGINT
#endif
#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING)
#include "ext/mbstring/mbstring.h"
#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */
#undef shutdown
/* {{{ Prototypes
@ -645,10 +641,6 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
fh.free_filename = 0;
fh.type = ZEND_HANDLE_FILENAME;
#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING)
php_mbstring_set_zend_encoding(TSRMLS_C);
#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */
zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &fh);
return OK;
}

6
sapi/cgi/cgi_main.c

@ -1960,7 +1960,7 @@ consult the installation file that came with this distribution, or visit \n\
case PHP_MODE_STRIP:
if (open_file_for_scanning(&file_handle TSRMLS_CC) == SUCCESS) {
zend_strip(TSRMLS_C);
fclose(file_handle.handle.fp);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
php_end_ob_buffers(1 TSRMLS_CC);
}
return SUCCESS;
@ -1975,7 +1975,7 @@ consult the installation file that came with this distribution, or visit \n\
if (fastcgi) {
goto fastcgi_request_done;
}
fclose(file_handle.handle.fp);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
php_end_ob_buffers(1 TSRMLS_CC);
}
return SUCCESS;
@ -1986,7 +1986,7 @@ consult the installation file that came with this distribution, or visit \n\
case PHP_MODE_INDENT:
open_file_for_scanning(&file_handle TSRMLS_CC);
zend_indent();
fclose(file_handle.handle.fp);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
return SUCCESS;
break;
#endif

4
sapi/cgi/tests/007.phpt

@ -12,11 +12,11 @@ reset_env_vars();
var_dump(`"$php" -n -f some.php -f some.php`);
var_dump(`"$php" -s -w -l`);
echo "Done\n";
?>
===DONE===
--EXPECTF--
string(25) "No input file specified.
"
string(31) "No syntax errors detected in -
"
Done
===DONE===

5
sapi/cli/php_cli.c

@ -550,6 +550,9 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
*lineno = 1;
file_handle->type = ZEND_HANDLE_FP;
file_handle->opened_path = NULL;
file_handle->free_filename = 0;
if (!(file_handle->handle.fp = VCWD_FOPEN(script_file, "rb"))) {
php_printf("Could not open input file: %s\n", script_file);
return FAILURE;
@ -1166,7 +1169,7 @@ int main(int argc, char *argv[])
case PHP_MODE_INDENT:
open_file_for_scanning(&file_handle TSRMLS_CC);
zend_indent();
fclose(file_handle.handle.fp);
zend_file_handle_dtor(file_handle.handle TSRMLS_CC);
goto out;
break;
#endif

23
sapi/cli/tests/010.phpt

@ -12,8 +12,8 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
$php = getenv('TEST_PHP_EXECUTABLE');
$filename = dirname(__FILE__)."/010.test.php";
$filename_txt = dirname(__FILE__)."/010.test.txt";
$filename = __DIR__."/010.test.php";
$filename_txt = __DIR__."/010.test.txt";
$code = '
<?php
@ -25,23 +25,22 @@ file_put_contents($filename, $code);
$txt = '
test
hello
';
hello';
file_put_contents($filename_txt, $txt);
var_dump(`cat "$filename_txt" | "$php" -n -F "$filename"`);
@unlink($filename);
@unlink($filename_txt);
echo "Done\n";
?>
===DONE===
--CLEAN--
<?php
@unlink(__DIR__."/010.test.php");
@unlink(__DIR__."/010.test.txt");
?>
--EXPECTF--
string(39) "
string(25) "
string(10) "test
hello"
string(0) ""
"
Done
===DONE===

105
sapi/cli/tests/016.phpt

@ -103,3 +103,108 @@ php > php { php { php > I was called!
php >
Done
--TEST--
CLI -a and readline
--SKIPIF--
<?php
include "skipif.inc";
if (!extension_loaded('readline') || readline_info('done') === NULL) {
die ("skip need readline support");
}
?>
--FILE--
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
$codes = array();
$codes[1] = <<<EOT
echo 'Hello world';
exit
EOT;
$codes[] = <<<EOT
echo 'multine
single
quote';
exit
EOT;
$codes[] = <<<EOT
echo <<<HEREDOC
Here
comes
the
doc
HEREDOC;
EOT;
$codes[] = <<<EOT
if (0) {
echo "I'm not there";
}
echo "Done";
EOT;
$codes[] = <<<EOT
function a_function_with_some_name() {
echo "I was called!";
}
a_function_w );
EOT;
foreach ($codes as $key => $code) {
echo "\n--------------\nSnippet no. $key:\n--------------\n";
$code = escapeshellarg($code);
echo `echo $code | "$php" -a`, "\n";
}
echo "\nDone\n";
?>
--EXPECTF--
--------------
Snippet no. 1:
--------------
Interactive shell
php > Hello world
php >
--------------
Snippet no. 2:
--------------
Interactive shell
php > php ' php ' multine
single
quote
php >
--------------
Snippet no. 3:
--------------
Interactive shell
php > <<< > <<< > <<< > <<< > <<< > Here
comes
the
doc
php >
--------------
Snippet no. 4:
--------------
Interactive shell
php > php { php { php > Done
php >
--------------
Snippet no. 5:
--------------
Interactive shell
php > php { php { php > I was called!
php >
Done

106
sapi/cli/tests/017.phpt

@ -103,4 +103,110 @@ Interactive shell
Parse error: syntax error, unexpected ')' in php shell code on line 1
Done
--TEST--
CLI -a and libedit
--SKIPIF--
<?php
include "skipif.inc";
if (!extension_loaded('readline') || readline_info('done') !== NULL) {
die ("skip need readline support using libedit");
}
?>
--FILE--
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
$codes = array();
$codes[1] = <<<EOT
echo 'Hello world';
exit
EOT;
$codes[] = <<<EOT
echo 'multine
single
quote';
exit
EOT;
$codes[] = <<<EOT
echo <<<HEREDOC
Here
comes
the
doc
HEREDOC;
EOT;
$codes[] = <<<EOT
if (0) {
echo "I'm not there";
}
echo "Done";
EOT;
$codes[] = <<<EOT
function a_function_with_some_name() {
echo "I was called!";
}
a_function_w );
EOT;
foreach ($codes as $key => $code) {
echo "\n--------------\nSnippet no. $key:\n--------------\n";
$code = escapeshellarg($code);
echo `echo $code | "$php" -a`, "\n";
}
echo "\nDone\n";
?>
--EXPECTF--
--------------
Snippet no. 1:
--------------
Interactive shell
Hello world
--------------
Snippet no. 2:
--------------
Interactive shell
multine
single
quote
--------------
Snippet no. 3:
--------------
Interactive shell
Here
comes
the
doc
--------------
Snippet no. 4:
--------------
Interactive shell
Done
--------------
Snippet no. 5:
--------------
Interactive shell
Parse error: syntax error, unexpected ')' in php shell code on line 1
Done

6
sapi/tests/test003.phpt

@ -9,9 +9,9 @@ PATH_INFO=/path/info
END;
--ENV--
return <<<END
PATH_TRANSLATED=$filename/path/info
PATH_INFO=$scriptname/path/info
SCRIPT_NAME=$scriptname
PATH_TRANSLATED=/path/bla
PATH_INFO=/path/info
SCRIPT_NAME=path
END;
--FILE--
<?php

6
sapi/tests/test004.phpt

@ -12,9 +12,9 @@ PATH_INFO=/path/info
END;
--ENV--
return <<<END
REDIRECT_URL=$scriptname
PATH_TRANSLATED=$filename/path/info
PATH_INFO=$scriptname/path/info
REDIRECT_URL=/path
PATH_TRANSLATED=/path/info/fpp
PATH_INFO=/path/info
SCRIPT_NAME=/scriptalias/php
SCRIPT_FILENAME=$this->conf['TEST_PHP_EXECUTABLE']
END;

6
win32/build/config.w32

@ -333,12 +333,6 @@ AC_DEFINE('HAVE_IPV6', main_network_has_ipv6);
ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256");
ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE));
ARG_ENABLE("zend-multibyte", "Enable Zend multibyte encoding support", "no");
if (PHP_ZEND_MULTIBYTE == "yes") {
STDOUT.WriteLine("Enabling Zend multibyte encoding support");
AC_DEFINE('ZEND_MULTIBYTE', 1);
}
AC_DEFINE('HAVE_USLEEP', 1);
AC_DEFINE('HAVE_STRCOLL', 1);

Loading…
Cancel
Save