Escape token for output as CSV string.
| 192 | |
| 193 | // Escape token for output as CSV string. |
| 194 | static void CSV_escape(FILE *fp, jsmntok_t *tok) |
| 195 | { |
| 196 | const char *p = input + tok->start; |
| 197 | const char *end = input + tok->end; |
| 198 | /* Check whether quotes are needed: */ |
| 199 | for (; p < end; p++) |
| 200 | if (*p == ',' || *p == '"') { |
| 201 | // start CSV string: |
| 202 | fputc('"', fp); |
| 203 | /* reset and quote ": */ |
| 204 | for (p = input + tok->start; p < end; p++) { |
| 205 | if (*p == '"') |
| 206 | fputc('"', fp); |
| 207 | fputc(*p, fp); |
| 208 | } |
| 209 | // end CSV string: |
| 210 | fputc('"', fp); |
| 211 | return; |
| 212 | } |
| 213 | show(fp, tok, -1); |
| 214 | } |
| 215 | |
| 216 | /* DFS */ |
| 217 | static void show_tokens_aux(Node n, Node p, Node gp, FILE *fp) |
no test coverage detected