Skip to content

Commit 56352d1

Browse files
author
Scott MacVicar
committed
MFB 5.3: Rest of the changes for re2c merge
1 parent e55a0de commit 56352d1

26 files changed

+146
-126
lines changed

Makefile.frag

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $(builddir)/zend_language_scanner.lo: $(srcdir)/zend_language_parser.h
77
$(builddir)/zend_ini_scanner.lo: $(srcdir)/zend_ini_parser.h
88

99
$(srcdir)/zend_language_scanner.c: $(srcdir)/zend_language_scanner.l
10-
@$(LEX) -Pzend -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_language_scanner.l
10+
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l)
1111

1212
$(srcdir)/zend_language_parser.h: $(srcdir)/zend_language_parser.c
1313
$(srcdir)/zend_language_parser.c: $(srcdir)/zend_language_parser.y
@@ -18,6 +18,6 @@ $(srcdir)/zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
1818
@$(YACC) -p ini_ -v -d $(srcdir)/zend_ini_parser.y -o $@
1919

2020
$(srcdir)/zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
21-
@$(LEX) -Pini_ -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_ini_scanner.l
21+
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l)
2222

2323
$(builddir)/zend_indent.lo $(builddir)/zend_highlight.lo $(builddir)/zend_compile.lo: $(srcdir)/zend_language_parser.h

acinclude.m4

