bug-gnulib
[Top][All Lists]
Advanced

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

Re: new module 'mbsinit'


From: Bruno Haible
Subject: Re: new module 'mbsinit'
Date: Thu, 18 Dec 2008 02:06:52 +0100
User-agent: KMail/1.9.9

Hey Paul!

Paul Eggert wrote:
> 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?

Yes, this is so. There is a comment that explains it: On these platforms
the system lacks not only mbsinit() but all functions that deal with
with mbstate_t. Therefore we are free to assign a meaning to it.

> >    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?

Good idea! Done:

2008-12-17  Bruno Haible  <address@hidden>

        * lib/mbsinit.c: Include verify.h. Verify an assumption.
        * modules/mbsinit (Depends-on): Add verify.
        Suggested by Paul Eggert.

--- lib/mbsinit.c.orig  2008-12-18 02:00:35.000000000 +0100
+++ lib/mbsinit.c       2008-12-18 02:00:18.000000000 +0100
@@ -20,6 +20,8 @@
 /* Specification.  */
 #include <wchar.h>
 
+#include "verify.h"
+
 /* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
    and wcrtomb(), wcsrtombs().
    We assume that
@@ -34,6 +36,8 @@
      - In wc -> mb direction, mbstate_t contains no information. In other
        words, it is always in the initial state.  */
 
+verify (sizeof (mbstate_t) >= 4);
+
 int
 mbsinit (const mbstate_t *ps)
 {
--- modules/mbsinit.orig        2008-12-18 02:00:35.000000000 +0100
+++ modules/mbsinit     2008-12-18 01:58:54.000000000 +0100
@@ -8,6 +8,7 @@
 
 Depends-on:
 wchar
+verify
 
 configure.ac:
 gl_FUNC_MBSINIT




reply via email to

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