Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Feb 2002 08:48:10 -0800
From:      Bill Fenner <fenner@research.att.com>
To:        bde@zeta.org.au
Cc:        standards@freebsd.org
Subject:   Re: scanf(3) patches for review
Message-ID:  <200202261648.IAA20603@windsor.research.att.com>

next in thread | raw e-mail | index | archive | help

>Better code would use a a specialized function for each result type and
>not risk gratutous sign extension bugs for storing all the results in a
>common type.

I actually typedef'd a type to avoid all the prototype-free casts:

typedef uintmax_t (*ccfn_t) (const char *, char **, int);

The big if is almost there already (as you noted later), dealing with
assigning back to the right vararg type.  Strictly speaking, it's cheating
for unsigned values, so a truly correct function would have to have the
extra ifs for signed/unsigned anyway.  At that point, putting the right
conversion function instead of "res" would be trivial.

>Strictly, uintmax_t is not suitable for storing pointers.

I thought uintmax_t was the largest integer type, and uintptr_t was
an integer type large enough to store a pointer -- so
sizeof(uintmax_t) >= sizeof(uintptr_t).

  Bill

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-standards" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202261648.IAA20603>