bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'mbsinit'


From: Paul Eggert
Subject: Re: new module 'mbsinit'
Date: Wed, 17 Dec 2008 16:48:32 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

Bruno Haible <address@hidden> writes:

> int
> mbsinit (const mbstate_t *ps)
> {
>   const char *pstate = (const char *)ps;
>
>   return pstate[0] == 0;
> }

If I understand things correctly, this code is hijacking the underlying
system's mbstate_t type and using it for its own purposes?  The idea
being that other gnulib code will be consistent with this?  If so,
perhaps this should appear in the source code, as a comment.  (The idea
of hijacking system data structures gives me the willies; I suppose it
works on all the platforms we care about, but there should be a comment
about it somewhere....)

>    We assume that
>      - sizeof (mbstate_t) >= 4,

How about adding a "verify (sizeof (mbstate_t) >= 4);" so that this
assumption is checked by the compiler?  Or is there some concern that
might define mbstate_t to be an incomplete type?  (If so, that could be
checked at configure-time, though this may be overkill....)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]