git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] quote: use isalnum() to check for alphanumeric characters

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Feb 23, 2020, 09:13 UTC
Message-ID
<CAN0heSr+S6FTVrjfa9ZQipyKjv611-DCLZpQPjJUm+T4sMM47w@mail.gmail.com>
In-Reply-To
<0157c714-2d9b-7896-f5dc-232d82a46625@web.de>
On Sat, 22 Feb 2020 at 19:53, René Scharfe <l.s.r@web.de> wrote:
>
> isalnum(c) is equivalent to isalpha(c) || isdigit(c), so use the
> former instead.  The result is shorter, simpler and slightly more
> efficient.

From git-compat-util.h I can see that the claim about equivalence is correct. And the efficiency claim, too. And agreed on "shorter and simpler".

Show 8 quoted lines
> --- a/quote.c
> +++ b/quote.c
> @@ -55,7 +55,7 @@ void sq_quote_buf_pretty(struct strbuf *dst, const char *src)
>         }
>
>         for (p = src; *p; p++) {
> -               if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) {
> +               if (!isalnum(*p) && !strchr(ok_punct, *p)) {
I failed to identify any similar constructs. Looks good to me.
Martin
Previous: René Scharfe
Message 2 of 2 in “quote: use isalnum() to check for alphanumeric characters”
  1. quote: use isalnum() to check for alphanumeric charactersRené Scharfe, Feb 22, 2020
  2. Martin ÅgrenFeb 23, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.