From: Bruno Haible Date: Sat, 22 Jul 2006 15:36:58 +0000 (+0000) Subject: Update from gnulib. X-Git-Tag: 0.16.x-branchpoint~343 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d287e2351552386436c0f29130bdbee125f0cdf;p=thirdparty%2Fgettext.git Update from gnulib. --- diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index fb043d903..9dd7aa1f6 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,5 +1,9 @@ 2006-07-22 Bruno Haible + * minmax.h: Update from gnulib. + + * mbswidth.c: Update from gnulib. + * wcwidth.h: New file, from gnulib. * Makefile.am (libgettextlib_la_SOURCES): Add it. diff --git a/gettext-tools/lib/mbswidth.c b/gettext-tools/lib/mbswidth.c index 6f04e21f7..48da6639d 100644 --- a/gettext-tools/lib/mbswidth.c +++ b/gettext-tools/lib/mbswidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2000-2006 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 @@ -32,7 +32,7 @@ /* Get isprint(). */ #include -/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ +/* Get mbstate_t, mbrtowc(), mbsinit(). */ #if HAVE_WCHAR_H /* Tru64 with Desktop Toolkit C has a bug: must be included before . @@ -43,13 +43,13 @@ # include #endif -/* Get iswprint(), iswcntrl(). */ +/* Get wcwidth(). */ +#include "wcwidth.h" + +/* Get iswcntrl(). */ #if HAVE_WCTYPE_H # include #endif -#if !defined iswprint && !HAVE_ISWPRINT -# define iswprint(wc) 1 -#endif #if !defined iswcntrl && !HAVE_ISWCNTRL # define iswcntrl(wc) 0 #endif @@ -60,26 +60,12 @@ # endif #endif -#ifndef HAVE_DECL_WCWIDTH -"this configure-time declaration test was not run" -#endif -#if !HAVE_DECL_WCWIDTH -int wcwidth (); -#endif - -#ifndef wcwidth -# if !HAVE_WCWIDTH -/* wcwidth doesn't exist, so assume all printable characters have - width 1. */ -# define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -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. With flags = MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE, this is - the multibyte analogue of the wcswidth function. */ + the multibyte analogue of the wcswidth function. + If STRING is not of length < INT_MAX / 2, integer overflow can occur. */ int mbswidth (const char *string, int flags) { @@ -89,7 +75,8 @@ mbswidth (const char *string, int flags) /* Returns the number of columns needed to represent the multibyte character string pointed to by STRING of length NBYTES. If a non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is - specified, -1 is returned. */ + specified, -1 is returned. + If NBYTES is not < INT_MAX / 2, integer overflow can occur. */ int mbsnwidth (const char *string, size_t nbytes, int flags) { diff --git a/gettext-tools/lib/minmax.h b/gettext-tools/lib/minmax.h index c0403f0c2..975ea76d1 100644 --- a/gettext-tools/lib/minmax.h +++ b/gettext-tools/lib/minmax.h @@ -1,5 +1,5 @@ /* MIN, MAX macros. - Copyright (C) 1995, 1998, 2001, 2003 Free Software Foundation, Inc. + Copyright (C) 1995, 1998, 2001, 2003, 2005 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 @@ -24,10 +24,17 @@ #include this file as the last one among the #include list. */ /* Before we define the following symbols we get the file - since otherwise we get redefinitions on some systems. */ -#include + since otherwise we get redefinitions on some systems if is + included after this file. Likewise for . + If more than one of these system headers define MIN and MAX, pick just + one of the headers (because the definitions most likely are the same). */ +#if HAVE_MINMAX_IN_LIMITS_H +# include +#elif HAVE_MINMAX_IN_SYS_PARAM_H +# include +#endif -/* Note: MIN and MAX should preferrably be used with two arguments of the +/* Note: MIN and MAX should be used with two arguments of the same type. They might not return the minimum and maximum of their two arguments, if the arguments have different types or have unusual floating-point values. For example, on a typical host with 32-bit 'int', @@ -42,28 +49,12 @@ /* MAX(a,b) returns the maximum of A and B. */ #ifndef MAX -# if __STDC__ && defined __GNUC__ && __GNUC__ >= 2 -# define MAX(a,b) (__extension__ \ - ({__typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a > _b ? _a : _b; \ - })) -# else -# define MAX(a,b) ((a) > (b) ? (a) : (b)) -# endif +# define MAX(a,b) ((a) > (b) ? (a) : (b)) #endif /* MIN(a,b) returns the minimum of A and B. */ #ifndef MIN -# if __STDC__ && defined __GNUC__ && __GNUC__ >= 2 -# define MIN(a,b) (__extension__ \ - ({__typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a < _b ? _a : _b; \ - })) -# else -# define MIN(a,b) ((a) < (b) ? (a) : (b)) -# endif +# define MIN(a,b) ((a) < (b) ? (a) : (b)) #endif #endif /* _MINMAX_H */ diff --git a/gettext-tools/m4/ChangeLog b/gettext-tools/m4/ChangeLog index f26735bd4..0ab037e00 100644 --- a/gettext-tools/m4/ChangeLog +++ b/gettext-tools/m4/ChangeLog @@ -1,5 +1,7 @@ 2006-07-22 Bruno Haible + * mbswidth.m4: Update from gnulib. + * wcwidth.m4: New file, from gnulib. * Makefile.am (EXTRA_DIST): Add it. diff --git a/gettext-tools/m4/mbswidth.m4 b/gettext-tools/m4/mbswidth.m4 index 878e5311d..3cb200039 100644 --- a/gettext-tools/m4/mbswidth.m4 +++ b/gettext-tools/m4/mbswidth.m4 @@ -1,5 +1,5 @@ -# mbswidth.m4 serial 11 -dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. +# mbswidth.m4 serial 12 +dnl Copyright (C) 2000-2002, 2004, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -9,33 +9,11 @@ dnl From Bruno Haible. AC_DEFUN([gl_MBSWIDTH], [ - AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) - AC_CHECK_FUNCS_ONCE(isascii iswprint mbsinit) - AC_CHECK_FUNCS(iswcntrl wcwidth) + AC_CHECK_HEADERS_ONCE([wchar.h wctype.h]) + AC_CHECK_FUNCS_ONCE([isascii mbsinit]) + AC_CHECK_FUNCS([iswcntrl]) gl_FUNC_MBRTOWC - AC_CACHE_CHECK([whether wcwidth is declared], ac_cv_have_decl_wcwidth, - [AC_TRY_COMPILE([ -/* AIX 3.2.5 declares wcwidth in . */ -#if HAVE_STRING_H -# include -#endif -#if HAVE_WCHAR_H -# include -#endif -], [ -#ifndef wcwidth - char *p = (char *) wcwidth; -#endif -], ac_cv_have_decl_wcwidth=yes, ac_cv_have_decl_wcwidth=no)]) - if test $ac_cv_have_decl_wcwidth = yes; then - ac_val=1 - else - ac_val=0 - fi - AC_DEFINE_UNQUOTED(HAVE_DECL_WCWIDTH, $ac_val, - [Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.]) - dnl UnixWare 7.1.1 has a declaration of a function mbswidth() dnl that clashes with ours. AC_CACHE_CHECK([whether mbswidth is declared in ],