public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: C2x strtol binary constant handling: Fix special case "0b"
Date: Thu, 16 Mar 2023 18:01:54 -0300	[thread overview]
Message-ID: <731d2025-ab53-4027-7d14-9326722b563e@linaro.org> (raw)
In-Reply-To: <3614039.ZfL8zNpBrT@nimes>



On 16/03/23 12:14, Bruno Haible wrote:
> Hi Joseph,
> 
> While adding C2x support to the strtol, strtoll, strtoul, strtoull
> functions in Gnulib, I was glad to see that you have already done
> the support in glibc. But I noticed that the glibc implementation
> apparently does not handle the input "0b" correctly. The unit test
> cases for this special case are:
> 
>   {
>     const char input[] = "0b";
>     char *ptr;
>     long result;
>     errno = 0;
>     result = strtol (input, &ptr, 2);
>     assert (result == 0L);
>     assert (ptr == input + 1);
>     assert (errno == 0);
>   }
>   {
>     const char input[] = "0b";
>     char *ptr;
>     long result;
>     errno = 0;
>     result = strtol (input, &ptr, 0);
>     assert (result == 0L);
>     assert (ptr == input + 1);
>     assert (errno == 0);
>   }
> 
> and likewise for strtoll, strtoul, strtoull.
> 
> Find attached a correction for this. I have tested it in Gnulib (which
> has very similar source code as glibc for this functionality), not in
> Glibc directly. Therefore, please review thoroughly.
> 
> Bruno

Could you also add these testscase on strtol tests ?

      reply	other threads:[~2023-03-16 21:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 15:14 Bruno Haible
2023-03-16 21:01 ` Adhemerval Zanella Netto [this message]

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=731d2025-ab53-4027-7d14-9326722b563e@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --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).