# HG changeset patch # User Bruno Haible # Date 1229944304 -3600 # Node ID a0bbe1a6f787380cba98a3e5fcd2ae7efb136003 # Parent 402b52de2fa270fb884cc6d4baa8be748d291ee3 Remove HAVE_MBRTOWC conditionals. Use mbrtowc unconditionally. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,45 @@ +2008-12-22 Bruno Haible + + Remove HAVE_MBRTOWC conditionals. + * lib/mbscasecmp.c: Include mbuiter.h unconditionally. + (mbscasecmp): Assume mbrtowc function. + * lib/mbscasestr.c: Include mbuiter.h unconditionally. + (knuth_morris_pratt_multibyte, mbscasestr): Assume mbrtowc function. + * lib/mbschr.c: Include mbuiter.h unconditionally. + (mbschr): Assume mbrtowc function. + * lib/mbscspn.c: Include mbuiter.h unconditionally. + (mbscspn): Assume mbrtowc function. + * lib/mbslen.c: Include mbuiter.h unconditionally. + (mbslen): Assume mbrtowc function. + * lib/mbsncasecmp.c: Include mbuiter.h unconditionally. + (mbsncasecmp): Assume mbrtowc function. + * lib/mbsnlen.c: Include mbiter.h unconditionally. + (mbsnlen): Assume mbrtowc function. + * lib/mbspbrk.c: Include mbuiter.h unconditionally. + (mbspbrk): Assume mbrtowc function. + * lib/mbspcasecmp.c: Include mbuiter.h unconditionally. + (mbspcasecmp): Assume mbrtowc function. + * lib/mbsrchr.c: Include mbuiter.h unconditionally. + (mbsrchr): Assume mbrtowc function. + * lib/mbssep.c: Include mbuiter.h unconditionally. + (mbssep): Assume mbrtowc function. + * lib/mbsspn.c: Include mbuiter.h unconditionally. + (mbsspn): Assume mbrtowc function. + * lib/mbsstr.c: Include mbuiter.h unconditionally. + (knuth_morris_pratt_multibyte, mbsstr): Assume mbrtowc function. + * lib/mbstok_r.c: Include mbuiter.h unconditionally. + (mbstok_r): Assume mbrtowc function. + * lib/propername.c: Include mbuiter.h unconditionally. + (mbsstr_trimmed_wordbounded): Assume mbrtowc function. + * lib/trim.c: Include mbchar.h, mbiter.h uncondtionally. + (trim2): Assume mbrtowc function. + * lib/mbswidth.c (mbsinit): Remove fallback definition. + (mbsnwidth): Assume mbrtowc function. + * modules/mbswidth (Depends-on): Add mbrtowc, mbsinit. + * lib/quotearg.c (MB_CUR_MAX, mbstate_t, mbrtowc, iswprint): Remove + fallback definitions. + * modules/quotearg (Depends-on): Add mbrtowc, mbsinit. + 2008-12-22 Bruno Haible * doc/posix-functions/mbtowc.texi: Mention a glibc bug. diff --git a/lib/mbscasecmp.c b/lib/mbscasecmp.c --- a/lib/mbscasecmp.c +++ b/lib/mbscasecmp.c @@ -1,5 +1,5 @@ /* Case-insensitive string comparison function. - Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2005, based on earlier glibc code. @@ -24,9 +24,7 @@ #include #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) @@ -44,7 +42,6 @@ /* Be careful not to look at the entire extent of s1 or s2 until needed. This is useful because when two strings differ, the difference is most often already in the very few first characters. */ -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter1; @@ -72,7 +69,6 @@ return 0; } else -#endif { const unsigned char *p1 = (const unsigned char *) s1; const unsigned char *p2 = (const unsigned char *) s2; diff --git a/lib/mbscasestr.c b/lib/mbscasestr.c --- a/lib/mbscasestr.c +++ b/lib/mbscasestr.c @@ -25,9 +25,7 @@ #include /* for NULL, in case a nonstandard string.h lacks it */ #include "malloca.h" -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) @@ -35,7 +33,6 @@ #define CANON_ELEMENT(c) TOLOWER (c) #include "str-kmp.h" -#if HAVE_MBRTOWC /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm Return a boolean indicating success: @@ -192,7 +189,6 @@ freea (memory); return true; } -#endif /* Find the first occurrence of the character string NEEDLE in the character string HAYSTACK, using case-insensitive comparison. @@ -206,7 +202,6 @@ - haystack may be very long, and a match of needle found early, - needle may be very long, and not even a short initial segment of needle may be found in haystack. */ -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter_needle; @@ -319,7 +314,6 @@ return (char *) haystack; } else -#endif { if (*needle != '\0') { diff --git a/lib/mbschr.c b/lib/mbschr.c --- a/lib/mbschr.c +++ b/lib/mbschr.c @@ -1,5 +1,5 @@ /* Searching a string for a character. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -20,16 +20,13 @@ /* Specification. */ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" /* Locate the first single-byte character C in the character string STRING, and return a pointer to it. Return NULL if C is not found in STRING. */ char * mbschr (const char *string, int c) { -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1 /* Optimization: We know that ASCII characters < 0x30 don't occur as part of multibyte characters longer than 1 byte. Hence, if c < 0x30, @@ -51,6 +48,5 @@ return NULL; } else -#endif return strchr (string, c); } diff --git a/lib/mbscspn.c b/lib/mbscspn.c --- a/lib/mbscspn.c +++ b/lib/mbscspn.c @@ -1,5 +1,5 @@ /* Searching a string for a character among a given set of characters. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -20,9 +20,7 @@ /* Specification. */ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" /* Find the first occurrence in the character string STRING of any character in the character string ACCEPT. Return the number of bytes from the @@ -40,7 +38,6 @@ return (ptr != NULL ? ptr - string : strlen (string)); } /* General case. */ -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter; @@ -67,6 +64,5 @@ return mbui_cur_ptr (iter) - string; } else -#endif return strcspn (string, accept); } diff --git a/lib/mbslen.c b/lib/mbslen.c --- a/lib/mbslen.c +++ b/lib/mbslen.c @@ -1,5 +1,5 @@ /* Counting the multibyte characters in a string. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -22,15 +22,12 @@ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" /* Return the number of multibyte characters in the character string STRING. */ size_t mbslen (const char *string) { -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { size_t count; @@ -43,6 +40,5 @@ return count; } else -#endif return strlen (string); } diff --git a/lib/mbsncasecmp.c b/lib/mbsncasecmp.c --- a/lib/mbsncasecmp.c +++ b/lib/mbsncasecmp.c @@ -1,5 +1,5 @@ /* Case-insensitive string comparison function. - Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2005, based on earlier glibc code. @@ -24,9 +24,7 @@ #include #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) @@ -46,7 +44,6 @@ /* Be careful not to look at the entire extent of s1 or s2 until needed. This is useful because when two strings differ, the difference is most often already in the very few first characters. */ -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter1; @@ -77,7 +74,6 @@ return 0; } else -#endif { const unsigned char *p1 = (const unsigned char *) s1; const unsigned char *p2 = (const unsigned char *) s2; diff --git a/lib/mbsnlen.c b/lib/mbsnlen.c --- a/lib/mbsnlen.c +++ b/lib/mbsnlen.c @@ -1,5 +1,5 @@ /* Counting the multibyte characters in a string. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -22,16 +22,13 @@ #include -#if HAVE_MBRTOWC -# include "mbiter.h" -#endif +#include "mbiter.h" /* Return the number of multibyte characters in the character string starting at STRING and ending at STRING + LEN. */ size_t mbsnlen (const char *string, size_t len) { -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { size_t count; @@ -44,6 +41,5 @@ return count; } else -#endif return len; } diff --git a/lib/mbspbrk.c b/lib/mbspbrk.c --- a/lib/mbspbrk.c +++ b/lib/mbspbrk.c @@ -1,5 +1,5 @@ /* Searching a string for a character among a given set of characters. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -20,9 +20,7 @@ /* Specification. */ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" /* Find the first occurrence in the character string STRING of any character in the character string ACCEPT. Return the pointer to it, or NULL if none @@ -36,7 +34,6 @@ if (accept[1] == '\0') return mbschr (string, accept[0]); /* General case. */ -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter; @@ -62,6 +59,5 @@ return NULL; } else -#endif return strpbrk (string, accept); } diff --git a/lib/mbspcasecmp.c b/lib/mbspcasecmp.c --- a/lib/mbspcasecmp.c +++ b/lib/mbspcasecmp.c @@ -1,5 +1,5 @@ /* Case-insensitive string comparison function. - Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -22,9 +22,7 @@ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) @@ -47,7 +45,6 @@ /* Be careful not to look at the entire extent of STRING or PREFIX until needed. This is useful because when two strings differ, the difference is most often already in the very few first characters. */ -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter1; @@ -74,7 +71,6 @@ return NULL; } else -#endif { const unsigned char *p1 = (const unsigned char *) string; const unsigned char *p2 = (const unsigned char *) prefix; diff --git a/lib/mbsrchr.c b/lib/mbsrchr.c --- a/lib/mbsrchr.c +++ b/lib/mbsrchr.c @@ -1,5 +1,5 @@ /* Searching a string for the last occurrence of a character. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -20,16 +20,13 @@ /* Specification. */ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" /* Locate the last single-byte character C in the character string STRING, and return a pointer to it. Return NULL if C is not found in STRING. */ char * mbsrchr (const char *string, int c) { -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1 /* Optimization: We know that ASCII characters < 0x30 don't occur as part of multibyte characters longer than 1 byte. Hence, if c < 0x30, @@ -48,6 +45,5 @@ return (char *) result; } else -#endif return strrchr (string, c); } diff --git a/lib/mbssep.c b/lib/mbssep.c --- a/lib/mbssep.c +++ b/lib/mbssep.c @@ -1,5 +1,5 @@ /* Tokenizing a string. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -20,14 +20,11 @@ /* Specification. */ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" char * mbssep (char **stringp, const char *delim) { -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { char *start = *stringp; @@ -60,6 +57,5 @@ } } else -#endif return strsep (stringp, delim); } diff --git a/lib/mbsspn.c b/lib/mbsspn.c --- a/lib/mbsspn.c +++ b/lib/mbsspn.c @@ -1,5 +1,5 @@ /* Searching a string for a character outside a given set of characters. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -20,9 +20,7 @@ /* Specification. */ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" /* Find the first occurrence in the character string STRING of any character not in the character string REJECT. Return the number of bytes from the @@ -38,7 +36,6 @@ { unsigned char uc = (unsigned char) reject[0]; -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter; @@ -50,7 +47,6 @@ return mbui_cur_ptr (iter) - string; } else -#endif { const char *ptr; @@ -61,7 +57,6 @@ } } /* General case. */ -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter; @@ -90,6 +85,5 @@ return mbui_cur_ptr (iter) - string; } else -#endif return strspn (string, reject); } diff --git a/lib/mbsstr.c b/lib/mbsstr.c --- a/lib/mbsstr.c +++ b/lib/mbsstr.c @@ -24,15 +24,12 @@ #include /* for NULL, in case a nonstandard string.h lacks it */ #include "malloca.h" -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" /* Knuth-Morris-Pratt algorithm. */ #define CANON_ELEMENT(c) c #include "str-kmp.h" -#if HAVE_MBRTOWC /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm Return a boolean indicating success: @@ -178,7 +175,6 @@ freea (memory); return true; } -#endif /* Find the first occurrence of the character string NEEDLE in the character string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. */ @@ -190,7 +186,6 @@ - haystack may be very long, and a match of needle found early, - needle may be very long, and not even a short initial segment of needle may be found in haystack. */ -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t iter_needle; @@ -291,7 +286,6 @@ return (char *) haystack; } else -#endif { if (*needle != '\0') { diff --git a/lib/mbstok_r.c b/lib/mbstok_r.c --- a/lib/mbstok_r.c +++ b/lib/mbstok_r.c @@ -1,5 +1,5 @@ /* Tokenizing a string. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -20,14 +20,11 @@ /* Specification. */ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" char * mbstok_r (char *string, const char *delim, char **save_ptr) { -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { if (string == NULL) @@ -65,6 +62,5 @@ return string; } else -#endif return strtok_r (string, delim, save_ptr); } diff --git a/lib/mbswidth.c b/lib/mbswidth.c --- a/lib/mbswidth.c +++ b/lib/mbswidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2007 Free Software Foundation, Inc. + Copyright (C) 2000-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,12 +35,6 @@ /* Get iswcntrl(). */ #include -#ifndef mbsinit -# if !HAVE_MBSINIT -# define mbsinit(ps) 1 -# endif -#endif - /* Returns the number of columns needed to represent the multibyte character string pointed to by STRING. If a non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. @@ -66,7 +60,6 @@ int width; width = 0; -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { while (p < plimit) @@ -158,7 +151,6 @@ } return width; } -#endif while (p < plimit) { diff --git a/lib/propername.c b/lib/propername.c --- a/lib/propername.c +++ b/lib/propername.c @@ -31,9 +31,7 @@ #include "trim.h" #include "mbchar.h" -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" #include "localcharset.h" #include "c-strcase.h" #include "xstriconv.h" @@ -60,7 +58,6 @@ break; else { -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbui_iterator_t string_iter; @@ -117,7 +114,6 @@ string = tsub_in_string + mb_len (mbui_cur (string_iter)); } else -#endif /* HAVE_MBRTOWC */ { bool word_boundary_before; const char *p; diff --git a/lib/quotearg.c b/lib/quotearg.c --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -37,23 +37,6 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -#if !HAVE_MBRTOWC -/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the - other macros are defined only for documentation and to satisfy C - syntax. */ -# undef MB_CUR_MAX -# define MB_CUR_MAX 1 -# undef mbstate_t -# define mbstate_t int -# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0) -# define iswprint(wc) isprint ((unsigned char) (wc)) -# undef HAVE_MBSINIT -#endif - -#if !defined mbsinit && !HAVE_MBSINIT -# define mbsinit(ps) 1 -#endif - #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif diff --git a/lib/trim.c b/lib/trim.c --- a/lib/trim.c +++ b/lib/trim.c @@ -23,14 +23,11 @@ #include #include +#include +#include -#if HAVE_MBRTOWC -# include -# include -# include "mbchar.h" -# include "mbiter.h" -#endif - +#include "mbchar.h" +#include "mbiter.h" #include "xalloc.h" /* Use this to suppress gcc's `...may be used before initialized' warnings. */ @@ -50,7 +47,6 @@ if (!d) xalloc_die(); -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1) { mbi_iterator_t i; @@ -114,7 +110,6 @@ } } else -#endif /* HAVE_MBRTOWC */ { char *p; diff --git a/modules/mbswidth b/modules/mbswidth --- a/modules/mbswidth +++ b/modules/mbswidth @@ -11,6 +11,8 @@ Depends-on: wchar wctype +mbrtowc +mbsinit wcwidth extensions diff --git a/modules/quotearg b/modules/quotearg --- a/modules/quotearg +++ b/modules/quotearg @@ -11,6 +11,8 @@ Depends-on: extensions gettext-h +mbrtowc +mbsinit memcmp stdbool wchar