1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-28 11:57:28 +00:00

Merge vendor changes onto mainline.

This commit is contained in:
Tim J. Robbins 2004-04-17 07:24:09 +00:00
parent d9872da232
commit 1ede161574
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128348
11 changed files with 217 additions and 709 deletions

View File

@ -1,76 +0,0 @@
/*
* Copyright (C) 1984-2000 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
*
* For more information about less, or for information on how to
* contact the author, see the README file.
*/
/*
* Regular expression library.
* Define exactly one of the following to be 1:
* HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
* HAVE_PCRE: PCRE (Perl-compatible regular expression) library
* HAVE_RE_COMP: BSD re_comp()
* HAVE_REGCMP: System V regcmp()
* HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
* NO_REGEX: pattern matching is supported, but without metacharacters.
*/
#undef HAVE_POSIX_REGCOMP
#undef HAVE_PCRE
#undef HAVE_RE_COMP
#undef HAVE_REGCMP
#undef HAVE_V8_REGCOMP
#undef NO_REGEX
#undef HAVE_REGEXEC2
/* Define HAVE_VOID if your compiler supports the "void" type. */
#undef HAVE_VOID
/* Define HAVE_CONST if your compiler supports the "const" modifier. */
#undef HAVE_CONST
/* Define HAVE_TIME_T if your system supports the "time_t" type. */
#undef HAVE_TIME_T
/* Define HAVE_STRERROR if you have the strerror() function. */
#undef HAVE_STRERROR
/* Define HAVE_FILENO if you have the fileno() macro. */
#undef HAVE_FILENO
/* Define HAVE_ERRNO if you have the errno variable */
/* Define MUST_DEFINE_ERRNO if you have errno but it is not define
* in errno.h */
#undef HAVE_ERRNO
#undef MUST_DEFINE_ERRNO
/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
#undef HAVE_SYS_ERRLIST
/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
* in termcap.h. */
#undef HAVE_OSPEED
#undef MUST_DEFINE_OSPEED
/* Define HAVE_LOCALE if you have locale.h and setlocale. */
#undef HAVE_LOCALE
/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
#undef HAVE_TERMIOS_FUNCS
/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
#undef HAVE_UPPER_LOWER
/* Define HAVE_SIGSET_T you have the sigset_t type */
#undef HAVE_SIGSET_T
/* Define HAVE_SIGEMPTYSET if you have the sigemptyset macro */
#undef HAVE_SIGEMPTYSET
/* Define EDIT_PGM to your editor. */
#define EDIT_PGM "vi"

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2002 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@ -64,7 +64,7 @@ static char *shellcmd = NULL; /* For holding last shell command for "!!" */
#endif
static int mca; /* The multicharacter command (action) */
static int search_type; /* The previous type of search */
static int number; /* The number typed by the user */
static LINENUM number; /* The number typed by the user */
static char optchar;
static int optflag;
static int optgetname;
@ -189,7 +189,7 @@ exec_mca()
{
case A_F_SEARCH:
case A_B_SEARCH:
multi_search(cbuf, number);
multi_search(cbuf, (int) number);
break;
case A_FIRSTCMD:
/*
@ -209,18 +209,20 @@ exec_mca()
optchar = '\0';
break;
case A_F_BRACKET:
match_brac(cbuf[0], cbuf[1], 1, number);
match_brac(cbuf[0], cbuf[1], 1, (int) number);
break;
case A_B_BRACKET:
match_brac(cbuf[1], cbuf[0], 0, number);
match_brac(cbuf[1], cbuf[0], 0, (int) number);
break;
#if EXAMINE
case A_EXAMINE:
if (secure)
break;
edit_list(cbuf);
#if TAGS
/* If tag structure is loaded then clean it up. */
cleantags();
#endif
break;
#endif
#if SHELL_ESCAPE
@ -363,7 +365,7 @@ mca_char(c)
* If so, display the complete name and stop
* accepting chars until user hits RETURN.
*/
struct option *o;
struct loption *o;
char *oname;
int lc;
@ -987,7 +989,7 @@ commands()
* Forward one window (and set the window size).
*/
if (number > 0)
swindow = number;
swindow = (int) number;
/* FALLTHRU */
case A_F_SCREEN:
/*
@ -998,7 +1000,7 @@ commands()
cmd_exec();
if (show_attn)
set_attnpos(bottompos);
forward(number, 0, 1);
forward((int) number, 0, 1);
break;
case A_B_WINDOW:
@ -1006,7 +1008,7 @@ commands()
* Backward one window (and set the window size).
*/
if (number > 0)
swindow = number;
swindow = (int) number;
/* FALLTHRU */
case A_B_SCREEN:
/*
@ -1015,7 +1017,7 @@ commands()
if (number <= 0)
number = get_swindow();
cmd_exec();
backward(number, 0, 1);
backward((int) number, 0, 1);
break;
case A_F_LINE:
@ -1027,7 +1029,7 @@ commands()
cmd_exec();
if (show_attn == OPT_ONPLUS && number > 1)
set_attnpos(bottompos);
forward(number, 0, 0);
forward((int) number, 0, 0);
break;
case A_B_LINE:
@ -1037,7 +1039,7 @@ commands()
if (number <= 0)
number = 1;
cmd_exec();
backward(number, 0, 0);
backward((int) number, 0, 0);
break;
case A_FF_LINE:
@ -1049,7 +1051,7 @@ commands()
cmd_exec();
if (show_attn == OPT_ONPLUS && number > 1)
set_attnpos(bottompos);
forward(number, 1, 0);
forward((int) number, 1, 0);
break;
case A_BF_LINE:
@ -1059,7 +1061,7 @@ commands()
if (number <= 0)
number = 1;
cmd_exec();
backward(number, 1, 0);
backward((int) number, 1, 0);
break;
case A_FF_SCREEN:
@ -1071,7 +1073,7 @@ commands()
cmd_exec();
if (show_attn == OPT_ONPLUS)
set_attnpos(bottompos);
forward(number, 1, 0);
forward((int) number, 1, 0);
break;
case A_F_FOREVER:
@ -1101,7 +1103,7 @@ commands()
* (default same as last 'd' or 'u' command).
*/
if (number > 0)
wscroll = number;
wscroll = (int) number;
cmd_exec();
if (show_attn == OPT_ONPLUS)
set_attnpos(bottompos);
@ -1114,7 +1116,7 @@ commands()
* (default same as last 'd' or 'u' command).
*/
if (number > 0)
wscroll = number;
wscroll = (int) number;
cmd_exec();
backward(wscroll, 0, 0);
break;
@ -1160,7 +1162,7 @@ commands()
if (number > 100)
number = 100;
cmd_exec();
jump_percent(number);
jump_percent((int) number);
break;
case A_GOEND:
@ -1181,7 +1183,7 @@ commands()
cmd_exec();
if (number < 0)
number = 0;
jump_line_loc((POSITION)number, jump_sline);
jump_line_loc((POSITION) number, jump_sline);
break;
case A_STAT:
@ -1229,7 +1231,7 @@ commands()
#define DO_SEARCH() if (number <= 0) number = 1; \
mca_search(); \
cmd_exec(); \
multi_search((char *)NULL, number);
multi_search((char *)NULL, (int) number);
case A_F_SEARCH:
@ -1368,14 +1370,16 @@ commands()
/*
* Examine next file.
*/
#if TAGS
if (ntags())
{
error("No next file", NULL_PARG);
break;
}
#endif
if (number <= 0)
number = 1;
if (edit_next(number))
if (edit_next((int) number))
{
if (quit_at_eof && hit_eof &&
!(ch_getflags() & CH_HELPFILE))
@ -1389,14 +1393,16 @@ commands()
/*
* Examine previous file.
*/
#if TAGS
if (ntags())
{
error("No previous file", NULL_PARG);
break;
}
#endif
if (number <= 0)
number = 1;
if (edit_prev(number))
if (edit_prev((int) number))
{
parg.p_string = (number > 1) ? "(N-th) " : "";
error("No %sprevious file", &parg);
@ -1404,9 +1410,10 @@ commands()
break;
case A_NEXT_TAG:
#if TAGS
if (number <= 0)
number = 1;
tagfile = nexttag(number);
tagfile = nexttag((int) number);
if (tagfile == NULL)
{
error("No next tag", NULL_PARG);
@ -1418,12 +1425,16 @@ commands()
if (pos != NULL_POSITION)
jump_loc(pos, jump_sline);
}
#else
error("Command not available", NULL_PARG);
#endif
break;
case A_PREV_TAG:
#if TAGS
if (number <= 0)
number = 1;
tagfile = prevtag(number);
tagfile = prevtag((int) number);
if (tagfile == NULL)
{
error("No previous tag", NULL_PARG);
@ -1435,6 +1446,9 @@ commands()
if (pos != NULL_POSITION)
jump_loc(pos, jump_sline);
}
#else
error("Command not available", NULL_PARG);
#endif
break;
case A_INDEX_FILE:
@ -1443,7 +1457,7 @@ commands()
*/
if (number <= 0)
number = 1;
if (edit_index(number))
if (edit_index((int) number))
error("No such file", NULL_PARG);
break;

View File

@ -1,322 +0,0 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(forwback.c)
AC_CONFIG_HEADER(defines.h)
dnl Checks for programs.
AC_PROG_CC
AC_ISC_POSIX
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
dnl Check for compilation model.
dnl AC_SYS_LARGEFILE is not supported in all versions of autoconf.
dnl Remove the dnl comment on the next line to use large (64 bit) files.
dnl AC_SYS_LARGEFILE
dnl Checks for libraries.
AC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
dnl Regular expressions (regcmp) are in -lgen on Solaris 2,
dnl and in -lintl on SCO Unix.
AC_CHECK_LIB(gen, regcmp)
AC_CHECK_LIB(intl, regcmp)
AC_CHECK_LIB(PW, regcmp)
dnl Checks for terminal libraries
AC_MSG_CHECKING(for working terminal libraries)
TERMLIBS=
dnl Check for systems where curses is broken.
curses_broken=0
if test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
if test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
curses_broken=1
fi
if test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
curses_broken=1
fi
fi
if test $curses_broken = 0; then
dnl -- Try xcurses.
if test "x$TERMLIBS" = x; then
if test $have_xcurses = yes; then
TERMLIBS="-lxcurses"
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
dnl -- Try ncurses.
if test "x$TERMLIBS" = x; then
if test $have_ncurses = yes; then
TERMLIBS="-lncurses"
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
dnl -- Try curses.
if test "x$TERMLIBS" = x; then
if test $have_curses = yes; then
TERMLIBS="-lcurses"
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
dnl -- Try curses & termcap.
if test "x$TERMLIBS" = x; then
if test $have_curses = yes; then
if test $have_termcap = yes; then
TERMLIBS="-lcurses -ltermcap"
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
fi
fi
dnl -- Try termcap.
if test "x$TERMLIBS" = x; then
if test $have_termcap = yes; then
TERMLIBS="-ltermcap"
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
dnl -- Try termlib.
if test "x$TERMLIBS" = x; then
if test $have_termlib = yes; then
TERMLIBS="-lcurses -ltermlib"
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
if test "x$TERMLIBS" = x; then
AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
exit 1
fi
AC_MSG_RESULT(using $TERMLIBS)
LIBS="$LIBS $TERMLIBS"
dnl Checks for header files.
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 sys/ptem.h)
dnl Checks for identifiers.
AC_TYPE_OFF_T
AC_MSG_CHECKING(for void)
AC_TRY_COMPILE(, [void *foo = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for const)
AC_TRY_COMPILE(, [const int foo = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for time_t)
AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
dnl Checks for functions and external variables.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system)
dnl Some systems have termios.h but not the corresponding functions.
AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
AC_MSG_CHECKING(for fileno)
AC_TRY_LINK([
#if HAVE_STDIO_H
#include <stdio.h>
#endif], [static int x; x = fileno(stdin);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for strerror)
AC_TRY_LINK([
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#endif], [static char *x; x = strerror(0);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for sys_errlist)
AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for sigset_t)
AC_TRY_LINK([
#include <signal.h>
], [sigset_t s; s = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGSET_T)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for sigemptyset)
AC_TRY_LINK([
#include <signal.h>
], [sigset_t s; sigemptyset(&s);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [AC_MSG_RESULT(no)])
have_errno=no
AC_MSG_CHECKING(for errno)
AC_TRY_LINK([
#if HAVE_ERRNO_H
#include <errno.h>
#endif], [static int x; x = errno;],
[AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
if test $have_errno = no; then
AC_TRY_LINK([
#if HAVE_ERRNO_H
#include <errno.h>
#endif], [extern int errno; static int x; x = errno;],
[AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
[AC_MSG_RESULT(no)])
fi
AC_MSG_CHECKING(for locale)
AC_TRY_LINK([#include <locale.h>
#include <ctype.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)])
dnl Checks for external variable ospeed in the termcap library.
have_ospeed=no
AC_MSG_CHECKING(termcap for ospeed)
AC_TRY_LINK([
#include <sys/types.h>
#if HAVE_TERMIOS_H
#include <termios.h>
#endif
#if HAVE_TERMCAP_H
#include <termcap.h>
#endif], [ospeed = 0;],
[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
if test $have_ospeed = no; then
AC_TRY_LINK(, [extern short ospeed; ospeed = 0;],
[AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
[AC_MSG_RESULT(no)])
fi
dnl Checks for regular expression functions.
have_regex=no
have_posix_regex=unknown
AC_MSG_CHECKING(for regcomp)
WANT_REGEX=auto
AC_ARG_WITH(regex,
[ --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} Select a regular expression library [auto]],
WANT_REGEX="$withval")
if test $have_regex = no; then
if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
dnl Some versions of Solaris have a regcomp() function, but it doesn't work!
dnl So we run a test program. If we're cross-compiling, do it the old way.
AC_TRY_RUN([
#include <sys/types.h>
#include <regex.h>
main() { regex_t r; regmatch_t rm; char *text = "xabcy";
if (regcomp(&r, "abc", 0)) exit(1);
if (regexec(&r, text, 1, &rm, 0)) exit(1);
#ifndef __WATCOMC__
if (rm.rm_so != 1) exit(1); /* check for correct offset */
#else
if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
#endif
exit(0); }],
have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
if test $have_posix_regex = yes; then
AC_MSG_RESULT(using POSIX regcomp)
AC_DEFINE(HAVE_POSIX_REGCOMP)
have_regex=yes
elif test $have_posix_regex = unknown; then
AC_TRY_LINK([
#include <sys/types.h>
#include <regex.h>],
[regex_t *r; regfree(r);],
AC_MSG_RESULT(using POSIX regcomp)
AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
else
AC_MSG_RESULT(no)
fi
fi
fi
if test $have_regex = no; then
if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
AC_CHECK_LIB(pcre, pcre_compile,
[AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
fi
fi
if test $have_regex = no; then
if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
AC_CHECK_FUNC(regcmp,
AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
fi
fi
if test $have_regex = no; then
if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
AC_TRY_LINK([
#include "regexp.h"], [regcomp("");],
AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
fi
fi
if test $have_regex = no && test -f ${srcdir}/regexp.c; then
if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) AC_DEFINE(HAVE_REGEXEC2) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
fi
fi
if test $have_regex = no; then
if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
fi
fi
if test $have_regex = no; then
AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
fi
AC_ARG_WITH(editor,
[ --with-editor=PROGRAM use PROGRAM as the default editor [vi]],
AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"))
AC_OUTPUT(Makefile)

View File

@ -1,173 +0,0 @@
/* Unix definition file for less. -*- C -*-
*
* This file has 3 sections:
* User preferences.
* Settings always true on Unix.
* Settings automatically determined by configure.
*
* * * * * * WARNING * * * * * *
* If you edit defines.h by hand, do "touch stamp-h" before you run make
* so config.status doesn't overwrite your changes.
*/
/* User preferences. */
/*
* SECURE is 1 if you wish to disable a bunch of features in order to
* be safe to run by unprivileged users.
*/
#define SECURE 0
/*
* SHELL_ESCAPE is 1 if you wish to allow shell escapes.
* (This is possible only if your system supplies the system() function.)
*/
#define SHELL_ESCAPE (!SECURE)
/*
* EXAMINE is 1 if you wish to allow examining files by name from within less.
*/
#define EXAMINE (!SECURE)
/*
* TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
* to complete filenames at prompts.
*/
#define TAB_COMPLETE_FILENAME (!SECURE)
/*
* CMD_HISTORY is 1 if you wish to allow keys to cycle through
* previous commands at prompts.
*/
#define CMD_HISTORY 1
/*
* HILITE_SEARCH is 1 if you wish to have search targets to be
* displayed in standout mode.
*/
#define HILITE_SEARCH 1
/*
* EDITOR is 1 if you wish to allow editor invocation (the "v" command).
* (This is possible only if your system supplies the system() function.)
* EDIT_PGM is the name of the (default) editor to be invoked.
*/
#define EDITOR (!SECURE)
/*
* TAGS is 1 if you wish to support tag files.
*/
#define TAGS (!SECURE)
/*
* USERFILE is 1 if you wish to allow a .less file to specify
* user-defined key bindings.
*/
#define USERFILE (!SECURE)
/*
* GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
* This will generally work if your system provides the "popen" function
* and the "echo" shell command.
*/
#define GLOB (!SECURE)
/*
* PIPEC is 1 if you wish to have the "|" command
* which allows the user to pipe data into a shell command.
*/
#define PIPEC (!SECURE)
/*
* LOGFILE is 1 if you wish to allow the -l option (to create log files).
*/
#define LOGFILE (!SECURE)
/*
* GNU_OPTIONS is 1 if you wish to support the GNU-style command
* line options --help and --version.
*/
#define GNU_OPTIONS 1
/*
* ONLY_RETURN is 1 if you want RETURN to be the only input which
* will continue past an error message.
* Otherwise, any key will continue past an error message.
*/
#define ONLY_RETURN 0
/*
* LESSKEYFILE is the filename of the default lesskey output file
* (in the HOME directory).
* LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
*/
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
/* Settings always true on Unix. */
/*
* Define MSDOS_COMPILER if compiling under Microsoft C.
*/
#define MSDOS_COMPILER 0
/*
* Pathname separator character.
*/
#define PATHNAME_SEP "/"
/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
#define HAVE_SYS_TYPES_H 1
/*
* Define if you have the <sgstat.h> header file.
*/
#undef HAVE_SGSTAT_H
/*
* HAVE_PERROR is 1 if your system has the perror() call.
* (Actually, if it has sys_errlist, sys_nerr and errno.)
*/
#define HAVE_PERROR 1
/*
* HAVE_TIME is 1 if your system has the time() call.
*/
#define HAVE_TIME 1
/*
* HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
*/
#define HAVE_SHELL 1
/*
* Default shell metacharacters and meta-escape character.
*/
#define DEF_METACHARS "; \t\n'\"()<>|&^`\\"
#define DEF_METAESCAPE "\\"
/*
* HAVE_DUP is 1 if your system has the dup() call.
*/
#define HAVE_DUP 1
/*
* Sizes of various buffers.
*/
#define CMDBUF_SIZE 512 /* Buffer for multichar commands */
#define UNGOT_SIZE 100 /* Max chars to unget() */
#define LINEBUF_SIZE 1024 /* Max size of line in input file */
#define OUTBUF_SIZE 1024 /* Output buffer */
#define PROMPT_SIZE 200 /* Max size of prompt string */
#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
#define TAGLINE_SIZE 512 /* Max size of line in tags file */
#define TABSTOP_MAX 32 /* Max number of custom tab stops */
/* Settings automatically determined by configure. */

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2002 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2002 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@ -155,6 +155,8 @@ void free();
* Special types and constants.
*/
typedef off_t POSITION;
typedef off_t LINENUM;
#define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */
#define NULL_POSITION ((POSITION)(-1))
@ -232,6 +234,7 @@ typedef union parg
{
char *p_string;
int p_int;
LINENUM p_linenum;
} PARG;
#define NULL_PARG ((PARG *)NULL)
@ -410,3 +413,7 @@ struct textlist
#include "funcs.h"
/* Functions not included in funcs.h */
void postoa();
void linenumtoa();
void inttoa();

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2002 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@ -177,6 +177,7 @@ main(argc, argv)
ifile = get_ifile(FAKE_HELPFILE, ifile);
while (argc-- > 0)
{
char *filename;
#if (MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC)
/*
* Because the "shell" doesn't expand filename patterns,
@ -186,16 +187,23 @@ main(argc, argv)
*/
struct textlist tlist;
char *gfilename;
char *filename;
gfilename = lglob(*argv++);
init_textlist(&tlist, gfilename);
filename = NULL;
while ((filename = forw_textlist(&tlist, filename)) != NULL)
ifile = get_ifile(filename, ifile);
{
(void) get_ifile(filename, ifile);
ifile = prev_ifile(NULL_IFILE);
}
free(gfilename);
#else
ifile = get_ifile(*argv++, ifile);
filename = shell_quote(*argv);
if (filename == NULL)
filename = *argv;
argv++;
(void) get_ifile(filename, ifile);
ifile = prev_ifile(NULL_IFILE);
#endif
}
/*
@ -224,11 +232,10 @@ main(argc, argv)
if (missing_cap && !know_dumb && !more_mode)
error("WARNING: terminal is not fully functional", NULL_PARG);
init_mark();
raw_mode(1);
open_getchr();
raw_mode(1);
init_signals(1);
/*
* Select the first file to examine.
*/
@ -273,6 +280,7 @@ main(argc, argv)
commands();
quit(QUIT_OK);
/*NOTREACHED*/
return (0);
}
/*
@ -307,6 +315,7 @@ ecalloc(count, size)
error("Cannot allocate memory", NULL_PARG);
quit(QUIT_ERROR);
/*NOTREACHED*/
return (NULL);
}
/*

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2002 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@ -114,31 +114,35 @@ ap_char(c)
ap_pos(pos)
POSITION pos;
{
char buf[INT_STRLEN_BOUND(pos) + 1];
char *p = buf + sizeof(buf) - 1;
int neg = (pos < 0);
if (neg)
pos = -pos;
*p = '\0';
do
*--p = '0' + (pos % 10);
while ((pos /= 10) != 0);
if (neg)
*--p = '-';
ap_str(p);
char buf[INT_STRLEN_BOUND(pos) + 2];
postoa(pos, buf);
ap_str(buf);
}
/*
* Append a line number to the end of the message.
*/
static void
ap_linenum(linenum)
LINENUM linenum;
{
char buf[INT_STRLEN_BOUND(linenum) + 2];
linenumtoa(linenum, buf);
ap_str(buf);
}
/*
* Append an integer to the end of the message.
*/
static void
ap_int(n)
int n;
ap_int(num)
int num;
{
char buf[INT_STRLEN_BOUND(n) + 1];
char buf[INT_STRLEN_BOUND(num) + 2];
sprintf(buf, "%d", n);
inttoa(num, buf);
ap_str(buf);
}
@ -200,9 +204,17 @@ cond(c, where)
case 'D': /* Same as L */
return (linenums && ch_length() != NULL_POSITION);
case 'm': /* More than one file? */
#if TAGS
return (ntags() ? (ntags() > 1) : (nifile() > 1));
#else
return (nifile() > 1);
#endif
case 'n': /* First prompt in a new file? */
#if TAGS
return (ntags() ? 1 : new_file);
#else
return (new_file);
#endif
case 'p': /* Percent into file (bytes) known? */
return (curr_byte(where) != NULL_POSITION &&
ch_length() > 0);
@ -214,8 +226,10 @@ cond(c, where)
case 'B':
return (ch_length() != NULL_POSITION);
case 'x': /* Is there a "next" file? */
#if TAGS
if (ntags())
return (0);
#endif
return (next_ifile(curr_ifile) != NULL_IFILE);
}
return (0);
@ -237,9 +251,9 @@ protochar(c, where, iseditproto)
POSITION pos;
POSITION len;
int n;
LINENUM linenum;
LINENUM last_linenum;
IFILE h;
char *s;
char *escs;
switch (c)
{
@ -254,19 +268,19 @@ protochar(c, where, iseditproto)
ap_int(hshift);
break;
case 'd': /* Current page number */
n = currline(where);
if (n > 0 && sc_height > 1)
ap_int(((n - 1) / (sc_height - 1)) + 1);
linenum = currline(where);
if (linenum > 0 && sc_height > 1)
ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);
else
ap_quest();
break;
case 'D': /* Last page number */
len = ch_length();
if (len == NULL_POSITION || len == ch_zero() ||
(n = find_linenum(len)) <= 0)
(linenum = find_linenum(len)) <= 0)
ap_quest();
else
ap_int(((n - 1) / (sc_height - 1)) + 1);
ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);
break;
#if EDITOR
case 'E': /* Editor name */
@ -274,45 +288,38 @@ protochar(c, where, iseditproto)
break;
#endif
case 'f': /* File name */
s = unquote_file(get_filename(curr_ifile));
/*
* If we are expanding editproto then we escape metachars.
* This allows us to run the editor on files with funny names.
*/
if (iseditproto && (escs = esc_metachars(s)) != NULL)
{
free(s);
s = escs;
}
ap_str(s);
free(s);
ap_str(get_filename(curr_ifile));
break;
case 'i': /* Index into list of files */
#if TAGS
if (ntags())
ap_int(curr_tag());
else
#endif
ap_int(get_index(curr_ifile));
break;
case 'l': /* Current line number */
n = currline(where);
if (n != 0)
ap_int(n);
linenum = currline(where);
if (linenum != 0)
ap_linenum(linenum);
else
ap_quest();
break;
case 'L': /* Final line number */
len = ch_length();
if (len == NULL_POSITION || len == ch_zero() ||
(n = find_linenum(len)) <= 0)
(linenum = find_linenum(len)) <= 0)
ap_quest();
else
ap_int(n-1);
ap_linenum(linenum-1);
break;
case 'm': /* Number of files */
#if TAGS
n = ntags();
if (n)
ap_int(n);
else
#endif
ap_int(nifile());
break;
case 'p': /* Percent into file (bytes) */
@ -324,13 +331,13 @@ protochar(c, where, iseditproto)
ap_quest();
break;
case 'P': /* Percent into file (lines) */
pos = (POSITION) currline(where);
if (pos == 0 ||
linenum = currline(where);
if (linenum == 0 ||
(len = ch_length()) == NULL_POSITION || len == ch_zero() ||
(n = find_linenum(len)) <= 0)
(last_linenum = find_linenum(len)) <= 0)
ap_quest();
else
ap_int(percentage(pos, (POSITION)n));
ap_int(percentage(linenum, last_linenum));
break;
case 's': /* Size of file */
case 'B':
@ -345,19 +352,18 @@ protochar(c, where, iseditproto)
mp--;
break;
case 'T': /* Type of list */
#if TAGS
if (ntags())
ap_str("tag");
else
#endif
ap_str("file");
break;
case 'x': /* Name of next file */
h = next_ifile(curr_ifile);
if (h != NULL_IFILE)
{
s = unquote_file(get_filename(h));
ap_str(s);
free(s);
} else
ap_str(get_filename(h));
else
ap_quest();
break;
}

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2002 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@ -232,6 +232,7 @@ extern int no_keypad;
extern int sigs;
extern int wscroll;
extern int screen_trashed;
extern int tty;
#if HILITE_SEARCH
extern int hilite_search;
#endif
@ -270,7 +271,7 @@ raw_mode(on)
/*
* Get terminal modes.
*/
tcgetattr(2, &s);
tcgetattr(tty, &s);
/*
* Save modes and set certain variables dependent on modes.
@ -426,9 +427,9 @@ raw_mode(on)
s = save_term;
}
#if HAVE_FSYNC
fsync(2);
fsync(tty);
#endif
tcsetattr(2, TCSADRAIN, &s);
tcsetattr(tty, TCSADRAIN, &s);
#if MUST_SET_LINE_DISCIPLINE
if (!on)
{
@ -438,7 +439,7 @@ raw_mode(on)
* is therefore not restored, yet. Restore the old
* line discipline by hand.
*/
ioctl(2, TIOCSETD, &save_term.c_line);
ioctl(tty, TIOCSETD, &save_term.c_line);
}
#endif
}
@ -454,7 +455,7 @@ raw_mode(on)
/*
* Get terminal modes.
*/
ioctl(2, TCGETA, &s);
ioctl(tty, TCGETA, &s);
/*
* Save modes and set certain variables dependent on modes.
@ -490,7 +491,7 @@ raw_mode(on)
*/
s = save_term;
}
ioctl(2, TCSETAW, &s);
ioctl(tty, TCSETAW, &s);
}
#else
#ifdef TIOCGETP
@ -504,7 +505,7 @@ raw_mode(on)
/*
* Get terminal modes.
*/
ioctl(2, TIOCGETP, &s);
ioctl(tty, TIOCGETP, &s);
/*
* Save modes and set certain variables dependent on modes.
@ -533,7 +534,7 @@ raw_mode(on)
*/
s = save_term;
}
ioctl(2, TIOCSETN, &s);
ioctl(tty, TIOCSETN, &s);
}
#else
#ifdef _OSK
@ -547,7 +548,7 @@ raw_mode(on)
/*
* Get terminal modes.
*/
_gs_opt(2, &s);
_gs_opt(tty, &s);
/*
* Save modes and set certain variables dependent on modes.
@ -575,7 +576,7 @@ raw_mode(on)
*/
s = save_term;
}
_ss_opt(2, &s);
_ss_opt(tty, &s);
}
#else
/* MS-DOS, Windows, or OS2 */

View File

@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2002 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@ -54,6 +54,7 @@ extern int sc_height;
extern int jump_sline;
extern int bs_mode;
extern int more_mode;
extern int ctldisp;
extern int status_col;
extern POSITION start_attnpos;
extern POSITION end_attnpos;
@ -108,6 +109,7 @@ static char *last_pattern = NULL;
#define CVT_TO_LC 01 /* Convert upper-case to lower-case */
#define CVT_BS 02 /* Do backspace processing */
#define CVT_CRLF 04 /* Remove CR after LF */
#define CVT_ANSI 010 /* Remove ANSI escape sequences */
static void
cvt_text(odst, osrc, ops)
@ -118,23 +120,53 @@ cvt_text(odst, osrc, ops)
register char *dst;
register char *src;
for (src = osrc, dst = odst; *src != '\0'; src++, dst++)
for (src = osrc, dst = odst; *src != '\0'; src++)
{
if ((ops & CVT_TO_LC) && isupper((unsigned char) *src))
/* Convert uppercase to lowercase. */
*dst = tolower((unsigned char) *src);
*dst++ = tolower((unsigned char) *src);
else if ((ops & CVT_BS) && *src == '\b' && dst > odst)
/* Delete BS and preceding char. */
dst -= 2;
else
dst--;
else if ((ops & CVT_ANSI) && *src == ESC)
{
/* Skip to end of ANSI escape sequence. */
while (src[1] != '\0')
if (is_ansi_end(*++src))
break;
} else
/* Just copy. */
*dst = *src;
*dst++ = *src;
}
if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r')
dst--;
*dst = '\0';
}
/*
* Determine which conversions to perform.
*/
static int
get_cvt_ops()
{
int ops = 0;
if (is_caseless || bs_mode == BS_SPECIAL)
{
if (is_caseless)
ops |= CVT_TO_LC;
if (bs_mode == BS_SPECIAL)
ops |= CVT_BS;
if (bs_mode != BS_CONTROL)
ops |= CVT_CRLF;
} else if (bs_mode != BS_CONTROL)
{
ops |= CVT_CRLF;
}
if (ctldisp == OPT_ONPLUS)
ops |= CVT_ANSI;
return (ops);
}
/*
* Are there any uppercase letters in this string?
*/
@ -589,9 +621,10 @@ add_hilite(anchor, hl)
* Adjust hl_startpos & hl_endpos to account for backspace processing.
*/
static void
adj_hilite(anchor, linepos)
adj_hilite(anchor, linepos, cvt_ops)
struct hilite *anchor;
POSITION linepos;
int cvt_ops;
{
char *line;
struct hilite *hl;
@ -633,18 +666,39 @@ adj_hilite(anchor, linepos)
}
if (*line == '\0')
break;
if (cvt_ops & CVT_ANSI)
{
while (line[0] == ESC)
{
/*
* Found an ESC. The file position moves
* forward past the entire ANSI escape sequence.
*/
line++;
npos++;
while (*line != '\0')
{
npos++;
if (is_ansi_end(*line++))
break;
}
}
}
opos++;
npos++;
line++;
while (line[0] == '\b' && line[1] != '\0')
if (cvt_ops & CVT_BS)
{
/*
* Found a backspace. The file position moves
* forward by 2 relative to the processed line
* which was searched in hilite_line.
*/
npos += 2;
line += 2;
while (line[0] == '\b' && line[1] != '\0')
{
/*
* Found a backspace. The file position moves
* forward by 2 relative to the processed line
* which was searched in hilite_line.
*/
npos += 2;
line += 2;
}
}
}
}
@ -655,11 +709,12 @@ adj_hilite(anchor, linepos)
* sp,ep delimit the first match already found.
*/
static void
hilite_line(linepos, line, sp, ep)
hilite_line(linepos, line, sp, ep, cvt_ops)
POSITION linepos;
char *line;
char *sp;
char *ep;
int cvt_ops;
{
char *searchp;
struct hilite *hl;
@ -708,15 +763,13 @@ hilite_line(linepos, line, sp, ep)
break;
} while (match_pattern(searchp, &sp, &ep, 1));
if (bs_mode == BS_SPECIAL)
{
/*
* If there were backspaces in the original line, they
* were removed, and hl_startpos/hl_endpos are not correct.
* {{ This is very ugly. }}
*/
adj_hilite(&hilites, linepos);
}
/*
* If there were backspaces in the original line, they
* were removed, and hl_startpos/hl_endpos are not correct.
* {{ This is very ugly. }}
*/
adj_hilite(&hilites, linepos, cvt_ops);
/*
* Now put the hilites into the real list.
*/
@ -873,9 +926,10 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
POSITION *pendpos;
{
char *line;
int linenum;
LINENUM linenum;
char *sp, *ep;
int line_match;
int cvt_ops;
POSITION linepos, oldpos;
linenum = find_linenum(pos);
@ -955,20 +1009,8 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* If it's a caseless search, convert the line to lowercase.
* If we're doing backspace processing, delete backspaces.
*/
if (is_caseless || bs_mode == BS_SPECIAL)
{
int ops = 0;
if (is_caseless)
ops |= CVT_TO_LC;
if (bs_mode == BS_SPECIAL)
ops |= CVT_BS;
if (bs_mode != BS_CONTROL)
ops |= CVT_CRLF;
cvt_text(line, line, ops);
} else if (bs_mode != BS_CONTROL)
{
cvt_text(line, line, CVT_CRLF);
}
cvt_ops = get_cvt_ops();
cvt_text(line, line, cvt_ops);
/*
* Test the next line to see if we have a match.
@ -992,7 +1034,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* hilite list and keep searching.
*/
if (line_match)
hilite_line(linepos, line, sp, ep);
hilite_line(linepos, line, sp, ep, cvt_ops);
#endif
} else if (--matches <= 0)
{
@ -1009,7 +1051,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
*/
clr_hilite();
if (line_match)
hilite_line(linepos, line, sp, ep);
hilite_line(linepos, line, sp, ep, cvt_ops);
}
#endif
if (plinepos != NULL)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2002 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.