--- 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/07/22 01:31:55 1.1.1.3 @@ -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 Thu Apr 19 12:42:11 2012 */ /* +----------------------------------------------------------------------+ | 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.3 2013/07/22 01:31:55 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); } + if (yych >= 0x01) goto yy41; 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 yy36; +yy6: yych = *++YYCURSOR; switch (yych) { case '0': @@ -141,52 +147,49 @@ yy5: case 'w': case 'x': case 'y': - case 'z': goto yy33; + case 'z': goto yy32; case ':': - case '?': goto yy30; - default: goto yy3; + case '?': goto yy29; + 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 +197,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 +223,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 +245,45 @@ 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,55 +350,49 @@ 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; -yy37: +yy36: switch (yych) { - case 0x00: goto yy38; - case '\'': goto yy40; - case '\\': goto yy39; - default: goto yy36; + case 0x00: goto yy2; + case '\'': goto yy38; + case '\\': goto yy37; + default: goto yy35; } -yy38: - YYCURSOR = YYMARKER; - switch (yyaccept) { - case 0: goto yy3; - case 1: goto yy9; - } -yy39: +yy37: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych <= 0x00) goto yy38; - goto yy36; -yy40: + if (yych <= 0x00) goto yy2; + goto yy35; +yy38: ++YYCURSOR; { RET(PDO_PARSER_TEXT); } -yy42: +yy40: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy43: +yy41: switch (yych) { - case 0x00: goto yy38; - case '"': goto yy45; - case '\\': goto yy44; - default: goto yy42; + case 0x00: goto yy2; + case '"': goto yy43; + case '\\': goto yy42; + default: goto yy40; } -yy44: +yy42: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych <= 0x00) goto yy38; - goto yy42; -yy45: + if (yych <= 0x00) goto yy2; + goto yy40; +yy43: ++YYCURSOR; { RET(PDO_PARSER_TEXT); } } @@ -428,6 +425,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 +545,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 +568,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 +579,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 +586,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 +741,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); }