* Escape the string, following the rules in RFC4180 */
| 300 | * Escape the string, following the rules in RFC4180 |
| 301 | */ |
| 302 | static void |
| 303 | csv_escape (xo_buffer_t *xbp, const char *value, size_t len) |
| 304 | { |
| 305 | const char *cp, *ep, *np; |
| 306 | |
| 307 | for (cp = value, ep = value + len; cp && cp < ep; cp = np) { |
| 308 | np = strchr(cp, '"'); |
| 309 | if (np) { |
| 310 | np += 1; |
| 311 | xo_buf_append(xbp, cp, np - cp); |
| 312 | xo_buf_append(xbp, "\"", 1); |
| 313 | } else |
| 314 | xo_buf_append(xbp, cp, ep - cp); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /* |
| 319 | * Append a newline to the buffer, following the settings of the "dos" |
no test coverage detected