]> granicus.if.org Git - php/commitdiff
Remove dead code
authorAdam Baratz <adambaratz@php.net>
Mon, 17 Oct 2016 21:06:49 +0000 (17:06 -0400)
committerAdam Baratz <adambaratz@php.net>
Mon, 17 Oct 2016 21:07:10 +0000 (17:07 -0400)
ext/pdo/pdo_sql_parser.c
ext/pdo/pdo_sql_parser.re

index 1b2afb9a6cf462a74a8e064669e47ee8e99c17a2..f34d36999f17378c96f72a4fd21eed54a81c3ce9 100644 (file)
@@ -731,132 +731,6 @@ clean_up:
        return ret;
 }
 
-#if 0
-int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **outquery,
-               int *outquery_len)
-{
-       Scanner s;
-       char *ptr;
-       int t;
-       int bindno = 0;
-       int newbuffer_len;
-       int padding;
-       HashTable *params = stmt->bound_params;
-       struct pdo_bound_param_data *param;
-       /* allocate buffer for query with expanded binds, ptr is our writing pointer */
-       newbuffer_len = inquery_len;
-
-       /* calculate the possible padding factor due to quoting */
-       if(stmt->dbh->max_escaped_char_length) {
-               padding = stmt->dbh->max_escaped_char_length;
-       } else {
-               padding = 3;
-       }
-       if(params) {
-               ZEND_HASH_FOREACH_PTR(params, param) {
-                       if(param->parameter) {
-                               convert_to_string(param->parameter);
-                               /* accommodate a string that needs to be fully quoted
-                   bind placeholders are at least 2 characters, so
-                   the accommodate their own "'s
-                */
-                               newbuffer_len += padding * Z_STRLEN_P(param->parameter);
-                       }
-               } ZEND_HASH_FOREACH_END();
-       }
-       *outquery = (char *) emalloc(newbuffer_len + 1);
-       *outquery_len = 0;
-
-       ptr = *outquery;
-       s.cur = inquery;
-       while((t = scan(&s)) != PDO_PARSER_EOI) {
-               if(t == PDO_PARSER_TEXT) {
-                       memcpy(ptr, s.tok, s.cur - s.tok);
-                       ptr += (s.cur - s.tok);
-                       *outquery_len += (s.cur - s.tok);
-               }
-               else if(t == PDO_PARSER_BIND) {
-                       if(!params) {
-                               /* error */
-                               efree(*outquery);
-                               *outquery = NULL;
-                               return (int) (s.cur - inquery);
-                       }
-                       /* lookup bind first via hash and then index */
-                       /* stupid keys need to be null-terminated, even though we know their length */
-                       if((NULL != (param = zend_hash_str_find_ptr(params, s.tok, s.cur-s.tok))
-                           ||
-                          NULL != (params = zend_hash_index_find_ptr(params, bindno)))
-                       {
-                               char *quotedstr;
-                               int quotedstrlen;
-                               /* restore the in-string key, doesn't need null-termination here */
-                               /* currently everything is a string here */
-
-                               /* quote the bind value if necessary */
-                               if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
-                                       Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen))
-                               {
-                                       memcpy(ptr, quotedstr, quotedstrlen);
-                                       ptr += quotedstrlen;
-                                       *outquery_len += quotedstrlen;
-                                       efree(quotedstr);
-                               } else {
-                                       memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter));
-                                       ptr += Z_STRLEN_P(param->parameter);
-                                       *outquery_len += (Z_STRLEN_P(param->parameter));
-                               }
-                       }
-                       else {
-                               /* error and cleanup */
-                               efree(*outquery);
-                               *outquery = NULL;
-                               return (int) (s.cur - inquery);
-                       }
-                       bindno++;
-               }
-               else if(t == PDO_PARSER_BIND_POS) {
-                       if(!params) {
-                               /* error */
-                               efree(*outquery);
-                               *outquery = NULL;
-                               return (int) (s.cur - inquery);
-                       }
-                       /* lookup bind by index */
-                       if(NULL != (params = zend_hash_index_find_ptr(params, bindno)))
-                       {
-                               char *quotedstr;
-                               int quotedstrlen;
-                               /* currently everything is a string here */
-
-                               /* quote the bind value if necessary */
-                               if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
-                                       Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen))
-                               {
-                                       memcpy(ptr, quotedstr, quotedstrlen);
-                                       ptr += quotedstrlen;
-                                       *outquery_len += quotedstrlen;
-                                       efree(quotedstr);
-                               } else {
-                                       memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter));
-                                       ptr += Z_STRLEN_P(param->parameter);
-                                       *outquery_len += (Z_STRLEN_P(param->parameter));
-                               }
-                       }
-                       else {
-                               /* error and cleanup */
-                               efree(*outquery);
-                               *outquery = NULL;
-                               return (int) (s.cur - inquery);
-                       }
-                       bindno++;
-               }
-       }
-       *ptr = '\0';
-       return 0;
-}
-#endif
-
 /*
  * Local variables:
  * tab-width: 4
index 604ec59304cf69f0f9bca2e9af8c8ffe68870f4d..16fc29f0f1e7293f939b080da67a1dacb32d2f35 100644 (file)
@@ -417,132 +417,6 @@ clean_up:
        return ret;
 }
 
-#if 0
-int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **outquery,
-               int *outquery_len)
-{
-       Scanner s;
-       char *ptr;
-       int t;
-       int bindno = 0;
-       int newbuffer_len;
-       int padding;
-       HashTable *params = stmt->bound_params;
-       struct pdo_bound_param_data *param;
-       /* allocate buffer for query with expanded binds, ptr is our writing pointer */
-       newbuffer_len = inquery_len;
-
-       /* calculate the possible padding factor due to quoting */
-       if(stmt->dbh->max_escaped_char_length) {
-               padding = stmt->dbh->max_escaped_char_length;
-       } else {
-               padding = 3;
-       }
-       if(params) {
-               ZEND_HASH_FOREACH_PTR(params, param) {
-                       if(param->parameter) {
-                               convert_to_string(param->parameter);
-                               /* accommodate a string that needs to be fully quoted
-                   bind placeholders are at least 2 characters, so
-                   the accommodate their own "'s
-                */
-                               newbuffer_len += padding * Z_STRLEN_P(param->parameter);
-                       }
-               } ZEND_HASH_FOREACH_END();
-       }
-       *outquery = (char *) emalloc(newbuffer_len + 1);
-       *outquery_len = 0;
-
-       ptr = *outquery;
-       s.cur = inquery;
-       while((t = scan(&s)) != PDO_PARSER_EOI) {
-               if(t == PDO_PARSER_TEXT) {
-                       memcpy(ptr, s.tok, s.cur - s.tok);
-                       ptr += (s.cur - s.tok);
-                       *outquery_len += (s.cur - s.tok);
-               }
-               else if(t == PDO_PARSER_BIND) {
-                       if(!params) {
-                               /* error */
-                               efree(*outquery);
-                               *outquery = NULL;
-                               return (int) (s.cur - inquery);
-                       }
-                       /* lookup bind first via hash and then index */
-                       /* stupid keys need to be null-terminated, even though we know their length */
-                       if((NULL != (param = zend_hash_str_find_ptr(params, s.tok, s.cur-s.tok))
-                           ||
-                          NULL != (params = zend_hash_index_find_ptr(params, bindno)))
-                       {
-                               char *quotedstr;
-                               int quotedstrlen;
-                               /* restore the in-string key, doesn't need null-termination here */
-                               /* currently everything is a string here */
-
-                               /* quote the bind value if necessary */
-                               if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
-                                       Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen))
-                               {
-                                       memcpy(ptr, quotedstr, quotedstrlen);
-                                       ptr += quotedstrlen;
-                                       *outquery_len += quotedstrlen;
-                                       efree(quotedstr);
-                               } else {
-                                       memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter));
-                                       ptr += Z_STRLEN_P(param->parameter);
-                                       *outquery_len += (Z_STRLEN_P(param->parameter));
-                               }
-                       }
-                       else {
-                               /* error and cleanup */
-                               efree(*outquery);
-                               *outquery = NULL;
-                               return (int) (s.cur - inquery);
-                       }
-                       bindno++;
-               }
-               else if(t == PDO_PARSER_BIND_POS) {
-                       if(!params) {
-                               /* error */
-                               efree(*outquery);
-                               *outquery = NULL;
-                               return (int) (s.cur - inquery);
-                       }
-                       /* lookup bind by index */
-                       if(NULL != (params = zend_hash_index_find_ptr(params, bindno)))
-                       {
-                               char *quotedstr;
-                               int quotedstrlen;
-                               /* currently everything is a string here */
-
-                               /* quote the bind value if necessary */
-                               if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
-                                       Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen))
-                               {
-                                       memcpy(ptr, quotedstr, quotedstrlen);
-                                       ptr += quotedstrlen;
-                                       *outquery_len += quotedstrlen;
-                                       efree(quotedstr);
-                               } else {
-                                       memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter));
-                                       ptr += Z_STRLEN_P(param->parameter);
-                                       *outquery_len += (Z_STRLEN_P(param->parameter));
-                               }
-                       }
-                       else {
-                               /* error and cleanup */
-                               efree(*outquery);
-                               *outquery = NULL;
-                               return (int) (s.cur - inquery);
-                       }
-                       bindno++;
-               }
-       }
-       *ptr = '\0';
-       return 0;
-}
-#endif
-
 /*
  * Local variables:
  * tab-width: 4