From: Bruno Haible Date: Sat, 22 Jul 2006 15:34:45 +0000 (+0000) Subject: Use gnulib module wcwidth. X-Git-Tag: 0.16.x-branchpoint~344 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3de720b0f2b925a3aca1f4b3175620803101e261;p=thirdparty%2Fgettext.git Use gnulib module wcwidth. --- diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index f28a7742b..50e4bcc2a 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,7 @@ +2006-07-22 Bruno Haible + + * configure.ac: Invoke gl_FUNC_WCWIDTH. + 2006-07-21 Bruno Haible * gettext-0.15 released. diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac index fbeb29695..65f6b3c78 100644 --- a/gettext-tools/configure.ac +++ b/gettext-tools/configure.ac @@ -165,6 +165,7 @@ gl_GETOPT gl_FUNC_EACCESS gl_FUNC_STPNCPY gl_FUNC_STRTOUL +gl_FUNC_WCWIDTH gl_MBSWIDTH gt_PREREQ_BACKUPFILE AC_FUNC_VFORK diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 9ac59443e..fb043d903 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,5 +1,8 @@ 2006-07-22 Bruno Haible + * wcwidth.h: New file, from gnulib. + * Makefile.am (libgettextlib_la_SOURCES): Add it. + * gcd.c: Update from gnulib. * fwriteerror.c: Update from gnulib. diff --git a/gettext-tools/lib/Makefile.am b/gettext-tools/lib/Makefile.am index 0d2511771..ee7c79a23 100644 --- a/gettext-tools/lib/Makefile.am +++ b/gettext-tools/lib/Makefile.am @@ -80,6 +80,7 @@ libgettextlib_la_SOURCES = \ unlocked-io.h \ verify.h \ wait-process.h wait-process.c \ + wcwidth.h \ xalloc.h xmalloc.c xstrdup.c \ xallocsa.h xallocsa.c \ xerror.h xerror.c \ diff --git a/gettext-tools/lib/wcwidth.h b/gettext-tools/lib/wcwidth.h new file mode 100644 index 000000000..9af75e0a7 --- /dev/null +++ b/gettext-tools/lib/wcwidth.h @@ -0,0 +1,70 @@ +/* Determine the number of screen columns needed for a character. + Copyright (C) 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _gl_WCWIDTH_H +#define _gl_WCWIDTH_H + +#if HAVE_WCHAR_T + +/* Get wcwidth if available, along with wchar_t. */ +# if HAVE_WCHAR_H +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.1 has a bug: and must be included before + . */ +# include +# include +# include +# endif + +/* Get iswprint. */ +# if HAVE_WCTYPE_H +# include +# endif +# if !defined iswprint && !HAVE_ISWPRINT +# define iswprint(wc) 1 +# endif + +# ifndef HAVE_DECL_WCWIDTH +"this configure-time declaration test was not run" +# endif +# ifndef wcwidth +# if !HAVE_WCWIDTH + +/* wcwidth doesn't exist, so assume all printable characters have + width 1. */ +static inline int +wcwidth (wchar_t wc) +{ + return wc == 0 ? 0 : iswprint (wc) ? 1 : -1; +} + +# elif !HAVE_DECL_WCWIDTH + +/* wcwidth exists but is not declared. */ +extern +# ifdef __cplusplus +"C" +# endif +int wcwidth (int /* actually wchar_t */); + +# endif +# endif + +#endif /* HAVE_WCHAR_H */ + +#endif /* _gl_WCWIDTH_H */