Re: [RFC PATCH 1/3] usage: extract `prefix_suffix_lines()` from `advise()`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 28, 2018 at 08:40:16PM +0200, Duy Nguyen wrote:

> On Fri, May 25, 2018 at 11:00 PM, Martin Ågren <martin.agren@xxxxxxxxx> wrote:
> > advice.c contains a useful code snippet which takes a multi-line string
> > and prints the lines, prefixing and suffixing each line with two
> > constant strings. This was originally added in 23cb5bf3b3 (i18n of
> > multi-line advice messages, 2011-12-22) to produce such output:
> >
> > hint: some multi-line advice
> > hint: prefixed with "hint: "
> >
> > The prefix is actually colored after 960786e761 (push: colorize errors,
> > 2018-04-21) and each line has a suffix for resetting the color.
> >
> > The next commit will teach the same "prefix all the lines"-trick to the
> > code that produces, e.g., "warning: "-messages. In preparation for that,
> > extract the code for printing the individual lines and expose it through
> > git-compat-util.h.
> >
> > Signed-off-by: Martin Ågren <martin.agren@xxxxxxxxx>
> > ---
> > I'm open for suggestions on the naming of `prefix_suffix_lines()`...
> 
> I think the important verb, print (to FILE*), is somehow missing. This
> current name would be great if it produces another str(buf).

It can't use a strbuf, since we want vreportf() to avoid calling any
allocation functions.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux