msvcrt: portable printf integer conversions

Jesse Allen the3dfxdude at gmail.com
Mon Sep 26 22:43:57 CDT 2005


On 9/26/05, Mike McCormack <mike at codeweavers.com> wrote:
>
> Hi Jesse,
>
>
> Code to handle %I64 and %I32 has been missing for a while.  Thanks for
> looking into this.
>
> Please make sure to write some test cases, as changing it will probably
> break something (or even make some of the current test cases pass).
>
> If you look at glibc's printf code, you'll realize how messy complete
> printf handling is...  IMO, it would be better to let glibc handle the
> complexities of printf where possible, and work around the differences
> as we have done so far.
>
> Some comments on the patch:
>
> > +    if( flags->Format == 'X' )
> > +        digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> > +    else
> > +        digits = "0123456789abcdefghijklmnopqrstuvwxyz";
>
> Do you really need the whole alphabet?

Heh,
I've read various printf implementation over time.  The last one,
ReactOS, seemed to provide support for numbering systems base 2
through 36.  You'll see my version does mimic theirs, but we never do
anything other than 8, 10, and 16.  I'm not sure if there is any
printf out there that actually allows you to specify the base.  For
this patch it could easily be cut to the 'f' as maximum, except I use
the 'x' digit in the case of the special 0x and 0X prepending cases. 
To change that, we just add in a test for the large type there.
>
> > +                else if( *(p+1) == '3' && *(p+2) == '2' )
> > +                {
> > +                    FIXME("%%I32 unhandled\n");
> > +                    p += 3;
> > +                }
> > +                else
> > +                {
> > +                    FIXME("%%I unhandled\n");
> > +                    p++;
>
> Seems like if you have the code to do %I64, then doing %I32 would be
> easy too...

Exactly, although we could forward I32 to libc's right?

>
> I think that you'll find that %I31 is invalid, but again you'll need a
> test case to make sure.
>
> Mike
>

I believe what happens if you pass a number other that 32 or 64, the
conversion stops.  Note that I64 floats will be just processed like
integers?  Not a big deal as we lacked any real function before.

I will pull up my patch of test cases (never applied) from last time
and see if it will still work against cvs.

Jesse



More information about the wine-devel mailing list