]> granicus.if.org Git - php/commitdiff
MFB 5.3: Rest of the changes for re2c merge
authorScott MacVicar <scottmac@php.net>
Wed, 26 Mar 2008 14:46:17 +0000 (14:46 +0000)
committerScott MacVicar <scottmac@php.net>
Wed, 26 Mar 2008 14:46:17 +0000 (14:46 +0000)
26 files changed:
Makefile.frag
acinclude.m4
configure.in
ext/spl/php_spl.c
ext/standard/tests/strings/006.phpt
ext/standard/tests/strings/007.phpt
ext/standard/tests/strings/highlight_file.phpt
ext/standard/tests/strings/strip_tags_basic1.phpt
ext/standard/tests/strings/strip_tags_basic2.phpt
ext/standard/tests/strings/strip_tags_error.phpt
ext/standard/tests/strings/strip_tags_variation1.phpt
ext/standard/tests/strings/strip_tags_variation10.phpt
ext/standard/tests/strings/strip_tags_variation2.phpt
ext/standard/tests/strings/strip_tags_variation3.phpt
ext/standard/tests/strings/strip_tags_variation4.phpt
ext/standard/tests/strings/strip_tags_variation6.phpt
ext/standard/tests/strings/strip_tags_variation7.phpt
ext/standard/tests/strings/strip_tags_variation8.phpt
ext/tokenizer/Makefile.frag
ext/tokenizer/tests/token_get_all_variation14.phpt
ext/tokenizer/tokenizer.c
main/main.c
sapi/cgi/cgi_main.c
sapi/cli/php_cli.c
win32/build/Makefile
win32/build/config.w32

index 81d5428c77b80efb718940db2746d8757336ee2b..c8b3cb2d8062a64add631423d8b65e2e31baf4d5 100644 (file)
@@ -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
+       @(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)
 
 $(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
+       @(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)
 
 $(builddir)/zend_indent.lo $(builddir)/zend_highlight.lo $(builddir)/zend_compile.lo: $(srcdir)/zend_language_parser.h
index cc71dd08f237b4d1ea1c4f08bec50e67cd771240..59dbb24686e63ff44d1d3dd6e9860ac7486ad3b8 100644 (file)
@@ -2155,7 +2155,7 @@ AC_DEFUN([PHP_PROG_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
+      if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then
         php_cv_re2c_version=invalid
       else
         php_cv_re2c_version="`re2c --version | cut -d ' ' -f 2  2>/dev/null` (ok)"
@@ -2164,7 +2164,7 @@ AC_DEFUN([PHP_PROG_RE2C],[
   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.4 or later if you want to regenerate PHP parsers.])
       RE2C="exit 0;"
       ;;
   esac
index 57c37be79da1bdf51ab022a4b426fcf5a08f1b7c..5aac926dd6c06b55cacab65f54392c96a0978662 100644 (file)
@@ -161,10 +161,38 @@ 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 -------------------------------------------------------------------------
index 2804feb0089dedb8c5fc22fd92fff18a4b18576c..75bbe6284a7f6393140eb5b19379bfe4efb61e0e 100755 (executable)
@@ -233,7 +233,7 @@ int spl_autoload(const zstr class_name, const zstr lc_name, int class_name_len,
                        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;
index f0156ccf6efd780bb82eaacc4fe3d37996517610..3cee5d14059a6fc8c41d808be416fcf4af008909 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 highlight_file() and output buffer
+--INI--
+log_errors_max_len=4096
 --FILE--
 <?php
 
index e0e5163892c98cb2d899031b1c941d3f325ad3be..12cfdbc1b33a34baf173c78eb8933b1d1ce86caf 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 php_strip_whitespace() and output buffer
+--INI--
+log_errors_max_len=4096
 --FILE--
 <?php
 
index 24c0c53c5c9a83d9230f2a9ca156dbddcdaa982f..6ffa29297109a7d87a17f14d6b8f85db476dcb00 100644 (file)
@@ -6,6 +6,7 @@ highlight.comment=#FF9900
 highlight.keyword=#007700
 highlight.default=#0000BB
 highlight.html=#000000
+allow_url_include=1
 --FILE--
 <?php
 
@@ -14,19 +15,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 
@@ -57,7 +48,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">
index e08bf4bc1eaecc0ae3f047d832dd53d322f03c6e..42f7a81af9d5c2107882fbe5fc9d475769d17f38 100644 (file)
@@ -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])
index 2d3e012217311f2dffca02f95ee34687ccf42793..fb3e8839574a25e1807b1cc9d7bf532676182d97 100644 (file)
@@ -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])
index 0fb2674d65ea214d6f5ccf0e9b4ed216a045f34a..4fd8044031abf842446cdb87a14f53c02e190c82 100644 (file)
@@ -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])
index 76334a5737732290016ab53bed3b318368627e15..e997051fc7d29edfbb0b529d19f447f5992a50e5 100644 (file)
@@ -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])
index aa6ff3c8c636c128cd9b9edf65dfed8b882335ef..ae06ecd4d67488c8d7d15d8d07df18b4dcd48cfc 100644 (file)
@@ -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])
index 8205769224fbc42ee2e2d8421857a22efd97a025..40f8bac884e182cddb16f285e7429d61c5aa39fc 100644 (file)
@@ -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])
index 1e971b82bfb5d58a807e1a7f9a2b0714aba969fc..9e49276424c359a879280232fd4c6f79718b8fce 100644 (file)
@@ -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])
index 9ab3ccc539262c816e975a7eb7bb16d44e5f021a..d3fce45d397b386d866d118871917b97263dbe20 100644 (file)
@@ -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])
index da50518c48b93f191118fadb149c3ab41f6b03ea..6db6408767b3a5a9d3418e773a4aeea29e93b7c8 100644 (file)
@@ -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])
index e75e942d6b71b8bafce3b80c1e78cee2cd249b6b..a34536132d1b4b7c8a669db87ad60442d47b10c0 100644 (file)
@@ -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])
index 86591ac0e9551c1e356ba1b0a6f77068d58e0b94..29c0ed00206f8c9ee99b01206cae38ad3fb45689 100644 (file)
@@ -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])
index 6802d40e9223d0081cf45bd5d602c87c8de3bf8b..6df0d199476e84bbd3b0f107587d5310c383f8d6 100644 (file)
@@ -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
\ No newline at end of file
index 61a2f8f9eeee9ac86b1a91894f8fc62dbbfcb8e5..40a3c2c5de782887d4bbd3ecce321eae0cec6d3a 100644 (file)
@@ -516,22 +516,13 @@ echo "hello world"; ?>"
   }
 }
 -- with invalid PHP tags and tokens --
