List for cgit developers and users
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: list@eworm.de
Cc: cgit@lists.zx2c4.com, Christian Hesse <mail@eworm.de>
Subject: Re: [PATCH 1/1] RFC: git: update to v2.41.0-rc2
Date: Fri, 26 May 2023 15:42:55 +0200	[thread overview]
Message-ID: <CAHmME9qfQQNnK18VG+TvWadJDL+MftbeUhyTeSHtNZvchMa9MA@mail.gmail.com> (raw)
In-Reply-To: <20230526110646.60621-1-list@eworm.de>

On Fri, May 26, 2023 at 1:07 PM Christian Hesse <list@eworm.de> wrote:
> @@ -564,9 +566,11 @@ char *get_mimetype_for_filename(const char *filename)
>         while (fgets(line, sizeof(line), file)) {
>                 if (!line[0] || line[0] == '#')
>                         continue;
> -               mimetype = strtok_r(line, " \t\r\n", &saveptr);
> -               while ((token = strtok_r(NULL, " \t\r\n", &saveptr))) {
> -                       if (!strcasecmp(ext, token)) {
> +               string_list_split_in_place(&list, line, " \t\r\n", -1);
> +               string_list_remove_empty_items(&list, 0);
> +               mimetype = list.items[0].string;
> +               for (i = 1; i < list.nr; i++) {
> +                       if (!strcasecmp(ext, list.items[i].string)) {
>                                 fclose(file);
>                                 return xstrdup(mimetype);
>                         }

What's the motivation here exactly? string_list allocates, I believe,
for its items array even if you set nostrdup, so that code probably
needs a free path. But also, what's the point of doing the splitting
up front and then iterating, rather than just munging the string like
usual with strtok_r?

Jason

  reply	other threads:[~2023-05-26 13:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 11:06 Christian Hesse
2023-05-26 13:42 ` Jason A. Donenfeld [this message]
2023-05-26 14:06   ` Christian Hesse
2023-05-26 14:17     ` Christian Hesse
2023-05-26 14:18       ` Jason A. Donenfeld
2023-05-26 14:21         ` Christian Hesse

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=CAHmME9qfQQNnK18VG+TvWadJDL+MftbeUhyTeSHtNZvchMa9MA@mail.gmail.com \
    --to=jason@zx2c4.com \
    --cc=cgit@lists.zx2c4.com \
    --cc=list@eworm.de \
    --cc=mail@eworm.de \
    /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).