bug-gnulib
[Top][All Lists]
Advanced

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

Re: new module mbrtoc32-regular


From: Paul Eggert
Subject: Re: new module mbrtoc32-regular
Date: Tue, 11 Jul 2023 09:14:07 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

On 2023-07-10 15:45, Bruno Haible wrote:
DEFINITION: We call an mbrtoc32 function_regular_  if
   - It never returns (size_t)-3.
   - When it returns < (size_t)-2, the mbstate_t is in the initial state.

"the initial state" -> "an initial state". But even with that change isn't the second part of this definition a bit too strict? Even if mbsinit returns nonzero, things are still OK if further scanning behaves as if the mbstate_t were all zero. Although this implementation behavior would be silly, POSIX doesn't prohibit it, and it would suffice for mbcel and should suffice for similar uses.

That being said, I think the newly-added test-mbrtoc32-regular.c, which uses mbrinit, is OK, as it should pass on all practical platforms. If an oddball platform ever comes up we can worry about it then.


+#  if GNULIB_MBRTOC32_REGULAR
+  /* Verify that mbrtoc32 is regular.  */
+  if (ret < (size_t) -3 && ! mbsinit (ps))
+    /* This occurs on glibc 2.36.  */
+    memset (ps, '\0', sizeof (mbstate_t));
+  if (ret == (size_t) -3)
+    abort ();
+#  endif

Since this is inside mbrtoc32, performance is relevant, so shouldn't this be tested at configure-time instead of at run-time? That is, shouldn't the "#if" test be something more like "#if GNULIB_MBRTOC32_REGULAR && HAVE_MBRTOC32_RETURNS_MINUS_3", where GNULIB_MBRTOC32_RETURNS_MINUS_3 is zero on all known platforms?



reply via email to

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