public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: "lancasterharp@gmail.com" <lancasterharp@gmail.com>
Cc: 'GNU C Library' <libc-alpha@sourceware.org>
Subject: Re: Fix %Z parsing in strptime [BZ #16088]
Date: Mon, 17 Jul 2023 12:57:25 +0000	[thread overview]
Message-ID: <PAWPR08MB8982F972C45EC77F64AEC132833BA@PAWPR08MB8982.eurprd08.prod.outlook.com> (raw)

Hi Stanley,

> +	  /* we recognize the format [-+a-zA-Z0-9]{3,} */

Is that really the correct format? Eg. should it be able to parse UTC offsets like UTC+04:30?

> 	  while (ISSPACE (*rp))
> 	    rp++;
>-	  while (!ISSPACE (*rp) && *rp != '\0')
>+	  
>+	  const char* stop_rp = rp + 3;
>+	  while (((*rp >= 'A' && *rp <= 'Z') || (*rp >= 'a' && *rp <= 'z') || (*rp >= '0' && *rp <= '9')) && (rp < stop_rp) && *rp != '\0')

This is basically isalnum() but not allowing '+' or '-'. And if timezone offsets are allowed,
we'd also need ':'. And rather than allowing any sequence of these characters, would it
not be better to scan just for isalpha() first, and only if you see '+' or '-' check the UTC
offset syntax?

Cheers,
Wilco

             reply	other threads:[~2023-07-17 12:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 12:57 Wilco Dijkstra [this message]
2023-07-17 17:19 ` Paul Eggert
  -- strict thread matches above, loose matches on Subject: below --
2023-07-14 14:52 Stanley Lancaster
2023-07-14 16:11 ` Paul Eggert
2023-07-18 17:17   ` Stanley Lancaster
2023-07-18 17:22     ` Stanley Lancaster
2023-07-19  2:13     ` Paul Eggert

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=PAWPR08MB8982F972C45EC77F64AEC132833BA@PAWPR08MB8982.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=lancasterharp@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).