Mercurial > hg > octave-lyh > gnulib-hg
changeset 9071:ee2dc6c88b11
Provide wcwidth replacement in separate file wcwidth.c.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 07 Jul 2007 19:27:06 +0000 |
parents | 1f5c82a3d787 |
children | afbf42785753 |
files | ChangeLog lib/wcwidth.c lib/wcwidth.h m4/wcwidth.m4 modules/wcwidth |
diffstat | 5 files changed, 51 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-07-07 Bruno Haible <bruno@clisp.org> + + * lib/wcwidth.c: New file, extracted from lib/wcwidth.h. + * lib/wcwidth.h: Don't include wctype.h. Replace inline function + definition with an external declaration. + * m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Use wcwidth.c when wcwidth is not + defined as a function. + * modules/wcwidth (Files): Add lib/wcwidth.c. + (Makefile.am): Remove redundant statement. + 2007-07-07 Bruno Haible <bruno@clisp.org> * MODULES.html.sh (Unicode string functions): Add the new modules.
new file mode 100644 --- /dev/null +++ b/lib/wcwidth.c @@ -0,0 +1,30 @@ +/* Determine the number of screen columns needed for a character. + Copyright (C) 2006, 2007 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. */ + +#include <config.h> + +/* Specification. */ +#include "wcwidth.h" + +/* Get iswprint. */ +#include <wctype.h> + +int +rpl_wcwidth (wchar_t wc) +{ + return wc == 0 ? 0 : iswprint (wc) ? 1 : -1; +}
--- a/lib/wcwidth.h +++ b/lib/wcwidth.h @@ -23,22 +23,15 @@ /* Get wcwidth if available, along with wchar_t. */ # include <wchar.h> -/* Get iswprint. */ -# include <wctype.h> - # 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; -} +/* Defined by gnulib. */ +# define wcwidth rpl_wcwidth +extern int wcwidth (wchar_t); # elif !HAVE_DECL_WCWIDTH
--- a/m4/wcwidth.m4 +++ b/m4/wcwidth.m4 @@ -1,4 +1,4 @@ -# wcwidth.m4 serial 8 +# wcwidth.m4 serial 9 dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -27,4 +27,9 @@ #include <stdio.h> #include <time.h> #include <wchar.h> -])]) +]) + + if test $ac_cv_func_wcwidth = no; then + AC_LIBOBJ([wcwidth]) + fi +])