From: George Schlossnagle Date: Fri, 21 May 2004 22:24:20 +0000 (+0000) Subject: ok, apprently we _don't_ want to count the nulls. X-Git-Tag: RELEASE_0_1_1~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d01a5c2d15269b0e979c855a32fb764c12f0850;p=php ok, apprently we _don't_ want to count the nulls. --- diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index f3002e0e98..5c4ee0ac06 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Fri May 21 17:19:22 2004 */ +/* Generated by re2c 0.5 on Fri May 21 17:33:58 2004 */ #line 1 "/home/george/src/pecl/pdo/pdo_sql_parser.re" /* +----------------------------------------------------------------------+ @@ -227,7 +227,6 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou *outquery_len += (s.cur - s.tok); } else if(t == PDO_PARSER_BIND) { - char crutch; if(!params) { /* error */ efree(*outquery); @@ -236,17 +235,13 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou } /* lookup bind first via hash and then index */ /* stupid keys need to be null-terminated, even though we know their length */ - crutch = s.tok[s.cur-s.tok]; - s.tok[s.cur-s.tok] = '\0'; - fprintf(stderr, "%d %s\n", s.cur-s.tok + 1, s.tok); - if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok + 1,(void **)¶m)) + if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok,(void **)¶m)) || (SUCCESS == zend_hash_index_find(params, bindno, (void **)¶m))) { char *quotedstr; int quotedstrlen; /* restore the in-string key, doesn't need null-termination here */ - s.tok[s.cur-s.tok] = crutch; /* currently everything is a string here */ /* quote the bind value if necessary */ diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index ca65667757..412f70ae06 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -111,7 +111,6 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou *outquery_len += (s.cur - s.tok); } else if(t == PDO_PARSER_BIND) { - char crutch; if(!params) { /* error */ efree(*outquery); @@ -120,16 +119,13 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou } /* lookup bind first via hash and then index */ /* stupid keys need to be null-terminated, even though we know their length */ - crutch = s.tok[s.cur-s.tok]; - s.tok[s.cur-s.tok] = '\0'; - if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok + 1,(void **)¶m)) + if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok,(void **)¶m)) || (SUCCESS == zend_hash_index_find(params, bindno, (void **)¶m))) { char *quotedstr; int quotedstrlen; /* restore the in-string key, doesn't need null-termination here */ - s.tok[s.cur-s.tok] = crutch; /* currently everything is a string here */ /* quote the bind value if necessary */ diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 0a5f231f10..2d70c38659 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -282,7 +282,8 @@ static PHP_METHOD(PDOStatement, execute) if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(input_params), ¶m.name, &str_length, &num_index, 0, NULL)) { - param.namelen = str_length; + /* yes this is correct. we don't want to count the null byte. ask wez */ + param.namelen = str_length - 1; param.paramno = -1; } else { /* we're okay to be zero based here */ @@ -540,14 +541,13 @@ static PHP_METHOD(PDOStatement, fetchAll) static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int is_param) { struct pdo_bound_param_data param = {0}; - int param_namelen; param.paramno = -1; param.param_type = PDO_PARAM_STR; if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sz|llz!", - ¶m.name, ¶m_namelen, ¶m.parameter, ¶m.param_type, + ¶m.name, ¶m.namelen, ¶m.parameter, ¶m.param_type, ¶m.max_value_len, ¶m.driver_params)) { if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|llz!", ¶m.paramno, @@ -555,12 +555,6 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, return 0; } } - /* - yes, this is correct. really. truly. - We need to count the null terminating byte as well, - which parse_parameters does not do. - */ - param.namelen = param_namelen + 1; if (param.paramno > 0) { --param.paramno; /* make it zero-based internally */