problematic document for isascii(3)

Eric Blake eblake@redhat.com
Thu May 23 14:25:00 GMT 2013


On 05/23/2013 07:21 AM, ntysdd wrote:
> Hi,
> I found something buggy in the document.
> The doc says "`isascii' is ANSI C", but it isn't.
> It is a BSD extension.

Actually, it is also POSIX, but you are correct that it is not C.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/isascii.html

> 
> Also the doc for isdigit says
> "It is defined only when `isascii'(C) is true or C is EOF."

This is a lie; isascii(128) returns false, but isdigit(128) is well=defined.

> 
> But isdigit is ANSI C so it should not rely on isascii.
> And after reading the ansi draft, I think isdigit is defined
> for anything representable as an unsigned char (plus EOF).

Correct, that is also the POSIX wording:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/isdigit.html

> 
> By the way, the doc says isdigit is a macro using a table.
> I don't think it need be implemented in this way because
> something like '0' <= C && C<='9' is good enough.

That's still a table lookup, of sorts.  The implementation can do
whatever it wants under the hood, as long as the as-if rule is honored
and you get the same results.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20130523/62aa3608/attachment.sig>


More information about the Newlib mailing list