[TRE-general] Bug in TRE 0.7.5: Undefined HAVE_MBSTATE_T strips essential declaration

Ville Laurikari ville at laurikari.net
Thu Mar 22 20:40:01 EET 2007


On Wed, Mar 21, 2007 at 06:03:47PM +0100, Sebastian Pipping wrote:
>    00068 #ifdef HAVE_MBSTATE_T
>    00069       mbstate_t state;
>    00070       memset(&state, '\0', sizeof(state));
>    00071 #endif /* HAVE_MBSTATE_T */
>    00072       while (n > 0)
>    00073 	{
>    00074 	  consumed = tre_mbrtowc(wcptr, regex, n, &state);
>
> If HAVE_MBSTATE_T is off then "state" will be used
> in line 74 though undeclared.

Actually, the HAVE_MBSTATE_T and HAVE_MBRTOWC macros aren't
orthogonal.  If HAVE_MBRTOWC is defined, then HAVE_MBSTATE_T must also
be defined.  This is admittedly not very clean and certainly not
documented anywhere.  Anyway, this has the effect that if
HAVE_MBSTATE_T is not defined, then tre_mbrtowc will ignore its last
argument.  You can confirm this by reading the definition for
tre_mbrtowc in tre-internal.h.

>From your posts I'm guessing you're porting TRE to a system which is
not UNIX-like (otherwise you could just run the configure script) and
not Windows either (you could then just use the win32/tre.dsw project
file).  Or, you're porting it for Windows and you're just not using
Visual Studio.

--
http://www.iki.fi/vl/


More information about the TRE-general mailing list