git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Maxwell Bernstein <tekk.nolagi@gmail.com>,
	Jonathan Tan <jonathantanmy@google.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] Documentation: clarify whitespace rules for trailers
Date: Thu, 25 Aug 2022 13:59:38 +0200	[thread overview]
Message-ID: <CAP8UFD0EfhDo9ZMNSYp8YVHXJs6mYtSBs=hwoFZWWF3xZ0wjpg@mail.gmail.com> (raw)
In-Reply-To: <xmqq4jy18q7h.fsf@gitster.g>

On Wed, Aug 24, 2022 at 8:13 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Christian Couder <christian.couder@gmail.com> writes:

> > -When reading trailers, there can be whitespaces after the
> > -token, the separator and the value. There can also be whitespaces
> > -inside the token and the value. The value may be split over multiple lines with
> > -each subsequent line starting with whitespace, like the "folding" in RFC 822.
> > +When reading trailers, there can be no whitespace inside the token,
> > +and only one regular space or tab character between the token and the
> > +separator.
>
> That may have been the intent, but does it match the behaviour?
>
>         static ssize_t find_separator(const char *line, const char *separators)
>         {
>                 int whitespace_found = 0;
>                 const char *c;
>                 for (c = line; *c; c++) {
>                         if (strchr(separators, *c))
>                                 return c - line;
>                         if (!whitespace_found && (isalnum(*c) || *c == '-'))
>                                 continue;
>                         if (c != line && (*c == ' ' || *c == '\t')) {
>                                 whitespace_found = 1;
>                                 continue;
>                         }
>                         break;
>                 }
>                 return -1;
>         }
>
> When parsing "X  :", first we encounter 'X', we haven't seen
> whitespace, 'X' passes isalnum(), and we continue.  Then we
> encounter ' ', we haven't seen whitespace but it is neither isalnum
> or dash, so we go on without hitting the first continue.  We are not
> at the beginning of the line, we are seeing a space, so we remember
> the fact that we saw whitespace and continue.  Next we see another ' ',
> we do not hit the first continue, we are not at the beginning of the
> line, and we are looking at ' ', so we again continue.  Finally, we see
> ':' that is a separator and we return happily.
>
> The code seems to be allowing zero or more space/tab before the
> separator.

Yeah, I agree. I misread the code. I will send a new version soon.

Thanks.

  reply	other threads:[~2022-08-25 12:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18  7:06 [PATCH] trailer: allow spaces in tokens Max Bernstein via GitGitGadget
2022-08-18  7:54 ` [PATCH v2] " Max Bernstein via GitGitGadget
2022-08-18 16:54   ` Junio C Hamano
2022-08-18 17:56     ` Jonathan Tan
2022-08-18 19:03     ` Maxwell Bernstein
2022-08-18 20:46       ` Christian Couder
2022-08-18 21:31         ` Junio C Hamano
2022-08-19  4:33           ` Junio C Hamano
2022-08-19 10:29             ` Christian Couder
2022-08-22 13:58               ` Johannes Schindelin
2022-08-23 14:06               ` [PATCH] Documentation: clarify whitespace rules for trailers Christian Couder
2022-08-24 18:13                 ` Junio C Hamano
2022-08-25 11:59                   ` Christian Couder [this message]
2022-08-25 16:20                     ` Junio C Hamano
2022-08-30 10:50                     ` [PATCH v2] " Christian Couder
2022-08-30 17:20                       ` Junio C Hamano
2022-08-18 16:48 ` [PATCH] trailer: allow spaces in tokens Junio C Hamano
2022-08-18 17:52   ` Jonathan Tan
2022-08-18 17:58     ` Junio C Hamano

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='CAP8UFD0EfhDo9ZMNSYp8YVHXJs6mYtSBs=hwoFZWWF3xZ0wjpg@mail.gmail.com' \
    --to=christian.couder@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=tekk.nolagi@gmail.com \
    /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).