+2008-12-22 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* doc/posix-functions/mbtowc.texi: Mention a glibc bug.
/* 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 <bruno@clisp.org>, 2005,
based on earlier glibc code.
#include <ctype.h>
#include <limits.h>
-#if HAVE_MBRTOWC
-# include "mbuiter.h"
-#endif
+#include "mbuiter.h"
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
/* 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;
return 0;
}
else
-#endif
{
const unsigned char *p1 = (const unsigned char *) s1;
const unsigned char *p2 = (const unsigned char *) s2;
#include <stddef.h> /* 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))
#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:
freea (memory);
return true;
}
-#endif
/* Find the first occurrence of the character string NEEDLE in the character
string HAYSTACK, using case-insensitive comparison.
- 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;
return (char *) haystack;
}
else
-#endif
{
if (*needle != '\0')
{
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
/* Specification. */
#include <string.h>
-#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,
return NULL;
}
else
-#endif
return strchr (string, c);
}
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
/* Specification. */
#include <string.h>
-#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
return (ptr != NULL ? ptr - string : strlen (string));
}
/* General case. */
-#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
mbui_iterator_t iter;
return mbui_cur_ptr (iter) - string;
}
else
-#endif
return strcspn (string, accept);
}
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
#include <stdlib.h>
-#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;
return count;
}
else
-#endif
return strlen (string);
}
/* 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 <bruno@clisp.org>, 2005,
based on earlier glibc code.
#include <ctype.h>
#include <limits.h>
-#if HAVE_MBRTOWC
-# include "mbuiter.h"
-#endif
+#include "mbuiter.h"
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
/* 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;
return 0;
}
else
-#endif
{
const unsigned char *p1 = (const unsigned char *) s1;
const unsigned char *p2 = (const unsigned char *) s2;
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
#include <stdlib.h>
-#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;
return count;
}
else
-#endif
return len;
}
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
/* Specification. */
#include <string.h>
-#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
if (accept[1] == '\0')
return mbschr (string, accept[0]);
/* General case. */
-#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
mbui_iterator_t iter;
return NULL;
}
else
-#endif
return strpbrk (string, accept);
}
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
#include <ctype.h>
-#if HAVE_MBRTOWC
-# include "mbuiter.h"
-#endif
+#include "mbuiter.h"
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
/* 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;
return NULL;
}
else
-#endif
{
const unsigned char *p1 = (const unsigned char *) string;
const unsigned char *p2 = (const unsigned char *) prefix;
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
/* Specification. */
#include <string.h>
-#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,
return (char *) result;
}
else
-#endif
return strrchr (string, c);
}
/* Tokenizing a string.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
/* Specification. */
#include <string.h>
-#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;
}
}
else
-#endif
return strsep (stringp, delim);
}
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
/* Specification. */
#include <string.h>
-#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
{
unsigned char uc = (unsigned char) reject[0];
-#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
mbui_iterator_t iter;
return mbui_cur_ptr (iter) - string;
}
else
-#endif
{
const char *ptr;
}
}
/* General case. */
-#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
mbui_iterator_t iter;
return mbui_cur_ptr (iter) - string;
}
else
-#endif
return strspn (string, reject);
}
#include <stddef.h> /* 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:
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. */
- 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;
return (char *) haystack;
}
else
-#endif
{
if (*needle != '\0')
{
/* 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 <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
/* Specification. */
#include <string.h>
-#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)
return string;
}
else
-#endif
return strtok_r (string, delim, save_ptr);
}
/* 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
/* Get iswcntrl(). */
#include <wctype.h>
-#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.
int width;
width = 0;
-#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
while (p < plimit)
}
return width;
}
-#endif
while (p < plimit)
{
#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"
break;
else
{
-#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
mbui_iterator_t string_iter;
string = tsub_in_string + mb_len (mbui_cur (string_iter));
}
else
-#endif /* HAVE_MBRTOWC */
{
bool word_boundary_before;
const char *p;
#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
#include <ctype.h>
#include <string.h>
+#include <stddef.h>
+#include <stdlib.h>
-#if HAVE_MBRTOWC
-# include <stddef.h>
-# include <stdlib.h>
-# 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. */
if (!d)
xalloc_die();
-#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
mbi_iterator_t i;
}
}
else
-#endif /* HAVE_MBRTOWC */
{
char *p;
Depends-on:
wchar
wctype
+mbrtowc
+mbsinit
wcwidth
extensions
Depends-on:
extensions
gettext-h
+mbrtowc
+mbsinit
memcmp
stdbool
wchar