[Pinfo-devel] r260 - in pinfo/trunk: . macros src
Bas Zoetekouw
bas at costa.debian.org
Tue Sep 27 15:23:28 UTC 2005
Author: bas
Date: 2005-09-27 15:23:27 +0000 (Tue, 27 Sep 2005)
New Revision: 260
Added:
pinfo/trunk/macros/wchar.m4
Modified:
pinfo/trunk/config.h.in
pinfo/trunk/configure.ac
pinfo/trunk/macros/Makefile.in
pinfo/trunk/macros/curses.m4
pinfo/trunk/macros/readline.m4
pinfo/trunk/src/Makefile.am
pinfo/trunk/src/common_includes.h
pinfo/trunk/src/filehandling_functions.c
pinfo/trunk/src/initializelinks.c
pinfo/trunk/src/mainfunction.c
pinfo/trunk/src/manual.c
pinfo/trunk/src/parse_config.c
pinfo/trunk/src/utils.c
pinfo/trunk/src/utils.h
Log:
Fixed displaying of multibyte (like UTF8) and wide (like kanji) characters.
This basically consists of 3 parts:
- detect (n)curses's wchar capabilities and only use them if supported
(and rewrite the entire curses.m4 while we're at it)
- detect the flags we need for the C library to make wcwidth() available
- replace all the position-dependent stuff (link positions, mostly) to
use the width of the string rather than the length of the string
- remove some obsolete string functions (like strsep()) that aren't supported
with _XOPEN_SOURCE=600 (which we need for wcwidth())
Modified: pinfo/trunk/config.h.in
===================================================================
--- pinfo/trunk/config.h.in 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/config.h.in 2005-09-27 15:23:27 UTC (rev 260)
@@ -5,6 +5,21 @@
*/
#undef CRAY_STACKSEG_END
+/* Defined if curses has support for colors */
+#undef CURSES_COLORS
+
+/* Name of the ncurses.h file that should be included */
+#undef CURSES_H_NAME
+
+/* Defined if curses has KEY_END definition */
+#undef CURSES_KEY_END
+
+/* Defined if curses has support for mouse events */
+#undef CURSES_MOUSE
+
+/* Does curses have support for non-iso8859 charsets? */
+#undef CURSES_WCHAR
+
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
@@ -12,9 +27,6 @@
language is requested. */
#undef ENABLE_NLS
-/* Found some version of curses that we're going to use */
-#undef HAS_CURSES
-
/* Defined if found readline */
#undef HAS_READLINE
@@ -112,9 +124,6 @@
declares uintmax_t. */
#undef HAVE_INTTYPES_H_WITH_UINTMAX
-/* defined if curses has KEY_END definition */
-#undef HAVE_KEY_END
-
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
@@ -239,6 +248,9 @@
/* Define to 1 if you have the `wcslen' function. */
#undef HAVE_WCSLEN
+/* Defined if wcswidth() is available in <wchar.h> */
+#undef HAVE_WCSWIDTH
+
/* Define if you have the 'wint_t' type. */
#undef HAVE_WINT_T
@@ -263,13 +275,6 @@
/* Define if integer division by zero raises signal SIGFPE. */
#undef INTDIV0_RAISES_SIGFPE
-/* Set to reflect version of ncurses 0 = version 1. 1 = version 1.9.9g 2 =
- version 4.0/4.1 */
-#undef NCURSES_970530
-
-/* If you Curses does not have color define this one */
-#undef NO_COLOR_CURSES
-
/* Package name */
#undef PACKAGE
@@ -291,9 +296,6 @@
/* Define if <inttypes.h> exists and defines unusable PRI* macros. */
#undef PRI_MACROS_BROKEN
-/* Define if you want to turn on SCO-specific code */
-#undef SCO_FLAVOR
-
/* Define as the maximum value of type 'size_t', if the system doesn't define
it. */
#undef SIZE_MAX
@@ -309,18 +311,13 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Use old BSD curses - not used right now */
-#undef USE_BSD_CURSES
-
/* Use Ncurses? */
-#undef USE_NCURSES
+#undef USE_CURSES
-/* Use SunOS SysV curses? */
-#undef USE_SUNOS_CURSES
+/* Defined if support for wide chars is wanted and supported. wchar.h,
+ wchar_t, mbstowcs(), and friends will be available. */
+#undef USE_WCHAR
-/* Use SystemV curses? */
-#undef USE_SYSV_CURSES
-
/* Package version */
#undef VERSION
Modified: pinfo/trunk/configure.ac
===================================================================
--- pinfo/trunk/configure.ac 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/configure.ac 2005-09-27 15:23:27 UTC (rev 260)
@@ -104,45 +104,37 @@
# curses
AC_CHECK_CURSES
-if test "$has_curses" = false; then
+if ! test "x$USE_CURSES" = "xtrue"; then
AC_MSG_ERROR([Curses not found. You need curses to compile pinfo])
fi
LIBS="$LIBS $CURSES_LIBS"
-CPPFLAGS="$CPPFLAGS $CURSES_INCLUDES"
+CPPFLAGS="$CPPFLAGS $CURSES_INCLUDES $CURSES_FLAGS"
# check for some functions in curses
AC_CHECK_FUNCS(curs_set use_default_colors bkgdset)
-# check if our curses lib knows about KEY_END
-AC_MSG_CHECKING(for KEY_END in curses)
-KEY_END=""
-AC_EGREP_CPP(HAVE_KEY_END,
-[
- #if defined(RENAMED_NCURSES) or !defined(USE_NCURSES)
- #include <curses.h>
- #else
- #include <ncurses.h>
- #endif
-
- #ifdef KEY_END
- HAVE_KEY_END
- #endif
-],
-[
- AC_DEFINE(HAVE_KEY_END,1,[defined if curses has KEY_END definition])
- KEY_END="KEY_END"
+# define the MAN_KEY_END var based on the curses support of KEY_END
+if test "x$CURSES_KEY_END" = "xtrue"
+then
MAN_KEY_END="End Key"
- AC_MSG_RESULT(yes)
-],
-[
- AC_MSG_RESULT(no)
- KEY_END="\'E\'"
+else
MAN_KEY_END="E"
-])
+fi
+AC_SUBST(MAN_KEY_END)
####################################################
-## i18n, t10n stuff
+## wchar stuff
####################################################
+AC_CHECK_WCHAR
+if test "x$USE_WCHAR" = "xtrue"
+then
+ CPPFLAGS="$CPPFLAGS $WCHAR_FLAGS"
+fi
+
+
+####################################################
+## locales
+####################################################
# the languages for which we have .po files
ALL_LINGUAS="pl cs sv de ru ja nl"
Modified: pinfo/trunk/macros/Makefile.in
===================================================================
--- pinfo/trunk/macros/Makefile.in 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/macros/Makefile.in 2005-09-27 15:23:27 UTC (rev 260)
@@ -61,8 +61,9 @@
$(top_srcdir)/macros/stdint_h.m4 \
$(top_srcdir)/macros/uintmax_t.m4 \
$(top_srcdir)/macros/ulonglong.m4 \
- $(top_srcdir)/macros/wchar_t.m4 $(top_srcdir)/macros/wint_t.m4 \
- $(top_srcdir)/macros/xsize.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/macros/wchar.m4 $(top_srcdir)/macros/wchar_t.m4 \
+ $(top_srcdir)/macros/wint_t.m4 $(top_srcdir)/macros/xsize.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/tools/mkinstalldirs
@@ -86,6 +87,7 @@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CURSES_FLAGS = @CURSES_FLAGS@
CURSES_INCLUDES = @CURSES_INCLUDES@
CURSES_LIBS = @CURSES_LIBS@
CYGPATH_W = @CYGPATH_W@
@@ -157,6 +159,7 @@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
+WCHAR_FLAGS = @WCHAR_FLAGS@
XGETTEXT = @XGETTEXT@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
Modified: pinfo/trunk/macros/curses.m4
===================================================================
--- pinfo/trunk/macros/curses.m4 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/macros/curses.m4 2005-09-27 15:23:27 UTC (rev 260)
@@ -1,301 +1,469 @@
-dnl Curses detection: Munged from Midnight Commander's configure.in
+dnl Curses detection:
+dnl Copyright (c) 2005 by Bas Zoetekouw <bas at debian.org>
+
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of version 2 of the GNU General Public License as
+dnl published by the Free Software Foundation.
dnl
-dnl What it does:
-dnl =============
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+dnl
+dnl How to use this?
+dnl (-) put a call to AC_CHECK_CURSES in configure.ac (after the call to
+dnl AC_PROG_CC, obviously)
+dnl (-) AC_CHECK_CURSES will look for a curses library (or look at the
+dnl location the user specified on the ./configure command line) , and
+dnl checks if it is usable. If it is found, and is usable, the shell
+dnl variable $USE_CURSES is set for use in configure.ac, and the
+dnl autoheader USE_CURSES will be defined.
+dnl (-) the includes and libraries cc options are put into the
+dnl $CURSES_INCLUDES and $CURSES_LIBS shell variables and the automake
+dnl variables @CURSES_INCLUDES@ and @CURSES_LIBS at . Additional flags
+dnl that are needed are put in $CURSES_FLAGS and @CURSES_FLAGS@
+
+
+
+dnl First define the headers for config.h.in:
+AH_TEMPLATE([USE_CURSES],[
+ Use Ncurses?
+])
+AH_TEMPLATE([CURSES_WCHAR],[
+ Does curses have support for non-iso8859 charsets?
+])
+AH_TEMPLATE(CURSES_H_NAME, [
+ Name of the ncurses.h file that should be included
+])
+AH_TEMPLATE([CURSES_COLORS],[
+ Defined if curses has support for colors
+])
+AH_TEMPLATE(CURSES_KEY_END,[
+ Defined if curses has KEY_END definition
+])
+AH_TEMPLATE(CURSES_MOUSE,[
+ Defined if curses has support for mouse events
+])
+
dnl
-dnl - Determine which version of curses is installed on your system
-dnl and set the -I/-L/-l compiler entries and add a few preprocessor
-dnl symbols
-dnl - Do an AC_SUBST on the CURSES_INCLUDES and CURSES_LIBS so that
-dnl @CURSES_INCLUDES@ and @CURSES_LIBS@ will be available in
-dnl Makefile.in's
-dnl - Modify the following configure variables (these are the only
-dnl curses.m4 variables you can access from within configure.in)
-dnl CURSES_INCLUDES - contains -I's and possibly -DRENAMED_CURSES if
-dnl an ncurses.h that's been renamed to curses.h
-dnl is found.
-dnl CURSES_LIBS - sets -L and -l's appropriately
-dnl CPPFLAGS - if --with-sco, add -D_SVID3
-dnl has_curses - exports result of tests to rest of configure
+dnl "main" function. Call this from configure.ac
dnl
-dnl Usage:
-dnl ======
-dnl 1) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
-dnl 2) Instead of #include <curses.h> you should use the following to
-dnl properly locate ncurses or curses header file
+AC_DEFUN([AC_CHECK_CURSES],[
+ CFLAGS=${CFLAGS--O}
+
+ curses_location=false
+ use_curses=true
+ AC_ARG_WITH(curses,
+ [ --with-curses=dir Use <dir> as base dir for curses library],
+ [
+ if test "x$withval" = "xno"
+ then
+ use_curses=false
+ fi
+ if test "x$withval" != "xyes"
+ then
+ curses_location=$withval
+ fi
+ ]
+ )
+
+ dnl search for (n)curses.h
+ if test "x$use_curses" = "xtrue"
+ then
+ AC_SEARCH_CURSES_H()
+ fi
+
+ dnl if we found anything, check if it works
+ if test "x$found_curses_h" = "xtrue"; then
+ AC_CHECK_CURSES_COMPILE()
+ else
+ curses_usable=false
+ fi
+
+ dnl if it works, check for several features and set variables
+ if test "x$curses_usable" = "xtrue"
+ then
+ USE_CURSES=true
+
+ dnl use curses
+ AC_DEFINE(USE_CURSES)
+
+ dnl define lib and include dirs
+ CURSES_INCLUDES=$curses_includes
+ CURSES_LIBS=$curses_libs
+ AC_SUBST(CURSES_INCLUDES)
+ AC_SUBST(CURSES_LIBS)
+
+ dnl name of ncurses.h file
+ AC_DEFINE_UNQUOTED(CURSES_H_NAME, [<$curses_h>])
+
+ dnl colors?
+ AC_CURSES_CHECK_COLORS()
+ if test "x$curses_colors" = "xtrue"
+ then
+ AC_DEFINE(CURSES_COLORS)
+ CURSES_COLORS=true
+ else
+ CURSES_COLORS=false
+ fi
+
+ dnl mouse?
+ AC_CURSES_CHECK_MOUSE()
+ if test "x$curses_mouse" = "xtrue"
+ then
+ AC_DEFINE(CURSES_MOUSE)
+ CURSES_MOUSE=true
+ else
+ CURSES_MOUSE=false
+ fi
+
+ dnl wchar?
+ AC_CURSES_CHECK_WIDECHAR()
+ if test "x$curses_wchar" = "xfalse"
+ then
+ CURSES_WCHAR=false
+ else
+ AC_DEFINE(CURSES_WCHAR)
+ CURSES_WCHAR=true
+ CURSES_FLAGS=$curses_wchar
+ AC_SUBST(CURSES_FLAGS)
+ fi
+
+ dnl end key?
+ AC_CURSES_CHECK_ENDKEY()
+ if test "x$curses_endkey" = "xtrue"
+ then
+ AC_DEFINE(CURSES_KEY_END)
+ CURSES_KEY_END=true
+ else
+ CURSES_KEY_END=false
+ fi
+
+ fi
+
+])
+
+
+
dnl
-dnl #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
-dnl #include <ncurses.h>
-dnl #else
-dnl #include <curses.h>
-dnl #endif
+dnl searches for curses in a specific place
+dnl Parameters: directory filename curses_LIBS curses_INCLUDES
dnl
-dnl 3) Make sure to add @CURSES_INCLUDES@ to your preprocessor flags
-dnl 4) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
+AC_DEFUN([AC_SEARCH_CURSES_FILE], [
+ if test "x$stop_searching" = "xfalse"
+ then
+ if test -f $1/$2
+ then
+ AC_MSG_RESULT([$1/$2])
+ curses_h="$2"
+ curses_libs="$3"
+ curses_includes="$4"
+ stop_searching=true
+ found_curses_h=true
+ fi
+ fi
+])
+
dnl
-dnl Notes with automake:
-dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
-dnl configure.in
-dnl - your Makefile.am can look something like this
-dnl -----------------------------------------------
-dnl INCLUDES= blah blah blah $(CURSES_INCLUDES)
-dnl if HAS_CURSES
-dnl CURSES_TARGETS=name_of_curses_prog
-dnl endif
-dnl bin_PROGRAMS = other_programs $(CURSES_TARGETS)
-dnl other_programs_SOURCES = blah blah blah
-dnl name_of_curses_prog_SOURCES = blah blah blah
-dnl other_programs_LDADD = blah
-dnl name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
-dnl -----------------------------------------------
+dnl Search for curses.h in several different places
dnl
-dnl
-dnl First define the headers for config.h.in:
-AH_TEMPLATE([HAS_CURSES],
- [ Found some version of curses that we're going to use ])
-AH_TEMPLATE([USE_SUNOS_CURSES],
- [ Use SunOS SysV curses? ])
-AH_TEMPLATE([USE_BSD_CURSES],
- [ Use old BSD curses - not used right now ])
-AH_TEMPLATE([USE_SYSV_CURSES],
- [ Use SystemV curses? ] )
-AH_TEMPLATE([USE_NCURSES],
- [ Use Ncurses? ] )
-AH_TEMPLATE([NO_COLOR_CURSES],
- [ If you Curses does not have color define this one ])
-AH_TEMPLATE([SCO_FLAVOR],
- [ Define if you want to turn on SCO-specific code ])
-AH_TEMPLATE([NCURSES_970530],
- [ Set to reflect version of ncurses
- 0 = version 1.
- 1 = version 1.9.9g
- 2 = version 4.0/4.1 ])
+AC_DEFUN([AC_SEARCH_CURSES_H], [
+ AC_MSG_CHECKING([location of curses.h file])
-AC_DEFUN([AC_CHECK_CURSES],[
- search_ncurses=true
- screen_manager=""
- has_curses=false
+ stop_searching=false
+ found_curses_h=false
- CFLAGS=${CFLAGS--O}
+ dnl if a particular location was specified
+ if test "x$curses_location" != "xfalse"
+ then
+ dnl check this particular location
+ AC_SEARCH_CURSES_FILE($curses_location/include, ncursesw/ncurses.h,
+ -L$curses_location/lib -lncursesw,
+ -I$curses_location/include )
+ AC_SEARCH_CURSES_FILE($curses_location/include, ncursesw.h,
+ -L$curses_location/lib -lncursesw,
+ -I$curses_location/include )
+ AC_SEARCH_CURSES_FILE($curses_location/include, ncurses/ncurses.h,
+ -L$curses_location/lib -lncurses,
+ -I$curses_location/include )
+ AC_SEARCH_CURSES_FILE($curses_location/include, ncurses.h,
+ -L$curses_location/lib -lncurses,
+ -I$curses_location/include )
+ AC_SEARCH_CURSES_FILE($curses_location/include, curses.h,
+ -L$curses_location/lib -lncurses,
+ -I$curses_location/include )
+
+ else
+ dnl check lots of default locations
- AC_SUBST(CURSES_LIBS)
- AC_SUBST(CURSES_INCLUDES)
+ dnl first preference is ncursesw
+ AC_SEARCH_CURSES_FILE(/usr/local/include, ncursesw/ncurses.h,
+ -L/usr/local/lib -lncursesw,
+ -I/usr/local/include )
+ AC_SEARCH_CURSES_FILE(/usr/local/include/, ncursesw.h,
+ -L/usr/local/lib -lncursesw,
+ -I/usr/local/include )
+
+ AC_SEARCH_CURSES_FILE(/usr/include, ncursesw/ncurses.h,
+ -L/usr/lib -lncursesw,
+ -I/usr/include )
+ AC_SEARCH_CURSES_FILE(/usr/include/, ncursesw.h,
+ -L/usr/lib -lncursesw,
+ -I/usr/include )
+
+ dnl after that, look for normal ncurses
+ AC_SEARCH_CURSES_FILE(/usr/local/include, ncurses.h,
+ -L/usr/local/lib -lncurses,
+ -I/usr/local/include )
+ AC_SEARCH_CURSES_FILE(/usr/local/include, ncurses/ncurses.h,
+ -L/usr/local/lib -lncurses,
+ -I/usr/local/include )
+
+ AC_SEARCH_CURSES_FILE(/usr/include, ncurses.h,
+ -L/usr/lib -lncurses,
+ -I/usr/include )
+ AC_SEARCH_CURSES_FILE(/usr/include, ncurses/ncurses.h,
+ -L/usr/lib -lncurses,
+ -I/usr/include )
- AC_ARG_WITH(sco,
- [ --with-sco Use this to turn on SCO-specific code],[
- if test x$withval = xyes; then
- AC_DEFINE(SCO_FLAVOR)
- CPPFLAGS="$CPPFLAGS -D_SVID3"
- fi
- ])
+ dnl after that, look for curses
+ AC_SEARCH_CURSES_FILE(/usr/local/include, curses.h,
+ -L/usr/local/lib -lncurses,
+ -I/usr/local/include )
+ AC_SEARCH_CURSES_FILE(/usr/local/include, curses/curses.h,
+ -L/usr/local/lib -lncurses,
+ -I/usr/local/include )
+
+ AC_SEARCH_CURSES_FILE(/usr/include, curses.h,
+ -L/usr/lib -lncurses,
+ -I/usr/include )
+ AC_SEARCH_CURSES_FILE(/usr/include, curses/curses.h,
+ -L/usr/lib -lncurses,
+ -I/usr/include )
+ fi
- AC_ARG_WITH(sunos-curses,
- [ --with-sunos-curses Used to force SunOS 4.x curses],[
- if test x$withval = xyes; then
- AC_USE_SUNOS_CURSES
- fi
- ])
+])
- AC_ARG_WITH(osf1-curses,
- [ --with-osf1-curses Used to force OSF/1 curses],[
- if test x$withval = xyes; then
- AC_USE_OSF1_CURSES
- fi
- ])
+dnl
+dnl check if the curses header we found, works
+dnl
+AC_DEFUN([AC_CHECK_CURSES_COMPILE], [
- AC_ARG_WITH(vcurses,
- [ --with-vcurses[=incdir] Used to force SysV curses],
- if test x$withval != xyes; then
- CURSES_INCLUDES="-I$withval"
- fi
- AC_USE_SYSV_CURSES
- )
+ dnl save CFLAGS and LDFLAGS and set new ones
+ CFLAGS_OLD=$CFLAGS
+ CFLAGS="$CFLAGS $curses_includes"
+ LDFLAGS_OLD=$LDFLAGS
+ LDFLAGS="$LDFLAGS $curses_libs"
- AC_ARG_WITH(ncurses,
- [ --with-ncurses[=dir] Compile with ncurses/locate base dir],
- if test x$withval = xno ; then
- search_ncurses=false
- elif test x$withval != xyes ; then
- CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
- CURSES_INCLUDES="-I$withval/include"
- search_ncurses=false
- screen_manager="ncurses"
- AC_DEFINE(USE_NCURSES)
- AC_DEFINE(HAS_CURSES)
- has_curses=true
- use_ncurses=true
- fi
+ dnl do the compile test
+ AC_MSG_CHECKING([if curses is usable])
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM(
+ [[
+ #include <$curses_h>
+ ]],
+ [[
+ initscr();
+ printw("Hello World !!!");
+ refresh();
+ getch();
+ endwin();
+ return 0;
+ ]]
+ )],
+ [
+ curses_usable=true
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ curses_usable=false
+ AC_MSG_RESULT([no])
+ ]
)
- if $search_ncurses
- then
- AC_SEARCH_NCURSES()
- fi
-
+ dnl restore variables
+ CFLAGS=$CFLAGS_OLD
+ LDFLAGS=$LDFLAGS_OLD
+
])
+dnl
+dnl check if this version of curses has support for colors
+dnl
+AC_DEFUN([AC_CURSES_CHECK_COLORS], [
-AC_DEFUN([AC_USE_SUNOS_CURSES], [
- search_ncurses=false
- screen_manager="SunOS 4.x /usr/5include curses"
- AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
- AC_DEFINE(USE_SUNOS_CURSES)
- AC_DEFINE(HAS_CURSES)
- has_curses=true
- AC_DEFINE(NO_COLOR_CURSES)
- AC_DEFINE(USE_SYSV_CURSES)
- CURSES_INCLUDES="-I/usr/5include"
- CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
- AC_MSG_RESULT(Please note that some screen refreshs may fail)
-])
+ dnl save and change CFLAGS
+ CFLAGS_OLD=$CFLAGS
+ CFLAGS="$CFLAGS $curses_includes"
+
+ dnl print nice message
+ AC_MSG_CHECKING([if ncurses supports colors])
-AC_DEFUN([AC_USE_OSF1_CURSES], [
- AC_MSG_RESULT(Using OSF1 curses)
- search_ncurses=false
- screen_manager="OSF1 curses"
- AC_DEFINE(HAS_CURSES)
- has_curses=true
- AC_DEFINE(NO_COLOR_CURSES)
- AC_DEFINE(USE_SYSV_CURSES)
- CURSES_LIBS="-lcurses"
-])
+ dnl we check for definition of COLOR_YELLOW
+ AC_EGREP_CPP(
+ HAVE_COLOR_YELLOW,
+ [
+ #include <$curses_h>
+ #ifdef COLOR_YELLOW
+ HAVE_COLOR_YELLOW
+ #endif
+ ],
+ [
+ curses_colors=true
+ AC_MSG_RESULT(yes)
+ ],
+ [
+ curses_colors=false
+ AC_MSG_RESULT(no)
+ ]
+ )
-AC_DEFUN([AC_USE_SYSV_CURSES], [
- AC_MSG_RESULT(Using SysV curses)
- AC_DEFINE(HAS_CURSES)
- has_curses=true
- AC_DEFINE(USE_SYSV_CURSES)
- search_ncurses=false
- screen_manager="SysV/curses"
- CURSES_LIBS="-lcurses"
+ dnl restore CFLAGS
+ CFLAGS=$CFLAGS_OLD
+
])
-
-dnl AC_ARG_WITH(bsd-curses,
-dnl [--with-bsd-curses Used to compile with bsd curses, not very fancy],
-dnl search_ncurses=false
-dnl screen_manager="Ultrix/cursesX"
-dnl if test $system = ULTRIX
-dnl then
-dnl THIS_CURSES=cursesX
-dnl else
-dnl THIS_CURSES=curses
-dnl fi
dnl
-dnl CURSES_LIBS="-l$THIS_CURSES -ltermcap"
-dnl AC_DEFINE(HAS_CURSES)
-dnl has_curses=true
-dnl AC_DEFINE(USE_BSD_CURSES)
-dnl AC_MSG_RESULT(Please note that some screen refreshs may fail)
-dnl AC_WARN(Use of the bsdcurses extension has some)
-dnl AC_WARN(display/input problems.)
-dnl AC_WARN(Reconsider using xcurses)
-dnl)
+dnl check if this version of curses can handle utf8 and friends
+dnl
+AC_DEFUN([AC_CURSES_CHECK_WIDECHAR], [
+ dnl save and change CFLAGS
+ CFLAGS_OLD=$CFLAGS
+ CFLAGS="$CFLAGS $curses_includes"
-dnl
-dnl Parameters: directory filename cureses_LIBS curses_INCLUDES nicename
-dnl
-AC_DEFUN([AC_NCURSES], [
- if $search_ncurses
- then
- if test -f $1/$2
+ dnl print nice message
+ AC_MSG_CHECKING([if ncurses supports extended chars])
+
+ dnl this will contain the define we need
+ curses_wchar=false
+
+ dnl first check with default options
+ dnl we check for existence of the add_wch() function
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM(
+ [[ #include <$curses_h> ]],
+ [[ char *p = (char *) add_wch; ]]
+ )],
+ [
+ dnl if found, set variables and print result
+ curses_wchar=true
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ dnl if not found, do NOP
+ true
+ ]
+ )
+
+ dnl not found, now try with -D_XOPEN_SOURCE_EXTENDED
+ if test "x$curses_wchar" = "xfalse"
then
- AC_MSG_RESULT(Found ncurses on $1/$2)
- CURSES_LIBS="$3"
- CURSES_INCLUDES="$4"
- search_ncurses=false
- screen_manager=$5
- AC_DEFINE(HAS_CURSES)
- has_curses=true
- AC_DEFINE(USE_NCURSES)
- use_ncurses=true
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM(
+ [[
+ #define _XOPEN_SOURCE_EXTENDED
+ #include <$curses_h>
+ ]],
+ [[ char *p = (char *) add_wch; ]]
+ )],
+ [
+ dnl if found, set variables and print result
+ curses_wchar=-D_XOPEN_SOURCE_EXTENDED
+ AC_MSG_RESULT([yes, with $curses_wchar])
+ ],
+ [
+ dnl if not found, do NOP
+ true
+ ]
+ )
fi
- fi
+
+ dnl restore CFLAGS
+ CFLAGS=$CFLAGS_OLD
+
+ dnl print message if not found
+ if test "x$curses_wchar" = "xfalse"
+ then
+ AC_MSG_RESULT([no]);
+ fi
+
])
-AC_DEFUN([AC_SEARCH_NCURSES], [
- AC_CHECKING("location of ncurses.h file")
+dnl
+dnl check if this version of curses has an end key definition
+dnl
+AC_DEFUN([AC_CURSES_CHECK_ENDKEY], [
- AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
- AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
- AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
- AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
+ dnl save and change CFLAGS
+ CFLAGS_OLD=$CFLAGS
+ CFLAGS="$CFLAGS $curses_includes"
+
+ dnl print nice message
+ AC_MSG_CHECKING([if ncurses supports the end key])
- AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
+ dnl we check for definition of HAVE_KEY_END
+ AC_EGREP_CPP(
+ HAVE_KEY_END,
+ [
+ #include <$curses_h>
+ #ifdef KEY_END
+ HAVE_KEY_END
+ #endif
+ ],
+ [
+ curses_endkey=true
+ AC_MSG_RESULT(yes)
+ ],
+ [
+ curses_endkey=false
+ AC_MSG_RESULT(no)
+ ]
+ )
- AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
+ dnl restore CFLAGS
+ CFLAGS=$CFLAGS_OLD
- dnl
- dnl We couldn't find ncurses, try SysV curses
- dnl
- if $search_ncurses
- then
- AC_EGREP_HEADER(init_color, /usr/include/curses.h,
- AC_USE_SYSV_CURSES)
- AC_EGREP_CPP(USE_NCURSES,[
-#include <curses.h>
-#ifdef __NCURSES_H
-#undef USE_NCURSES
-USE_NCURSES
-#endif
-],[
- CURSES_INCLUDES="$CURSES_INCLUDES -DRENAMED_NCURSES"
- AC_DEFINE(HAS_CURSES)
- has_curses=true
- AC_DEFINE(USE_NCURSES)
- use_ncurses=true
- search_ncurses=false
- screen_manager="ncurses installed as curses"
])
- fi
- dnl
- dnl Try SunOS 4.x /usr/5{lib,include} ncurses
- dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
- dnl should be replaced by a more fine grained selection routine
- dnl
- if $search_ncurses
- then
- if test -f /usr/5include/curses.h
- then
- AC_USE_SUNOS_CURSES
- fi
- else
- # check for ncurses version, to properly ifdef mouse-fix
- AC_MSG_CHECKING(for ncurses version)
- ncurses_version=unknown
-cat > conftest.$ac_ext <<EOF
-[#]line __oline__ "configure"
-#include "confdefs.h"
-#ifdef RENAMED_NCURSES
-#include <curses.h>
-#else
-#include <ncurses.h>
-#endif
-#undef VERSION
-VERSION:NCURSES_VERSION
-EOF
- if (eval "$ac_cpp $CURSES_INCLUDES conftest.$ac_ext") 2>&AC_FD_CC |
- egrep "VERSION:" >conftest.out 2>&1; then
-changequote(,)dnl
- ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
-changequote([,])dnl
- fi
- rm -rf conftest*
- AC_MSG_RESULT($ncurses_version)
- case "$ncurses_version" in
-changequote(,)dnl
- 4.[01])
-changequote([,])dnl
- AC_DEFINE(NCURSES_970530,2)
- ;;
- 1.9.9g)
- AC_DEFINE(NCURSES_970530,1)
- ;;
- 1*)
- AC_DEFINE(NCURSES_970530,0)
- ;;
- esac
- fi
+dnl
+dnl check if this version of curses has support for mouse events
+dnl
+AC_DEFUN([AC_CURSES_CHECK_MOUSE], [
+
+ dnl save and change CFLAGS
+ CFLAGS_OLD=$CFLAGS
+ CFLAGS="$CFLAGS $curses_includes"
+
+ dnl print nice message
+ AC_MSG_CHECKING([if ncurses supports mouse events])
+
+ dnl we check for definition of BUTTON1_CLICKED
+ AC_EGREP_CPP(
+ HAVE_BUTTON1_CLICKED,
+ [
+ #include <$curses_h>
+ #ifdef BUTTON1_CLICKED
+ HAVE_BUTTON1_CLICKED
+ #endif
+ ],
+ [
+ curses_mouse=true
+ AC_MSG_RESULT(yes)
+ ],
+ [
+ curses_mouse=false
+ AC_MSG_RESULT(no)
+ ]
+ )
+
+ dnl restore CFLAGS
+ CFLAGS=$CFLAGS_OLD
+
])
+dnl vim:ts=4:sw=4
Modified: pinfo/trunk/macros/readline.m4
===================================================================
--- pinfo/trunk/macros/readline.m4 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/macros/readline.m4 2005-09-27 15:23:27 UTC (rev 260)
@@ -53,7 +53,7 @@
AC_SUBST(READLINE_INCLUDES)
AC_ARG_WITH(readline,
- [ --with-readline[=dir] Compile with readline/locate base dir [no compile]],
+ [ --with-readline[=dir] Compile with readline/locate base dir [no compile]],
if test "x$withval" = "xno" ; then
search_readline=false
elif test "x$withval" != "xyes" ; then
@@ -114,7 +114,7 @@
] )
AC_DEFUN([AC_READLINE_VERSION], [
- AC_CHECKING(for readline version)
+ AC_MSG_CHECKING(for readline version)
readline_version=unknown
cat > conftest.$ac_ext <<EOF
[#]line __oline__ "configure"
Added: pinfo/trunk/macros/wchar.m4
===================================================================
--- pinfo/trunk/macros/wchar.m4 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/macros/wchar.m4 2005-09-27 15:23:27 UTC (rev 260)
@@ -0,0 +1,127 @@
+dnl Detection of wchar_t and friends
+dnl Copyright (c) 2005 by Bas Zoetekouw <bas at debian.org>
+
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of version 2 of the GNU General Public License as
+dnl published by the Free Software Foundation.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+dnl USA
+
+
+dnl To use thisscript , put a call to AC_CHECK_WCHAR in your configure.ac
+dnl After the call, USE_WCHAR will be defined and $USE_WCHAR=true if
+dnl wide characters are supported.
+dnl Additional flags that are needed are defined in
+dnl $WCHAR_FLAGS and @WCHAR_FLAGS@
+
+AH_TEMPLATE([USE_WCHAR],
+ [Defined if support for wide chars is wanted and supported.
+ wchar.h, wchar_t, mbstowcs(), and friends will be available.]
+)
+AH_TEMPLATE([HAVE_WCSWIDTH],
+ [Defined if wcswidth() is available in <wchar.h>]
+)
+
+AC_DEFUN([AC_CHECK_WCHAR],[
+
+ wchar_flags=
+
+ dnl first check for wchar_t
+ AC_MSG_CHECKING([for wchar_t in wchar.h])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([
+ [ #include <wchar.h> ],
+ [ wchar_t foo = (wchar_t)'\0'; ]
+ ])],
+ [
+ AC_MSG_RESULT([yes])
+ wchar_usable=true
+ ],
+ [
+ AC_MSG_RESULT([no])
+ wchar_usable=false
+ ]
+ )
+
+ if test "x$wchar_usable" = "xtrue"
+ then
+ dnl then check for mbstowcs
+ AC_CHECK_DECL([mbstowcs],
+ [ have_mbstowcs=true ],
+ [ have_mbstowcs=false ]
+ )
+
+ dnl then check for wcwidth
+ have_wcwidth=false
+ AC_MSG_CHECKING([for wcwidth])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM(
+ [ #include <wchar.h> ],
+ [ char *p = (char *) wcwidth; ]
+ )],
+ [
+ dnl if found, set variables and print result
+ have_wcwidth=true
+ AC_MSG_RESULT([yes])
+ ],
+ [ ]
+ )
+ if test "x$have_wcwidth" = "xfalse"
+ then
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM(
+ [[
+ #define _XOPEN_SOURCE 600
+ #include <wchar.h>
+ ]],
+ [[ char *p = (char *) wcwidth; ]]
+ )],
+ [
+ dnl if found, set variables and print result
+ have_wcwidth=true
+ wchar_flags="$wchar_flags -D_XOPEN_SOURCE=600"
+ AC_MSG_RESULT([with -D_XOPEN_SOURCE=600])
+ ],
+ [ ]
+ )
+ fi
+
+ fi
+
+
+ if test \( "x$wchar_usable" = "xtrue" \) \
+ -a \( "x$have_mbstowcs" = "xtrue" \) \
+ -a \( "x$have_wcwidth" = "xtrue" \)
+ then
+ USE_WCHAR=true
+ AC_DEFINE(USE_WCHAR)
+ WCHAR_FLAGS=$wchar_flags
+ AC_SUBST(WCHAR_FLAGS)
+ else
+ USE_WCHAR=false
+ fi
+
+ if test "x$USE_WCHAR" = "xtrue"
+ then
+ dnl check for wcswidth
+ CPPFLAGS_OLD=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS $wchar_flags"
+ AC_CHECK_DECL([wcswidth],
+ [ AC_DEFINE(HAVE_WCSWIDTH) ],
+ [ true ],
+ [ #include <wchar.h> ]
+ )
+ CPPFLAGS=$CPPFLAGS_OLD
+ fi
+
+])
+
+dnl vim:ts=4:sw=4
Modified: pinfo/trunk/src/Makefile.am
===================================================================
--- pinfo/trunk/src/Makefile.am 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/Makefile.am 2005-09-27 15:23:27 UTC (rev 260)
@@ -63,9 +63,13 @@
INCLUDES = @READLINE_INCLUDES@
-pinfo_LDADD = $(pinfo_READLINE_OBJ) $(pinfo_SNPRINTF_OBJ)\
- $(pinfo_SIGBLOCK_OBJ) @READLINE_LIBS@ $(INTLLIBS)
+pinfo_LDADD = \
+ $(pinfo_READLINE_OBJ) $(pinfo_SNPRINTF_OBJ) \
+ $(pinfo_SIGBLOCK_OBJ) @READLINE_LIBS@ $(INTLLIBS) \
+ @CURSES_LIBS@
+pinfo_CPPFLAGS = @CURSES_FLAGS@ @CURSES_INCLUDES@ @WCHAR_FLAGS@
+
pinfo_DEPENDENCIES = $(pinfo_READLINE_OBJ)\
$(pinfo_SNPRINTF_OBJ)\
$(pinfo_SIGBLOCK_OBJ)\
Modified: pinfo/trunk/src/common_includes.h
===================================================================
--- pinfo/trunk/src/common_includes.h 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/common_includes.h 2005-09-27 15:23:27 UTC (rev 260)
@@ -22,16 +22,9 @@
#ifndef __COMMON_INCLUDES_H
#define __COMMON_INCLUDES_H
-#include "localestuff.h"
-
-#if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
-#include <ncurses.h>
-#else
-#include <curses.h>
-#endif
-
#include <stdio.h>
#include <string.h>
+#include <strings.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
@@ -42,9 +35,26 @@
#include <grp.h>
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
+#include CURSES_H_NAME
+
+/* fall back to using 'E' is curses doesn't support the end key */
+#ifndef CURSES_KEY_END
+ #define KEY_END 'E'
+#endif
+/* quick hack;
+ * really should replace all the NO_COLOR_CURSES checks
+ * by CURSES_COLORS
+ */
+#ifndef CURSES_COLORS
+ #define NO_COLOR_CURSES
+#endif
+
+
+#include "localestuff.h"
+
#include "rcsid.h"
#include "datatypes.h"
#include "filehandling_functions.h"
Modified: pinfo/trunk/src/filehandling_functions.c
===================================================================
--- pinfo/trunk/src/filehandling_functions.c 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/filehandling_functions.c 2005-09-27 15:23:27 UTC (rev 260)
@@ -911,7 +911,7 @@
char emptystr[1] = "";
char **paths = NULL;
char *infopath = NULL, *langpath = NULL;
- char *c, *dir, *env;
+ char *c, *dir, *env, *next;
char *rawlang = NULL, *lang = NULL, *langshort = NULL;
int ret;
unsigned int i, j, maxpaths, numpaths = 0, infolen, langlen;
@@ -925,25 +925,33 @@
{
env = emptystr;
}
- infolen = strlen(env) + strlen(configuredinfopath) + 2;
+ infolen = strlen(env) + strlen(configuredinfopath) + 3;
infopath = (char *) xmalloc( infolen );
strcat(infopath, env);
strcat(infopath, ":");
strcat(infopath, configuredinfopath);
+ /* end with a :, otherwise the strchr below will fail for the last entry */
+ strcat(infopath, ":");
/* alloc the paths[] array */
maxpaths = 3 * (charcount( infopath, ':' ) + 1); // *3 for $LANG
paths = (char **) xmalloc( maxpaths * sizeof(char *) );
/* split at ':' and put the path components into paths[] */
- c = infopath;
- while ( (dir = strsep(&c, ":")) != NULL )
+ dir = infopath;
+ /* if this actually is a non-empty string, add it to paths[] */
+ while ( (next = strchr(dir, ':')) != NULL )
{
- /* if this actually is a non-empty string, add it to paths[] */
+ *next = '\0'; /* terminate the string */
+
+ /* if the dir actually is a non-empty string, add it to paths[] */
if ( dir && strlen(dir)>0 )
{
paths[numpaths++] = dir;
}
+
+ /* and advance the pointer to the next entry */
+ dir = next+1;
}
/* get the current $LANG, if any (to use for localized info pages) */
Modified: pinfo/trunk/src/initializelinks.c
===================================================================
--- pinfo/trunk/src/initializelinks.c 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/initializelinks.c 2005-09-27 15:23:27 UTC (rev 260)
@@ -93,16 +93,22 @@
calculate_len(char *start, char *end)
{
int len = 0;
- while (start < end)
+ char *c = start;
+ while (c < end)
{
- len++;
- if (*start == '\t')
+ if (*c == '\t')
{
- len--;
- len +=(8 -((len) -(((len) >> 3) << 3)));
+ /* now, first count everything leading up to this position */
+ len += width_of_string(start, c - start);
+ start = c+1;
+ /* then add the extra width of the tab */
+ len = ( len & ~0x07 ) + 0x08;
}
- start++;
+ c++;
}
+ /* then count everything after the last tab */
+ len += width_of_string(start, c - start);
+
return len;
}
Modified: pinfo/trunk/src/mainfunction.c
===================================================================
--- pinfo/trunk/src/mainfunction.c 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/mainfunction.c 2005-09-27 15:23:27 UTC (rev 260)
@@ -1063,7 +1063,7 @@
/*==========================================================================*/
/**************************** end of keyboard handling **********************/
/******************************** mouse handler *****************************/
-#ifdef NCURSES_MOUSE_VERSION
+#ifdef CURSES_MOUSE
if (key == KEY_MOUSE)
{
MEVENT mouse;
@@ -1166,7 +1166,7 @@
ungetch(keys.pgdn_1);
} /* end: button doubleclicked */
}
-#endif
+#endif /* NCURSES_MOUSE */
/*****************************************************************************/
}
if ((key == keys.quit_2) ||(key == keys.quit_1))
Modified: pinfo/trunk/src/manual.c
===================================================================
--- pinfo/trunk/src/manual.c 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/manual.c 2005-09-27 15:23:27 UTC (rev 260)
@@ -24,6 +24,7 @@
#include <ctype.h>
#include <sys/stat.h>
+#include <stdlib.h>
#define HTTPSECTION 100
#define FTPSECTION 101
@@ -720,7 +721,7 @@
urlend = findurlend(urlstart);
manuallinks = xrealloc(manuallinks, sizeof(manuallink) *(ManualLinks + 3));
manuallinks[ManualLinks].line = ManualLines;
- manuallinks[ManualLinks].col = urlstart - tmp;
+ manuallinks[ManualLinks].col = width_of_string(tmp, urlstart - tmp);
strcpy(manuallinks[ManualLinks].section, "HTTPSECTION");
manuallinks[ManualLinks].section_mark = HTTPSECTION;
manuallinks[ManualLinks].name = xmalloc(urlend - urlstart + 10);
@@ -739,7 +740,7 @@
urlend = findurlend(urlstart);
manuallinks = xrealloc(manuallinks, sizeof(manuallink) *(ManualLinks + 3));
manuallinks[ManualLinks].line = ManualLines;
- manuallinks[ManualLinks].col = urlstart - tmp;
+ manuallinks[ManualLinks].col = width_of_string(tmp, urlstart - tmp);
strcpy(manuallinks[ManualLinks].section, "FTPSECTION");
manuallinks[ManualLinks].section_mark = FTPSECTION;
manuallinks[ManualLinks].name = xmalloc(urlend - urlstart + 10);
@@ -758,7 +759,7 @@
urlend = findurlend(urlstart);
manuallinks = xrealloc(manuallinks, sizeof(manuallink) *(ManualLinks + 3));
manuallinks[ManualLinks].line = ManualLines;
- manuallinks[ManualLinks].col = urlstart - tmp;
+ manuallinks[ManualLinks].col = width_of_string(tmp, urlstart - tmp);
strcpy(manuallinks[ManualLinks].section, "MAILSECTION");
manuallinks[ManualLinks].section_mark = MAILSECTION;
manuallinks[ManualLinks].name = xmalloc(urlend - urlstart + 10);
@@ -828,6 +829,9 @@
* manuallinks table to make free space for new entry
*/
+ /* calculate the number of columns in front of the link */
+ int cols_before_link = width_of_string(tmp, i-1);
+
/* a small check */
if (!((use_apropos) &&(manualhistorylength == 0)))
{
@@ -846,7 +850,7 @@
}
manuallinks = xrealloc(manuallinks, sizeof(manuallink) *(ManualLinks + 3));
manuallinks[ManualLinks].line = ManualLines;
- manuallinks[ManualLinks].col = i;
+ manuallinks[ManualLinks].col = cols_before_link + 1;
if (LongManualLinks)
{
for (b = 1; mylink[b] != ')'; b++)
@@ -1439,7 +1443,7 @@
/*=====================================================*/
/********* end of keyboard handling *********************/
/********* mouse handler ********************************/
-#ifdef NCURSES_MOUSE_VERSION
+#ifdef CURSES_MOUSE
if (key == KEY_MOUSE)
{
MEVENT mouse;
@@ -1530,7 +1534,7 @@
ungetch(keys.pgdn_1);
} /* end: button doubleclicked */
}
-#endif
+#endif /* CURSES_MOUSE */
/*****************************************************************************/
}
if ((key == keys.quit_2) ||(key == keys.quit_1))
Modified: pinfo/trunk/src/parse_config.c
===================================================================
--- pinfo/trunk/src/parse_config.c 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/parse_config.c 2005-09-27 15:23:27 UTC (rev 260)
@@ -179,10 +179,8 @@
char *temp;
int *fore = NULL;
int *key = NULL;
-#ifdef HAS_CURSES
int *back = NULL, *bold = NULL, *blink = NULL, *p = NULL;
int i;
-#endif /* HAS_CURSES */
if (line[0] == '#')
return 0;
@@ -877,10 +875,8 @@
*key = KEY_F(11);
else if (!(strncmp(temp + 4, "F(12)", 5)))
*key = KEY_F(12);
-#ifdef USE_NCURSES
else if (!(strncmp(temp + 4, "END", 3)))
*key = KEY_END;
-#endif
else if (!(strncmp(temp + 4, "CTRL", 4)))
{
if (!(temp = skip_whitespace(temp + 8)))
Modified: pinfo/trunk/src/utils.c
===================================================================
--- pinfo/trunk/src/utils.c 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/utils.c 2005-09-27 15:23:27 UTC (rev 260)
@@ -25,7 +25,12 @@
#include <regex.h>
#include <ctype.h>
+#include <sys/select.h>
+#ifdef USE_WCHAR
+ #include <wchar.h>
+#endif
+
char *safe_user = "nobody";
char *safe_group = "nogroup";
@@ -284,9 +289,8 @@
/* meta(stdscr, TRUE); */
initcolors();
shell_cursor = curs_set(0);
-#ifdef NCURSES_MOUSE_VERSION
+#ifdef CURSES_MOUSE
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED, NULL);
-/* NCURSES_MOUSE_VERSION */
#endif
curses_open = 1;
}
@@ -583,3 +587,70 @@
}
}
+
+/*
+ * The wcswidth function returns the number of columns needed to represent
+ * the wide-character string pointed to by s, but at most n wide charac‐
+ * ters. If a non-printable wide character occurs among these characters,
+ * -1 is returned.
+ */
+#if defined(USE_WCHAR) && !defined(HAVE_WCSWIDTH)
+int
+wcswidth(const wchar_t *wstr, size_t max_len)
+{
+ int width = 0;
+ size_t i;
+ size_t len = wcslen(wstr);
+
+ /* never count more than max_len chars */
+ if (len>max_len) len=max_len;
+
+ for (i=0; i<len; i++)
+ {
+ if (!iswprint(wstr[i])) return -1;
+ width += wcwidth(wstr[i]);
+ }
+
+ return width;
+}
+#endif /* USE_WCHAR && !HAVE_WCSWIDTH */
+
+
+/* calculcate length of string, handling multibyte strings correctly
+ * returns value <= len
+ */
+int
+width_of_string( const char * const mbs, const int len)
+{
+ if (len<0) return -1;
+ if (len==0) return 0;
+
+ int width;
+
+ /* copy the string to a local buffer, because we only want to
+ * compare the first len bytes */
+ char *str = xmalloc(len+1);
+ memcpy(str, mbs, len);
+
+#ifdef USE_WCHAR
+
+ /* allocate a widestring */
+ wchar_t *wstr = xmalloc( (len+1)*sizeof(wchar_t) );
+
+ mbstowcs(wstr, str, len);
+ width = wcswidth(wstr, len);
+
+ /* clean up */
+ xfree(wstr);
+
+#else /* USE_WCHAR */
+
+ width = strlen(str);
+
+#endif /* USE_WCHAR */
+
+ /* clean up */
+ xfree(str);
+
+ return width;
+}
Modified: pinfo/trunk/src/utils.h
===================================================================
--- pinfo/trunk/src/utils.h 2005-09-26 07:21:36 UTC (rev 259)
+++ pinfo/trunk/src/utils.h 2005-09-27 15:23:27 UTC (rev 260)
@@ -90,4 +90,10 @@
check_node_name( const char * const node_name, const char * const node_header);
+/* calculate width of string, handling multibyte encodings
+ * correctly */
+int
+width_of_string( const char * const mbs, const int len);
+
+
#endif
More information about the Pinfo-devel
mailing list