git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>, Jeff King <peff@peff.net>
Subject: Re: [PATCH v2 0/3] pkt-line: war on magical `4` literal
Date: Sun, 14 Jun 2020 14:32:51 -0700	[thread overview]
Message-ID: <xmqqimftxri4.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <cover.1592119902.git.liu.denton@gmail.com> (Denton Liu's message of "Sun, 14 Jun 2020 03:31:57 -0400")

Denton Liu <liu.denton@gmail.com> writes:

> +static inline void control_packet_write(int fd, const char *s, const char *type)
> +{
> +	packet_trace_str(s, 1);
> +	if (write_str_in_full(fd, s) < 0)
> +		die_errno(_("unable to write %s packet"), type);

This construct, whether "type" is a localized string _("...")  or
English literal "...", would not translate well, would it?  The
former causes sentence lego and the latter injects untranslated
adjective that modifies the word "packet" in the final sentence.

As write_str_in_full() MUST count how long the string is at runtime,
without any possibility to offload the work to compiler, when these
strings that are sent with the "magical 4" are all compile-time
constant literal strings, I am not sure if this is something we
should be happy with---we should aim better for a solution that does
not require the runtime to count if possible.

Thanks.

  parent reply	other threads:[~2020-06-14 21:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-13 13:43 [PATCH] pkt-line: extract out PACKET_HEADER_SIZE Denton Liu
2020-06-13 14:23 ` Đoàn Trần Công Danh
2020-06-13 14:39   ` Denton Liu
2020-06-13 16:51   ` Junio C Hamano
2020-06-14 18:24     ` Junio C Hamano
2020-06-14  7:31 ` Denton Liu
2020-06-14  7:31 ` [PATCH v2 0/3] pkt-line: war on magical `4` literal Denton Liu
2020-06-14  7:31   ` [PATCH v2 1/3] remote-curl: use strlen() instead of magic numbers Denton Liu
2020-06-14  7:31   ` [PATCH v2 2/3] pkt-line: use string versions of functions Denton Liu
2020-06-14  8:31     ` Đoàn Trần Công Danh
2020-06-14  9:07       ` [PATCH v2] " Denton Liu
2020-06-14 21:35         ` Junio C Hamano
2020-06-14 22:28           ` Denton Liu
2020-06-15 12:32         ` Đoàn Trần Công Danh
2020-06-14  7:32   ` [PATCH v2 3/3] pkt-line: extract out PACKET_HEADER_SIZE Denton Liu
2020-06-14 21:32   ` Junio C Hamano [this message]
2020-06-23 17:55   ` [PATCH v3 0/3] pkt-line: war on magical `4` literal Denton Liu
2020-06-23 17:55     ` [PATCH v3 1/3] remote-curl: use strlen() instead of magic numbers Denton Liu
2020-06-23 18:54       ` Jeff King
2020-06-23 19:39         ` Junio C Hamano
2020-06-23 17:55     ` [PATCH v3 2/3] pkt-line: use string versions of functions Denton Liu
2020-06-23 19:11       ` Jeff King
2020-06-23 17:55     ` [PATCH v3 3/3] pkt-line: extract out PACKET_HEADER_SIZE Denton Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqimftxri4.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=liu.denton@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).