+2-2
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,7 @@ AC_DEFUN([PHP_PROG_RE2C],[
21552155
if test -n "$RE2C"; then
21562156
AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
21572157
re2c_vernum=`re2c --vernum 2>/dev/null`
2158-
if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1200"; then
2158+
if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then
21592159
php_cv_re2c_version=invalid
21602160
else
21612161
php_cv_re2c_version="`re2c --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
@@ -2164,7 +2164,7 @@ AC_DEFUN([PHP_PROG_RE2C],[
21642164
fi
21652165
case $php_cv_re2c_version in
21662166
""|invalid[)]
2167-
AC_MSG_WARN([You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.])
2167+
AC_MSG_WARN([You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.])
21682168
RE2C="exit 0;"
21692169
;;
21702170
esac

configure.in

+30-2
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,38 @@ dnl check for -R, etc. switch
161161
PHP_RUNPATH_SWITCH
162162

163163
dnl Checks for some support/generator progs
164-
PHP_PROG_RE2C
164+
165165
PHP_PROG_AWK
166166
PHP_PROG_BISON
167-
PHP_PROG_LEX
167+
PHP_PROG_RE2C
168+
169+
PHP_ARG_ENABLE(re2c-cgoto, whether to enable computed goto gcc extension with re2c,
170+
[ --enable-re2c-cgoto Enable -g flag to re2c to use computed goto gcc extension], no, no)
171+
172+
if test "$PHP_RE2C_CGOTO" = "no"; then
173+
RE2C_FLAGS=""
174+
else
175+
AC_MSG_CHECKING([whether re2c -g works])
176+
AC_TRY_COMPILE([],[
177+
int main(int argc, const char **argv)
178+
{
179+
argc = argc;
180+
argv = argv;
181+
label1:
182+
label2:
183+
static void *adr[] = { &&label1, &&label2};
184+
goto *adr[0];
185+
return 0;
186+
}
187+
],[
188+
RE2C_FLAGS=""
189+
AC_MSG_RESULT([no])
190+
],[
191+
RE2C_FLAGS="-g"
192+
AC_MSG_RESULT([yes])
193+
])
194+
fi
195+
PHP_SUBST(RE2C_FLAGS)
168196

169197
dnl Platform-specific compile settings.
170198
dnl -------------------------------------------------------------------------

ext/spl/php_spl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ int spl_autoload(const zstr class_name, const zstr lc_name, int class_name_len,
233233
zend_destroy_file_handle(&file_handle TSRMLS_CC);
234234
} else {
235235
new_op_array = NULL;
236-
zend_file_handle_dtor(&file_handle);
236+
zend_file_handle_dtor(&file_handle TSRMLS_CC);
237237
}
238238
if (new_op_array) {
239239
EG(return_value_ptr_ptr) = &result;

ext/standard/tests/strings/006.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
highlight_file() and output buffer
3+
--INI--
4+
log_errors_max_len=4096
35
--FILE--
46
<?php
57

ext/standard/tests/strings/007.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
php_strip_whitespace() and output buffer
3+
--INI--
4+
log_errors_max_len=4096
35
--FILE--
46
<?php
57

ext/standard/tests/strings/highlight_file.phpt

+4-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ highlight.comment=#FF9900
66
highlight.keyword=#007700
77
highlight.default=#0000BB
88
highlight.html=#000000
9+
allow_url_include=1
910
--FILE--
1011
<?php
1112

@@ -14,19 +15,9 @@ $filename = dirname(__FILE__)."/highlight_file.dat";
1415
var_dump(highlight_file());
1516
var_dump(highlight_file($filename));
1617

17-
$data = <<<DATA
18-
<?php echo "test"; ?>
19-
DATA;
18+
var_dump(highlight_file('data:,<?php echo "test"; ?>'));
2019

21-
file_put_contents($filename, $data);
22-
var_dump(highlight_file($filename));
23-
24-
$data = <<<DATA
25-
<?php echo "test ?>
26-
DATA;
27-
28-
file_put_contents($filename, $data);
29-
var_dump(highlight_file($filename));
20+
var_dump(highlight_file('data:,<?php echo "test ?>'));
3021

3122
$data = '
3223
<?php
@@ -57,7 +48,7 @@ bool(false)
5748
</span>
5849
</code>bool(true)
5950
<code><span style="color: #000000">
60-
<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"test&nbsp;?&gt;</span>
51+
<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #FF9900">"test&nbsp;?&gt;</span>
6152
</span>
6253
</code>bool(true)
6354
<code><span style="color: #000000">

ext/standard/tests/strings/strip_tags_basic1.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : basic functionality - with default arguments
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_basic2.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : basic functionality - with all arguments
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_error.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : error conditions
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_variation1.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : usage variations - unexpected values for 'str' argument
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_variation10.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : usage variations - single quoted strings
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_variation2.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : usage variations - unexpected values for 'allowable_tags'
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_variation3.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : usage variations - unexpected values for both 'str' and 'allowable_tags'
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_variation4.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : usage variations - invalid values for 'str' and valid 'allowable_tags'
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_variation6.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : usage variations - binary safe checking
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_variation7.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : usage variations - invalid values for 'str' and 'allowable_tags'
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/standard/tests/strings/strip_tags_variation8.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Test strip_tags() function : usage variations - valid value for 'str' and invalid values for 'allowable_tags'
33
--INI--
4-
set short_open_tag = on
4+
short_open_tag = on
55
--FILE--
66
<?php
77
/* Prototype : string strip_tags(string $str [, string $allowable_tags])

ext/tokenizer/Makefile.frag

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

ext/tokenizer/tests/token_get_all_variation14.phpt

+2-11
Original file line numberDiff line numberDiff line change
@@ -516,22 +516,13 @@ echo "hello world"; ?>"
516516
}
517517
}
518518
-- with invalid PHP tags and tokens --
519-
array(2) {
519+
array(1) {
520520
[0]=>
521521
array(3) {
522522
[0]=>
523523
int(313)
524524
[1]=>
525-
string(18) "<PDP display $a; "
526-
[2]=>
527-
int(1)
528-
}
529-
[1]=>
530-
array(3) {
531-
[0]=>
532-
int(313)
533-
[1]=>
534-
string(1) "<"
525+
string(19) "<PDP display $a; <"
535526
[2]=>
536527
int(1)
537528
}

ext/tokenizer/tokenizer.c

+2-60
Original file line numberDiff line numberDiff line change
@@ -27,67 +27,9 @@
2727
#include "ext/standard/info.h"
2828
#include "php_tokenizer.h"
2929

30-
typedef struct yy_buffer_state *YY_BUFFER_STATE;
31-
typedef unsigned int yy_size_t;
32-
struct yy_buffer_state
33-
{
34-
FILE *yy_input_file;
35-
36-
char *yy_ch_buf; /* input buffer */
37-
char *yy_buf_pos; /* current position in input buffer */
38-
39-
/* Size of input buffer in bytes, not including room for EOB
40-
* characters.
41-
*/
42-
yy_size_t yy_buf_size;
43-
44-
/* Number of characters read into yy_ch_buf, not including EOB
45-
* characters.
46-
*/
47-
int yy_n_chars;
48-
49-
/* Whether we "own" the buffer - i.e., we know we created it,
50-
* and can realloc() it to grow it, and should free() it to
51-
* delete it.
52-
*/
53-
int yy_is_our_buffer;
54-
55-
/* Whether this is an "interactive" input source; if so, and
56-
* if we're using stdio for input, then we want to use getc()
57-
* instead of fread(), to make sure we stop fetching input after
58-
* each newline.
59-
*/
60-
int yy_is_interactive;
61-
62-
/* Whether we're considered to be at the beginning of a line.
63-
* If so, '^' rules will be active on the next match, otherwise
64-
* not.
65-
*/
66-
int yy_at_bol;
67-
68-
/* Whether to try to fill the input buffer when we reach the
69-
* end of it.
70-
*/
71-
int yy_fill_buffer;
72-
73-
int yy_buffer_status;
74-
#define YY_BUFFER_NEW 0
75-
#define YY_BUFFER_NORMAL 1
76-
/* When an EOF's been seen but there's still some text to process
77-
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
78-
* shouldn't try reading from the input source any more. We might
79-
* still have a bunch of tokens to match, though, because of
80-
* possible backing-up.
81-
*
82-
* When we actually see the EOF, we change the status to "new"
83-
* (via yyrestart()), so that the user can continue scanning by
84-
* just pointing yyin at a new input file.
85-
*/
86-
#define YY_BUFFER_EOF_PENDING 2
87-
};
88-
8930
#include "zend.h"
9031
#include "zend_language_scanner.h"
32+
#include "zend_language_scanner_defs.h"
9133
#include <zend_language_parser.h>
9234

9335
#define zendtext LANG_SCNG(yy_text)
@@ -224,7 +166,7 @@ PHP_FUNCTION(token_get_all)
224166
RETURN_EMPTY_STRING();
225167
}
226168

227-
LANG_SCNG(start) = 1;
169+
LANG_SCNG(yy_state) = yycINITIAL;
228170

229171
tokenize(return_value TSRMLS_CC);
230172

0 commit comments

Comments
 (0)