Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. /* in order to support named params, which Firebird itself doesn't,
  2. we need to replace :foo by ?, and store the name we just replaced */
  3.  
  4. new_sql = c = emalloc(sql_len+1);
  5.  
  6. for (l = in_quote = in_param = 0; l <= sql_len; ++l) {
  7. if (!(in_quote ^= (sql[l] == '\''))) {
  8. if (!in_param) {
  9. switch (sql[l]) {
  10. case ':':
  11. in_param = 1;
  12. ppname = pname;
  13. *ppname++ = sql[l];
  14. case '?':
  15. *c++ = '?';
  16. ++pindex;
  17. continue;
  18. }
  19. } else {
  20. if ((in_param &= ((sql[l] >= 'A' && sql[l] <= 'Z') || (sql[l] >= 'a' && sql[l] <= 'z')
  21. || (sql[l] >= '0' && sql[l] <= '9') || sql[l] == '_' || sql[l] == '-'))) {
  22. *ppname++ = sql[l];
  23. continue;
  24. } else {
  25. *ppname++ = 0;
  26. if (named_params) {
  27. zval tmp;
  28. ZVAL_LONG(&tmp, pindex);
  29. zend_hash_str_update(named_params, pname, (unsigned int)(ppname - pname - 1), &tmp);
  30. }
  31. }
  32. }
  33. }
  34. *c++ = sql[l];
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement