* doc/posix-headers/limits.texi: Document the issue.
* lib/limits.in.h (MB_LEN_MAX): New macro, if not already defined.
* m4/limits-h.m4 (gl_LIMITS_H): Test for MB_LEN_MAX.
* tests/test-limits-h.c: Check that it’s positive.
---
 ChangeLog                     | 8 ++++++++
 doc/posix-headers/limits.texi | 3 +++
 lib/limits.in.h               | 5 +++++
 m4/limits-h.m4                | 1 +
 tests/test-limits-h.c         | 2 ++
 5 files changed, 19 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index e25324c3de..8f03557265 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-05-01  Paul Eggert  <egg...@cs.ucla.edu>
+
+       limits-h: port to pcc
+       * doc/posix-headers/limits.texi: Document the issue.
+       * lib/limits.in.h (MB_LEN_MAX): New macro, if not already defined.
+       * m4/limits-h.m4 (gl_LIMITS_H): Test for MB_LEN_MAX.
+       * tests/test-limits-h.c: Check that it’s positive.
+
 2023-04-28  Paul Eggert  <egg...@cs.ucla.edu>
 
        year2038-recommended: new module
diff --git a/doc/posix-headers/limits.texi b/doc/posix-headers/limits.texi
index 09440cac8d..5fdcd14546 100644
--- a/doc/posix-headers/limits.texi
+++ b/doc/posix-headers/limits.texi
@@ -12,6 +12,9 @@ The macros @code{LLONG_MIN}, @code{LLONG_MAX}, 
@code{ULLONG_MAX} are not
 defined on some platforms:
 older glibc systems (e.g. Fedora 1), AIX 5.1, HP-UX 11, IRIX 6.5, OpenVMS.
 @item
+The macro @code{MB_LEN_MAX} is not defined on some platforms:
+pcc 1.2.0.DEVEL 20220331.
+@item
 The macros @code{WORD_BIT}, @code{LONG_BIT} are not defined on some platforms:
 glibc 2.11 without @code{-D_GNU_SOURCE}, Cygwin, mingw, MSVC 14.
 @item
diff --git a/lib/limits.in.h b/lib/limits.in.h
index a01b4c6a28..45d46fd689 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -99,6 +99,11 @@
 # endif
 #endif
 
+/* Assume no multibyte character is longer than 16 bytes.  */
+#ifndef MB_LEN_MAX
+# define MB_LEN_MAX 16
+#endif
+
 /* Macros specified by C23 and by ISO/IEC TS 18661-1:2014.  */
 
 #if (! defined ULLONG_WIDTH                                             \
diff --git a/m4/limits-h.m4 b/m4/limits-h.m4
index 4f8ce41098..ca0294e550 100644
--- a/m4/limits-h.m4
+++ b/m4/limits-h.m4
@@ -24,6 +24,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H],
             int ullw = ULLONG_WIDTH;
             int bw = BOOL_WIDTH;
             int bm = BOOL_MAX;
+            int mblm = MB_LEN_MAX;
           ]])],
        [gl_cv_header_limits_width=yes],
        [gl_cv_header_limits_width=no])])
diff --git a/tests/test-limits-h.c b/tests/test-limits-h.c
index d8cdac288d..d7cfba7131 100644
--- a/tests/test-limits-h.c
+++ b/tests/test-limits-h.c
@@ -113,6 +113,8 @@ verify_width (ULLONG_WIDTH, 0, ULLONG_MAX);
 int bool_attrs[] = { BOOL_MAX, BOOL_WIDTH };
 static_assert (BOOL_MAX == (((1U << (BOOL_WIDTH - 1)) - 1) * 2) + 1);
 
+static_assert (0 < MB_LEN_MAX);
+
 int
 main (void)
 {
-- 
2.39.2


Reply via email to