git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: "Carlos L." <00xc@protonmail.com>
Cc: "Carlos L. via GitGitGadget" <gitgitgadget@gmail.com>,
	"Martin Ågren [ ]" <martin.agren@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] grep: add --max-count command line option
Date: Mon, 20 Jun 2022 11:32:35 -0500	[thread overview]
Message-ID: <7b7a2876-f6fe-1234-813b-71ba94a00422@cs.ucla.edu> (raw)
In-Reply-To: <xy0kCdbtIjKb_GkXpHs7eeE8eWLbbct69_tVczBGS3CMnnnKTlTheaeNlH-RB1mMAfWThSTN6bMThsQ4lLtr0Ji6RwG3Nd52L1muiEqdtCU=@protonmail.com>

On 6/20/22 11:25, Carlos L. wrote:
> This does not work well with OPTION_INTEGER, since it assumes the value to be int-sized:
>
> parse-options.c:
>   219             *(int *)opt->value = strtol(arg, (char **)&s, 10);

OK, so parse-options messes up if the user specifies a count that does 
not fit in 'int'? Although that's a separate bug, let's not make things 
worse here; let's make the new count an 'int'.

In the long run parse-options should be changed to use strtoimax instead 
of strtol, and the corresponding integers should be changed to intmax_t, 
and the proper thing should be done if the string value does not fit 
into intmax_t. But this longer-run fix affects all integer-valued 
options, not just this one.


> I also wanted to avoid using signed int so both sides of the comparison with `count` in grep_source_1() have the same sign.

Such comparisons cannot misfire if both values are nonnegative, and that 
can easily be arranged here.


  reply	other threads:[~2022-06-20 16:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 15:49 [PATCH] grep: add --max-count command line option Carlos L. via GitGitGadget
2022-06-20 15:57 ` Paul Eggert
2022-06-20 16:25   ` Carlos L.
2022-06-20 16:32     ` Paul Eggert [this message]
2022-06-21  5:36 ` [PATCH v2] " Carlos L. via GitGitGadget
2022-06-21 16:27   ` Junio C Hamano
2022-06-22  6:41     ` Carlos L.
2022-06-22  6:56       ` Junio C Hamano
     [not found]   ` <220622.86mte5knbe.gmgdl@evledraar.gmail.com>
2022-06-22 13:23     ` Carlos L.
2022-06-22 17:07   ` [PATCH v3 0/2] " Carlos L. via GitGitGadget
2022-06-22 17:07     ` [PATCH v3 1/2] " Carlos López via GitGitGadget
2022-06-22 17:07     ` [PATCH v3 2/2] tests: add tests for grep --max-count Carlos López via GitGitGadget
2022-06-22 18:10       ` Junio C Hamano
2022-06-22 19:47     ` [PATCH v4] grep: add --max-count command line option Carlos L. via GitGitGadget
  -- strict thread matches above, loose matches on Subject: below --
2022-05-12 13:20 [PATCH] " Carlos L. via GitGitGadget
2022-05-14 18:16 ` Martin Ågren
2022-05-16  5:57 ` Junio C Hamano
2022-05-16  7:28   ` Paul Eggert
2022-05-16  8:38     ` Carlos L.
2022-05-16 15:36       ` Junio C Hamano
2022-05-17  5:53         ` Paul Eggert
2022-05-16 15:18     ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7b7a2876-f6fe-1234-813b-71ba94a00422@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=00xc@protonmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=martin.agren@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).