--- embedaddon/php/ext/pdo/pdo_sql_parser.c 2012/05/29 12:34:40 1.1.1.2 +++ embedaddon/php/ext/pdo/pdo_sql_parser.c 2013/10/14 08:02:24 1.1.1.4 @@ -1,9 +1,9 @@ -/* Generated by re2c 0.13.5 on Sat Jun 4 18:42:25 2011 */ +/* Generated by re2c 0.13.5 on Tue Aug 20 18:02:48 2013 */ /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | + | Copyright (c) 1997-2013 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sql_parser.c,v 1.1.1.2 2012/05/29 12:34:40 misho Exp $ */ +/* $Id: pdo_sql_parser.c,v 1.1.1.4 2013/10/14 08:02:24 misho Exp $ */ #include "php.h" #include "php_pdo_driver.h" @@ -33,12 +33,12 @@ #define YYCTYPE unsigned char #define YYCURSOR cursor -#define YYLIMIT cursor +#define YYLIMIT s->end #define YYMARKER s->ptr -#define YYFILL(n) +#define YYFILL(n) { RET(PDO_PARSER_EOI); } typedef struct Scanner { - char *ptr, *cur, *tok; + char *ptr, *cur, *tok, *end; } Scanner; static int scan(Scanner *s) @@ -56,27 +56,33 @@ static int scan(Scanner *s) if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { - case 0x00: goto yy13; - case '"': goto yy2; - case '\'': goto yy4; - case '-': goto yy10; - case '/': goto yy8; - case ':': goto yy5; - case '?': goto yy6; - default: goto yy11; + case 0x00: goto yy2; + case '"': goto yy3; + case '\'': goto yy5; + case '-': goto yy11; + case '/': goto yy9; + case ':': goto yy6; + case '?': goto yy7; + default: goto yy12; } yy2: + YYCURSOR = YYMARKER; + switch (yyaccept) { + case 0: goto yy4; + case 1: goto yy10; + } +yy3: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych >= 0x01) goto yy43; -yy3: - { SKIP_ONE(PDO_PARSER_TEXT); } yy4: + { SKIP_ONE(PDO_PARSER_TEXT); } +yy5: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x00) goto yy3; - goto yy37; -yy5: + if (yych <= 0x00) goto yy4; + goto yy38; +yy6: yych = *++YYCURSOR; switch (yych) { case '0': @@ -141,52 +147,47 @@ yy5: case 'w': case 'x': case 'y': - case 'z': goto yy33; - case ':': - case '?': goto yy30; - default: goto yy3; + case 'z': goto yy32; + case ':': goto yy35; + default: goto yy4; } -yy6: +yy7: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case ':': - case '?': goto yy30; - default: goto yy7; + case '?': goto yy29; + default: goto yy8; } -yy7: - { RET(PDO_PARSER_BIND_POS); } yy8: + { RET(PDO_PARSER_BIND_POS); } +yy9: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '*': goto yy20; - default: goto yy12; + case '*': goto yy19; + default: goto yy13; } -yy9: - { RET(PDO_PARSER_TEXT); } yy10: + { RET(PDO_PARSER_TEXT); } +yy11: yych = *++YYCURSOR; switch (yych) { - case '-': goto yy15; - default: goto yy12; + case '-': goto yy14; + default: goto yy13; } -yy11: +yy12: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy12: +yy13: switch (yych) { case 0x00: case '"': case '\'': case ':': - case '?': goto yy9; - default: goto yy11; + case '?': goto yy10; + default: goto yy12; } -yy13: +yy14: ++YYCURSOR; - { RET(PDO_PARSER_EOI); } -yy15: - ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { @@ -194,23 +195,23 @@ yy15: case '"': case '\'': case ':': - case '?': goto yy18; + case '?': goto yy17; case '\n': - case '\r': goto yy11; - default: goto yy15; + case '\r': goto yy12; + default: goto yy14; } -yy17: +yy16: { RET(PDO_PARSER_TEXT); } -yy18: +yy17: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '\n': - case '\r': goto yy17; - default: goto yy18; + case '\r': goto yy16; + default: goto yy17; } -yy20: +yy19: yyaccept = 1; YYMARKER = ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -220,19 +221,19 @@ yy20: case '"': case '\'': case ':': - case '?': goto yy22; - case '*': goto yy24; - default: goto yy20; + case '?': goto yy21; + case '*': goto yy23; + default: goto yy19; } -yy22: +yy21: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { - case '*': goto yy27; - default: goto yy22; + case '*': goto yy26; + default: goto yy21; } -yy24: +yy23: yyaccept = 1; YYMARKER = ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -242,45 +243,44 @@ yy24: case '"': case '\'': case ':': - case '?': goto yy22; - case '*': goto yy24; - case '/': goto yy26; - default: goto yy20; + case '?': goto yy21; + case '*': goto yy23; + case '/': goto yy25; + default: goto yy19; } -yy26: +yy25: yych = *++YYCURSOR; switch (yych) { case 0x00: case '"': case '\'': case ':': - case '?': goto yy17; - default: goto yy11; + case '?': goto yy16; + default: goto yy12; } -yy27: +yy26: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { - case '*': goto yy27; - case '/': goto yy29; - default: goto yy22; + case '*': goto yy26; + case '/': goto yy28; + default: goto yy21; } -yy29: +yy28: yych = *++YYCURSOR; - goto yy17; -yy30: + goto yy16; +yy29: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { - case ':': - case '?': goto yy30; - default: goto yy32; + case '?': goto yy29; + default: goto yy31; } -yy32: +yy31: { RET(PDO_PARSER_TEXT); } -yy33: +yy32: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -347,34 +347,36 @@ yy33: case 'w': case 'x': case 'y': - case 'z': goto yy33; - default: goto yy35; + case 'z': goto yy32; + default: goto yy34; } -yy35: +yy34: { RET(PDO_PARSER_BIND); } -yy36: +yy35: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; + switch (yych) { + case ':': goto yy35; + default: goto yy31; + } yy37: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy38: switch (yych) { - case 0x00: goto yy38; + case 0x00: goto yy2; case '\'': goto yy40; case '\\': goto yy39; - default: goto yy36; + default: goto yy37; } -yy38: - YYCURSOR = YYMARKER; - switch (yyaccept) { - case 0: goto yy3; - case 1: goto yy9; - } yy39: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych <= 0x00) goto yy38; - goto yy36; + if (yych <= 0x00) goto yy2; + goto yy37; yy40: ++YYCURSOR; { RET(PDO_PARSER_TEXT); } @@ -384,7 +386,7 @@ yy42: yych = *YYCURSOR; yy43: switch (yych) { - case 0x00: goto yy38; + case 0x00: goto yy2; case '"': goto yy45; case '\\': goto yy44; default: goto yy42; @@ -393,7 +395,7 @@ yy44: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych <= 0x00) goto yy38; + if (yych <= 0x00) goto yy2; goto yy42; yy45: ++YYCURSOR; @@ -428,6 +430,7 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *i ptr = *outquery; s.cur = inquery; + s.end = inquery + inquery_len + 1; /* phase 1: look for args */ while((t = scan(&s)) != PDO_PARSER_EOI) { @@ -547,7 +550,7 @@ safe: param->param_type TSRMLS_CC)) { /* bork */ ret = -1; - strcpy(stmt->error_code, stmt->dbh->error_code); + strncpy(stmt->error_code, stmt->dbh->error_code, 6); if (buf) { efree(buf); } @@ -570,6 +573,9 @@ safe: plc->freeq = 0; break; + case IS_BOOL: + convert_to_long(param->parameter); + case IS_LONG: case IS_DOUBLE: convert_to_string(param->parameter); @@ -578,8 +584,6 @@ safe: plc->freeq = 0; break; - case IS_BOOL: - convert_to_long(param->parameter); default: convert_to_string(param->parameter); if (!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter), @@ -587,7 +591,7 @@ safe: param->param_type TSRMLS_CC)) { /* bork */ ret = -1; - strcpy(stmt->error_code, stmt->dbh->error_code); + strncpy(stmt->error_code, stmt->dbh->error_code, 6); goto clean_up; } plc->freeq = 1; @@ -742,9 +746,9 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inque while (SUCCESS == zend_hash_get_current_data(params, (void**)¶m)) { if(param->parameter) { convert_to_string(param->parameter); - /* accomodate a string that needs to be fully quoted + /* accommodate a string that needs to be fully quoted bind placeholders are at least 2 characters, so - the accomodate their own "'s + the accommodate their own "'s */ newbuffer_len += padding * Z_STRLEN_P(param->parameter); }