Mercurial > hg > index.cgi
comparison lwasm/pseudo.c @ 521:56c32bc798f8
Fix argument parsing problems with IFSTR
Neglecting to take into account comma separators and opening delimiters led
to a number of off by one errors making IFSTR largely useless.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 19 Dec 2021 17:46:02 -0700 |
parents | 724bcc4508bc |
children | e10618b48e68 |
comparison
equal
deleted
inserted
replaced
520:63450eb68f45 | 521:56c32bc798f8 |
---|---|
1837 strncpy(arg, tstr, i); | 1837 strncpy(arg, tstr, i); |
1838 arg[i] = 0; | 1838 arg[i] = 0; |
1839 | 1839 |
1840 if (tstr[i]) | 1840 if (tstr[i]) |
1841 i++; | 1841 i++; |
1842 if (tstr[i] == ',') | |
1843 i++; | |
1842 | 1844 |
1843 *p += i; | 1845 *p += i + 1; |
1844 return arg; | 1846 return arg; |
1845 } | 1847 } |
1846 else if (*tstr == '\'') | 1848 else if (*tstr == '\'') |
1847 { | 1849 { |
1848 // single quote delim | 1850 // single quote delim |
1854 strncpy(arg, tstr, i); | 1856 strncpy(arg, tstr, i); |
1855 arg[i] = 0; | 1857 arg[i] = 0; |
1856 | 1858 |
1857 if (tstr[i]) | 1859 if (tstr[i]) |
1858 i++; | 1860 i++; |
1859 | 1861 if (tstr[i] == ',') |
1860 *p += i; | 1862 i++; |
1863 *p += i + 1; | |
1861 return arg; | 1864 return arg; |
1862 } | 1865 } |
1863 else | 1866 else |
1864 { | 1867 { |
1865 // bare word - whitespace or comma delim | 1868 // bare word - whitespace or comma delim |
1885 char *arg2; | 1888 char *arg2; |
1886 int c = 0; | 1889 int c = 0; |
1887 | 1890 |
1888 arg1 = strcond_parsearg(p); | 1891 arg1 = strcond_parsearg(p); |
1889 arg2 = strcond_parsearg(p); | 1892 arg2 = strcond_parsearg(p); |
1890 | 1893 |
1891 if (strcmp(arg1, arg2) == 0) | 1894 if (strcmp(arg1, arg2) == 0) |
1892 c = 1; | 1895 c = 1; |
1893 lw_free(arg1); | 1896 lw_free(arg1); |
1894 lw_free(arg2); | 1897 lw_free(arg2); |
1895 return c; | 1898 return c; |