| 48 | } |
| 49 | |
| 50 | void sq_quote_buf_pretty(struct strbuf *dst, const char *src) |
| 51 | { |
| 52 | static const char ok_punct[] = "+,-./:=@_^"; |
| 53 | const char *p; |
| 54 | |
| 55 | /* Avoid losing a zero-length string by adding '' */ |
| 56 | if (!*src) { |
| 57 | strbuf_addstr(dst, "''"); |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | for (p = src; *p; p++) { |
| 62 | if (!isalnum(*p) && !strchr(ok_punct, *p)) { |
| 63 | sq_quote_buf(dst, src); |
| 64 | return; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /* if we get here, we did not need quoting */ |
| 69 | strbuf_addstr(dst, src); |
| 70 | } |
| 71 | |
| 72 | void sq_quotef(struct strbuf *dst, const char *fmt, ...) |
| 73 | { |
no test coverage detected