Remove lexer files generated by RE2C

This patch removes generated lexer files by re2c during the build
process so they are not tracked by Git yet can be still shipped when
PHP is released. The genfiles script additionally provides generation
of these lexer files when creating a release of the PHP source code.

The genfiles script refactorings:
- added file header
- echoing steps instead of comments
- cleaning only lines starting with `#line`
- eval removed in favor of direct executed commands
- the debug mode `set -x` removed
- script can be called from any path
- improved comments
This commit is contained in:
Peter Kokot 2018-11-10 02:47:26 +01:00
parent 1c873c1191
commit f0251a8b16
13 changed files with 103 additions and 19784 deletions

15
.gitignore vendored
View File

@ -153,6 +153,21 @@ config.h.in
/scripts/phpize
php
# ------------------------------------------------------------------------------
# Lexer files generated by re2c
# ------------------------------------------------------------------------------
/ext/json/json_scanner.c
/ext/json/php_json_scanner_defs.h
/ext/pdo/pdo_sql_parser.c
/ext/phar/phar_path_check.c
/ext/standard/url_scanner_ex.c
/ext/standard/var_unserializer.c
/sapi/phpdbg/phpdbg_lexer.c
/Zend/zend_ini_scanner.c
/Zend/zend_ini_scanner_defs.h
/Zend/zend_language_scanner.c
/Zend/zend_language_scanner_defs.h
# ------------------------------------------------------------------------------
# PHP parser files generated by bison during the build process
# ------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
/* Generated by re2c 1.0.3 */
#line 3 "Zend/zend_ini_scanner_defs.h"
enum YYCONDTYPE {
yycINITIAL,
yycST_OFFSET,
yycST_SECTION_VALUE,
yycST_VALUE,
yycST_SECTION_RAW,
yycST_DOUBLE_QUOTES,
yycST_VARNAME,
yycST_RAW,
};

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
/* Generated by re2c 1.0.1 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {
yycST_IN_SCRIPTING,
yycST_LOOKING_FOR_PROPERTY,
yycST_BACKQUOTE,
yycST_DOUBLE_QUOTES,
yycST_HEREDOC,
yycST_LOOKING_FOR_VARNAME,
yycST_VAR_OFFSET,
yycINITIAL,
yycST_END_HEREDOC,
yycST_NOWDOC,
};

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
/* Generated by re2c 1.0.3 */
enum YYCONDTYPE {
yycJS,
yycSTR_P1,
yycSTR_P2_BIN,
yycSTR_P2_UTF,
};

View File

