Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Latest CVS + ZLE_UNICODE_SUPPORT on RHEL3



Peter Stephenson wrote:
> Andrey Borzenkov wrote:
> > Oh, and for some reasons mbrtowc(&outchar, &cnull, 1, &ps) segfaulted on me
> > (Mandrake cooker).
> 
> Hmmm... that was the only way I could see to ensure the shift state was
> initialised.  The documentation suggested ps was otherwise assumed to be
> valid, which it can't be for the first character.  However, I may be
> missing the intention.

I looked further.  The glibc documentation says

       An mbstate_t  object  a  can  be
       initialized to the initial state by zeroing it, for example using

              memset(&a, 0, sizeof(a));

but the standard gives no indication this is portable (though clearly
it would be a perfectly acceptable extension).  The standard does refer
obscurely to a "zero-valued mbstate_t" object in the documentation for
mbsinit() (which, maddeningly, tests whether the object is in the
initial state but doesn't set it).  However, that's not the same thing
as saying you can memset() an mbstate_t value to zero --- for example, a
zero-valued floating point number is not necessarily represented by a
set of zero bytes.  Still, maybe that's the best we're going to get?

Alternatively, since we're not going to be using this in multiple
threads, we could use a NULL pointer and rely on the internal state.
However, I would then be worried about what happened after we'd read
an invalid character; we might end up screwing up input permanently.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author