X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=quote.c;h=fb9e4ca253ea9bcadbcb55dcdd62be614c66758f;hb=cfabd6eee1745cfec58cfcb794ce8847e43b888a;hp=a418a0f803f91d218b66ae89a1e8615a94ff27bc;hpb=d0a75a179e0e872c47d4a25350565a8c7c04dd0b;p=git.git diff --git a/quote.c b/quote.c index a418a0f80..fb9e4ca25 100644 --- a/quote.c +++ b/quote.c @@ -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); +}