]> granicus.if.org Git - php/commitdiff
ok, apprently we _don't_ want to count the nulls.
authorGeorge Schlossnagle <gschlossnagle@php.net>
Fri, 21 May 2004 22:24:20 +0000 (22:24 +0000)
committerGeorge Schlossnagle <gschlossnagle@php.net>
Fri, 21 May 2004 22:24:20 +0000 (22:24 +0000)
ext/pdo/pdo_sql_parser.c
ext/pdo/pdo_sql_parser.re
ext/pdo/pdo_stmt.c

index f3002e0e98838d92744d99876f041bbfe1a64e66..5c4ee0ac0650b67d0efbb01164bece799588bfd9 100644 (file)
@@ -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 **)&param))  
+                       if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok,(void **)&param))  
                            ||
                           (SUCCESS == zend_hash_index_find(params, bindno, (void **)&param))) 
                        {
                                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 */
index ca656677575f5eb0fb7c85814ec6a384447fdf2e..412f70ae060fcca45e3cc4cd905bb8c6740f0144 100644 (file)
@@ -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 **)&param))  
+                       if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok,(void **)&param))  
                            ||
                           (SUCCESS == zend_hash_index_find(params, bindno, (void **)&param))) 
                        {
                                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 */
index 0a5f231f1031abd7a2f34e92a2bd78c9806a6344..2d70c38659466c8d78c42f8992ab88f975de1c4c 100755 (executable)
@@ -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),
                                                &param.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!",
-                               &param.name, &param_namelen, &param.parameter, &param.param_type,
+                               &param.name, &param.namelen, &param.parameter, &param.param_type,
                                &param.max_value_len,
                                &param.driver_params)) {
                if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|llz!", &param.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 */