wprintf anybody?

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Apr 10 09:22:00 GMT 2008

On Apr  9 14:34, Brian Dessent wrote:
> Corinna Vinschen wrote:
> > while we're at it, multibyte/wide chars and all, I just found that it
> > would be helpful to have the wprintf family of functions, and possibly
> > related stuff like fputwc, fputws, fgetwc, fgetws and fwide.  Is anybody
> > here interested in adding this to Cygwin or, FWIW, newlib?
> I had a tentative spot on my TODO to simply audit Cygwin+newlib for the
> current state of C99 wchar_t support, and make a list of what all is
> missing.  I have a feeling it's a lot, but I agree that low hanging

Looking into newlib, I don't think it's really a lot.  It's more about
complexity.  Most of the usual string manipulation functions exist.

What's missing is a real LC_COLLATE implementation, so that wcscoll
and wcsxfrm (and, FWIW, strcoll and strxfrm) are not just simple cmp
and cpy functions.

What's missing are the float to string functions wcstof, wcstod,

And what's missing is wchar_t IO like fputwc, fgetws and wprintf.

I think that's it, basically.  Are you going to take a stab at it?

> fruit like wprintf would be a good idea to have.  I'm sure that
> libstdc++ could benefit from this, since at the moment I think it has
> all wide character support disabled due to no underlying libc support.
> Oh and that reminds me... There is this little gem in syscalls.cc:
> /* FIXME: to do this right, maybe work out the usoft va_list machine
>    and use wsvprintfW instead?
> */
> extern "C" int
> wprintf (const char *fmt, ...)
> {
>   va_list ap;
>   int ret;
>   va_start (ap, fmt);
>   ret = vprintf (fmt, ap);
>   va_end (ap);
>   return ret;
> }
> Naturally, we never exported this function so it didn't cause any
> damage.

Unfortunately we *do* export this function.  Oh crap!

> But from what I can tell from a dig through the ChangeLogs,
> this little guy dates back to at least 1996, and he's just been sitting
> there doing nothing and being useless the whole time.

I seriously hope nobody ever used it.  I will remove this function for
now.  We will see if something breaks.  If so, the more we need a
working implementation of it.


(*) Above all, wcstold is missing because there's no long double support
    in newlib.  There's not a single long double function so far.
    Too bad that sizeof (long double) > sizeof (double)...

Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

More information about the Cygwin-developers mailing list