diff options
Diffstat (limited to 'quote.c')
-rw-r--r-- | quote.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -1,5 +1,7 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "path.h" #include "quote.h" +#include "strbuf.h" #include "strvec.h" int quote_path_fully = 1; @@ -471,6 +473,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 = '\''; |