ncurses 5.6 - patch 20080906

+ corrected gcc options for building shared libraries on IRIX64.
+ add configure check for awk programs unable to handle big-strings,
  use that to improve the default for --enable-big-strings option.
+ makefile-fixes for --enable-weak-symbols (report by Frederic L W
  Meunier).
+ update test/configure script.
+ adapt ifdef's from library to make test/view.c build when mbrtowc()
  is unavailable, e.g., with HPUX 10.20.
+ add configure check for wcsrtombs, mbsrtowcs, which are used in
  test/ncurses.c, and use wcstombs, mbstowcs instead if available,
  fixing build of ncursew for HPUX 11.00
This commit is contained in:
Thomas E. Dickey 2008-09-07 01:02:23 +00:00
parent d8b5e3f818
commit a7d99bb6b2
13 changed files with 1638 additions and 1508 deletions

15
NEWS
View File

@ -25,7 +25,7 @@
-- sale, use or other dealings in this Software without prior written -- -- sale, use or other dealings in this Software without prior written --
-- authorization. -- -- authorization. --
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- $Id: NEWS,v 1.1281 2008/08/30 23:33:29 tom Exp $ -- $Id: NEWS,v 1.1287 2008/09/06 22:04:07 tom Exp $
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started This is a log of changes that ncurses has gone through since Zeyd started
@ -45,6 +45,19 @@ See the AUTHORS file for the corresponding full names.
Changes through 1.9.9e did not credit all contributions; Changes through 1.9.9e did not credit all contributions;
it is not possible to add this information. it is not possible to add this information.
20080906
+ corrected gcc options for building shared libraries on IRIX64.
+ add configure check for awk programs unable to handle big-strings,
use that to improve the default for --enable-big-strings option.
+ makefile-fixes for --enable-weak-symbols (report by Frederic L W
Meunier).
+ update test/configure script.
+ adapt ifdef's from library to make test/view.c build when mbrtowc()
is unavailable, e.g., with HPUX 10.20.
+ add configure check for wcsrtombs, mbsrtowcs, which are used in
test/ncurses.c, and use wcstombs, mbstowcs instead if available,
fixing build of ncursew for HPUX 11.00
20080830 20080830
+ fixes to make Ada95 demo_panels() example work. + fixes to make Ada95 demo_panels() example work.
+ modify Ada95 'rain' test program to accept keyboard commands like the + modify Ada95 'rain' test program to accept keyboard commands like the

32
aclocal.m4 vendored
View File

@ -28,7 +28,7 @@ dnl***************************************************************************
dnl dnl
dnl Author: Thomas E. Dickey 1995-on dnl Author: Thomas E. Dickey 1995-on
dnl dnl
dnl $Id: aclocal.m4,v 1.453 2008/08/23 22:27:51 tom Exp $ dnl $Id: aclocal.m4,v 1.457 2008/09/06 21:36:49 tom Exp $
dnl Macros used in NCURSES auto-configuration script. dnl Macros used in NCURSES auto-configuration script.
dnl dnl
dnl These macros are maintained separately from NCURSES. The copyright on dnl These macros are maintained separately from NCURSES. The copyright on
@ -331,6 +331,30 @@ You have the following choices:
fi fi
])dnl ])dnl
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
dnl CF_AWK_BIG_PRINTF version: 1 updated: 2008/09/06 17:17:18
dnl -----------------
dnl Check if awk can handle big strings using printf. Some older versions of
dnl awk choke on large strings passed via "%s".
dnl
dnl $1 = desired string size
dnl $2 = variable to set with result
AC_DEFUN([CF_AWK_BIG_PRINTF],
[
case x$AWK in #(vi
x)
eval $2=no
;;
*) #(vi
if ( ${AWK} 'BEGIN { xx = "x"; while (length(xx) < $1) { xx = xx "x"; }; printf("%s\n", xx); }' \
| $AWK '{ if (length([$]0) != $1) exit 1; }' 2>/dev/null >/dev/null ); then
eval $2=yes
else
eval $2=no
fi
;;
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18 dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18
dnl ------------ dnl ------------
dnl Test if 'bool' is a builtin type in the configured C++ compiler. Some dnl Test if 'bool' is a builtin type in the configured C++ compiler. Some
@ -3931,7 +3955,7 @@ AC_MSG_RESULT(no)
fi fi
])dnl ])dnl
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
dnl CF_SHARED_OPTS version: 48 updated: 2008/06/14 15:08:17 dnl CF_SHARED_OPTS version: 49 updated: 2008/09/06 17:36:03
dnl -------------- dnl --------------
dnl -------------- dnl --------------
dnl Attempt to determine the appropriate CC/LD options for creating a shared dnl Attempt to determine the appropriate CC/LD options for creating a shared
@ -4066,8 +4090,10 @@ CF_EOF
# tested with IRIX 5.2 and 'cc'. # tested with IRIX 5.2 and 'cc'.
if test "$GCC" != yes; then if test "$GCC" != yes; then
CC_SHARED_OPTS='-KPIC' CC_SHARED_OPTS='-KPIC'
MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
else
MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]'
fi fi
MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
cf_cv_rm_so_locs=yes cf_cv_rm_so_locs=yes
;; ;;
linux*|gnu*|k*bsd*-gnu) linux*|gnu*|k*bsd*-gnu)

