From: Masahiro Yamada <masahiroy@kernel.org>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: [PATCH 1/5] git-compat-util: add isblank() and isgraph()
Date: Sat, 11 Feb 2023 01:56:48 +0900 [thread overview]
Message-ID: <CAK7LNASLR6VLoX+Mf5MTemAMbts81kqf=dM5Bzne1QdZpT7tgQ@mail.gmail.com> (raw)
In-Reply-To: <230210.861qmxwtbz.gmgdl@evledraar.gmail.com>
On Fri, Feb 10, 2023 at 10:20 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
>
> On Fri, Feb 10 2023, Masahiro Yamada wrote:
>
> > git-compat-util.h implements most of is*() macros.
> >
> > Add isblank() and isgraph(), which are useful to clean up wildmatch.c
> > in a consistent way (in this and later commits).
>
> You are on a journey to fix wildmatch.c, so...
>
> > The same issue already exists for isspace().
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> > [...]
> > -#ifdef isblank
> > -# define ISBLANK(c) (ISASCII(c) && isblank(c))
> > -#else
> > -# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
> > -#endif
> > -
> > -#ifdef isgraph
> > -# define ISGRAPH(c) (ISASCII(c) && isgraph(c))
> > -#else
> > -# define ISGRAPH(c) (ISASCII(c) && isprint(c) && !isspace(c))
> > -#endif
> > -
> > +#define ISBLANK(c) (ISASCII(c) && isblank(c))
> > +#define ISGRAPH(c) (ISASCII(c) && isgraph(c))
> > #define ISPRINT(c) (ISASCII(c) && isprint(c))
> > #define ISDIGIT(c) (ISASCII(c) && isdigit(c))
> > #define ISALNUM(c) (ISASCII(c) && isalnum(c))
>
> You make this change, but not others in tree.
>
> Personally I wouldn't mind seeing this expanded to fix the various other
I wouldn't mind seeing somebody use this for tree-wide cleanups.
I do not see any reason to do that in this patch set, either.
> trivially convertable cases in-tree, e.g.:
>
> $ git -P grep -n "(' '|'\\\t').*\|\|.*(' '|'\\\t')"
> builtin/am.c:602: if (*sb.buf == '\t' || *sb.buf == ' ')
> compat/regex/regex_internal.h:60:# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
> compat/regex/regex_internal.h:73: return (c == ' ' || c == '\t');
> config.c:893: while (c == ' ' || c == '\t')
> fsck.c:837: while (*p == ' ' || *p == '\t')
> mailinfo.c:749: (line->buf[0] == ' ' || line->buf[0] == '\t')) {
> sequencer.c:2476: (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) &&
> sequencer.c:2536: (*bol == ' ' || *bol == '\t')) {
> sequencer.c:2540: (*bol == ' ' || *bol == '\t')) {
> sequencer.c:2594: if (is_command(TODO_PICK, &bol) && (*bol == ' ' || *bol == '\t'))
> sequencer.c:2597: (*bol == ' ' || *bol == '\t'))
> t/helper/test-json-writer.c:443: if (c == '\n' || c == '\r' || c == ' ' || c == '\t')
> t/helper/test-json-writer.c:449: while (*buf == ' ' || *buf == '\t')
> t/t4256/1/mailinfo.c:737: (line->buf[0] == ' ' || line->buf[0] == '\t')) {
> t/t4256/1/mailinfo.c.orig:726: (line->buf[0] == ' ' || line->buf[0] == '\t')) {
> trailer.c:630: if (c != line && (*c == ' ' || *c == '\t')) {
> wildmatch.c:34:# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
>
> Some of those are false positves, but most are not.
--
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2023-02-10 16:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 7:59 [PATCH 0/5] Clean up wildmatch.c Masahiro Yamada
2023-02-10 7:59 ` [PATCH 1/5] git-compat-util: add isblank() and isgraph() Masahiro Yamada
2023-02-10 13:16 ` Ævar Arnfjörð Bjarmason
2023-02-10 16:56 ` Masahiro Yamada [this message]
2023-02-10 19:10 ` Junio C Hamano
2023-02-10 19:25 ` Masahiro Yamada
2023-02-10 22:03 ` René Scharfe
2023-02-11 7:01 ` Masahiro Yamada
2023-02-11 13:48 ` René Scharfe
2023-02-11 14:11 ` René Scharfe
2023-02-10 7:59 ` [PATCH 2/5] wildmatch: remove IS*() macros Masahiro Yamada
2023-02-10 7:59 ` [PATCH 3/5] wildmatch: remove NEGATE_CLASS and NEGATE_CLASS2 macros Masahiro Yamada
2023-02-10 13:11 ` Ævar Arnfjörð Bjarmason
2023-02-10 17:03 ` Masahiro Yamada
2023-02-10 7:59 ` [PATCH 4/5] wildmatch: use char instead of uchar Masahiro Yamada
2023-02-10 13:09 ` Ævar Arnfjörð Bjarmason
2023-02-10 7:59 ` [PATCH 5/5] wildmatch: more cleanups after killing uchar Masahiro Yamada
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='CAK7LNASLR6VLoX+Mf5MTemAMbts81kqf=dM5Bzne1QdZpT7tgQ@mail.gmail.com' \
--to=masahiroy@kernel.org \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@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).