]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Use gnulib module wcwidth.
authorBruno Haible <bruno@clisp.org>
Sat, 22 Jul 2006 15:34:45 +0000 (15:34 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:39 +0000 (12:13 +0200)
gettext-tools/ChangeLog
gettext-tools/configure.ac
gettext-tools/lib/ChangeLog
gettext-tools/lib/Makefile.am
gettext-tools/lib/wcwidth.h [new file with mode: 0644]

index f28a7742b7ee70b582270a8254226ac1248b7739..50e4bcc2af71c3ba2cc751ae05d89d672467806e 100644 (file)
@@ -1,3 +1,7 @@
+2006-07-22  Bruno Haible  <bruno@clisp.org>
+
+       * configure.ac: Invoke gl_FUNC_WCWIDTH.
+
 2006-07-21  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.15 released.
index fbeb29695a7b2bba3c5f647035b89292a322dfa9..65f6b3c783800542ccd4d03cad9a95d4d4692004 100644 (file)
@@ -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
index 9ac59443e9ea696881d1cf6e6d38c396f96939c4..fb043d9035e1516c780de9d870dc524a45fe425b 100644 (file)
@@ -1,5 +1,8 @@
 2006-07-22  Bruno Haible  <bruno@clisp.org>
 
+       * wcwidth.h: New file, from gnulib.
+       * Makefile.am (libgettextlib_la_SOURCES): Add it.
+
        * gcd.c: Update from gnulib.
 
        * fwriteerror.c: Update from gnulib.
index 0d2511771f0a3e9cea9e0aaa68ef6d98dc40d6c0..ee7c79a23cebea395708421107cd27b4b7e44591 100644 (file)
@@ -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 (file)
index 0000000..9af75e0
--- /dev/null
@@ -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: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
+   <wchar.h>.  */
+#  include <stdio.h>
+#  include <time.h>
+#  include <wchar.h>
+# endif
+
+/* Get iswprint.  */
+# if HAVE_WCTYPE_H
+#  include <wctype.h>
+# 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 */