X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=quote.c;h=fb9e4ca253ea9bcadbcb55dcdd62be614c66758f;hb=baf5597ae43398e485f63f8e9216d34b5cd0a0d6;hp=a418a0f803f91d218b66ae89a1e8615a94ff27bc;hpb=bd45fec8397f1f0804db1d18af7193be323b0326;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); +}