summaryrefslogtreecommitdiff
path: root/quote.c
diff options
context:
space:
mode:
Diffstat (limited to 'quote.c')
-rw-r--r--quote.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/quote.c b/quote.c
index 8a3a5e39eb..26719d21d1 100644
--- a/quote.c
+++ b/quote.c
@@ -471,6 +471,23 @@ void perl_quote_buf(struct strbuf *sb, const char *src)
strbuf_addch(sb, sq);
}
+void perl_quote_buf_with_len(struct strbuf *sb, const char *src, size_t len)
+{
+ const char sq = '\'';
+ const char bq = '\\';
+ const char *c = src;
+ const char *end = src + len;
+
+ strbuf_addch(sb, sq);
+ while (c != end) {
+ if (*c == sq || *c == bq)
+ strbuf_addch(sb, bq);
+ strbuf_addch(sb, *c);
+ c++;
+ }
+ strbuf_addch(sb, sq);
+}
+
void python_quote_buf(struct strbuf *sb, const char *src)
{
const char sq = '\'';