* simple parser to detect :identif symbols in query */
| 1838 | * simple parser to detect :identif symbols in query |
| 1839 | */ |
| 1840 | static char * |
| 1841 | next_token(char *str, char **start, size_t *len, orafceTokenType *typ, char **sep, size_t *seplen) |
| 1842 | { |
| 1843 | if (*str == '\0') |
| 1844 | { |
| 1845 | *typ = TOKEN_NONE; |
| 1846 | return NULL; |
| 1847 | } |
| 1848 | |
| 1849 | /* reduce spaces */ |
| 1850 | if (*str == ' ') |
| 1851 | { |
| 1852 | *start = str++; |
| 1853 | while (*str == ' ') |
| 1854 | str++; |
| 1855 | |
| 1856 | *typ = TOKEN_SPACES; |
| 1857 | *len = 1; |
| 1858 | return str; |
| 1859 | } |
| 1860 | |
| 1861 | /* Postgres's dolar strings */ |
| 1862 | if (*str == '$' && (str[1] == '$' || |
| 1863 | is_identif((unsigned char) str[1]) || str[1] == '_')) |
| 1864 | { |
| 1865 | char *aux = str + 1; |
| 1866 | char *endstr; |
| 1867 | bool is_valid = false; |
| 1868 | char *buffer; |
| 1869 | |
| 1870 | /* try to find end of separator */ |
| 1871 | while (*aux) |
| 1872 | { |
| 1873 | if (*aux == '$') |
| 1874 | { |
| 1875 | is_valid = true; |
| 1876 | aux++; |
| 1877 | break; |
| 1878 | } |
| 1879 | else if (is_identif((unsigned char) *aux) || |
| 1880 | isdigit(*aux) || |
| 1881 | *aux == '_') |
| 1882 | { |
| 1883 | aux++; |
| 1884 | } |
| 1885 | else |
| 1886 | break; |
| 1887 | } |
| 1888 | |
| 1889 | if (!is_valid) |
| 1890 | { |
| 1891 | *typ = TOKEN_OTHER; |
| 1892 | *len = 1; |
| 1893 | *start = str; |
| 1894 | return str + 1; |
| 1895 | } |
| 1896 | |
| 1897 | /* now it looks like correct $ separator */ |
no test coverage detected