mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
Full rework of quote_c_style and write_name_quoted.
* quote_c_style works on a strbuf instead of a wild buffer. * quote_c_style is now clever enough to not add double quotes if not needed. * write_name_quoted inherits those advantages, but also take a different set of arguments. Now instead of asking for quotes or not, you pass a "terminator". If it's \0 then we assume you don't want to escape, else C escaping is performed. In any case, the terminator is also appended to the stream. It also no longer takes the prefix/prefix_len arguments, as it's seldomly used, and makes some optimizations harder. * write_name_quotedpfx is created to work like write_name_quoted and take the prefix/prefix_len arguments. Thanks to those API changes, diff.c has somehow lost weight, thanks to the removal of functions that were wrappers around the old write_name_quoted trying to give it a semantics like the new one, but performing a lot of allocations for this goal. Now we always write directly to the stream, no intermediate allocation is performed. As a side effect of the refactor in builtin-apply.c, the length of the bar graphs in diffstats are not affected anymore by the fact that the path was clipped. Signed-off-by: Pierre Habouzit <madcoder@debian.org>
This commit is contained in:
committed by
Junio C Hamano
parent
7fb1011e61
commit
663af3422a
8
quote.h
8
quote.h
@@ -44,11 +44,11 @@ extern int add_to_string(char **ptrp, int *sizep, const char *str, int quote);
|
||||
extern char *sq_dequote(char *);
|
||||
|
||||
extern int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);
|
||||
extern int quote_c_style(const char *name, char *outbuf, FILE *outfp,
|
||||
int nodq);
|
||||
extern size_t quote_c_style(const char *name, struct strbuf *, FILE *, int no_dq);
|
||||
|
||||
extern void write_name_quoted(const char *prefix, int prefix_len,
|
||||
const char *name, int quote, FILE *out);
|
||||
extern void write_name_quoted(const char *name, FILE *, int terminator);
|
||||
extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,
|
||||
const char *name, FILE *, int terminator);
|
||||
|
||||
/* quoting as a string literal for other languages */
|
||||
extern void perl_quote_print(FILE *stream, const char *src);
|
||||
|
||||
Reference in New Issue
Block a user