i18n: done
Markus Kuhn
Markus.Kuhn@cl.cam.ac.uk
Fri Feb 2 11:57:00 GMT 2001
Ulrich Drepper wrote on 2001-02-02 09:26 UTC:
> Today is a pretty important day. With the regex changes by Isamu
> Hasegawa the internationalization support in glibc is basically done.
Congratulations! Excellent achievement!
> I cannot think of any documented and required functionality missing
> which leaves "only" documentation. There are a few more functions
> coming in the future but they are not based on existing interfaces.
There is one relatively minor but nevertheless critical thing with the
current i18n code that I really would love to see fixed:
Isn't it possible to have fwide(...,1)==1 and fwide(...,-1)==-1 succeed
in changing the already set orientation of a stream? In particular, it
would be practically very important that changing the orientation of a
stream works for the three standard streams. Otherwise we get into big
troubles if different modules of a program try to access the same stream
in different orientations.
In other words, I'd wish that the following test always passes under
glibc:
assert(fwide( stdin, -1) == -1);
assert(fwide( stdin, 1) == 1);
assert(fwide( stdin, -1) == -1);
assert(fwide(stdout, -1) == -1);
assert(fwide(stdout, 1) == 1);
assert(fwide(stdout, -1) == -1);
assert(fwide(stderr, -1) == -1);
assert(fwide(stderr, 1) == 1);
assert(fwide(stderr, -1) == -1);
I understand that the buffer structures for byte and wide streams look
different, but at least with an empty buffer after an fflush it should
not be a big deal at all to change the orientation.
It is certainly much better to fflush a buffer and then to change the
orientation with empty buffers than to let fwide() simply fail every
time. I know that this is not required by the letter of the standard,
but this would be a very helpful detail where it seems worth to exceed
the required minimum spec a little bit. Unix guarantees many nice
implementation features that the ISO C standard does not require, and
this should be another one. I don't care much if the user has to do the
fflush on a stream herself before you allow an fwide to succeed in
changing the direction or if fwide does the fflush automatically if
necessary (probably preferable). But simply having no change of getting
stderr back to byte mode once some module has started using it in wide
mode is a quite severe and very unfortunate restriction of
functionality.
At the moment, libio/iofwide.c simply says
if (fp->_mode != 0)
/* The orientation already has been determined. */
return fp->_mode;
which means that once the mode has been set for a stream, it can never
every be changed again, except via reopening it (which is not possible
for the three standard streams).
Markus
--
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org, WWW: < http://www.cl.cam.ac.uk/~mgk25/ >
More information about the Libc-alpha
mailing list