@ -1,739 +0,0 @@
/* Generated by re2c 1.0.3 */
#line 1 "ext/pdo/pdo_sql_parser.re"
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: George Schlossnagle <george@omniti.com> |
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "php_pdo_driver.h"
#include "php_pdo_int.h"
#define PDO_PARSER_TEXT 1
#define PDO_PARSER_BIND 2
#define PDO_PARSER_BIND_POS 3
#define PDO_PARSER_EOI 4
#define RET(i) {s->cur = cursor; return i; }
#define SKIP_ONE(i) {s->cur = s->tok + 1; return i; }
#define YYCTYPE unsigned char
#define YYCURSOR cursor
#define YYLIMIT s->end
#define YYMARKER s->ptr
#define YYFILL(n) { RET(PDO_PARSER_EOI); }
typedef struct Scanner {
char *ptr, *cur, *tok, *end;
} Scanner;
static int scan(Scanner *s)
{
char *cursor = s->cur;
s->tok = cursor;
#line 53 "ext/pdo/pdo_sql_parser.re"
#line 53 "ext/pdo/pdo_sql_parser.c"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch (yych) {
case 0x00: goto yy2;
case '"': goto yy6;
case '\'': goto yy8;
case '(':
case ')':
case '*':
case '+':
case ',':
case '.': goto yy9;
case '-': goto yy10;
case '/': goto yy11;
case ':': goto yy12;
case '?': goto yy13;
default: goto yy3;
}
yy2:
YYCURSOR = YYMARKER;
goto yy7;
yy3:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch (yych) {
case 0x00:
case '"':
case '\'':
case '(':
case ')':
case '*':
case '+':
case ',':
case '-':
case '.':
case '/':
case ':':
case '?': goto yy5;
default: goto yy3;
}
yy5:
#line 63 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 100 "ext/pdo/pdo_sql_parser.c"
yy6:
yych = *(YYMARKER = ++YYCURSOR);
if (yych >= 0x01) goto yy16;
yy7:
#line 61 "ext/pdo/pdo_sql_parser.re"
{ SKIP_ONE(PDO_PARSER_TEXT); }
#line 107 "ext/pdo/pdo_sql_parser.c"
yy8:
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= 0x00) goto yy7;
goto yy21;
yy9:
++YYCURSOR;
goto yy7;
yy10:
yych = *++YYCURSOR;
switch (yych) {
case '-': goto yy25;
default: goto yy7;
}
yy11:
yych = *++YYCURSOR;
switch (yych) {
case '*': goto yy28;
default: goto yy7;
}
yy12:
yych = *++YYCURSOR;
switch (yych) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '_':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z': goto yy30;
case ':': goto yy33;
default: goto yy7;
}
yy13:
yych = *++YYCURSOR;
switch (yych) {
case '?': goto yy36;
default: goto yy14;
}
yy14:
#line 60 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_BIND_POS); }
#line 205 "ext/pdo/pdo_sql_parser.c"
yy15:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy16:
switch (yych) {
case 0x00: goto yy2;
case '"': goto yy17;
case '\\': goto yy19;
default: goto yy15;
}
yy17:
++YYCURSOR;
#line 56 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 221 "ext/pdo/pdo_sql_parser.c"
yy19:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yych <= 0x00) goto yy2;
goto yy15;
yy20:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy21:
switch (yych) {
case 0x00: goto yy2;
case '\'': goto yy22;
case '\\': goto yy24;
default: goto yy20;
}
yy22:
++YYCURSOR;
#line 57 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 243 "ext/pdo/pdo_sql_parser.c"
yy24:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yych <= 0x00) goto yy2;
goto yy20;
yy25:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch (yych) {
case '\n':
case '\r': goto yy27;
default: goto yy25;
}
yy27:
#line 62 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 262 "ext/pdo/pdo_sql_parser.c"
yy28:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch (yych) {
case '*': goto yy38;
default: goto yy28;
}
yy30:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch (yych) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '_':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z': goto yy30;
default: goto yy32;
}
yy32:
#line 59 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_BIND); }
#line 344 "ext/pdo/pdo_sql_parser.c"
yy33:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch (yych) {
case ':': goto yy33;
default: goto yy35;
}
yy35:
#line 58 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 356 "ext/pdo/pdo_sql_parser.c"
yy36:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch (yych) {
case '?': goto yy36;
default: goto yy35;
}
yy38:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch (yych) {
case '*': goto yy38;
case '/': goto yy40;
default: goto yy28;
}
yy40:
++YYCURSOR;
goto yy27;
}
#line 64 "ext/pdo/pdo_sql_parser.re"
}
struct placeholder {
char *pos;
size_t len;
size_t qlen; /* quoted length of value */
char *quoted; /* quoted value */
int freeq;
int bindno;
struct placeholder *next;
};
static void free_param_name(zval *el) {
efree(Z_PTR_P(el));
}
PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
char **outquery, size_t *outquery_len)
{
Scanner s;
char *ptr, *newbuffer;
ptrdiff_t t;
uint32_t bindno = 0;
int ret = 0;
size_t newbuffer_len;
HashTable *params;
struct pdo_bound_param_data *param;
int query_type = PDO_PLACEHOLDER_NONE;
struct placeholder *placeholders = NULL, *placetail = NULL, *plc = NULL;
ptr = *outquery;
s.cur = inquery;
s.end = inquery + inquery_len + 1;
/* phase 1: look for args */
while((t = scan(&s)) != PDO_PARSER_EOI) {
if (t == PDO_PARSER_BIND || t == PDO_PARSER_BIND_POS) {
if (t == PDO_PARSER_BIND) {
ptrdiff_t len = s.cur - s.tok;
if ((inquery < (s.cur - len)) && isalnum(*(s.cur - len - 1))) {
continue;
}
query_type |= PDO_PLACEHOLDER_NAMED;
} else {
query_type |= PDO_PLACEHOLDER_POSITIONAL;
}
plc = emalloc(sizeof(*plc));
memset(plc, 0, sizeof(*plc));
plc->next = NULL;
plc->pos = s.tok;
plc->len = s.cur - s.tok;
plc->bindno = bindno++;
if (placetail) {
placetail->next = plc;
} else {
placeholders = plc;
}
placetail = plc;
}
}
if (bindno == 0) {
/* nothing to do; good! */
return 0;
}
/* did the query make sense to me? */
if (query_type == (PDO_PLACEHOLDER_NAMED|PDO_PLACEHOLDER_POSITIONAL)) {
/* they mixed both types; punt */
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "mixed named and positional parameters");
ret = -1;
goto clean_up;
}
if (stmt->supports_placeholders == query_type && !stmt->named_rewrite_template) {
/* query matches native syntax */
ret = 0;
goto clean_up;
}
if (stmt->named_rewrite_template) {
/* magic/hack.
* We we pretend that the query was positional even if
* it was named so that we fall into the
* named rewrite case below. Not too pretty,
* but it works. */
query_type = PDO_PLACEHOLDER_POSITIONAL;
}
params = stmt->bound_params;
/* Do we have placeholders but no bound params */
if (bindno && !params && stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "no parameters were bound");
ret = -1;
goto clean_up;
}
if (params && bindno != zend_hash_num_elements(params) && stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
/* extra bit of validation for instances when same params are bound more than once */
if (query_type != PDO_PLACEHOLDER_POSITIONAL && bindno > zend_hash_num_elements(params)) {
int ok = 1;
for (plc = placeholders; plc; plc = plc->next) {
if ((param = zend_hash_str_find_ptr(params, plc->pos, plc->len)) == NULL) {
ok = 0;
break;
}
}
if (ok) {
goto safe;
}
}
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "number of bound variables does not match number of tokens");
ret = -1;
goto clean_up;
}
safe:
/* what are we going to do ? */
if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
/* query generation */
newbuffer_len = inquery_len;
/* let's quote all the values */
for (plc = placeholders; plc; plc = plc->next) {
if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
param = zend_hash_index_find_ptr(params, plc->bindno);
} else {
param = zend_hash_str_find_ptr(params, plc->pos, plc->len);
}
if (param == NULL) {
/* parameter was not defined */
ret = -1;
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined");
goto clean_up;
}
if (stmt->dbh->methods->quoter) {
zval *parameter;
if (Z_ISREF(param->parameter)) {
parameter = Z_REFVAL(param->parameter);
} else {
parameter = &param->parameter;
}
if (param->param_type == PDO_PARAM_LOB && Z_TYPE_P(parameter) == IS_RESOURCE) {
php_stream *stm;
php_stream_from_zval_no_verify(stm, parameter);
if (stm) {
zend_string *buf;
buf = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0);
if (!buf) {
buf = ZSTR_EMPTY_ALLOC();
}
if (!stmt->dbh->methods->quoter(stmt->dbh, ZSTR_VAL(buf), ZSTR_LEN(buf), &plc->quoted, &plc->qlen,
param->param_type)) {
/* bork */
ret = -1;
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
if (buf) {
zend_string_release_ex(buf, 0);
}
goto clean_up;
}
if (buf) {
zend_string_release_ex(buf, 0);
}
} else {
pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource");
ret = -1;
goto clean_up;
}
plc->freeq = 1;
} else {
enum pdo_param_type param_type = param->param_type;
zend_string *buf = NULL;
/* assume all types are nullable */
if (Z_TYPE_P(parameter) == IS_NULL) {
param_type = PDO_PARAM_NULL;
}
switch (param_type) {
case PDO_PARAM_BOOL:
plc->quoted = zend_is_true(parameter) ? "1" : "0";
plc->qlen = sizeof("1")-1;
plc->freeq = 0;
break;
case PDO_PARAM_INT:
buf = zend_long_to_str(zval_get_long(parameter));
plc->qlen = ZSTR_LEN(buf);
plc->quoted = estrdup(ZSTR_VAL(buf));
plc->freeq = 1;
break;
case PDO_PARAM_NULL:
plc->quoted = "NULL";
plc->qlen = sizeof("NULL")-1;
plc->freeq = 0;
break;
default:
buf = zval_get_string(parameter);
if (!stmt->dbh->methods->quoter(stmt->dbh, ZSTR_VAL(buf),
ZSTR_LEN(buf), &plc->quoted, &plc->qlen,
param_type)) {
/* bork */
ret = -1;
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
if (buf) {
zend_string_release_ex(buf, 0);
}
goto clean_up;
}
plc->freeq = 1;
}
if (buf) {
zend_string_release_ex(buf, 0);
}
}
} else {
zval *parameter;
if (Z_ISREF(param->parameter)) {
parameter = Z_REFVAL(param->parameter);
} else {
parameter = &param->parameter;
}
plc->quoted = Z_STRVAL_P(parameter);
plc->qlen = Z_STRLEN_P(parameter);
}
newbuffer_len += plc->qlen;
}
rewrite:
/* allocate output buffer */
newbuffer = emalloc(newbuffer_len + 1);
*outquery = newbuffer;
/* and build the query */
plc = placeholders;
ptr = inquery;
do {
t = plc->pos - ptr;
if (t) {
memcpy(newbuffer, ptr, t);
newbuffer += t;
}
memcpy(newbuffer, plc->quoted, plc->qlen);
newbuffer += plc->qlen;
ptr = plc->pos + plc->len;
plc = plc->next;
} while (plc);
t = (inquery + inquery_len) - ptr;
if (t) {
memcpy(newbuffer, ptr, t);
newbuffer += t;
}
*newbuffer = '\0';
*outquery_len = newbuffer - *outquery;
ret = 1;
goto clean_up;
} else if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
/* rewrite ? to :pdoX */
char *name, *idxbuf;
const char *tmpl = stmt->named_rewrite_template ? stmt->named_rewrite_template : ":pdo%d";
int bind_no = 1;
newbuffer_len = inquery_len;
if (stmt->bound_param_map == NULL) {
ALLOC_HASHTABLE(stmt->bound_param_map);
zend_hash_init(stmt->bound_param_map, 13, NULL, free_param_name, 0);
}
for (plc = placeholders; plc; plc = plc->next) {
int skip_map = 0;
char *p;
name = estrndup(plc->pos, plc->len);
/* check if bound parameter is already available */
if (!strcmp(name, "?") || (p = zend_hash_str_find_ptr(stmt->bound_param_map, name, plc->len)) == NULL) {
spprintf(&idxbuf, 0, tmpl, bind_no++);
} else {
idxbuf = estrdup(p);
skip_map = 1;
}
plc->quoted = idxbuf;
plc->qlen = strlen(plc->quoted);
plc->freeq = 1;
newbuffer_len += plc->qlen;
if (!skip_map && stmt->named_rewrite_template) {
/* create a mapping */
zend_hash_str_update_mem(stmt->bound_param_map, name, plc->len, idxbuf, plc->qlen + 1);
}
/* map number to name */
zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, idxbuf, plc->qlen + 1);
efree(name);
}
goto rewrite;
} else {
/* rewrite :name to ? */
newbuffer_len = inquery_len;
if (stmt->bound_param_map == NULL) {
ALLOC_HASHTABLE(stmt->bound_param_map);
zend_hash_init(stmt->bound_param_map, 13, NULL, free_param_name, 0);
}
for (plc = placeholders; plc; plc = plc->next) {
char *name;
name = estrndup(plc->pos, plc->len);
zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, name, plc->len + 1);
efree(name);
plc->quoted = "?";
plc->qlen = 1;
}
goto rewrite;
}
clean_up:
while (placeholders) {
plc = placeholders;
placeholders = plc->next;
if (plc->freeq) {
efree(plc->quoted);
}
efree(plc);
}
return ret;
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker ft=c
* vim<600: noet sw=4 ts=4
*/

