summaryrefslogtreecommitdiff
path: root/ext/pdo/pdo_sql_parser.re
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo/pdo_sql_parser.re')
-rw-r--r--ext/pdo/pdo_sql_parser.re24
1 files changed, 11 insertions, 13 deletions
diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re
index 3b89d14d0..3199937a1 100644
--- a/ext/pdo/pdo_sql_parser.re
+++ b/ext/pdo/pdo_sql_parser.re
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 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 |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_sql_parser.re,v 1.28.2.4.2.12 2007/12/31 07:17:40 sebastian Exp $ */
+/* $Id: pdo_sql_parser.re,v 1.28.2.4.2.18 2008/12/31 11:16:23 sebastian Exp $ */
#include "php.h"
#include "php_pdo_driver.h"
@@ -50,15 +50,15 @@ static int scan(Scanner *s)
QUESTION = [?];
SPECIALS = [:?"'];
MULTICHAR = [:?];
- EOF = [\000];
+ EOF = [\000];
ANYNOEOF = [\001-\377];
*/
/*!re2c
- (["] ([^"])* ["]) { RET(PDO_PARSER_TEXT); }
- (['] ([^'])* [']) { RET(PDO_PARSER_TEXT); }
+ (["](([\\]ANYNOEOF)|ANYNOEOF\["\\])*["]) { RET(PDO_PARSER_TEXT); }
+ (['](([\\]ANYNOEOF)|ANYNOEOF\['\\])*[']) { RET(PDO_PARSER_TEXT); }
MULTICHAR{2,} { RET(PDO_PARSER_TEXT); }
- BINDCHR { RET(PDO_PARSER_BIND); }
+ BINDCHR { RET(PDO_PARSER_BIND); }
QUESTION { RET(PDO_PARSER_BIND_POS); }
SPECIALS { SKIP_ONE(PDO_PARSER_TEXT); }
(ANYNOEOF\SPECIALS)+ { RET(PDO_PARSER_TEXT); }
@@ -299,9 +299,9 @@ rewrite:
} else if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
/* rewrite ? to :pdoX */
- char idxbuf[32];
+ char *name, *idxbuf;
const char *tmpl = stmt->named_rewrite_template ? stmt->named_rewrite_template : ":pdo%d";
- char *name;
+ int bind_no = 1;
newbuffer_len = inquery_len;
@@ -317,21 +317,19 @@ rewrite:
/* check if bound parameter is already available */
if (!strcmp(name, "?") || zend_hash_find(stmt->bound_param_map, name, plc->len + 1, (void**) &p) == FAILURE) {
- snprintf(idxbuf, sizeof(idxbuf), tmpl, plc->bindno + 1);
+ spprintf(&idxbuf, 0, tmpl, bind_no++);
} else {
- memset(idxbuf, 0, sizeof(idxbuf));
- memcpy(idxbuf, p, sizeof(idxbuf));
+ idxbuf = estrdup(p);
skip_map = 1;
}
- plc->quoted = estrdup(idxbuf);
+ 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_update(stmt->bound_param_map, name, plc->len + 1, idxbuf, plc->qlen + 1, NULL);
}