summaryrefslogtreecommitdiff
path: root/quote.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-10-25 13:29:12 -0700
committerJunio C Hamano <junkio@cox.net>2006-10-25 13:29:12 -0700
commit9ee93dceb5dbef8052b0abde3eea94181bd9d95b (patch)
tree2643405a0c9846b8985c95f9af8fd95f6bbcbc1e /quote.c
parent8e95026f2942c2c485d9686736d861a6477480b5 (diff)
parent1729fa9878ed8c99ae0bb2aecced557618d0c894 (diff)
downloadgit-9ee93dceb5dbef8052b0abde3eea94181bd9d95b.tar.gz
Merge for-each-ref to sync gitweb fully with 'next'
Diffstat (limited to 'quote.c')
-rw-r--r--quote.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/quote.c b/quote.c
index e3a4d4aef3..ee7d62c751 100644
--- a/quote.c
+++ b/quote.c
@@ -349,3 +349,41 @@ void write_name_quoted(const char *prefix, int prefix_len,
else
goto no_quote;
}
+
+/* quoting as a string literal for other languages */
+
+void perl_quote_print(FILE *stream, const char *src)
+{
+ const char sq = '\'';
+ const char bq = '\\';
+ char c;
+
+ fputc(sq, stream);
+ while ((c = *src++)) {
+ if (c == sq || c == bq)
+ fputc(bq, stream);
+ fputc(c, stream);
+ }
+ fputc(sq, stream);
+}
+
+void python_quote_print(FILE *stream, const char *src)
+{
+ const char sq = '\'';
+ const char bq = '\\';
+ const char nl = '\n';
+ char c;
+
+ fputc(sq, stream);
+ while ((c = *src++)) {
+ if (c == nl) {
+ fputc(bq, stream);
+ fputc('n', stream);
+ continue;
+ }
+ if (c == sq || c == bq)
+ fputc(bq, stream);
+ fputc(c, stream);
+ }
+ fputc(sq, stream);
+}