View File

@ -1,259 +0,0 @@
/* Generated by re2c 1.0.3 */
#line 1 "ext/phar/phar_path_check.re"
/*
+----------------------------------------------------------------------+
| phar php single-file executable PHP extension |
+----------------------------------------------------------------------+
| Copyright (c) 2007-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#include "phar_internal.h"
phar_path_check_result phar_path_check(char **s, size_t *len, const char **error)
{
const unsigned char *p = (const unsigned char*)*s;
const unsigned char *m;
if (*len == 1 && *p == '.') {
*error = "current directory reference";
return pcr_err_curr_dir;
} else if (*len == 2 && p[0] == '.' && p[1] == '.') {
*error = "upper directory reference";
return pcr_err_up_dir;
}
#define YYCTYPE unsigned char
#define YYCURSOR p
#define YYLIMIT p+*len
#define YYMARKER m
#define YYFILL(n)
loop:
#line 47 "ext/phar/phar_path_check.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
yych = *YYCURSOR;
if (yych <= '[') {
if (yych <= ')') {
if (yych <= '\f') {
if (yych >= 0x01) goto yy4;
} else {
if (yych <= '\r') goto yy6;
if (yych <= 0x19) goto yy4;
goto yy7;
}
} else {
if (yych <= '/') {
if (yych <= '*') goto yy9;
if (yych <= '.') goto yy7;
goto yy11;
} else {
if (yych == '?') goto yy12;
goto yy7;
}
}
} else {
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\\') goto yy14;
if (yych <= 0x7F) goto yy7;
goto yy4;
} else {
if (yych <= 0xDF) goto yy16;
if (yych <= 0xE0) goto yy17;
goto yy18;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy19;
if (yych <= 0xEF) goto yy18;
goto yy20;
} else {
if (yych <= 0xF3) goto yy21;
if (yych <= 0xF4) goto yy22;
goto yy4;
}
}
}
++YYCURSOR;
#line 93 "ext/phar/phar_path_check.re"
{
if (**s == '/') {
(*s)++;
(*len)--;
}
if ((p - (const unsigned char*)*s) - 1 != *len)
{
*error ="illegal character";
return pcr_err_illegal_char;
}
*error = NULL;
return pcr_is_ok;
}
#line 110 "ext/phar/phar_path_check.c"
yy4:
++YYCURSOR;
yy5:
#line 106 "ext/phar/phar_path_check.re"
{
*error ="illegal character";
return pcr_err_illegal_char;
}
#line 119 "ext/phar/phar_path_check.c"
yy6:
yych = *++YYCURSOR;
if (yych == '\n') goto yy4;
goto yy5;
yy7:
++YYCURSOR;
yy8:
#line 90 "ext/phar/phar_path_check.re"
{
goto loop;
}
#line 131 "ext/phar/phar_path_check.c"
yy9:
++YYCURSOR;
#line 78 "ext/phar/phar_path_check.re"
{
*error = "star";
return pcr_err_star;
}
#line 139 "ext/phar/phar_path_check.c"
yy11:
yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= '-') goto yy8;
if (yych <= '.') goto yy23;
if (yych <= '/') goto yy25;
goto yy8;
yy12:
++YYCURSOR;
#line 82 "ext/phar/phar_path_check.re"
{
if (**s == '/') {
(*s)++;
}
*len = (p - (const unsigned char*)*s) -1;
*error = NULL;
return pcr_use_query;
}
#line 158 "ext/phar/phar_path_check.c"
yy14:
++YYCURSOR;
#line 74 "ext/phar/phar_path_check.re"
{
*error = "back-slash";
return pcr_err_back_slash;
}
#line 166 "ext/phar/phar_path_check.c"
yy16:
yych = *++YYCURSOR;
if (yych <= 0x7F) goto yy5;
if (yych <= 0xBF) goto yy7;
goto yy5;
yy17:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= 0x9F) goto yy5;
if (yych <= 0xBF) goto yy27;
goto yy5;
yy18:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= 0x7F) goto yy5;
if (yych <= 0xBF) goto yy27;
goto yy5;
yy19:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= 0x7F) goto yy5;
if (yych <= 0x9F) goto yy27;
goto yy5;
yy20:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= 0x8F) goto yy5;
if (yych <= 0xBF) goto yy28;
goto yy5;
yy21:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= 0x7F) goto yy5;
if (yych <= 0xBF) goto yy28;
goto yy5;
yy22:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= 0x7F) goto yy5;
if (yych <= 0x8F) goto yy28;
goto yy5;
yy23:
yych = *++YYCURSOR;
if (yych <= 0x00) goto yy29;
if (yych <= '-') goto yy24;
if (yych <= '.') goto yy31;
if (yych <= '/') goto yy29;
yy24:
YYCURSOR = YYMARKER;
if (yyaccept == 0) {
goto yy8;
} else {
goto yy5;
}
yy25:
++YYCURSOR;
#line 62 "ext/phar/phar_path_check.re"
{
*error = "double slash";
return pcr_err_double_slash;
}
#line 228 "ext/phar/phar_path_check.c"
yy27:
yych = *++YYCURSOR;
if (yych <= 0x7F) goto yy24;
if (yych <= 0xBF) goto yy7;
goto yy24;
yy28:
yych = *++YYCURSOR;
if (yych <= 0x7F) goto yy24;
if (yych <= 0xBF) goto yy27;
goto yy24;
yy29:
++YYCURSOR;
#line 70 "ext/phar/phar_path_check.re"
{
*error = "current directory reference";
return pcr_err_curr_dir;
}
#line 246 "ext/phar/phar_path_check.c"
yy31:
yych = *++YYCURSOR;
if (yych <= 0x00) goto yy32;
if (yych != '/') goto yy24;
yy32:
++YYCURSOR;
#line 66 "ext/phar/phar_path_check.re"
{
*error = "upper directory reference";
return pcr_err_up_dir;
}
#line 258 "ext/phar/phar_path_check.c"
}
#line 110 "ext/phar/phar_path_check.re"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

111
genfiles
View File

@ -1,36 +1,101 @@
#! /bin/sh
#!/bin/sh
#
# +----------------------------------------------------------------------+
# | PHP Version 7 |
# +----------------------------------------------------------------------+
# | Copyright (c) 1997-2018 The PHP Group |
# +----------------------------------------------------------------------+
# | This source file is subject to version 3.01 of the PHP license, |
# | that is bundled with this package in the file LICENSE, and is |
# | available through the world-wide-web at the following url: |
# | https://php.net/license/3_01.txt |
# | If you did not receive a copy of the PHP license and are unable to |
# | obtain it through the world-wide-web, please send a note to |
# | license@php.net so we can mail you a copy immediately. |
# +----------------------------------------------------------------------+
# | Authors: Sascha Schumann <sascha@schumann.cx> |
# +----------------------------------------------------------------------+
#
# This script generates PHP lexer and parser files required to build PHP. The
# generated files are ignored in the Git repository and packaged during the PHP
# release process into the release installation archive download. This way the
# bison and re2c dependencies are not required to build PHP when downloading
# release archive.
#
# Usage: genfiles
#
# Environment:
# The following environment variables can override default generators paths.
#
# YACC Parser generator program, default bison
# RE2C Lexer generator program, default re2c
#
# For example:
# YACC=/path/to/bison ./genfiles
if [ -z $YACC ]; then
YACC="bison"
fi
# Parser generator
YACC=${YACC:-bison}
YACC="$YACC -y -l"
if [ -z $RE2C ]; then
RE2C="re2c"
fi
# Lexer generator
RE2C=${RE2C:-re2c}
RE2C_FLAGS="-i"
# Generate Zend parser and lexer files
STD="make -f Zend/Makefile.frag RE2C='$RE2C' RE2C_FLAGS='-i' YACC='$YACC' srcdir=Zend builddir=Zend top_srcdir=."
(eval "$STD Zend/zend_language_parser.c Zend/zend_language_scanner.c Zend/zend_ini_parser.c Zend/zend_ini_scanner.c")
# Current path to return to it later. This enables running script from any path.
original_path=`pwd`
# Generate phpdbg parser and lexer files
STD="make -f sapi/phpdbg/Makefile.frag RE2C='$RE2C' RE2C_FLAGS='-i' YACC='$YACC' srcdir=sapi/phpdbg builddir=sapi/phpdbg top_srcdir=."
(eval "$STD sapi/phpdbg/phpdbg_parser.c sapi/phpdbg/phpdbg_lexer.c")
# Project root directory
project_root=`CDPATH= cd -- "$(dirname -- "$0")" && pwd -P`
cd $project_root
# Generate json parser and lexer files
STD="make -f ext/json/Makefile.frag RE2C='$RE2C' RE2C_FLAGS='-i' YACC='$YACC' srcdir=ext/json builddir=ext/json top_srcdir=."
(eval "$STD ext/json/json_parser.tab.c ext/json/json_scanner.c")
echo "Generating Zend parser and lexer files"
make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=Zend builddir=Zend top_srcdir=. \
-f Zend/Makefile.frag \
Zend/zend_language_parser.c \
Zend/zend_language_scanner.c \
Zend/zend_ini_parser.c \
Zend/zend_ini_scanner.c
set -x
echo "Generating phpdbg parser and lexer files"
make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=sapi/phpdbg builddir=sapi/phpdbg top_srcdir=. \
-f sapi/phpdbg/Makefile.frag \
sapi/phpdbg/phpdbg_parser.c \
sapi/phpdbg/phpdbg_lexer.c
CLEANUP_FILES=" \
ext/pdo/pdo_sql_parser.c \
ext/date/lib/parse_date.c \
ext/standard/url_scanner_ex.c \
echo "Generating json extension parser and lexer files"
make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=ext/json builddir=ext/json top_srcdir=. \
-f ext/json/Makefile.frag \
ext/json/json_parser.tab.c \
ext/json/json_scanner.c
echo "Generating PDO lexer file"
make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/pdo builddir=ext/pdo top_srcdir=. \
-f ext/pdo/Makefile.frag \
ext/pdo/pdo_sql_parser.c
echo "Generating standard extension lexer files"
make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/standard builddir=ext/standard top_srcdir=. \
-f ext/standard/Makefile.frag \
ext/standard/var_unserializer.c \
ext/standard/url_scanner_ex.c
echo "Generating phar extension lexer file"
make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/phar builddir=ext/phar top_srcdir=. \
-f ext/phar/Makefile.frag \
ext/phar/phar_path_check.c
# Clean debug #line XY info from the bundled lexer files.
cleanup_files=" \
ext/date/lib/parse_date.c \
ext/date/lib/parse_iso_intervals.c \
"
for f in $CLEANUP_FILES; do
for f in $cleanup_files; do
echo "Cleaning file $f"
cp $f $f.orig
grep -v '#line ' $f.orig > $f
grep -v '^#line ' $f.orig > $f
rm -f $f.orig
done
# Return to the original directory.
cd $original_path

File diff suppressed because it is too large Load Diff