On Fri, May 25, 2018 at 11:00:53PM +0200, Martin Ågren wrote:
> +/*
> + * Write the message to the file, prefixing and suffixing
> + * each line with `prefix` resp. `suffix`.
> + */
> +void prefix_suffix_lines(FILE *f, const char *prefix,
> + const char *message, const char *suffix);
Should this perhaps learn about colors, too?
That would save us from having to allocate here:
> diff --git a/advice.c b/advice.c
> index 370a56d054..ffb29e7ef4 100644
> --- a/advice.c
> +++ b/advice.c
> @@ -79,24 +79,22 @@ static struct {
>
> void advise(const char *advice, ...)
> {
> + struct strbuf prefix = STRBUF_INIT;
> struct strbuf buf = STRBUF_INIT;
> va_list params;
> - const char *cp, *np;
> +
> + strbuf_addf(&prefix, _("%shint: "),
> + advise_get_color(ADVICE_COLOR_HINT));
But most importantly, it means we could eventually colorize errors, too,
where we are not allowed to allocate.
So perhaps:
void report_lines(FILE *out,
const char *color, const char *color_reset,
const char *prefix, const char *msg);
or something?
-Peff