2191
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -28,14 +28,14 @@ dnl***************************************************************************
dnl dnl
dnl Author: Thomas E. Dickey 1995-on dnl Author: Thomas E. Dickey 1995-on
dnl dnl
dnl $Id: configure.in,v 1.443 2008/08/30 19:53:49 tom Exp $ dnl $Id: configure.in,v 1.446 2008/09/06 21:02:20 tom Exp $
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl dnl
dnl See http://invisible-island.net/autoconf/ for additional information. dnl See http://invisible-island.net/autoconf/ for additional information.
dnl dnl
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
AC_PREREQ(2.13.20020210) AC_PREREQ(2.13.20020210)
AC_REVISION($Revision: 1.443 $) AC_REVISION($Revision: 1.446 $)
AC_INIT(ncurses/base/lib_initscr.c) AC_INIT(ncurses/base/lib_initscr.c)
AC_CONFIG_HEADER(include/ncurses_cfg.h:include/ncurses_cfg.hin) AC_CONFIG_HEADER(include/ncurses_cfg.h:include/ncurses_cfg.hin)
@ -504,12 +504,13 @@ AC_MSG_RESULT($with_big_core)
test "$with_big_core" = "yes" && AC_DEFINE(HAVE_BIG_CORE) test "$with_big_core" = "yes" && AC_DEFINE(HAVE_BIG_CORE)
### ISO C only guarantees 512-char strings, we have tables which load faster ### ISO C only guarantees 512-char strings, we have tables which load faster
### when constructed using "big" strings. ### when constructed using "big" strings. More than the C compiler, the awk
### program is a limit on most vendor UNIX systems. Check that we can build.
AC_MSG_CHECKING(if big-strings option selected) AC_MSG_CHECKING(if big-strings option selected)
AC_ARG_ENABLE(big-strings, AC_ARG_ENABLE(big-strings,
[ --disable-big-strings assume compiler has only standard-size strings], [ --disable-big-strings assume compiler has only standard-size strings],
[with_big_strings=no], [with_big_strings=$enableval],
[with_big_strings=yes]) [CF_AWK_BIG_PRINTF(4000,with_big_strings)])
AC_MSG_RESULT($with_big_strings) AC_MSG_RESULT($with_big_strings)
USE_BIG_STRINGS=0 USE_BIG_STRINGS=0
@ -681,7 +682,7 @@ if test "$with_widec" = yes ; then
CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED) CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
# with_overwrite=no # with_overwrite=no
NCURSES_CH_T=cchar_t NCURSES_CH_T=cchar_t
AC_CHECK_FUNCS(putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc) AC_CHECK_FUNCS(putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc wcsrtombs mbsrtowcs wcstombs mbstowcs)
if test "$ac_cv_func_putwc" != yes ; then if test "$ac_cv_func_putwc" != yes ; then
CF_LIBUTF8 CF_LIBUTF8
if test "$cf_cv_libutf8" = yes ; then if test "$cf_cv_libutf8" = yes ; then

