[PATCH]: Implement fwide (was Re: swprintf() and friends?)

Corinna Vinschen vinschen@redhat.com
Thu Dec 11 00:34:00 GMT 2008


On Dec 10 16:06, Howland Craig D (Craig) wrote:
> Corinna:
>      I looked over the changes for wchar.h, and confirmed what is added
> against what C99 requires in terms of the prototypes.  One minor issue
> is that there's an inconsistency in the use of __FILE versus FILE
> (__FILE occurs 4 times).  For example:
> > +int _EXFUN(fputws, (const wchar_t *, FILE *));
> > +int _EXFUN (fwide, (__FILE *, int));
> I'd think that we'd want FILE for all.

No, I think it should be __FILE.  Otherwise you would force any
source including wchar.h to include stdio.h as well.

I already patched that in my local sources but forgot to submit the
change so far.  Sorry about that.


Corinna


Index: libc/include/wchar.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/wchar.h,v
retrieving revision 1.17
diff -u -p -r1.17 wchar.h
--- libc/include/wchar.h	27 Nov 2008 20:45:37 -0000	1.17
+++ libc/include/wchar.h	10 Dec 2008 21:27:29 -0000
@@ -91,6 +91,33 @@ long long _EXFUN(_wcstoll_r, (struct _re
 unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *, wchar_t **, int));
 unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const wchar_t *, wchar_t **, int));
 
+wint_t _EXFUN(fgetwc, (__FILE *));
+wchar_t *_EXFUN(fgetws, (wchar_t *, int, __FILE *));
+wint_t _EXFUN(fputwc, (wchar_t, __FILE *));
+int _EXFUN(fputws, (const wchar_t *, __FILE *));
+int _EXFUN (fwide, (__FILE *, int));
+wint_t _EXFUN (getwc, (__FILE *));
+wint_t _EXFUN (getwchar, (void));
+wint_t _EXFUN(putwc, (wchar_t, __FILE *));
+wint_t _EXFUN(putwchar, (wchar_t));
+wint_t _EXFUN (ungetwc, (wint_t wc, __FILE *));
+
+wint_t _EXFUN(_fgetwc_r, (struct _reent *, __FILE *));
+wchar_t *_EXFUN(_fgetws_r, (struct _reent *, wchar_t *, int, __FILE *));
+wint_t _EXFUN(_fputwc_r, (struct _reent *, wchar_t, __FILE *));
+int _EXFUN(_fputws_r, (struct _reent *, const wchar_t *, __FILE *));
+int _EXFUN (_fwide_r, (struct _reent *, __FILE *, int));
+wint_t _EXFUN (_getwc_r, (struct _reent *, __FILE *));
+wint_t _EXFUN (_getwchar_r, (struct _reent *ptr));
+wint_t _EXFUN(_putwc_r, (struct _reent *, wchar_t, __FILE *));
+wint_t _EXFUN(_putwchar_r, (struct _reent *, wchar_t));
+wint_t _EXFUN (_ungetwc_r, (struct _reent *, wint_t wc, __FILE *));
+
+#define getwc(fp)	fgetwc(fp)
+#define getwchar()	fgetwc(stdin)
+#define putwc(wc,fp)	fputwc((wc), (fp))
+#define putwchar(wc)	fputwc((wc), stdout)
+
 _END_STD_C
 
 #endif /* _WCHAR_H_ */

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat



More information about the Newlib mailing list