| 121 | } |
| 122 | |
| 123 | char *sq_dequote_step(char *arg, char **next) |
| 124 | { |
| 125 | char *dst = arg; |
| 126 | char *src = arg; |
| 127 | char c; |
| 128 | |
| 129 | if (*src != '\'') |
| 130 | return NULL; |
| 131 | for (;;) { |
| 132 | c = *++src; |
| 133 | if (!c) |
| 134 | return NULL; |
| 135 | if (c != '\'') { |
| 136 | *dst++ = c; |
| 137 | continue; |
| 138 | } |
| 139 | /* We stepped out of sq */ |
| 140 | switch (*++src) { |
| 141 | case '\0': |
| 142 | *dst = 0; |
| 143 | if (next) |
| 144 | *next = NULL; |
| 145 | return arg; |
| 146 | case '\\': |
| 147 | /* |
| 148 | * Allow backslashed characters outside of |
| 149 | * single-quotes only if they need escaping, |
| 150 | * and only if we resume the single-quoted part |
| 151 | * afterward. |
| 152 | */ |
| 153 | if (need_bs_quote(src[1]) && src[2] == '\'') { |
| 154 | *dst++ = src[1]; |
| 155 | src += 2; |
| 156 | continue; |
| 157 | } |
| 158 | /* Fallthrough */ |
| 159 | default: |
| 160 | if (!next) |
| 161 | return NULL; |
| 162 | *dst = 0; |
| 163 | *next = src; |
| 164 | return arg; |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | char *sq_dequote(char *arg) |
| 170 | { |
no test coverage detected