View File

@ -25,7 +25,7 @@
# use or other dealings in this Software without prior written # # use or other dealings in this Software without prior written #
# authorization. # # authorization. #
############################################################################## ##############################################################################
# $Id: dist.mk,v 1.657 2008/08/30 16:23:22 tom Exp $ # $Id: dist.mk,v 1.658 2008/09/06 15:28:23 tom Exp $
# Makefile for creating ncurses distributions. # Makefile for creating ncurses distributions.
# #
# This only needs to be used directly as a makefile by developers, but # This only needs to be used directly as a makefile by developers, but
@ -37,7 +37,7 @@ SHELL = /bin/sh
# These define the major/minor/patch versions of ncurses. # These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 5 NCURSES_MAJOR = 5
NCURSES_MINOR = 6 NCURSES_MINOR = 6
NCURSES_PATCH = 20080830 NCURSES_PATCH = 20080906
# We don't append the patch to the version, since this only applies to releases # We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)

View File

@ -1,4 +1,4 @@
# $Id: ncurses_defs,v 1.39 2008/08/16 23:12:31 tom Exp $ # $Id: ncurses_defs,v 1.40 2008/09/06 15:57:41 tom Exp $
############################################################################## ##############################################################################
# Copyright (c) 2000-2007,2008 Free Software Foundation, Inc. # # Copyright (c) 2000-2007,2008 Free Software Foundation, Inc. #
# # # #
@ -60,8 +60,8 @@ HAVE_GETEGID
HAVE_GETEUID HAVE_GETEUID
HAVE_GETMAXX 1 HAVE_GETMAXX 1
HAVE_GETNSTR HAVE_GETNSTR
HAVE_GETPARX 1
HAVE_GETOPT_H HAVE_GETOPT_H
HAVE_GETPARX 1
HAVE_GETTIMEOFDAY HAVE_GETTIMEOFDAY
HAVE_GETTTYNAM HAVE_GETTTYNAM
HAVE_GETWIN 1 HAVE_GETWIN 1
@ -88,6 +88,8 @@ HAVE_LONG_FILE_NAMES
HAVE_MBLEN HAVE_MBLEN
HAVE_MBRLEN HAVE_MBRLEN
HAVE_MBRTOWC HAVE_MBRTOWC
HAVE_MBSRTOWCS
HAVE_MBSTOWCS
HAVE_MBTOWC HAVE_MBTOWC
HAVE_MENU_H HAVE_MENU_H
HAVE_MKSTEMP HAVE_MKSTEMP
@ -153,6 +155,8 @@ HAVE_USE_DEFAULT_COLORS
HAVE_VFSCANF HAVE_VFSCANF
HAVE_VSNPRINTF HAVE_VSNPRINTF
HAVE_VSSCANF HAVE_VSSCANF
HAVE_WCSRTOMBS
HAVE_WCSTOMBS
HAVE_WCTOB HAVE_WCTOB
HAVE_WCTOMB HAVE_WCTOMB
HAVE_WCTYPE_H HAVE_WCTYPE_H

View File

@ -1,4 +1,4 @@
# $Id: Makefile.in,v 1.77 2007/10/13 22:25:53 tom Exp $ # $Id: Makefile.in,v 1.78 2008/09/06 17:28:26 tom Exp $
############################################################################## ##############################################################################
# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. # # Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
# # # #
@ -109,10 +109,10 @@ LDFLAGS_SHARED = $(LDFLAGS) $(CFLAGS_SHARED) @LD_SHARED_OPTS@
LDFLAGS_DEFAULT = $(LDFLAGS_@DFT_UPR_MODEL@) LDFLAGS_DEFAULT = $(LDFLAGS_@DFT_UPR_MODEL@)
LIBS_TIC = @LDFLAGS_STATIC@ @TICS_ARGS@ @TINFO_ARGS@ @LDFLAGS_SHARED@ @LD_MODEL@ @LIBS@ LIBS_TIC = @LDFLAGS_STATIC@ @TICS_ARGS@ @TINFO_ARGS@ @LDFLAGS_SHARED@ @LD_MODEL@ @LIBS@ @PTHREAD@
LDFLAGS_TIC = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TIC) LDFLAGS_TIC = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TIC)
LIBS_TINFO = @LDFLAGS_STATIC@ @TINFO_ARGS@ @LDFLAGS_SHARED@ @LD_MODEL@ @LIBS@ LIBS_TINFO = @LDFLAGS_STATIC@ @TINFO_ARGS@ @LDFLAGS_SHARED@ @LD_MODEL@ @LIBS@ @PTHREAD@
LDFLAGS_TINFO = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TINFO) LDFLAGS_TINFO = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TINFO)
LINT = @LINT@ LINT = @LINT@

