/ Make a valid key from the passed argument. */ /
| 1798 | /* Make a valid key from the passed argument. */ |
| 1799 | /*********************************************************************************/ |
| 1800 | static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) |
| 1801 | { |
| 1802 | if (args->arg_count > (unsigned)i) { |
| 1803 | int j = 0, n = args->attribute_lengths[i]; |
| 1804 | my_bool b; // true if attribute is zero terminated |
| 1805 | PSZ p; |
| 1806 | PCSZ s = args->attributes[i]; |
| 1807 | |
| 1808 | if (s && *s && (n || *s == '\'')) { |
| 1809 | if ((b = (!n || !s[n]))) |
| 1810 | n = strlen(s); |
| 1811 | |
| 1812 | if (IsJson(args, i)) |
| 1813 | j = (int)(strchr(s, '_') - s + 1); |
| 1814 | |
| 1815 | if (j && n > j) { |
| 1816 | s += j; |
| 1817 | n -= j; |
| 1818 | } else if (*s == '\'' && s[n-1] == '\'') { |
| 1819 | s++; |
| 1820 | n -= 2; |
| 1821 | b = false; |
| 1822 | } // endif *s |
| 1823 | |
| 1824 | if (n < 1) |
| 1825 | return (PCSZ) "Key"; |
| 1826 | |
| 1827 | if (!b) { |
| 1828 | if ((p = (PSZ)PlgDBSubAlloc(g, NULL, n + 1))) { |
| 1829 | memcpy(p, s, n); |
| 1830 | p[n] = 0; |
| 1831 | } else |
| 1832 | PUSH_WARNING(g->Message); |
| 1833 | |
| 1834 | s = p; |
| 1835 | } // endif b |
| 1836 | |
| 1837 | } // endif s |
| 1838 | |
| 1839 | return s; |
| 1840 | } // endif count |
| 1841 | |
| 1842 | return (PCSZ) "Key"; |
| 1843 | } // end of MakeKey |
| 1844 | |
| 1845 | /*********************************************************************************/ |
| 1846 | /* Parse a json file. */ |
no test coverage detected