This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.
     One other general thought.  All of the new functions are from
wchar.h.  But all of the files are being put into the stdio directory
(following the lead of some others that are that way), which is already
pretty big at this point.  Would it make sense to make a new wchar
directory for the wchar.h items?  (It's sometimes hard to find things
now, as where they are is does not seem to be completely consistent.)
				Craig  

-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
On Behalf Of Corinna Vinschen
Sent: Wednesday, December 10, 2008 9:33 AM
To: newlib@sourceware.org
Subject: Re: [PATCH]: Implement fwide (was Re: swprintf() and friends?)

Jeff?

Did you have a look in the meantime?


Thanks,
Corinna

On Dec  4 15:05, Corinna Vinschen wrote:
...
> 
> 
> 	Implement basic wide char stdio functionality, based on FreeBSD.
> 	* libc/include/stdio.h (__SORD): Define.
> 	(__SWID): Define.
> 	* libc/include/wchar.h: Add declarations for new wide char
functions.
> 	(getwc): Define as macro.
> 	(getwchar): Ditto.
> 	(putwc): Ditto.
> 	(putwchar): Ditto.
> 	* libc/include/sys/reent.h (struct __sFILE): Add _mbstate
member.
> 	(struct __sFILE64): Ditto.
> 	* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add fgetwc.c,
fgetws.c,
> 	fputwc.c, fputws.c, fwide.c, getwc.c, getwchar.c, putwc.c,
putwchar.c
> 	and ungetwc.c.
> 	(CHEWOUT_FILES): Add fgetwc.def, fgetws.def, fputwc.def,
fputws.def,
> 	fwide.def, getwc.def, getwchar.def, putwc.def, putwchar.def and
> 	ungetwc.def.
> 	Add header dependency rules for the new files.
> 	* libc/stdio/Makefile.in: Regenerate.
> 	* libc/stdio/fgetwc.c: New file, implementing fgetwc and
_fgetwc_r.
> 	* libc/stdio/fgetws.c: New file, implementing fgetws and
_fgetws_r.
> 	* libc/stdio/findfp.c (std): Initialize FILE's _mbstate member.
> 	(__sfmoreglue): Ditto.
> 	* libc/stdio/fputs.c (_fputs_r): Set stream orientation.
> 	* libc/stdio/fputwc.c: New file, implementing fputwc and
_fputwc_r.
> 	* libc/stdio/fputws.c: New file, implementing fputws and
_fputws_r.
> 	* libc/stdio/fread.c (_fread_r): Set stream orientation.
> 	* libc/stdio/freopen.c (_freopen_r): Reset stream orientation.
Reset
> 	_mbstate.
> 	* libc/stdio/fseek.c (_fseek_r): Reset _mbstate.
> 	* libc/stdio/fwide.c: New file, implementing fwide and _fwide_r.
> 	* libc/stdio/fwrite.c (_fwrite_r): Set stream orientation.
> 	* libc/stdio/getwc.c: New file, implementing getwc and _getwc_r.
> 	* libc/stdio/getwchar.c: New file, implementing getwchar and
> 	_getwchar_r.
> 	* libc/stdio/local.h (ORIENT): New macro.
> 	* libc/stdio/puts.c (_puts_r): Set stream orientation.
> 	* libc/stdio/putwc.c: New file, implementing putwc and _putwc_r.
> 	* libc/stdio/putwchar.c: New file, implementing putwchar and
> 	_putwchar_r.
> 	* libc/stdio/refill.c (__srefill_r): Set stream orientation.
> 	* libc/stdio/stdio.tex: Add documentation for new functions.
> 	* libc/stdio/ungetc.c (_ungetc_r): Set stream orientation.
> 	* libc/stdio/ungetwc.c: New file, implementing ungetwc and
_ungetwc_r.
> 	* libc/stdio/vfscanf.c (__SVFSCANF_R): Set stream orientation.
> 	* libc/stdio/wbuf.c (__swbuf_r): Ditto.
> 
...
> 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	4 Dec 2008 14:03:04 -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_ */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]