-array(2) {
+array(1) {
   [0]=>
   array(3) {
     [0]=>
     int(313)
     [1]=>
-    string(18) "<PDP display  $a; "
-    [2]=>
-    int(1)
-  }
-  [1]=>
-  array(3) {
-    [0]=>
-    int(313)
-    [1]=>
-    string(1) "<"
+    string(19) "<PDP display  $a; <"
     [2]=>
     int(1)
   }
index 082619b275508f5ed20713f74358dbe181f996be..963ffd5b390b71be702e19bbb44a9380bbd66274 100644 (file)
 #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)
@@ -224,7 +166,7 @@ PHP_FUNCTION(token_get_all)
                RETURN_EMPTY_STRING();
        }
 
-       LANG_SCNG(start) = 1;
+       LANG_SCNG(yy_state) = yycINITIAL;
 
        tokenize(return_value TSRMLS_CC);
        
index e375464d404a7c7d8e2d6900898d54b0189c5fca..fecbfd3d5c6ad722c8ebc79ce91438599e9fb479 100644 (file)
@@ -1159,15 +1159,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 TSRMLS_CC);
+}
+/* }}} */
+
+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;
 }
 /* }}} */
 
@@ -1179,19 +1190,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)) != 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);
 
@@ -2126,7 +2148,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
index ad061490fdcaedc70086dc3669f4f65af6e4f8e0..e59b1cc81116ad37dde635ede2d0f800463a4881 100644 (file)
@@ -1966,7 +1966,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_output_teardown();
                                        }
                                        return SUCCESS;
@@ -1981,7 +1981,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_output_teardown();
                                                }
                                                return SUCCESS;
