summaryrefslogtreecommitdiffstats
path: root/gl/m4/mbrtowc.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/mbrtowc.m4')
-rw-r--r--gl/m4/mbrtowc.m473
1 files changed, 7 insertions, 66 deletions
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4
index cc09a5fb..a49872fa 100644
--- a/gl/m4/mbrtowc.m4
+++ b/gl/m4/mbrtowc.m4
@@ -1,6 +1,6 @@
1# mbrtowc.m4 1# mbrtowc.m4
2# serial 46 2# serial 47
3dnl Copyright (C) 2001-2002, 2004-2005, 2008-2025 Free Software Foundation, 3dnl Copyright (C) 2001-2002, 2004-2005, 2008-2026 Free Software Foundation,
4dnl Inc. 4dnl Inc.
5dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
@@ -33,7 +33,6 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
33 REPLACE_MBRTOWC=1 33 REPLACE_MBRTOWC=1
34 else 34 else
35 gl_MBRTOWC_NULL_ARG1 35 gl_MBRTOWC_NULL_ARG1
36 gl_MBRTOWC_NULL_ARG2
37 gl_MBRTOWC_RETVAL 36 gl_MBRTOWC_RETVAL
38 gl_MBRTOWC_NUL_RETVAL 37 gl_MBRTOWC_NUL_RETVAL
39 gl_MBRTOWC_STORES_INCOMPLETE 38 gl_MBRTOWC_STORES_INCOMPLETE
@@ -46,13 +45,6 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
46 REPLACE_MBRTOWC=1 45 REPLACE_MBRTOWC=1
47 ;; 46 ;;
48 esac 47 esac
49 case "$gl_cv_func_mbrtowc_null_arg2" in
50 *yes) ;;
51 *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1],
52 [Define if the mbrtowc function has the NULL string argument bug.])
53 REPLACE_MBRTOWC=1
54 ;;
55 esac
56 case "$gl_cv_func_mbrtowc_retval" in 48 case "$gl_cv_func_mbrtowc_retval" in
57 *yes) ;; 49 *yes) ;;
58 *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], 50 *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
@@ -170,10 +162,10 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
170 dnl is present. 162 dnl is present.
171changequote(,)dnl 163changequote(,)dnl
172 case "$host_os" in 164 case "$host_os" in
173 # Guess no on AIX and OSF/1. 165 # Guess no on AIX.
174 aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; 166 aix*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
175 # Guess yes otherwise. 167 # Guess yes otherwise.
176 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; 168 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
177 esac 169 esac
178changequote([,])dnl 170changequote([,])dnl
179 if test $LOCALE_JA != none; then 171 if test $LOCALE_JA != none; then
@@ -346,57 +338,6 @@ int main ()
346 ]) 338 ])
347]) 339])
348 340
349dnl Test whether mbrtowc supports a NULL string argument correctly.
350dnl Result is gl_cv_func_mbrtowc_null_arg2.
351
352AC_DEFUN([gl_MBRTOWC_NULL_ARG2],
353[
354 AC_REQUIRE([AC_PROG_CC])
355 AC_REQUIRE([gt_LOCALE_EN_UTF8])
356 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
357 AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
358 [gl_cv_func_mbrtowc_null_arg2],
359 [
360 dnl Initial guess, used when cross-compiling or when no suitable locale
361 dnl is present.
362changequote(,)dnl
363 case "$host_os" in
364 # Guess no on OSF/1.
365 osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;;
366 # Guess yes otherwise.
367 *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;;
368 esac
369changequote([,])dnl
370 if test "$LOCALE_EN_UTF8" != none; then
371 AC_RUN_IFELSE(
372 [AC_LANG_SOURCE([[
373#include <locale.h>
374#include <string.h>
375#include <wchar.h>
376int main ()
377{
378 if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
379 {
380 mbstate_t state;
381 wchar_t wc;
382 int ret;
383
384 memset (&state, '\0', sizeof (mbstate_t));
385 wc = (wchar_t) 0xBADFACE;
386 mbrtowc (&wc, NULL, 5, &state);
387 /* Check that wc was not modified. */
388 if (wc != (wchar_t) 0xBADFACE)
389 return 2;
390 }
391 return 0;
392}]])],
393 [gl_cv_func_mbrtowc_null_arg2=yes],
394 [gl_cv_func_mbrtowc_null_arg2=no],
395 [:])
396 fi
397 ])
398])
399
400dnl Test whether mbrtowc, when parsing the end of a multibyte character, 341dnl Test whether mbrtowc, when parsing the end of a multibyte character,
401dnl correctly returns the number of bytes that were needed to complete the 342dnl correctly returns the number of bytes that were needed to complete the
402dnl character (not the total number of bytes of the multibyte character). 343dnl character (not the total number of bytes of the multibyte character).
@@ -716,7 +657,7 @@ AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT],
716dnl Test whether mbrtowc reports encoding errors in the C locale. 657dnl Test whether mbrtowc reports encoding errors in the C locale.
717dnl Although POSIX was never intended to allow this, the GNU C Library 658dnl Although POSIX was never intended to allow this, the GNU C Library
718dnl and other implementations do it. See: 659dnl and other implementations do it. See:
719dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 660dnl https://sourceware.org/PR19932
720dnl POSIX has now clarified it: 661dnl POSIX has now clarified it:
721dnl <https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrtowc.html> 662dnl <https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrtowc.html>
722dnl says: "In the POSIX locale an [EILSEQ] error cannot occur since all byte 663dnl says: "In the POSIX locale an [EILSEQ] error cannot occur since all byte