Re: [PATCH 1/2] advice: extract function to print messages with prefix

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

 



Ralf Thielow <ralf.thielow@xxxxxxxxx> writes:

> Extract a function that allows to print messages
> with a prefix.
>
> Signed-off-by: Ralf Thielow <ralf.thielow@xxxxxxxxx>
> ---
>  advice.c | 14 ++++++++++----
>  advice.h |  1 +
>  2 Dateien geändert, 11 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
>
> diff --git a/advice.c b/advice.c
> index edfbd4a..e73d53b 100644
> --- a/advice.c
> +++ b/advice.c
> @@ -25,25 +25,31 @@ static struct {
>  	{ "detachedhead", &advice_detached_head },
>  };
>  
> -void advise(const char *advice, ...)
> +void print_with_prefix(const char *prefix, const char *msg, ...)
>  {
>  	struct strbuf buf = STRBUF_INIT;
>  	va_list params;
>  	const char *cp, *np;
>  
> -	va_start(params, advice);
> -	strbuf_vaddf(&buf, advice, params);
> +	va_start(params, msg);
> +	strbuf_vaddf(&buf, msg, params);
>  	va_end(params);
>  
>  	for (cp = buf.buf; *cp; cp = np) {
>  		np = strchrnul(cp, '\n');
> -		fprintf(stderr,	_("hint: %.*s\n"), (int)(np - cp), cp);
> +		fprintf(stderr,	 "%s %.*s\n", prefix, (int)(np - cp), cp);

Hrm, naively, printf("%s: %.*s\n", _("hint"), ...) might look more
natural, but I vaguely recall that the current code places _()
around the entire "hint: %.*s\n" on purpose.  IIRC, it was to allow
translations that flow from RTL e.g. ".siht od t'nod :tnih".

Doesn't this patch break it?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]