View File

@ -1,4 +1,4 @@
# $Id: Makefile.in,v 1.100 2008/08/16 21:51:16 tom Exp $ # $Id: Makefile.in,v 1.101 2008/09/06 17:32:47 tom Exp $
############################################################################## ##############################################################################
# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. # # Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
# # # #
@ -91,7 +91,7 @@ LDFLAGS_SHARED = $(LDFLAGS) $(CFLAGS_SHARED) @LD_SHARED_OPTS@
TEST_ARGS = @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@ TEST_ARGS = @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@
# use these for linking with all of the libraries # use these for linking with all of the libraries
LIBS_DEFAULT = $(TEST_ARGS) @LIBS@ $(TEST_LIBS) $(MATH_LIB) LIBS_DEFAULT = $(TEST_ARGS) @LIBS@ $(TEST_LIBS) $(MATH_LIB) @PTHREAD@
LDFLAGS_DEFAULT = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_DEFAULT) LDFLAGS_DEFAULT = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_DEFAULT)
# use these for linking with the (n)curses library and possibly pthreads # use these for linking with the (n)curses library and possibly pthreads
@ -99,11 +99,11 @@ LIBS_THREADS = `echo "$(TEST_ARGS) @LIBS@" | sed -e 's/-lform.*-lpanel[^ ]*//'`
LDFLAGS_THREADS = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_THREADS) LDFLAGS_THREADS = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_THREADS)
# use these for linking with the (n)curses library # use these for linking with the (n)curses library
LIBS_CURSES = `echo "$(TEST_ARGS) @LIBS@" | sed -e 's/-lform.*-lpanel[^ ]*//'` $(TEST_LIBS) $(MATH_LIB) LIBS_CURSES = `echo "$(TEST_ARGS) @LIBS@" | sed -e 's/-lform.*-lpanel[^ ]*//'` $(TEST_LIBS) $(MATH_LIB) @PTHREAD@
LDFLAGS_CURSES = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_CURSES) LDFLAGS_CURSES = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_CURSES)
# use these for linking with the tinfo library if we have it, or curses library if not # use these for linking with the tinfo library if we have it, or curses library if not
LIBS_TINFO = @LDFLAGS_STATIC@ @TINFO_ARGS@ @LDFLAGS_SHARED@ @LIBS@ $(TEST_LIBS) $(MATH_LIB) LIBS_TINFO = @LDFLAGS_STATIC@ @TINFO_ARGS@ @LDFLAGS_SHARED@ @LIBS@ $(TEST_LIBS) $(MATH_LIB) @PTHREAD@
LDFLAGS_TINFO = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TINFO) LDFLAGS_TINFO = $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TINFO)
LINT = @LINT@ LINT = @LINT@

