Diff for /embedaddon/php/ext/pdo/pdo_sql_parser.c between versions 1.1.1.2 and 1.1.1.5

version 1.1.1.2, 2012/05/29 12:34:40 version 1.1.1.5, 2014/06/15 20:03:51
Line 1 Line 1
/* Generated by re2c 0.13.5 on Sat Jun  4 18:42:25 2011 *//* Generated by re2c 0.13.5 on Thu Nov  7 18:02:29 2013 */
 /*  /*
   +----------------------------------------------------------------------+    +----------------------------------------------------------------------+
   | PHP Version 5                                                        |    | PHP Version 5                                                        |
   +----------------------------------------------------------------------+    +----------------------------------------------------------------------+
  | Copyright (c) 1997-2012 The PHP Group                                |  | Copyright (c) 1997-2014 The PHP Group                                |
   +----------------------------------------------------------------------+    +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |    | 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        |    | that is bundled with this package in the file LICENSE, and is        |
Line 33 Line 33
   
 #define YYCTYPE         unsigned char  #define YYCTYPE         unsigned char
 #define YYCURSOR        cursor  #define YYCURSOR        cursor
#define YYLIMIT         cursor#define YYLIMIT         s->end
 #define YYMARKER        s->ptr  #define YYMARKER        s->ptr
#define YYFILL(n)#define YYFILL(n)               { RET(PDO_PARSER_EOI); }
   
 typedef struct Scanner {  typedef struct Scanner {
        char    *ptr, *cur, *tok;        char    *ptr, *cur, *tok, *end;
 } Scanner;  } Scanner;
   
 static int scan(Scanner *s)   static int scan(Scanner *s) 
Line 56  static int scan(Scanner *s)  Line 56  static int scan(Scanner *s) 
         if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);          if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
         yych = *YYCURSOR;          yych = *YYCURSOR;
         switch (yych) {          switch (yych) {
        case 0x00:      goto yy13;        case 0x00:      goto yy2;
        case '"':       goto yy2;        case '"':       goto yy3;
        case '\'':      goto yy4;        case '\'':      goto yy5;
        case '-':       goto yy10;        case '-':       goto yy11;
        case '/':       goto yy8;        case '/':       goto yy9;
        case ':':       goto yy5;        case ':':       goto yy6;
        case '?':       goto yy6;        case '?':       goto yy7;
        default:        goto yy11;        default:        goto yy12;
         }          }
 yy2:  yy2:
           YYCURSOR = YYMARKER;
           switch (yyaccept) {
           case 0:         goto yy4;
           case 1:         goto yy10;
           }
   yy3:
         yyaccept = 0;          yyaccept = 0;
         yych = *(YYMARKER = ++YYCURSOR);          yych = *(YYMARKER = ++YYCURSOR);
         if (yych >= 0x01) goto yy43;          if (yych >= 0x01) goto yy43;
 yy3:  
         { SKIP_ONE(PDO_PARSER_TEXT); }  
 yy4:  yy4:
           { SKIP_ONE(PDO_PARSER_TEXT); }
   yy5:
         yyaccept = 0;          yyaccept = 0;
         yych = *(YYMARKER = ++YYCURSOR);          yych = *(YYMARKER = ++YYCURSOR);
        if (yych <= 0x00) goto yy3;        if (yych <= 0x00) goto yy4;
        goto yy37;        goto yy38;
yy5:yy6:
         yych = *++YYCURSOR;          yych = *++YYCURSOR;
         switch (yych) {          switch (yych) {
         case '0':          case '0':
Line 141  yy5: Line 147  yy5:
         case 'w':          case 'w':
         case 'x':          case 'x':
         case 'y':          case 'y':
        case 'z':       goto yy33;        case 'z':       goto yy32;
        case ':':        case ':':      goto yy35;
        case '?':      goto yy30;        default:        goto yy4;
        default:        goto yy3; 
         }          }
yy6:yy7:
         ++YYCURSOR;          ++YYCURSOR;
         switch ((yych = *YYCURSOR)) {          switch ((yych = *YYCURSOR)) {
        case ':':        case '?':       goto yy29;
        case '?':       goto yy30;        default:        goto yy8;
        default:        goto yy7; 
         }          }
 yy7:  
         { RET(PDO_PARSER_BIND_POS); }  
 yy8:  yy8:
           { RET(PDO_PARSER_BIND_POS); }
   yy9:
         ++YYCURSOR;          ++YYCURSOR;
         switch ((yych = *YYCURSOR)) {          switch ((yych = *YYCURSOR)) {
        case '*':       goto yy20;        case '*':       goto yy19;
        default:        goto yy12;        default:        goto yy13;
         }          }
 yy9:  
         { RET(PDO_PARSER_TEXT); }  
 yy10:  yy10:
           { RET(PDO_PARSER_TEXT); }
   yy11:
         yych = *++YYCURSOR;          yych = *++YYCURSOR;
         switch (yych) {          switch (yych) {
        case '-':       goto yy15;        case '-':       goto yy14;
        default:        goto yy12;        default:        goto yy13;
         }          }
yy11:yy12:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
yy12:yy13:
         switch (yych) {          switch (yych) {
         case 0x00:          case 0x00:
         case '"':          case '"':
         case '\'':          case '\'':
         case ':':          case ':':
        case '?':       goto yy9;        case '?':       goto yy10;
        default:        goto yy11;        default:        goto yy12;
         }          }
yy13:yy14:
         ++YYCURSOR;          ++YYCURSOR;
         { RET(PDO_PARSER_EOI); }  
 yy15:  
         ++YYCURSOR;  
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
         switch (yych) {          switch (yych) {
Line 194  yy15: Line 195  yy15:
         case '"':          case '"':
         case '\'':          case '\'':
         case ':':          case ':':
        case '?':       goto yy18;        case '?':       goto yy17;
         case '\n':          case '\n':
        case '\r':      goto yy11;        case '\r':      goto yy12;
        default:        goto yy15;        default:        goto yy14;
         }          }
yy17:yy16:
         { RET(PDO_PARSER_TEXT); }          { RET(PDO_PARSER_TEXT); }
yy18:yy17:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
         switch (yych) {          switch (yych) {
         case '\n':          case '\n':
        case '\r':      goto yy17;        case '\r':      goto yy16;
        default:        goto yy18;        default:        goto yy17;
         }          }
yy20:yy19:
         yyaccept = 1;          yyaccept = 1;
         YYMARKER = ++YYCURSOR;          YYMARKER = ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
Line 220  yy20: Line 221  yy20:
         case '"':          case '"':
         case '\'':          case '\'':
         case ':':          case ':':
        case '?':       goto yy22;        case '?':       goto yy21;
        case '*':       goto yy24;        case '*':       goto yy23;
        default:        goto yy20;        default:        goto yy19;
         }          }
yy22:yy21:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
         switch (yych) {          switch (yych) {
        case '*':       goto yy27;        case '*':       goto yy26;
        default:        goto yy22;        default:        goto yy21;
         }          }
yy24:yy23:
         yyaccept = 1;          yyaccept = 1;
         YYMARKER = ++YYCURSOR;          YYMARKER = ++YYCURSOR;
         if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);          if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
Line 242  yy24: Line 243  yy24:
         case '"':          case '"':
         case '\'':          case '\'':
         case ':':          case ':':
        case '?':       goto yy22;        case '?':       goto yy21;
        case '*':       goto yy24;        case '*':       goto yy23;
        case '/':       goto yy26;        case '/':       goto yy25;
        default:        goto yy20;        default:        goto yy19;
         }          }
yy26:yy25:
         yych = *++YYCURSOR;          yych = *++YYCURSOR;
         switch (yych) {          switch (yych) {
         case 0x00:          case 0x00:
         case '"':          case '"':
         case '\'':          case '\'':
         case ':':          case ':':
        case '?':       goto yy17;        case '?':       goto yy16;
        default:        goto yy11;        default:        goto yy12;
         }          }
yy27:yy26:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
         switch (yych) {          switch (yych) {
        case '*':       goto yy27;        case '*':       goto yy26;
        case '/':       goto yy29;        case '/':       goto yy28;
        default:        goto yy22;        default:        goto yy21;
         }          }
yy29:yy28:
         yych = *++YYCURSOR;          yych = *++YYCURSOR;
        goto yy17;        goto yy16;
yy30:yy29:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
         switch (yych) {          switch (yych) {
        case ':':        case '?':       goto yy29;
        case '?':       goto yy30;        default:        goto yy31;
        default:        goto yy32; 
         }          }
yy32:yy31:
         { RET(PDO_PARSER_TEXT); }          { RET(PDO_PARSER_TEXT); }
yy33:yy32:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
Line 347  yy33: Line 347  yy33:
         case 'w':          case 'w':
         case 'x':          case 'x':
         case 'y':          case 'y':
        case 'z':       goto yy33;        case 'z':       goto yy32;
        default:        goto yy35;        default:        goto yy34;
         }          }
yy35:yy34:
         { RET(PDO_PARSER_BIND); }          { RET(PDO_PARSER_BIND); }
yy36:yy35:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
           switch (yych) {
           case ':':       goto yy35;
           default:        goto yy31;
           }
 yy37:  yy37:
           ++YYCURSOR;
           if (YYLIMIT <= YYCURSOR) YYFILL(1);
           yych = *YYCURSOR;
   yy38:
         switch (yych) {          switch (yych) {
        case 0x00:      goto yy38;        case 0x00:      goto yy2;
         case '\'':      goto yy40;          case '\'':      goto yy40;
         case '\\':      goto yy39;          case '\\':      goto yy39;
        default:        goto yy36;        default:        goto yy37;
         }          }
 yy38:  
         YYCURSOR = YYMARKER;  
         switch (yyaccept) {  
         case 0:         goto yy3;  
         case 1:         goto yy9;  
         }  
 yy39:  yy39:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
        if (yych <= 0x00) goto yy38;        if (yych <= 0x00) goto yy2;
        goto yy36;        goto yy37;
 yy40:  yy40:
         ++YYCURSOR;          ++YYCURSOR;
         { RET(PDO_PARSER_TEXT); }          { RET(PDO_PARSER_TEXT); }
Line 384  yy42: Line 386  yy42:
         yych = *YYCURSOR;          yych = *YYCURSOR;
 yy43:  yy43:
         switch (yych) {          switch (yych) {
        case 0x00:      goto yy38;        case 0x00:      goto yy2;
         case '"':       goto yy45;          case '"':       goto yy45;
         case '\\':      goto yy44;          case '\\':      goto yy44;
         default:        goto yy42;          default:        goto yy42;
Line 393  yy44: Line 395  yy44:
         ++YYCURSOR;          ++YYCURSOR;
         if (YYLIMIT <= YYCURSOR) YYFILL(1);          if (YYLIMIT <= YYCURSOR) YYFILL(1);
         yych = *YYCURSOR;          yych = *YYCURSOR;
        if (yych <= 0x00) goto yy38;        if (yych <= 0x00) goto yy2;
         goto yy42;          goto yy42;
 yy45:  yy45:
         ++YYCURSOR;          ++YYCURSOR;
Line 428  PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *i Line 430  PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *i
   
         ptr = *outquery;          ptr = *outquery;
         s.cur = inquery;          s.cur = inquery;
           s.end = inquery + inquery_len + 1;
   
         /* phase 1: look for args */          /* phase 1: look for args */
         while((t = scan(&s)) != PDO_PARSER_EOI) {          while((t = scan(&s)) != PDO_PARSER_EOI) {
Line 547  safe: Line 550  safe:
                                                                 param->param_type TSRMLS_CC)) {                                                                  param->param_type TSRMLS_CC)) {
                                                         /* bork */                                                          /* bork */
                                                         ret = -1;                                                          ret = -1;
                                                        strcpy(stmt->error_code, stmt->dbh->error_code);                                                        strncpy(stmt->error_code, stmt->dbh->error_code, 6);
                                                         if (buf) {                                                          if (buf) {
                                                                 efree(buf);                                                                  efree(buf);
                                                         }                                                          }
Line 563  safe: Line 566  safe:
                                         }                                          }
                                         plc->freeq = 1;                                          plc->freeq = 1;
                                 } else {                                  } else {
                                        switch (Z_TYPE_P(param->parameter)) {                                        zval tmp_param = *param->parameter;
                                         zval_copy_ctor(&tmp_param);
                                         switch (Z_TYPE(tmp_param)) {
                                                 case IS_NULL:                                                  case IS_NULL:
                                                         plc->quoted = "NULL";                                                          plc->quoted = "NULL";
                                                         plc->qlen = sizeof("NULL")-1;                                                          plc->qlen = sizeof("NULL")-1;
                                                         plc->freeq = 0;                                                          plc->freeq = 0;
                                                         break;                                                          break;
   
                                                   case IS_BOOL:
                                                           convert_to_long(&tmp_param);
                                                           /* fall through */
                                                 case IS_LONG:                                                  case IS_LONG:
                                                 case IS_DOUBLE:                                                  case IS_DOUBLE:
                                                        convert_to_string(param->parameter);                                                        convert_to_string(&tmp_param);
                                                        plc->qlen = Z_STRLEN_P(param->parameter);                                                        plc->qlen = Z_STRLEN(tmp_param);
                                                        plc->quoted = Z_STRVAL_P(param->parameter);                                                        plc->quoted = estrdup(Z_STRVAL(tmp_param));
                                                        plc->freeq = 0;                                                        plc->freeq = 1;
                                                         break;                                                          break;
   
                                                 case IS_BOOL:  
                                                         convert_to_long(param->parameter);  
                                                 default:                                                  default:
                                                        convert_to_string(param->parameter);                                                        convert_to_string(&tmp_param);
                                                        if (!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),                                                        if (!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL(tmp_param),
                                                                        Z_STRLEN_P(param->parameter), &plc->quoted, &plc->qlen,                                                                        Z_STRLEN(tmp_param), &plc->quoted, &plc->qlen,
                                                                         param->param_type TSRMLS_CC)) {                                                                          param->param_type TSRMLS_CC)) {
                                                                 /* bork */                                                                  /* bork */
                                                                 ret = -1;                                                                  ret = -1;
                                                                strcpy(stmt->error_code, stmt->dbh->error_code);                                                                strncpy(stmt->error_code, stmt->dbh->error_code, 6);
                                                                 goto clean_up;                                                                  goto clean_up;
                                                         }                                                          }
                                                         plc->freeq = 1;                                                          plc->freeq = 1;
                                         }                                          }
                                           zval_dtor(&tmp_param);
                                 }                                  }
                         } else {                          } else {
                                 plc->quoted = Z_STRVAL_P(param->parameter);                                  plc->quoted = Z_STRVAL_P(param->parameter);
Line 742  int old_pdo_parse_params(pdo_stmt_t *stmt, char *inque Line 749  int old_pdo_parse_params(pdo_stmt_t *stmt, char *inque
                 while (SUCCESS == zend_hash_get_current_data(params, (void**)&param)) {                  while (SUCCESS == zend_hash_get_current_data(params, (void**)&param)) {
                         if(param->parameter) {                          if(param->parameter) {
                                 convert_to_string(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                     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);                                  newbuffer_len += padding * Z_STRLEN_P(param->parameter);
                         }                          }

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>