@@ -1992,7 +1992,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);
                                        php_output_teardown();
                                        return SUCCESS;
                                        break;
index 6b0f419cf202972aedf494cf07f749be628d1595..7bca968aefcbd6d6b3af2ad520562457405294e7 100644 (file)
@@ -566,6 +566,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;
@@ -1182,7 +1185,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
index 9bb242aa1fdbee29e6adc9dfa6276da6e82c8cf3..a929f58d73391f2f451b7d247fd742617f1df7c7 100644 (file)
@@ -21,6 +21,7 @@ CC="$(CL)"
 LD="$(LINK)"
 MC="$(MC)"
 MT="$(MT)"
+RE2C="$(RE2C)"
 
 MCFILE=$(BUILD_DIR)\wsyslog.rc
 
@@ -28,10 +29,16 @@ all: generated_files $(EXT_TARGETS) $(PECL_TARGETS) $(SAPI_TARGETS)
 
 build_dirs: $(BUILD_DIR) $(BUILD_DIRS_SUB)
 
+!if $(RE2C) == ""
+generated_files: build_dirs Zend\zend_ini_parser.c \
+       Zend\zend_language_parser.c \
+       $(PHPDEF) $(MCFILE)
+!else
 generated_files: build_dirs Zend\zend_ini_parser.c \
        Zend\zend_language_parser.c Zend\zend_ini_scanner.c \
        Zend\zend_language_scanner.c \
        $(PHPDEF) $(MCFILE)
+!endif
 
 $(BUILD_DIR)\$(PHPDLL).def: $(PHP_DLL_DEF_SOURCES)
        type $(PHP_DLL_DEF_SOURCES) > $(BUILD_DIR)\$(PHPDLL).def
@@ -42,11 +49,13 @@ Zend\zend_ini_parser.c Zend\zend_ini_parser.h: Zend\zend_ini_parser.y
 Zend\zend_language_parser.c Zend\zend_language_parser.h: Zend\zend_language_parser.y
        $(BISON) --output=Zend/zend_language_parser.c -v -d -p zend Zend/zend_language_parser.y
 
+!if $(RE2C) != ""
 Zend\zend_ini_scanner.c: Zend\flex.skl Zend\zend_ini_scanner.l
-       $(FLEX) -B -i -SZend/flex.skl -Pini_ -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
+       $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
 
 Zend\zend_language_scanner.c: Zend\flex.skl Zend\zend_language_scanner.l
-       $(FLEX) -i -SZend/flex.skl -Pzend -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
+       $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
+!endif
 
 PHPDLL_RES=$(BUILD_DIR)\$(PHPDLL).res
 
index 8cb44452d8aafa7aece22e94754b176a79498f3a..c6be09a4c53d34b6fdc9dffc7292b6f2be3c61e2 100644 (file)
@@ -56,10 +56,40 @@ PATH_PROG('lib', null, 'MAKE_LIB');
 if (!PATH_PROG('bison')) {
        ERROR('bison is required')
 }
-if (!PATH_PROG('flex')) {
-       ERROR('flex is required')
+
+// There's a minimum requirement for re2c..
+MINRE2C = "0.13.4";
+
+function probe_re2c_version(RE2C)
+{
+       var command = "cmd /c " + RE2C + " -v";
+       var version = execute(command + '" 2>&1"');
+
+       if (version.match(/((\d+)\.(\d+)\.(\d+))/)) {
+               return RegExp.$1;
+       }
+       return 0;
+}
+
+RE2C = PATH_PROG('re2c');
+if (RE2C) {
+       var intvers, intmin;
+       var pattern = /\./g;
+
+       RE2CVERS = probe_re2c_version(RE2C);
+       intvers = RE2CVERS.replace(pattern, '') - 0;
+       intmin = MINRE2C.replace(pattern, '') - 0;
+
+       if (intvers < intmin) {
+               STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C + ', ' + RE2CVERS + ' detected');
+               STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c');
+               DEFINE('RE2C', '');
+       } else {
+               DEFINE('RE2C_FLAGS', '');
+       }
+} else {
+       STDOUT.WriteLine('Parsers will not be regenerated');
 }
-PATH_PROG('re2c');
 PATH_PROG('zip');
 PATH_PROG('lemon');