746
test/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ dnl***************************************************************************
dnl dnl
dnl Author: Thomas E. Dickey 1996, etc. dnl Author: Thomas E. Dickey 1996, etc.
dnl dnl
dnl $Id: configure.in,v 1.65 2008/02/09 18:24:11 tom Exp $ dnl $Id: configure.in,v 1.67 2008/09/06 22:10:23 tom Exp $
dnl This is a simple configuration-script for the ncurses test programs that dnl This is a simple configuration-script for the ncurses test programs that
dnl allows the test-directory to be separately configured against a reference dnl allows the test-directory to be separately configured against a reference
dnl system (i.e., sysvr4 curses) dnl system (i.e., sysvr4 curses)
@ -52,28 +52,30 @@ AC_PROG_CPP
AC_PROG_AWK AC_PROG_AWK
dnl Things that we don't need (or must override) if we're not building ncurses dnl Things that we don't need (or must override) if we're not building ncurses
CC_G_OPT="-g" AC_SUBST(CC_G_OPT) CC_G_OPT="-g" AC_SUBST(CC_G_OPT)
CC_SHARED_OPTS=unknown AC_SUBST(CC_SHARED_OPTS) CC_SHARED_OPTS=unknown AC_SUBST(CC_SHARED_OPTS)
CPPFLAGS="$CPPFLAGS" AC_SUBST(CPPFLAGS) CPPFLAGS="$CPPFLAGS" AC_SUBST(CPPFLAGS)
DFT_DEP_SUFFIX="" AC_SUBST(DFT_DEP_SUFFIX) DFT_DEP_SUFFIX="" AC_SUBST(DFT_DEP_SUFFIX)
DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'` AC_SUBST(DFT_OBJ_SUBDIR) DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'` AC_SUBST(DFT_OBJ_SUBDIR)
DFT_UPR_MODEL="NORMAL" AC_SUBST(DFT_UPR_MODEL) DFT_UPR_MODEL="NORMAL" AC_SUBST(DFT_UPR_MODEL)
LD="ld" AC_SUBST(LD) LD="ld" AC_SUBST(LD)
LDFLAGS_SHARED="" AC_SUBST(LDFLAGS_SHARED) LDFLAGS_SHARED="" AC_SUBST(LDFLAGS_SHARED)
LDFLAGS_STATIC="" AC_SUBST(LDFLAGS_STATIC) LDFLAGS_STATIC="" AC_SUBST(LDFLAGS_STATIC)
LD_MODEL="" AC_SUBST(LD_MODEL) LD_MODEL="" AC_SUBST(LD_MODEL)
LD_SHARED_OPTS="" AC_SUBST(LD_SHARED_OPTS) LD_SHARED_OPTS="" AC_SUBST(LD_SHARED_OPTS)
LIBTOOL="" AC_SUBST(LIBTOOL) LIBTOOL="" AC_SUBST(LIBTOOL)
LIB_CLEAN="" AC_SUBST(LIB_CLEAN) LIB_CLEAN="" AC_SUBST(LIB_CLEAN)
LIB_COMPILE="" AC_SUBST(LIB_COMPILE) LIB_COMPILE="" AC_SUBST(LIB_COMPILE)
LIB_LINK='${CC}' AC_SUBST(LIB_LINK) LIB_LINK='${CC}' AC_SUBST(LIB_LINK)
LINK_TESTS="" AC_SUBST(LINK_TESTS) LINK_TESTS="" AC_SUBST(LINK_TESTS)
LINT=lint AC_SUBST(LINT) LINT=lint AC_SUBST(LINT)
LINT_OPTS="" AC_SUBST(LINT_OPTS) LINT_OPTS="" AC_SUBST(LINT_OPTS)
LOCAL_LDFLAGS="" AC_SUBST(LOCAL_LDFLAGS) LOCAL_LDFLAGS="" AC_SUBST(LOCAL_LDFLAGS)
MATH_LIB="-lm" AC_SUBST(MATH_LIB) MATH_LIB="-lm" AC_SUBST(MATH_LIB)
TEST_ARGS="" AC_SUBST(TEST_ARGS) PTHREAD="-lm" AC_SUBST(PTHREAD)
TEST_DEPS="" AC_SUBST(TEST_DEPS) TEST_ARGS="" AC_SUBST(TEST_ARGS)
TEST_DEPS="" AC_SUBST(TEST_DEPS)
TEST_LIBS="" AC_SUBST(TEST_LIBS)
TINFO_ARGS='$(LIBS_CURSES)' AC_SUBST(TINFO_ARGS) TINFO_ARGS='$(LIBS_CURSES)' AC_SUBST(TINFO_ARGS)
cf_cv_abi_version="" AC_SUBST(cf_cv_abi_version) cf_cv_abi_version="" AC_SUBST(cf_cv_abi_version)
cf_cv_rel_version="" AC_SUBST(cf_cv_rel_version) cf_cv_rel_version="" AC_SUBST(cf_cv_rel_version)
@ -179,7 +181,15 @@ unistd.h \
AC_CHECK_FUNCS( \ AC_CHECK_FUNCS( \
gettimeofday \ gettimeofday \
mblen \
mbrlen \
mbrtowc \
mbsrtowcs \
mbstowcs \
mbtowc \
strdup \ strdup \
wcsrtombs \
wcstombs \
) )
CF_CURSES_FUNCS( \ CF_CURSES_FUNCS( \

View File

@ -40,7 +40,7 @@ AUTHOR
Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993 Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
Thomas E. Dickey (beginning revision 1.27 in 1996). Thomas E. Dickey (beginning revision 1.27 in 1996).
$Id: ncurses.c,v 1.324 2008/08/04 16:27:54 tom Exp $ $Id: ncurses.c,v 1.327 2008/09/06 17:31:44 tom Exp $
***************************************************************************/ ***************************************************************************/
@ -118,6 +118,28 @@ extern unsigned _nc_tracing;
#endif #endif
#if HAVE_WCSRTOMBS
#define count_wchars(src, len, state) wcsrtombs(0, &src, len, state)
#define trans_wchars(dst, src, len, state) wcsrtombs(dst, &src, len, state)
#define reset_wchars(state) memset(&state, 0, sizeof(state))
#elif HAVE_WCSTOMBS && HAVE_MBTOWC && HAVE_MBLEN
#define count_wchars(src, len, state) wcstombs(0, src, len)
#define trans_wchars(dst, src, len, state) wcstombs(dst, src, len)
#define reset_wchars(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
#define state_unused
#endif
#if HAVE_MBSRTOWCS
#define count_mbytes(src, len, state) mbsrtowcs(0, &src, len, state)
#define trans_mbytes(dst, src, len, state) mbsrtowcs(dst, &src, len, state)
#define reset_mbytes(state) memset(&state, 0, sizeof(state))
#elif HAVE_MBSTOWCS && HAVE_MBTOWC && HAVE_MBLEN
#define count_mbytes(src, len, state) mbstowcs(0, src, len)
#define trans_mbytes(dst, src, len, state) mbstowcs(dst, src, len)
#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
#define state_unused
#endif
#define ToggleAcs(temp,real) temp = ((temp == real) ? 0 : real) #define ToggleAcs(temp,real) temp = ((temp == real) ? 0 : real)
#define P(string) printw("%s\n", string) #define P(string) printw("%s\n", string)
@ -928,16 +950,18 @@ static char *
wcstos(const wchar_t *src) wcstos(const wchar_t *src)
{ {
int need; int need;
mbstate_t state;
char *result = 0; char *result = 0;
const wchar_t *tmp = src; const wchar_t *tmp = src;
#ifndef state_unused
mbstate_t state;
#endif
memset(&state, 0, sizeof(state)); reset_wchars(state);
if ((need = (int) wcsrtombs(0, &tmp, 0, &state)) > 0) { if ((need = (int) count_wchars(tmp, 0, &state)) > 0) {
unsigned have = (unsigned) need; unsigned have = (unsigned) need;
if ((result = typeCalloc(char, have + 1)) != 0) { if ((result = typeCalloc(char, have + 1)) != 0) {
tmp = src; tmp = src;
if (wcsrtombs(result, &tmp, have, &state) != have) { if (trans_wchars(result, tmp, have, &state) != have) {
free(result); free(result);
result = 0; result = 0;
} }
@ -2705,20 +2729,22 @@ wide_slk_test(void)
size_t used = strlen(temp); size_t used = strlen(temp);
size_t want = SLKLEN; size_t want = SLKLEN;
size_t test; size_t test;
#ifndef state_unused
mbstate_t state; mbstate_t state;
#endif
buf[0] = L'\0'; buf[0] = L'\0';
while (want > 0 && used != 0) { while (want > 0 && used != 0) {
const char *base = s; const char *base = s;
memset(&state, 0, sizeof(state)); reset_mbytes(state);
test = mbsrtowcs(0, &base, 0, &state); test = count_mbytes(base, 0, &state);
if (test == (size_t) -1) { if (test == (size_t) -1) {
temp[--used] = 0; temp[--used] = 0;
} else if (test > want) { } else if (test > want) {
temp[--used] = 0; temp[--used] = 0;
} else { } else {
memset(&state, 0, sizeof(state)); reset_mbytes(state);
mbsrtowcs(buf, &base, want, &state); trans_mbytes(buf, base, want, &state);
break; break;
} }
} }

View File

@ -29,7 +29,7 @@
/**************************************************************************** /****************************************************************************
* Author: Thomas E. Dickey 1996-on * * Author: Thomas E. Dickey 1996-on *
****************************************************************************/ ****************************************************************************/
/* $Id: test.priv.h,v 1.77 2008/04/12 19:25:48 tom Exp $ */ /* $Id: test.priv.h,v 1.78 2008/09/06 22:01:24 tom Exp $ */
#ifndef __TEST_PRIV_H #ifndef __TEST_PRIV_H
#define __TEST_PRIV_H 1 #define __TEST_PRIV_H 1
@ -570,4 +570,6 @@ typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
#define USE_TRACE 0 #define USE_TRACE 0
#endif #endif
#define init_mb(state) memset(&state, 0, sizeof(state))
#endif /* __TEST_PRIV_H */ #endif /* __TEST_PRIV_H */

View File

@ -50,7 +50,7 @@
* scroll operation worked, and the refresh() code only had to do a * scroll operation worked, and the refresh() code only had to do a
* partial repaint. * partial repaint.
* *
* $Id: view.c,v 1.68 2008/08/03 11:37:07 tom Exp $ * $Id: view.c,v 1.69 2008/09/06 22:10:50 tom Exp $
*/ */
#include <test.priv.h> #include <test.priv.h>
@ -79,6 +79,23 @@
#include <sys/ptem.h> #include <sys/ptem.h>
#endif #endif
#if USE_WIDEC_SUPPORT
#if HAVE_MBTOWC && HAVE_MBLEN
#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
#define count_mbytes(buffer,length,state) mblen(buffer,length)
#define check_mbytes(wch,buffer,length,state) \
(int) mbtowc(&wch, buffer, length)
#define state_unused
#elif HAVE_MBRTOWC && HAVE_MBRLEN
#define reset_mbytes(state) init_mb(state)
#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
#define check_mbytes(wch,buffer,length,state) \
(int) mbrtowc(&wch, buffer, length, &state)
#else
make an error
#endif
#endif /* USE_WIDEC_SUPPORT */
static RETSIGTYPE finish(int sig) GCC_NORETURN; static RETSIGTYPE finish(int sig) GCC_NORETURN;
static void show_all(const char *tag); static void show_all(const char *tag);
@ -158,17 +175,19 @@ ch_dup(char *src)
wchar_t wstr[CCHARW_MAX + 1]; wchar_t wstr[CCHARW_MAX + 1];
wchar_t wch; wchar_t wch;
int l = 0; int l = 0;
mbstate_t state;
size_t rc; size_t rc;
int width; int width;
#ifndef state_unused
mbstate_t state;
#endif #endif
#endif /* USE_WIDEC_SUPPORT */
#if USE_WIDEC_SUPPORT #if USE_WIDEC_SUPPORT
memset(&state, 0, sizeof(state)); reset_mbytes(state);
#endif #endif
for (j = k = 0; j < len; j++) { for (j = k = 0; j < len; j++) {
#if USE_WIDEC_SUPPORT #if USE_WIDEC_SUPPORT
rc = mbrtowc(&wch, src + j, len - j, &state); rc = check_mbytes(wch, src + j, len - j, state);
if (rc == (size_t) -1 || rc == (size_t) -2) if (rc == (size_t) -1 || rc == (size_t) -2)
break; break;
j += rc - 1; j += rc - 1;