File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,19 @@ void sq_quote_buf(struct strbuf *dst, const char *src)
4343 free (to_free );
4444}
4545
46+ void sq_quotef (struct strbuf * dst , const char * fmt , ...)
47+ {
48+ struct strbuf src = STRBUF_INIT ;
49+
50+ va_list ap ;
51+ va_start (ap , fmt );
52+ strbuf_vaddf (& src , fmt , ap );
53+ va_end (ap );
54+
55+ sq_quote_buf (dst , src .buf );
56+ strbuf_release (& src );
57+ }
58+
4659void sq_quote_argv (struct strbuf * dst , const char * * argv , size_t maxlen )
4760{
4861 int i ;
Original file line number Diff line number Diff line change @@ -25,10 +25,13 @@ struct strbuf;
2525 * sq_quote_buf() writes to an existing buffer of specified size; it
2626 * will return the number of characters that would have been written
2727 * excluding the final null regardless of the buffer size.
28+ *
29+ * sq_quotef() quotes the entire formatted string as a single result.
2830 */
2931
3032extern void sq_quote_buf (struct strbuf * , const char * src );
3133extern void sq_quote_argv (struct strbuf * , const char * * argv , size_t maxlen );
34+ extern void sq_quotef (struct strbuf * , const char * fmt , ...);
3235
3336/* This unwraps what sq_quote() produces in place, but returns
3437 * NULL if the input does not look like what sq_quote would have
You can’t perform that action at this time.
0 commit comments