X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=quote.c;h=fb9e4ca253ea9bcadbcb55dcdd62be614c66758f;hb=cfabd6eee1745cfec58cfcb794ce8847e43b888a;hp=ee7d62c751272f511d46894e5c5cd32e4403c721;hpb=244a0ae114824c8ca29bdc2148b98caaae39cac2;p=git.git diff --git a/quote.c b/quote.c index ee7d62c75..fb9e4ca25 100644 --- a/quote.c +++ b/quote.c @@ -209,7 +209,7 @@ static int quote_c_style_counted(const char *name, int namelen, if (!ch) break; if ((ch < ' ') || (ch == '"') || (ch == '\\') || - (ch == 0177)) { + (ch >= 0177)) { needquote = 1; switch (ch) { case '\a': EMITQ(); ch = 'a'; break; @@ -387,3 +387,37 @@ void python_quote_print(FILE *stream, const char *src) } fputc(sq, stream); } + +void tcl_quote_print(FILE *stream, const char *src) +{ + char c; + + fputc('"', stream); + while ((c = *src++)) { + switch (c) { + case '[': case ']': + case '{': case '}': + case '$': case '\\': case '"': + fputc('\\', stream); + default: + fputc(c, stream); + break; + case '\f': + fputs("\\f", stream); + break; + case '\r': + fputs("\\r", stream); + break; + case '\n': + fputs("\\n", stream); + break; + case '\t': + fputs("\\t", stream); + break; + case '\v': + fputs("\\v", stream); + break; + } + } + fputc('"', stream); +}