Skip to content

Commit

Permalink
Use wide version of ctype functions if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 6, 2007
1 parent b8645e0 commit e806daf
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 8 deletions.
11 changes: 10 additions & 1 deletion NEWS.VER
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@
======================================================================


Major changes between "less" versions 406 and @@VERSION@@
Major changes between "less" versions 409 and @@VERSION@@

* Make searching with -i/-I work correctly with non-ASCII text.

* Fix DJGPP build.

======================================================================

Major changes between "less" versions 406 and 409

* Support CSI escape sequences, like SGR escape sequences.

Expand Down Expand Up @@ -698,3 +706,4 @@




24 changes: 23 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ AC_PROG_INSTALL
AC_SYS_LARGEFILE

# Checks for general libraries.
AC_CHECK_LIB(tinfo, tgoto, [have_tinfo=yes], [have_tinfo=no])
AC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
AC_CHECK_LIB(ncursesw, initscr, [have_ncursesw=yes], [have_ncursesw=no])
AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
Expand Down Expand Up @@ -51,6 +52,20 @@ fi
fi

if test $curses_broken = 0; then

# -- Try tinfo.
if test "x$TERMLIBS" = x; then
if test $have_tinfo = yes; then
TERMLIBS="-ltinfo"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
[termok=yes], [termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
fi

# -- Try xcurses.
if test "x$TERMLIBS" = x; then
if test $have_xcurses = yes; then
Expand Down Expand Up @@ -154,7 +169,7 @@ LIBS="$LIBS $TERMLIBS"

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h])
AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
Expand Down Expand Up @@ -204,6 +219,8 @@ AH_TEMPLATE([HAVE_TERMIOS_FUNCS],
[Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr.])
AH_TEMPLATE([HAVE_UPPER_LOWER],
[Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower.])
AH_TEMPLATE([HAVE_WCTYPE],
[Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower.])
AH_TEMPLATE([HAVE_SIGSET_T],
[Define HAVE_SIGSET_T you have the sigset_t type.])
AH_TEMPLATE([HAVE_SIGEMPTYSET],
Expand Down Expand Up @@ -307,13 +324,18 @@ AC_TRY_LINK([#include <locale.h>
#include <ctype.h>
#include <langinfo.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for ctype functions)
AC_TRY_LINK([
#if HAVE_CTYPE_H
#include <ctype.h>
#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for Unicode ctype functions)
AC_TRY_LINK([#include <wctype.h>], [iswlower(0); iswupper(0); towlower(0); towupper(0);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WCTYPE)], [AC_MSG_RESULT(no)])

# Checks for external variable ospeed in the termcap library.
have_ospeed=no
AC_MSG_CHECKING(termcap for ospeed)
Expand Down
3 changes: 3 additions & 0 deletions defines.ds
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1

/* Define if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 0

/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1

Expand Down
3 changes: 3 additions & 0 deletions defines.o2
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1

/* Define if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 0

/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1

Expand Down
3 changes: 3 additions & 0 deletions defines.o9
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1

/* Define if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 0

/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1

Expand Down
3 changes: 3 additions & 0 deletions defines.wn
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1

/* Define if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 1

/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1

Expand Down
20 changes: 15 additions & 5 deletions less.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
#if HAVE_CTYPE_H
#include <ctype.h>
#endif
#if HAVE_WCTYPE_H
#include <wctype.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
Expand Down Expand Up @@ -125,16 +128,23 @@ void free();
#undef IS_SPACE
#undef IS_DIGIT

#if !HAVE_UPPER_LOWER
#define IS_UPPER(c) ASCII_IS_UPPER(c)
#define IS_LOWER(c) ASCII_IS_LOWER(c)
#define TO_UPPER(c) ASCII_TO_UPPER(c)
#define TO_LOWER(c) ASCII_TO_LOWER(c)
#if HAVE_WCTYPE
#define IS_UPPER(c) iswupper(c)
#define IS_LOWER(c) iswlower(c)
#define TO_UPPER(c) towupper(c)
#define TO_LOWER(c) towlower(c)
#else
#if HAVE_UPPER_LOWER
#define IS_UPPER(c) isupper((unsigned char) (c))
#define IS_LOWER(c) islower((unsigned char) (c))
#define TO_UPPER(c) toupper((unsigned char) (c))
#define TO_LOWER(c) tolower((unsigned char) (c))
#else
#define IS_UPPER(c) ASCII_IS_UPPER(c)
#define IS_LOWER(c) ASCII_IS_LOWER(c)
#define TO_UPPER(c) ASCII_TO_UPPER(c)
#define TO_LOWER(c) ASCII_TO_LOWER(c)
#endif
#endif

#ifdef isspace
Expand Down
3 changes: 2 additions & 1 deletion version.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ v406 6/17/07 Fix secure build.
v407 8/16/07 Fix bugs; support CSI chars.
v408 10/1/07 Fix bug in -i with non-ASCII chars.
v409 10/12/07 Fix crash when viewing text with invalid UTF-8 sequences.
v410 11/5/07 Fix case-insensitive searching with non-ASCII text.
*/

char version[] = "409";
char version[] = "410";

0 comments on commit e806daf

Please sign in to comment.