This is the mail archive of the 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?)

I was actually just reading in the C99 standard that the function
for fwide() calls for stdio.h to be included before fwide.h:
#include <stdio.h>
#include <wchar.h>
int fwide(FILE *stream, int mode);
POSIX calls for the same thing.
In fact, for all fwide.h funtions that contain FILE in the function
protoype, the C99 standard shows #include <stdio.h> first.  So I was
wondering if the synopsis in the new fwide.c ought to have the
#include <stdio.h> just to match what both C99 and POSIX say.  That
would actually address the problem that you are addressing in a
different manner in this last email, but it doesn't help a compile
on the prototype when using wchar.h with one of the functions that
tell you to use stdio.h also, so the fix described here is needed,
Two other comments related to the new fwide.c.
1)  The comments in the start of the file say C99 and POSIX.1-2001.
POSIX adds (with respect to C99) setting errno to EBADF if the stream
argument is invalid.  However, this is not done.  So either setting
errno should be added or the POSIX note should be deleted.  What is
the better approach?
2)  Another comment at the start of the file says "Once a stream has an
orientation, it cannot be changed and persists until the stream is
Actually, C99 allows it to be changed by freopen() (end of the paragraph
at the top of the page on page 264, which is paragraph 4 in section
7.19.2).  A proposed modification is:
"Once a stream has an orientation, it cannot be changed and persists
until the stream is closed, unless the stream is re-opened with freopen,
which removes the orientation of the stream."
I've attached a patch file as an alternative new fwide.c that adds the
stdio.h include that the standards call for (even though they are not
really needed) and that has an alternate wording for my second comment.
I did not do anything to address my #1, as there's a question as to
the approach to take.  Of course, it is a question as to whether the
spurious stdio include should be there or not, but I tossed it in so
that it matches the letter of the standards.
Craig Howland

-----Original Message-----
From: []
On Behalf Of Corinna Vinschen
Sent: Friday, November 07, 2008 10:18 AM
Subject: Re: [PATCH]: Implement fwide (was Re: swprintf() and friends?)

On Nov  7 15:11, Corinna Vinschen wrote:
> Index: libc/include/wchar.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/wchar.h,v
> retrieving revision 1.16
> diff -u -p -r1.16 wchar.h
> --- libc/include/wchar.h	19 Dec 2007 17:33:11 -0000	1.16
> +++ libc/include/wchar.h	7 Nov 2008 14:07:05 -0000
> @@ -90,6 +90,9 @@ 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));
> +int _EXFUN (fwide, (FILE *, int));
> +int _EXFUN (_fwide_r, (struct _reent *, FILE *, int));
> +
>  #endif /* _WCHAR_H_ */

Make that

  int _EXFUN (fwide, (__FILE *, int));
  int _EXFUN (_fwide_r, (struct _reent *, __FILE *, int));

otherwise we would have to include stdio.h from wchar.h.


Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

Attachment: altfwide_c.patch
Description: altfwide_c.patch

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