This commit was generated by cvs2svn to compensate for changes in r128345,
which included commits to RCS files with non-trunk default branches.
This commit is contained in:
commit
ccdc13ce06
@ -2,7 +2,7 @@
|
||||
------------
|
||||
|
||||
Less
|
||||
Copyright (C) 1984-2000 Mark Nudelman
|
||||
Copyright (C) 1984-2002 Mark Nudelman
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -23,9 +23,9 @@ DISTFILES_W = \
|
||||
DISTFILES = \
|
||||
${SRC} regexp.c regexp.h \
|
||||
COPYING INSTALL LICENSE Makefile.in Makefile.aut NEWS README \
|
||||
configure configure.in acconfig.h lesskey.c lessecho.c scrsize.c \
|
||||
configure configure.ac lesskey.c lessecho.c scrsize.c \
|
||||
cmd.h funcs.h lglob.h less.h lesskey.h option.h pckeys.h position.h \
|
||||
install.sh defines.h.in defines.h.top mkinstalldirs \
|
||||
install.sh defines.h.in mkinstalldirs \
|
||||
less.nro lesskey.nro less.man lesskey.man less.hlp \
|
||||
mkfuncs.awk mkhelp.c \
|
||||
${DISTFILES_W}
|
||||
@ -41,10 +41,8 @@ help.c: less.hlp mkhelp
|
||||
mkhelp: mkhelp.c
|
||||
${CC} -o mkhelp mkhelp.c
|
||||
|
||||
${srcdir}/configure: ${srcdir}/configure.in \
|
||||
${srcdir}/Makefile.in \
|
||||
${srcdir}/defines.h.top \
|
||||
${srcdir}/acconfig.h
|
||||
${srcdir}/configure: ${srcdir}/configure.ac \
|
||||
${srcdir}/Makefile.in
|
||||
cd ${srcdir}; autoheader; autoconf
|
||||
|
||||
funcs.h: ${SRC:%=${srcdir}/%}
|
||||
|
@ -6,6 +6,9 @@ srcdir = .
|
||||
VPATH = .
|
||||
|
||||
CC = gcc
|
||||
INSTALL = ginstall -c
|
||||
INSTALL_PROGRAM = ginstall
|
||||
INSTALL_DATA = ginstall -m 644
|
||||
AWK = gawk
|
||||
|
||||
CFLAGS = -O2 -g
|
||||
@ -15,13 +18,20 @@ LDFLAGS = -g
|
||||
O=o
|
||||
|
||||
LIBS =
|
||||
prefix = /dev/env/DJDIR
|
||||
exec_prefix = ${prefix}
|
||||
|
||||
bindir = ${exec_prefix}/bin
|
||||
sysconfdir = ${prefix}/etc
|
||||
mandir = ${prefix}/man
|
||||
manext = 1
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
# This rule allows us to supply the necessary -D options
|
||||
# in addition to whatever the user asks for.
|
||||
.c.o:
|
||||
${CC} -I. ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
|
||||
${CC} -I. ${CFLAGS_COMPILE_ONLY} -DBINDIR=\"${bindir}\" -DSYSDIR=\"${sysconfdir}\" ${CPPFLAGS} ${CFLAGS} $<
|
||||
|
||||
OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
|
||||
command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
|
||||
@ -44,7 +54,14 @@ lessecho: lessecho.${O} version.${O}
|
||||
defines.h: defines.ds
|
||||
command.com /c copy $< $@
|
||||
|
||||
${OBJ}: less.h defines.h funcs.h
|
||||
${OBJ}: ${srcdir}/less.h defines.h ${srcdir}/funcs.h
|
||||
|
||||
install: all ${srcdir}/less.man ${srcdir}/lesskey.man
|
||||
${INSTALL_PROGRAM} less.exe ${bindir}/less.exe
|
||||
${INSTALL_PROGRAM} lesskey.exe ${bindir}/lesskey.exe
|
||||
${INSTALL_PROGRAM} lessecho.exe ${bindir}/lessecho.exe
|
||||
${INSTALL_DATA} ${srcdir}/less.man ${mandir}/man${manext}/less.${manext}
|
||||
${INSTALL_DATA} ${srcdir}/lesskey.man ${mandir}/man${manext}/lesskey.${manext}
|
||||
|
||||
info:
|
||||
install-info:
|
||||
|
@ -96,7 +96,7 @@ Makefile: ${srcdir}/Makefile.in config.status
|
||||
config.status: ${srcdir}/configure
|
||||
./config.status --recheck
|
||||
|
||||
${srcdir}/configure: ${srcdir}/configure.in
|
||||
${srcdir}/configure: ${srcdir}/configure.ac
|
||||
cd ${srcdir}; autoheader; autoconf
|
||||
|
||||
clean:
|
||||
|
@ -13,7 +13,38 @@
|
||||
======================================================================
|
||||
|
||||
|
||||
Major changes between "less" versions 358 and 371
|
||||
Major changes between "less" versions 378 and 381
|
||||
|
||||
* New -L option to disable LESSOPEN processing.
|
||||
|
||||
* Further support for large (64 bit) file addressing.
|
||||
Large file support is now set up by the configure script.
|
||||
|
||||
* Use autoconf 2.54.
|
||||
Replace configure.in, acconfig.h, defines.h.top with configure.ac.
|
||||
|
||||
* Overstriking underscore with underscore is now bold or underlined
|
||||
depending on context.
|
||||
|
||||
* Use only 7 spaces for line numbers in -N mode, if possible.
|
||||
|
||||
* Fix some bugs in handling overstriking in UTF-8 files.
|
||||
|
||||
* Fix some nroff issues in the man page.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 376 and 378
|
||||
|
||||
* Bug fixes:
|
||||
Default buffer space is now 64K as documented.
|
||||
Search highlighting works properly when used with -R.
|
||||
Windows version works properly when input file contains carriage returns.
|
||||
Clean up some compiler warnings.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 358 and 376
|
||||
|
||||
* -x option can now specify multiple variable-width tab stops.
|
||||
|
||||
@ -41,7 +72,10 @@
|
||||
|
||||
* Default LESSCHARSET for MS-DOS versions is now "dos".
|
||||
|
||||
* Improved performance in reading very large files.
|
||||
* Searching works better with ANSI (SGR) escape sequences.
|
||||
ANSI color escape sequences are now supported in the MS-DOS (DJGPP) version.
|
||||
|
||||
* Improved performance in reading very large pipes.
|
||||
|
||||
* Eliminated some dependencies on file offets being 32 bits.
|
||||
|
||||
@ -51,6 +85,8 @@
|
||||
|
||||
* Improved horizontal shifting of text using -R option with ANSI color.
|
||||
|
||||
* Improved handling of filenames containing shell metacharacters.
|
||||
|
||||
* Some fixes for EBCDIC systems.
|
||||
|
||||
* Some fixes for OS/2 systems.
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
Less, version 371
|
||||
Less, version 381
|
||||
|
||||
This is the distribution of less, version 371, released 26 Dec 2001.
|
||||
This is the distribution of less, version 381, released 17 Jan 2003.
|
||||
This program is part of the GNU project (http://www.gnu.org).
|
||||
|
||||
This program is free software. You may redistribute it and/or
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
@ -93,10 +93,10 @@ struct filestate {
|
||||
|
||||
static struct filestate *thisfile;
|
||||
static int ch_ungotchar = -1;
|
||||
static int maxbufs = -1;
|
||||
|
||||
extern int autobuf;
|
||||
extern int sigs;
|
||||
extern int cbufs;
|
||||
extern int secure;
|
||||
extern constant char helpdata[];
|
||||
extern constant int size_helpdata;
|
||||
@ -162,7 +162,7 @@ fch_get()
|
||||
* 2. We haven't allocated the max buffers for this file yet.
|
||||
*/
|
||||
if ((autobuf && !(ch_flags & CH_CANSEEK)) ||
|
||||
(cbufs == -1 || ch_nbufs < cbufs))
|
||||
(maxbufs < 0 || ch_nbufs < maxbufs))
|
||||
if (ch_addbuf())
|
||||
/*
|
||||
* Allocation failed: turn off autobuf.
|
||||
@ -561,32 +561,21 @@ ch_back_get()
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate buffers.
|
||||
* Caller wants us to have a total of at least want_nbufs buffers.
|
||||
* Set max amount of buffer space.
|
||||
* bufspace is in units of 1024 bytes. -1 mean no limit.
|
||||
*/
|
||||
public int
|
||||
ch_nbuf(want_nbufs)
|
||||
int want_nbufs;
|
||||
public void
|
||||
ch_setbufspace(bufspace)
|
||||
int bufspace;
|
||||
{
|
||||
PARG parg;
|
||||
|
||||
while (ch_nbufs < want_nbufs)
|
||||
if (bufspace < 0)
|
||||
maxbufs = -1;
|
||||
else
|
||||
{
|
||||
if (ch_addbuf())
|
||||
{
|
||||
/*
|
||||
* Cannot allocate enough buffers.
|
||||
* If we don't have ANY, then quit.
|
||||
* Otherwise, just report the error and return.
|
||||
*/
|
||||
parg.p_int = want_nbufs - ch_nbufs;
|
||||
error("Cannot allocate %d buffers", &parg);
|
||||
if (ch_nbufs == 0)
|
||||
quit(QUIT_ERROR);
|
||||
break;
|
||||
}
|
||||
maxbufs = ((bufspace * 1024) + LBUFSIZE-1) / LBUFSIZE;
|
||||
if (maxbufs < 1)
|
||||
maxbufs = 1;
|
||||
}
|
||||
return (ch_nbufs);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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.
|
||||
@ -164,6 +164,7 @@ icharset(name)
|
||||
error("invalid charset name", NULL_PARG);
|
||||
quit(QUIT_ERROR);
|
||||
/*NOTREACHED*/
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if HAVE_LOCALE
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
@ -64,25 +64,25 @@ struct mlist
|
||||
*/
|
||||
struct mlist mlist_search =
|
||||
{ &mlist_search, &mlist_search, &mlist_search, NULL };
|
||||
public void constant *ml_search = (void *) &mlist_search;
|
||||
public void * constant ml_search = (void *) &mlist_search;
|
||||
|
||||
struct mlist mlist_examine =
|
||||
{ &mlist_examine, &mlist_examine, &mlist_examine, NULL };
|
||||
public void constant *ml_examine = (void *) &mlist_examine;
|
||||
public void * constant ml_examine = (void *) &mlist_examine;
|
||||
|
||||
#if SHELL_ESCAPE || PIPEC
|
||||
struct mlist mlist_shell =
|
||||
{ &mlist_shell, &mlist_shell, &mlist_shell, NULL };
|
||||
public void constant *ml_shell = (void *) &mlist_shell;
|
||||
public void * constant ml_shell = (void *) &mlist_shell;
|
||||
#endif
|
||||
|
||||
#else /* CMD_HISTORY */
|
||||
|
||||
/* If CMD_HISTORY is off, these are just flags. */
|
||||
public void constant *ml_search = (void *)1;
|
||||
public void constant *ml_examine = (void *)2;
|
||||
public void * constant ml_search = (void *)1;
|
||||
public void * constant ml_examine = (void *)2;
|
||||
#if SHELL_ESCAPE || PIPEC
|
||||
public void constant *ml_shell = (void *)3;
|
||||
public void * constant ml_shell = (void *)3;
|
||||
#endif
|
||||
|
||||
#endif /* CMD_HISTORY */
|
||||
@ -730,7 +730,10 @@ delimit_word()
|
||||
char *word;
|
||||
#if SPACES_IN_FILENAMES
|
||||
char *p;
|
||||
int quoted;
|
||||
int delim_quoted = 0;
|
||||
int meta_quoted = 0;
|
||||
char *esc = get_meta_escape();
|
||||
int esclen = strlen(esc);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -751,6 +754,7 @@ delimit_word()
|
||||
* We're already at the end of the word.
|
||||
*/
|
||||
;
|
||||
#if 0
|
||||
} else
|
||||
{
|
||||
/*
|
||||
@ -758,9 +762,10 @@ delimit_word()
|
||||
* Huh? There's no word here.
|
||||
*/
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Search backwards for beginning of the word.
|
||||
* Find the beginning of the word which the cursor is in.
|
||||
*/
|
||||
if (cp == cmdbuf)
|
||||
return (NULL);
|
||||
@ -770,24 +775,34 @@ delimit_word()
|
||||
* without a corresponding close quote), we return everything
|
||||
* from the open quote, including spaces.
|
||||
*/
|
||||
quoted = 0;
|
||||
for (word = cmdbuf; word < cp; word++)
|
||||
if (*word != ' ')
|
||||
break;
|
||||
if (word >= cp)
|
||||
return (cp);
|
||||
for (p = cmdbuf; p < cp; p++)
|
||||
{
|
||||
if (!quoted && *p == openquote)
|
||||
if (meta_quoted)
|
||||
{
|
||||
quoted = 1;
|
||||
word = p;
|
||||
} else if (quoted && *p == closequote)
|
||||
meta_quoted = 0;
|
||||
} else if (esclen > 0 && p + esclen < cp &&
|
||||
strncmp(p, esc, esclen) == 0)
|
||||
{
|
||||
quoted = 0;
|
||||
meta_quoted = 1;
|
||||
p += esclen - 1;
|
||||
} else if (delim_quoted)
|
||||
{
|
||||
if (*p == closequote)
|
||||
delim_quoted = 0;
|
||||
} else /* (!delim_quoted) */
|
||||
{
|
||||
if (*p == openquote)
|
||||
delim_quoted = 1;
|
||||
else if (*p == ' ')
|
||||
word = p+1;
|
||||
}
|
||||
}
|
||||
if (quoted)
|
||||
return (word);
|
||||
#endif
|
||||
for (word = cp-1; word > cmdbuf; word--)
|
||||
if (word[-1] == ' ')
|
||||
break;
|
||||
return (word);
|
||||
}
|
||||
|
||||
@ -835,11 +850,20 @@ init_compl()
|
||||
*/
|
||||
c = *cp;
|
||||
*cp = '\0';
|
||||
#if SPACES_IN_FILENAMES
|
||||
if (*word == openquote)
|
||||
word++;
|
||||
#endif
|
||||
tk_text = fcomplete(word);
|
||||
if (*word != openquote)
|
||||
{
|
||||
tk_text = fcomplete(word);
|
||||
} else
|
||||
{
|
||||
char *qword = shell_quote(word+1);
|
||||
if (qword == NULL)
|
||||
tk_text = fcomplete(word+1);
|
||||
else
|
||||
{
|
||||
tk_text = fcomplete(qword);
|
||||
free(qword);
|
||||
}
|
||||
}
|
||||
*cp = c;
|
||||
}
|
||||
|
||||
@ -1006,10 +1030,15 @@ cmd_char(c)
|
||||
/*
|
||||
* Return the number currently in the command buffer.
|
||||
*/
|
||||
public int
|
||||
public LINENUM
|
||||
cmd_int()
|
||||
{
|
||||
return (atoi(cmdbuf));
|
||||
register char *p;
|
||||
LINENUM n = 0;
|
||||
|
||||
for (p = cmdbuf; *p != '\0'; p++)
|
||||
n = (10 * n) + (*p - '0');
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
|
6993
contrib/less/configure
vendored
6993
contrib/less/configure
vendored
File diff suppressed because it is too large
Load Diff
563
contrib/less/configure.ac
Normal file
563
contrib/less/configure.ac
Normal file
@ -0,0 +1,563 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# 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.
|
||||
#
|
||||
# For more information about less, or for information on how to
|
||||
# contact the author, see the README file.
|
||||
|
||||
# Autoconf initialization.
|
||||
AC_INIT(less, 1)
|
||||
AC_CONFIG_SRCDIR([forwback.c])
|
||||
AC_CONFIG_HEADER([defines.h])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_ISC_POSIX
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_INSTALL
|
||||
|
||||
# Checks for compilation model.
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
# Checks for general 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])
|
||||
# Regular expressions (regcmp) are in -lgen on Solaris 2,
|
||||
# and in -lintl on SCO Unix.
|
||||
AC_CHECK_LIB(gen, regcmp)
|
||||
AC_CHECK_LIB(intl, regcmp)
|
||||
AC_CHECK_LIB(PW, regcmp)
|
||||
|
||||
# Checks for terminal libraries
|
||||
AC_MSG_CHECKING([for working terminal libraries])
|
||||
TERMLIBS=
|
||||
|
||||
# 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
|
||||
# -- 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
|
||||
|
||||
# -- 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
|
||||
|
||||
# -- 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
|
||||
|
||||
# -- 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
|
||||
|
||||
# -- 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
|
||||
|
||||
# -- 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"
|
||||
|
||||
# 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 sys/ptem.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_HEADER_STAT
|
||||
AC_C_CONST
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_SIZE_T
|
||||
AC_HEADER_TIME
|
||||
|
||||
# Autoheader templates for symbols defined later by AC_DEFINE.
|
||||
AH_TEMPLATE([HAVE_POSIX_REGCOMP],
|
||||
[POSIX regcomp() and regex.h])
|
||||
AH_TEMPLATE([HAVE_PCRE],
|
||||
[PCRE (Perl-compatible regular expression) library])
|
||||
AH_TEMPLATE([HAVE_RE_COMP],
|
||||
[BSD re_comp()])
|
||||
AH_TEMPLATE([HAVE_REGCMP],
|
||||
[System V regcmp()])
|
||||
AH_TEMPLATE([HAVE_V8_REGCOMP],
|
||||
[Henry Spencer V8 regcomp() and regexp.h])
|
||||
AH_TEMPLATE([NO_REGEX],
|
||||
[pattern matching is supported, but without metacharacters.])
|
||||
AH_TEMPLATE([HAVE_REGEXEC2],
|
||||
[])
|
||||
AH_TEMPLATE([HAVE_VOID],
|
||||
[Define HAVE_VOID if your compiler supports the "void" type.])
|
||||
AH_TEMPLATE([HAVE_CONST],
|
||||
[Define HAVE_CONST if your compiler supports the "const" modifier.])
|
||||
AH_TEMPLATE([HAVE_TIME_T],
|
||||
[Define HAVE_TIME_T if your system supports the "time_t" type.])
|
||||
AH_TEMPLATE([HAVE_STRERROR],
|
||||
[Define HAVE_STRERROR if you have the strerror() function.])
|
||||
AH_TEMPLATE([HAVE_FILENO],
|
||||
[Define HAVE_FILENO if you have the fileno() macro.])
|
||||
AH_TEMPLATE([HAVE_ERRNO],
|
||||
[Define HAVE_ERRNO if you have the errno variable.])
|
||||
AH_TEMPLATE([MUST_DEFINE_ERRNO],
|
||||
[Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.])
|
||||
AH_TEMPLATE([HAVE_SYS_ERRLIST],
|
||||
[Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable.])
|
||||
AH_TEMPLATE([HAVE_OSPEED],
|
||||
[Define HAVE_OSPEED if your termcap library has the ospeed variable.])
|
||||
AH_TEMPLATE([MUST_DEFINE_OSPEED],
|
||||
[Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in termcap.h.])
|
||||
AH_TEMPLATE([HAVE_LOCALE],
|
||||
[Define HAVE_LOCALE if you have locale.h and setlocale.])
|
||||
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_SIGSET_T],
|
||||
[Define HAVE_SIGSET_T you have the sigset_t type.])
|
||||
AH_TEMPLATE([HAVE_SIGEMPTYSET],
|
||||
[Define HAVE_SIGEMPTYSET if you have the sigemptyset macro.])
|
||||
AH_TEMPLATE([EDIT_PGM],
|
||||
[Define EDIT_PGM to your editor.])
|
||||
|
||||
# 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)])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system])
|
||||
|
||||
# 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)])
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# Some versions of Solaris have a regcomp() function, but it doesn't work!
|
||||
# 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_DEFINE(EDIT_PGM, "vi"))
|
||||
|
||||
AH_TOP([
|
||||
/* 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. */
|
||||
])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
@ -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.
|
||||
@ -260,7 +260,7 @@ expand_special_keys(table, len)
|
||||
repl = special_key_str(fm[1]);
|
||||
klen = fm[2] & 0377;
|
||||
fm += klen;
|
||||
if (repl == NULL || strlen(repl) > klen)
|
||||
if (repl == NULL || (int) strlen(repl) > klen)
|
||||
repl = "\377";
|
||||
while (*repl != '\0')
|
||||
*to++ = *repl++;
|
||||
@ -653,7 +653,7 @@ lesskey(filename, sysvar)
|
||||
/*
|
||||
* Try to open the lesskey file.
|
||||
*/
|
||||
filename = unquote_file(filename);
|
||||
filename = shell_unquote(filename);
|
||||
f = open(filename, OPEN_READ);
|
||||
free(filename);
|
||||
if (f < 0)
|
||||
|
@ -169,6 +169,12 @@
|
||||
*/
|
||||
#define HAVE_SHELL 0
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
@ -1,4 +1,6 @@
|
||||
/* defines.h.in. Generated automatically from configure.in by autoheader. */
|
||||
/* defines.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
|
||||
/* Unix definition file for less. -*- C -*-
|
||||
*
|
||||
* This file has 3 sections:
|
||||
@ -10,7 +12,7 @@
|
||||
* 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. */
|
||||
|
||||
/*
|
||||
@ -108,7 +110,7 @@
|
||||
#define LESSKEYFILE_SYS SYSDIR "/sysless"
|
||||
#define DEF_LESSKEYINFILE ".lesskey"
|
||||
|
||||
|
||||
|
||||
/* Settings always true on Unix. */
|
||||
|
||||
/*
|
||||
@ -150,7 +152,7 @@
|
||||
/*
|
||||
* Default shell metacharacters and meta-escape character.
|
||||
*/
|
||||
#define DEF_METACHARS "; \t\n'\"()<>|&^`\\"
|
||||
#define DEF_METACHARS "; *?\t\n'\"()<>|&^`#\\"
|
||||
#define DEF_METAESCAPE "\\"
|
||||
|
||||
/*
|
||||
@ -170,170 +172,224 @@
|
||||
#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. */
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/*
|
||||
* 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 EDIT_PGM to your editor. */
|
||||
#undef EDIT_PGM
|
||||
|
||||
/* 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 to 1 if you have the <ctype.h> header file. */
|
||||
#undef HAVE_CTYPE_H
|
||||
|
||||
/* Define HAVE_STRERROR if you have the strerror() function. */
|
||||
#undef HAVE_STRERROR
|
||||
/* Define HAVE_ERRNO if you have the errno variable. */
|
||||
#undef HAVE_ERRNO
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* 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 to 1 if you have the `fsync' function. */
|
||||
#undef HAVE_FSYNC
|
||||
|
||||
/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
|
||||
#undef HAVE_SYS_ERRLIST
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* 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 to 1 if you have the `gen' library (-lgen). */
|
||||
#undef HAVE_LIBGEN
|
||||
|
||||
/* Define to 1 if you have the `intl' library (-lintl). */
|
||||
#undef HAVE_LIBINTL
|
||||
|
||||
/* Define to 1 if you have the `PW' library (-lPW). */
|
||||
#undef HAVE_LIBPW
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* 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"
|
||||
|
||||
/* Define if you have the _setjmp function. */
|
||||
#undef HAVE__SETJMP
|
||||
|
||||
/* Define if you have the fsync function. */
|
||||
#undef HAVE_FSYNC
|
||||
|
||||
/* Define if you have the memcpy function. */
|
||||
/* Define to 1 if you have the `memcpy' function. */
|
||||
#undef HAVE_MEMCPY
|
||||
|
||||
/* Define if you have the popen function. */
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define HAVE_OSPEED if your termcap library has the ospeed variable. */
|
||||
#undef HAVE_OSPEED
|
||||
|
||||
/* PCRE (Perl-compatible regular expression) library */
|
||||
#undef HAVE_PCRE
|
||||
|
||||
/* Define to 1 if you have the `popen' function. */
|
||||
#undef HAVE_POPEN
|
||||
|
||||
/* Define if you have the sigprocmask function. */
|
||||
/* POSIX regcomp() and regex.h */
|
||||
#undef HAVE_POSIX_REGCOMP
|
||||
|
||||
/* System V regcmp() */
|
||||
#undef HAVE_REGCMP
|
||||
|
||||
/* */
|
||||
#undef HAVE_REGEXEC2
|
||||
|
||||
/* BSD re_comp() */
|
||||
#undef HAVE_RE_COMP
|
||||
|
||||
/* Define HAVE_SIGEMPTYSET if you have the sigemptyset macro. */
|
||||
#undef HAVE_SIGEMPTYSET
|
||||
|
||||
/* Define to 1 if you have the `sigprocmask' function. */
|
||||
#undef HAVE_SIGPROCMASK
|
||||
|
||||
/* Define if you have the sigsetmask function. */
|
||||
/* Define to 1 if you have the `sigsetmask' function. */
|
||||
#undef HAVE_SIGSETMASK
|
||||
|
||||
/* Define if you have the stat function. */
|
||||
/* Define HAVE_SIGSET_T you have the sigset_t type. */
|
||||
#undef HAVE_SIGSET_T
|
||||
|
||||
/* Define to 1 if you have the `stat' function. */
|
||||
#undef HAVE_STAT
|
||||
|
||||
/* Define if you have the strchr function. */
|
||||
#undef HAVE_STRCHR
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define if you have the strstr function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define if you have the system function. */
|
||||
#undef HAVE_SYSTEM
|
||||
|
||||
/* Define if you have the <ctype.h> header file. */
|
||||
#undef HAVE_CTYPE_H
|
||||
|
||||
/* Define if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define if you have the <stdio.h> header file. */
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#undef HAVE_STDIO_H
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define HAVE_STRERROR if you have the strerror() function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define if you have the <sys/ioctl.h> header file. */
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define to 1 if you have the `system' function. */
|
||||
#undef HAVE_SYSTEM
|
||||
|
||||
/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable. */
|
||||
#undef HAVE_SYS_ERRLIST
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define if you have the <sys/ptem.h> header file. */
|
||||
/* Define to 1 if you have the <sys/ptem.h> header file. */
|
||||
#undef HAVE_SYS_PTEM_H
|
||||
|
||||
/* Define if you have the <sys/stream.h> header file. */
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stream.h> header file. */
|
||||
#undef HAVE_SYS_STREAM_H
|
||||
|
||||
/* Define if you have the <termcap.h> header file. */
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <termcap.h> header file. */
|
||||
#undef HAVE_TERMCAP_H
|
||||
|
||||
/* Define if you have the <termio.h> header file. */
|
||||
#undef HAVE_TERMIO_H
|
||||
/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr. */
|
||||
#undef HAVE_TERMIOS_FUNCS
|
||||
|
||||
/* Define if you have the <termios.h> header file. */
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#undef HAVE_TERMIOS_H
|
||||
|
||||
/* Define if you have the <time.h> header file. */
|
||||
/* Define to 1 if you have the <termio.h> header file. */
|
||||
#undef HAVE_TERMIO_H
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#undef HAVE_TIME_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
/* Define HAVE_TIME_T if your system supports the "time_t" type. */
|
||||
#undef HAVE_TIME_T
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the <values.h> header file. */
|
||||
/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower. */
|
||||
#undef HAVE_UPPER_LOWER
|
||||
|
||||
/* Henry Spencer V8 regcomp() and regexp.h */
|
||||
#undef HAVE_V8_REGCOMP
|
||||
|
||||
/* Define to 1 if you have the <values.h> header file. */
|
||||
#undef HAVE_VALUES_H
|
||||
|
||||
/* Define if you have the PW library (-lPW). */
|
||||
#undef HAVE_LIBPW
|
||||
/* Define HAVE_VOID if your compiler supports the "void" type. */
|
||||
#undef HAVE_VOID
|
||||
|
||||
/* Define if you have the gen library (-lgen). */
|
||||
#undef HAVE_LIBGEN
|
||||
/* Define to 1 if you have the `_setjmp' function. */
|
||||
#undef HAVE__SETJMP
|
||||
|
||||
/* Define if you have the intl library (-lintl). */
|
||||
#undef HAVE_LIBINTL
|
||||
/* Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.
|
||||
*/
|
||||
#undef MUST_DEFINE_ERRNO
|
||||
|
||||
/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in
|
||||
termcap.h. */
|
||||
#undef MUST_DEFINE_OSPEED
|
||||
|
||||
/* pattern matching is supported, but without metacharacters. */
|
||||
#undef NO_REGEX
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
|
||||
#undef STAT_MACROS_BROKEN
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#undef _LARGE_FILES
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `long' if <sys/types.h> does not define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
@ -150,6 +150,12 @@
|
||||
*/
|
||||
#define HAVE_SHELL 0
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
@ -151,6 +151,12 @@
|
||||
*/
|
||||
#define HAVE_SHELL 0
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
@ -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.
|
||||
@ -54,7 +54,10 @@ init_textlist(tlist, str)
|
||||
{
|
||||
char *s;
|
||||
#if SPACES_IN_FILENAMES
|
||||
int quoted = 0;
|
||||
int meta_quoted = 0;
|
||||
int delim_quoted = 0;
|
||||
char *esc = get_meta_escape();
|
||||
int esclen = strlen(esc);
|
||||
#endif
|
||||
|
||||
tlist->string = skipsp(str);
|
||||
@ -62,12 +65,25 @@ init_textlist(tlist, str)
|
||||
for (s = str; s < tlist->endstring; s++)
|
||||
{
|
||||
#if SPACES_IN_FILENAMES
|
||||
if (*s == ' ' && !quoted)
|
||||
*s = '\0';
|
||||
if (!quoted && *s == openquote)
|
||||
quoted = 1;
|
||||
else if (quoted && *s == closequote)
|
||||
quoted = 0;
|
||||
if (meta_quoted)
|
||||
{
|
||||
meta_quoted = 0;
|
||||
} else if (esclen > 0 && s + esclen < tlist->endstring &&
|
||||
strncmp(s, esc, esclen) == 0)
|
||||
{
|
||||
meta_quoted = 1;
|
||||
s += esclen - 1;
|
||||
} else if (delim_quoted)
|
||||
{
|
||||
if (*s == closequote)
|
||||
delim_quoted = 0;
|
||||
} else /* (!delim_quoted) */
|
||||
{
|
||||
if (*s == openquote)
|
||||
delim_quoted = 1;
|
||||
else if (*s == ' ')
|
||||
*s = '\0';
|
||||
}
|
||||
#else
|
||||
if (*s == ' ')
|
||||
*s = '\0';
|
||||
@ -132,7 +148,6 @@ back_textlist(tlist, prev)
|
||||
close_file()
|
||||
{
|
||||
struct scrpos scrpos;
|
||||
char *filename;
|
||||
|
||||
if (curr_ifile == NULL_IFILE)
|
||||
return;
|
||||
@ -157,9 +172,8 @@ close_file()
|
||||
*/
|
||||
if (curr_altfilename != NULL)
|
||||
{
|
||||
filename = unquote_file(get_filename(curr_ifile));
|
||||
close_altfile(curr_altfilename, filename, curr_altpipe);
|
||||
free(filename);
|
||||
close_altfile(curr_altfilename, get_filename(curr_ifile),
|
||||
curr_altpipe);
|
||||
free(curr_altfilename);
|
||||
curr_altfilename = NULL;
|
||||
}
|
||||
@ -194,6 +208,7 @@ edit_ifile(ifile)
|
||||
int chflags;
|
||||
char *filename;
|
||||
char *open_filename;
|
||||
char *qopen_filename;
|
||||
char *alt_filename;
|
||||
void *alt_pipe;
|
||||
IFILE was_curr_ifile;
|
||||
@ -244,13 +259,14 @@ edit_ifile(ifile)
|
||||
return (0);
|
||||
}
|
||||
|
||||
filename = unquote_file(get_filename(ifile));
|
||||
filename = save(get_filename(ifile));
|
||||
/*
|
||||
* See if LESSOPEN specifies an "alternate" file to open.
|
||||
*/
|
||||
alt_pipe = NULL;
|
||||
alt_filename = open_altfile(filename, &f, &alt_pipe);
|
||||
open_filename = (alt_filename != NULL) ? alt_filename : filename;
|
||||
qopen_filename = shell_unquote(open_filename);
|
||||
|
||||
chflags = 0;
|
||||
if (alt_pipe != NULL)
|
||||
@ -301,13 +317,14 @@ edit_ifile(ifile)
|
||||
free(alt_filename);
|
||||
}
|
||||
del_ifile(ifile);
|
||||
free(qopen_filename);
|
||||
free(filename);
|
||||
/*
|
||||
* Re-open the current file.
|
||||
*/
|
||||
reedit_ifile(was_curr_ifile);
|
||||
return (1);
|
||||
} else if ((f = open(open_filename, OPEN_READ)) < 0)
|
||||
} else if ((f = open(qopen_filename, OPEN_READ)) < 0)
|
||||
{
|
||||
/*
|
||||
* Got an error trying to open it.
|
||||
@ -335,6 +352,7 @@ edit_ifile(ifile)
|
||||
}
|
||||
}
|
||||
}
|
||||
free(qopen_filename);
|
||||
|
||||
/*
|
||||
* Get the new ifile.
|
||||
@ -683,7 +701,7 @@ use_logfile(filename)
|
||||
/*
|
||||
* {{ We could use access() here. }}
|
||||
*/
|
||||
filename = unquote_file(filename);
|
||||
filename = shell_unquote(filename);
|
||||
exists = open(filename, OPEN_READ);
|
||||
close(exists);
|
||||
exists = (exists >= 0);
|
||||
|
@ -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.
|
||||
@ -50,6 +50,7 @@
|
||||
|
||||
extern int force_open;
|
||||
extern int secure;
|
||||
extern int use_lessopen;
|
||||
extern IFILE curr_ifile;
|
||||
extern IFILE old_ifile;
|
||||
#if SPACES_IN_FILENAMES
|
||||
@ -61,24 +62,157 @@ extern char closequote;
|
||||
* Remove quotes around a filename.
|
||||
*/
|
||||
public char *
|
||||
unquote_file(str)
|
||||
shell_unquote(str)
|
||||
char *str;
|
||||
{
|
||||
#if SPACES_IN_FILENAMES
|
||||
char *name;
|
||||
char *p;
|
||||
|
||||
if (*str != openquote)
|
||||
return (save(str));
|
||||
name = (char *) ecalloc(strlen(str), sizeof(char));
|
||||
strcpy(name, str+1);
|
||||
p = name + strlen(name) - 1;
|
||||
if (*p == closequote)
|
||||
*p = '\0';
|
||||
name = p = (char *) ecalloc(strlen(str)+1, sizeof(char));
|
||||
if (*str == openquote)
|
||||
{
|
||||
str++;
|
||||
while (*str != '\0')
|
||||
{
|
||||
if (*str == closequote)
|
||||
{
|
||||
if (str[1] != closequote)
|
||||
break;
|
||||
str++;
|
||||
}
|
||||
*p++ = *str++;
|
||||
}
|
||||
} else
|
||||
{
|
||||
char *esc = get_meta_escape();
|
||||
int esclen = strlen(esc);
|
||||
while (*str != '\0')
|
||||
{
|
||||
if (esclen > 0 && strncmp(str, esc, esclen) == 0)
|
||||
str += esclen;
|
||||
*p++ = *str++;
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
return (name);
|
||||
#else
|
||||
return (save(str));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the shell's escape character.
|
||||
*/
|
||||
public char *
|
||||
get_meta_escape()
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = lgetenv("LESSMETAESCAPE");
|
||||
if (s == NULL)
|
||||
s = DEF_METAESCAPE;
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the characters which the shell considers to be "metacharacters".
|
||||
*/
|
||||
static char *
|
||||
metachars()
|
||||
{
|
||||
static char *mchars = NULL;
|
||||
|
||||
if (mchars == NULL)
|
||||
{
|
||||
mchars = lgetenv("LESSMETACHARS");
|
||||
if (mchars == NULL)
|
||||
mchars = DEF_METACHARS;
|
||||
}
|
||||
return (mchars);
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this a shell metacharacter?
|
||||
*/
|
||||
static int
|
||||
metachar(c)
|
||||
char c;
|
||||
{
|
||||
return (strchr(metachars(), c) != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a backslash before each metacharacter in a string.
|
||||
*/
|
||||
public char *
|
||||
shell_quote(s)
|
||||
char *s;
|
||||
{
|
||||
char *p;
|
||||
char *newstr;
|
||||
int len;
|
||||
char *esc = get_meta_escape();
|
||||
int esclen = strlen(esc);
|
||||
int use_quotes = 0;
|
||||
int have_quotes = 0;
|
||||
|
||||
/*
|
||||
* Determine how big a string we need to allocate.
|
||||
*/
|
||||
len = 1; /* Trailing null byte */
|
||||
for (p = s; *p != '\0'; p++)
|
||||
{
|
||||
len++;
|
||||
if (*p == openquote || *p == closequote)
|
||||
have_quotes = 1;
|
||||
if (metachar(*p))
|
||||
{
|
||||
if (esclen == 0)
|
||||
{
|
||||
/*
|
||||
* We've got a metachar, but this shell
|
||||
* doesn't support escape chars. Use quotes.
|
||||
*/
|
||||
use_quotes = 1;
|
||||
} else
|
||||
{
|
||||
/*
|
||||
* Allow space for the escape char.
|
||||
*/
|
||||
len += esclen;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (use_quotes)
|
||||
{
|
||||
if (have_quotes)
|
||||
/*
|
||||
* We can't quote a string that contains quotes.
|
||||
*/
|
||||
return (NULL);
|
||||
len = strlen(s) + 3;
|
||||
}
|
||||
/*
|
||||
* Allocate and construct the new string.
|
||||
*/
|
||||
newstr = p = (char *) ecalloc(len, sizeof(char));
|
||||
if (use_quotes)
|
||||
{
|
||||
sprintf(newstr, "%c%s%c", openquote, s, closequote);
|
||||
} else
|
||||
{
|
||||
while (*s != '\0')
|
||||
{
|
||||
if (metachar(*s))
|
||||
{
|
||||
/*
|
||||
* Add the escape char.
|
||||
*/
|
||||
strcpy(p, esc);
|
||||
p += esclen;
|
||||
}
|
||||
*p++ = *s++;
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
return (newstr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -107,7 +241,7 @@ dirfile(dirname, filename)
|
||||
/*
|
||||
* Make sure the file exists.
|
||||
*/
|
||||
qpathname = unquote_file(pathname);
|
||||
qpathname = shell_unquote(pathname);
|
||||
f = open(qpathname, OPEN_READ);
|
||||
if (f < 0)
|
||||
{
|
||||
@ -274,6 +408,7 @@ fcomplete(s)
|
||||
char *s;
|
||||
{
|
||||
char *fpat;
|
||||
char *qs;
|
||||
|
||||
if (secure)
|
||||
return (NULL);
|
||||
@ -303,17 +438,19 @@ fcomplete(s)
|
||||
fpat = (char *) ecalloc(strlen(s)+2, sizeof(char));
|
||||
sprintf(fpat, "%s*", s);
|
||||
#endif
|
||||
s = lglob(fpat);
|
||||
qs = lglob(fpat);
|
||||
s = shell_unquote(qs);
|
||||
if (strcmp(s,fpat) == 0)
|
||||
{
|
||||
/*
|
||||
* The filename didn't expand.
|
||||
*/
|
||||
free(s);
|
||||
s = NULL;
|
||||
free(qs);
|
||||
qs = NULL;
|
||||
}
|
||||
free(s);
|
||||
free(fpat);
|
||||
return (s);
|
||||
return (qs);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -398,108 +535,6 @@ readfd(fd)
|
||||
return (buf);
|
||||
}
|
||||
|
||||
#if HAVE_SHELL
|
||||
|
||||
/*
|
||||
* Get the shell's escape character.
|
||||
*/
|
||||
static char *
|
||||
get_meta_escape()
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = lgetenv("LESSMETAESCAPE");
|
||||
if (s == NULL)
|
||||
s = DEF_METAESCAPE;
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this a shell metacharacter?
|
||||
*/
|
||||
static int
|
||||
metachar(c)
|
||||
char c;
|
||||
{
|
||||
static char *metachars = NULL;
|
||||
|
||||
if (metachars == NULL)
|
||||
{
|
||||
metachars = lgetenv("LESSMETACHARS");
|
||||
if (metachars == NULL)
|
||||
metachars = DEF_METACHARS;
|
||||
}
|
||||
return (strchr(metachars, c) != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a backslash before each metacharacter in a string.
|
||||
*/
|
||||
public char *
|
||||
esc_metachars(s)
|
||||
char *s;
|
||||
{
|
||||
char *p;
|
||||
char *newstr;
|
||||
int len;
|
||||
char *esc;
|
||||
int esclen;
|
||||
|
||||
/*
|
||||
* Determine how big a string we need to allocate.
|
||||
*/
|
||||
esc = get_meta_escape();
|
||||
esclen = strlen(esc);
|
||||
len = 1; /* Trailing null byte */
|
||||
for (p = s; *p != '\0'; p++)
|
||||
{
|
||||
len++;
|
||||
if (metachar(*p))
|
||||
{
|
||||
if (*esc == '\0')
|
||||
{
|
||||
/*
|
||||
* We've got a metachar, but this shell
|
||||
* doesn't support escape chars. Give up.
|
||||
*/
|
||||
return (NULL);
|
||||
}
|
||||
/*
|
||||
* Allow space for the escape char.
|
||||
*/
|
||||
len += esclen;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Allocate and construct the new string.
|
||||
*/
|
||||
newstr = p = (char *) ecalloc(len, sizeof(char));
|
||||
while (*s != '\0')
|
||||
{
|
||||
if (metachar(*s))
|
||||
{
|
||||
/*
|
||||
* Add the escape char.
|
||||
*/
|
||||
strcpy(p, esc);
|
||||
p += esclen;
|
||||
}
|
||||
*p++ = *s++;
|
||||
}
|
||||
*p = '\0';
|
||||
return (newstr);
|
||||
}
|
||||
|
||||
#else /* HAVE_SHELL */
|
||||
|
||||
public char *
|
||||
esc_metachars(s)
|
||||
char *s;
|
||||
{
|
||||
return (save(s));
|
||||
}
|
||||
|
||||
#endif /* HAVE_SHELL */
|
||||
|
||||
|
||||
#if HAVE_POPEN
|
||||
@ -526,43 +561,32 @@ shellcmd(cmd)
|
||||
char *esccmd;
|
||||
|
||||
/*
|
||||
* Try to escape any metacharacters in the command.
|
||||
* If we can't do that, just put the command in quotes.
|
||||
* (But that doesn't work well if the command itself
|
||||
* contains quotes.)
|
||||
* Read the output of <$SHELL -c cmd>.
|
||||
* Escape any metacharacters in the command.
|
||||
*/
|
||||
if ((esccmd = esc_metachars(cmd)) == NULL)
|
||||
esccmd = shell_quote(cmd);
|
||||
if (esccmd == NULL)
|
||||
{
|
||||
/*
|
||||
* Cannot escape the metacharacters, so use quotes.
|
||||
* Read the output of <$SHELL -c "cmd">.
|
||||
*/
|
||||
scmd = (char *) ecalloc(strlen(shell) + strlen(cmd) + 7,
|
||||
sizeof(char));
|
||||
sprintf(scmd, "%s -c \"%s\"", shell, cmd);
|
||||
fd = popen(cmd, "r");
|
||||
} else
|
||||
{
|
||||
/*
|
||||
* Read the output of <$SHELL -c cmd>.
|
||||
* No quotes; use the escaped cmd.
|
||||
*/
|
||||
scmd = (char *) ecalloc(strlen(shell) + strlen(esccmd) + 5,
|
||||
sizeof(char));
|
||||
sprintf(scmd, "%s -c %s", shell, esccmd);
|
||||
sprintf(scmd, "%s %s %s", shell, shell_coption(), esccmd);
|
||||
free(esccmd);
|
||||
fd = popen(scmd, "r");
|
||||
free(scmd);
|
||||
}
|
||||
fd = popen(scmd, "r");
|
||||
free(scmd);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
fd = popen(cmd, "r");
|
||||
/*
|
||||
* Redirection in `popen' might have messed with the
|
||||
* standard devices. Restore binary input mode.
|
||||
*/
|
||||
SET_BINARY(0);
|
||||
}
|
||||
/*
|
||||
* Redirection in `popen' might have messed with the
|
||||
* standard devices. Restore binary input mode.
|
||||
*/
|
||||
SET_BINARY(0);
|
||||
return (fd);
|
||||
}
|
||||
|
||||
@ -582,7 +606,7 @@ lglob(filename)
|
||||
ofilename = fexpand(filename);
|
||||
if (secure)
|
||||
return (ofilename);
|
||||
filename = unquote_file(ofilename);
|
||||
filename = shell_unquote(ofilename);
|
||||
|
||||
#ifdef DECL_GLOB_LIST
|
||||
{
|
||||
@ -591,6 +615,7 @@ lglob(filename)
|
||||
*/
|
||||
int length;
|
||||
char *p;
|
||||
char *qfilename;
|
||||
DECL_GLOB_LIST(list)
|
||||
|
||||
GLOB_LIST(filename, list);
|
||||
@ -603,23 +628,23 @@ lglob(filename)
|
||||
for (SCAN_GLOB_LIST(list, p))
|
||||
{
|
||||
INIT_GLOB_LIST(list, p);
|
||||
length += strlen(p) + 1;
|
||||
#if SPACES_IN_FILENAMES
|
||||
if (strchr(p, ' ') != NULL)
|
||||
length += 2; /* Allow for quotes */
|
||||
#endif
|
||||
qfilename = shell_quote(p);
|
||||
if (qfilename != NULL)
|
||||
{
|
||||
length += strlen(qfilename) + 1;
|
||||
free(qfilename);
|
||||
}
|
||||
}
|
||||
gfilename = (char *) ecalloc(length, sizeof(char));
|
||||
for (SCAN_GLOB_LIST(list, p))
|
||||
{
|
||||
INIT_GLOB_LIST(list, p);
|
||||
#if SPACES_IN_FILENAMES
|
||||
if (strchr(p, ' ') != NULL)
|
||||
sprintf(gfilename + strlen(gfilename), "%c%s%c ",
|
||||
openquote, p, closequote);
|
||||
else
|
||||
#endif
|
||||
sprintf(gfilename + strlen(gfilename), "%s ", p);
|
||||
qfilename = shell_quote(p);
|
||||
if (qfilename != NULL)
|
||||
{
|
||||
sprintf(gfilename + strlen(gfilename), "%s ", qfilename);
|
||||
free(qfilename);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Overwrite the final trailing space with a null terminator.
|
||||
@ -637,9 +662,8 @@ lglob(filename)
|
||||
register char *p;
|
||||
register int len;
|
||||
register int n;
|
||||
#if SPACES_IN_FILENAMES
|
||||
register int spaces_in_file;
|
||||
#endif
|
||||
char *pathname;
|
||||
char *qpathname;
|
||||
DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle)
|
||||
|
||||
GLOB_FIRST_NAME(filename, &fnd, handle);
|
||||
@ -655,36 +679,32 @@ lglob(filename)
|
||||
p = gfilename;
|
||||
do {
|
||||
n = strlen(drive) + strlen(dir) + strlen(fnd.GLOB_NAME) + 1;
|
||||
#if SPACES_IN_FILENAMES
|
||||
spaces_in_file = 0;
|
||||
if (strchr(fnd.GLOB_NAME, ' ') != NULL ||
|
||||
strchr(filename, ' ') != NULL)
|
||||
pathname = (char *) ecalloc(n, sizeof(char));
|
||||
sprintf(pathname, "%s%s%s", drive, dir, fnd.GLOB_NAME);
|
||||
qpathname = shell_quote(pathname);
|
||||
free(pathname);
|
||||
if (qpathname != NULL)
|
||||
{
|
||||
spaces_in_file = 1;
|
||||
n += 2;
|
||||
n = strlen(qpathname);
|
||||
while (p - gfilename + n + 2 >= len)
|
||||
{
|
||||
/*
|
||||
* No room in current buffer.
|
||||
* Allocate a bigger one.
|
||||
*/
|
||||
len *= 2;
|
||||
*p = '\0';
|
||||
p = (char *) ecalloc(len, sizeof(char));
|
||||
strcpy(p, gfilename);
|
||||
free(gfilename);
|
||||
gfilename = p;
|
||||
p = gfilename + strlen(gfilename);
|
||||
}
|
||||
strcpy(p, qpathname);
|
||||
free(qpathname);
|
||||
p += n;
|
||||
*p++ = ' ';
|
||||
}
|
||||
#endif
|
||||
while (p - gfilename + n+2 >= len)
|
||||
{
|
||||
/*
|
||||
* No room in current buffer. Allocate a bigger one.
|
||||
*/
|
||||
len *= 2;
|
||||
*p = '\0';
|
||||
p = (char *) ecalloc(len, sizeof(char));
|
||||
strcpy(p, gfilename);
|
||||
free(gfilename);
|
||||
gfilename = p;
|
||||
p = gfilename + strlen(gfilename);
|
||||
}
|
||||
#if SPACES_IN_FILENAMES
|
||||
if (spaces_in_file)
|
||||
sprintf(p, "%c%s%s%s%c ", openquote,
|
||||
drive, dir, fnd.GLOB_NAME, closequote);
|
||||
else
|
||||
#endif
|
||||
sprintf(p, "%s%s%s ", drive, dir, fnd.GLOB_NAME);
|
||||
p += n;
|
||||
} while (GLOB_NEXT_NAME(handle, &fnd) == 0);
|
||||
|
||||
/*
|
||||
@ -704,30 +724,30 @@ lglob(filename)
|
||||
char *s;
|
||||
char *lessecho;
|
||||
char *cmd;
|
||||
char *esc;
|
||||
|
||||
lessecho = lgetenv("LESSECHO");
|
||||
if (lessecho == NULL || *lessecho == '\0')
|
||||
lessecho = "lessecho";
|
||||
s = esc_metachars(filename);
|
||||
if (s == NULL)
|
||||
esc = get_meta_escape();
|
||||
if (strlen(esc) == 0)
|
||||
esc = "-";
|
||||
esc = shell_quote(esc);
|
||||
if (esc == NULL)
|
||||
{
|
||||
/*
|
||||
* There may be dangerous metachars in this name.
|
||||
* We can't risk passing it to the shell.
|
||||
* {{ For example, do "!;TAB" when the first file
|
||||
* in the dir is named "rm". }}
|
||||
*/
|
||||
free(filename);
|
||||
return (ofilename);
|
||||
}
|
||||
lessecho = lgetenv("LESSECHO");
|
||||
if (lessecho == NULL || *lessecho == '\0')
|
||||
lessecho = "lessecho";
|
||||
/*
|
||||
* Invoke lessecho, and read its output (a globbed list of filenames).
|
||||
*/
|
||||
cmd = (char *) ecalloc(strlen(lessecho) + strlen(s) + 24, sizeof(char));
|
||||
sprintf(cmd, "%s -p0x%x -d0x%x -- %s",
|
||||
lessecho, openquote, closequote, s);
|
||||
cmd = (char *) ecalloc(strlen(lessecho) + strlen(ofilename) + (7*strlen(metachars())) + 24, sizeof(char));
|
||||
sprintf(cmd, "%s -p0x%x -d0x%x -e%s ", lessecho, openquote, closequote, esc);
|
||||
free(esc);
|
||||
for (s = metachars(); *s != '\0'; s++)
|
||||
sprintf(cmd + strlen(cmd), "-n0x%x ", *s);
|
||||
sprintf(cmd + strlen(cmd), "-- %s", ofilename);
|
||||
fd = shellcmd(cmd);
|
||||
free(s);
|
||||
free(cmd);
|
||||
if (fd == NULL)
|
||||
{
|
||||
@ -774,14 +794,13 @@ open_altfile(filename, pf, pfd)
|
||||
return (NULL);
|
||||
#else
|
||||
char *lessopen;
|
||||
char *gfilename;
|
||||
char *cmd;
|
||||
FILE *fd;
|
||||
#if HAVE_FILENO
|
||||
int returnfd = 0;
|
||||
#endif
|
||||
|
||||
if (secure)
|
||||
if (!use_lessopen || secure)
|
||||
return (NULL);
|
||||
ch_ungetchar(-1);
|
||||
if ((lessopen = lgetenv("LESSOPEN")) == NULL)
|
||||
@ -803,19 +822,10 @@ open_altfile(filename, pf, pfd)
|
||||
#endif
|
||||
}
|
||||
|
||||
gfilename = esc_metachars(filename);
|
||||
if (gfilename == NULL)
|
||||
{
|
||||
/*
|
||||
* Cannot escape metacharacters.
|
||||
*/
|
||||
return (NULL);
|
||||
}
|
||||
cmd = (char *) ecalloc(strlen(lessopen) + strlen(gfilename) + 2,
|
||||
cmd = (char *) ecalloc(strlen(lessopen) + strlen(filename) + 2,
|
||||
sizeof(char));
|
||||
sprintf(cmd, lessopen, gfilename);
|
||||
sprintf(cmd, lessopen, filename);
|
||||
fd = shellcmd(cmd);
|
||||
free(gfilename);
|
||||
free(cmd);
|
||||
if (fd == NULL)
|
||||
{
|
||||
@ -850,14 +860,14 @@ open_altfile(filename, pf, pfd)
|
||||
return (save("-"));
|
||||
}
|
||||
#endif
|
||||
gfilename = readfd(fd);
|
||||
cmd = readfd(fd);
|
||||
pclose(fd);
|
||||
if (*gfilename == '\0')
|
||||
if (*cmd == '\0')
|
||||
/*
|
||||
* Pipe is empty. This means there is no alt file.
|
||||
*/
|
||||
return (NULL);
|
||||
return (gfilename);
|
||||
return (cmd);
|
||||
#endif /* HAVE_POPEN */
|
||||
}
|
||||
|
||||
@ -872,8 +882,6 @@ close_altfile(altfilename, filename, pipefd)
|
||||
{
|
||||
#if HAVE_POPEN
|
||||
char *lessclose;
|
||||
char *gfilename;
|
||||
char *galtfilename;
|
||||
FILE *fd;
|
||||
char *cmd;
|
||||
|
||||
@ -892,23 +900,10 @@ close_altfile(altfilename, filename, pipefd)
|
||||
}
|
||||
if ((lessclose = lgetenv("LESSCLOSE")) == NULL)
|
||||
return;
|
||||
gfilename = esc_metachars(filename);
|
||||
if (gfilename == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
galtfilename = esc_metachars(altfilename);
|
||||
if (galtfilename == NULL)
|
||||
{
|
||||
free(gfilename);
|
||||
return;
|
||||
}
|
||||
cmd = (char *) ecalloc(strlen(lessclose) + strlen(gfilename) +
|
||||
strlen(galtfilename) + 2, sizeof(char));
|
||||
sprintf(cmd, lessclose, gfilename, galtfilename);
|
||||
cmd = (char *) ecalloc(strlen(lessclose) + strlen(filename) +
|
||||
strlen(altfilename) + 2, sizeof(char));
|
||||
sprintf(cmd, lessclose, filename, altfilename);
|
||||
fd = shellcmd(cmd);
|
||||
free(galtfilename);
|
||||
free(gfilename);
|
||||
free(cmd);
|
||||
if (fd != NULL)
|
||||
pclose(fd);
|
||||
@ -924,7 +919,7 @@ is_dir(filename)
|
||||
{
|
||||
int isdir = 0;
|
||||
|
||||
filename = unquote_file(filename);
|
||||
filename = shell_unquote(filename);
|
||||
#if HAVE_STAT
|
||||
{
|
||||
int r;
|
||||
@ -960,15 +955,15 @@ bad_file(filename)
|
||||
{
|
||||
register char *m = NULL;
|
||||
|
||||
filename = unquote_file(filename);
|
||||
filename = shell_unquote(filename);
|
||||
if (is_dir(filename))
|
||||
{
|
||||
static char is_dir[] = " is a directory";
|
||||
static char is_a_dir[] = " is a directory";
|
||||
|
||||
m = (char *) ecalloc(strlen(filename) + sizeof(is_dir),
|
||||
m = (char *) ecalloc(strlen(filename) + sizeof(is_a_dir),
|
||||
sizeof(char));
|
||||
strcpy(m, filename);
|
||||
strcat(m, is_dir);
|
||||
strcat(m, is_a_dir);
|
||||
} else
|
||||
{
|
||||
#if HAVE_STAT
|
||||
@ -1020,3 +1015,11 @@ filesize(f)
|
||||
return (seek_filesize(f));
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
public char *
|
||||
shell_coption()
|
||||
{
|
||||
return ("-c");
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
public POSITION ch_tell ();
|
||||
public int ch_forw_get ();
|
||||
public int ch_back_get ();
|
||||
public int ch_nbuf ();
|
||||
public void ch_setbufspace ();
|
||||
public void ch_flush ();
|
||||
public int seekable ();
|
||||
public void ch_init ();
|
||||
@ -62,7 +62,7 @@
|
||||
public void cmd_addhist ();
|
||||
public void cmd_accept ();
|
||||
public int cmd_char ();
|
||||
public int cmd_int ();
|
||||
public LINENUM cmd_int ();
|
||||
public char * get_cmdbuf ();
|
||||
public int in_mca ();
|
||||
public void dispversion ();
|
||||
@ -96,19 +96,20 @@
|
||||
public int edit_stdin ();
|
||||
public void cat_file ();
|
||||
public void use_logfile ();
|
||||
public char * unquote_file ();
|
||||
public char * shell_unquote ();
|
||||
public char * get_meta_escape ();
|
||||
public char * shell_quote ();
|
||||
public char * homefile ();
|
||||
public char * fexpand ();
|
||||
public char * fcomplete ();
|
||||
public int bin_file ();
|
||||
public char * esc_metachars ();
|
||||
public char * esc_metachars ();
|
||||
public char * lglob ();
|
||||
public char * open_altfile ();
|
||||
public void close_altfile ();
|
||||
public int is_dir ();
|
||||
public char * bad_file ();
|
||||
public POSITION filesize ();
|
||||
public char * shell_coption ();
|
||||
public void forw ();
|
||||
public void back ();
|
||||
public void forward ();
|
||||
@ -152,9 +153,9 @@
|
||||
public POSITION back_raw_line ();
|
||||
public void clr_linenum ();
|
||||
public void add_lnum ();
|
||||
public int find_linenum ();
|
||||
public LINENUM find_linenum ();
|
||||
public POSITION find_pos ();
|
||||
public int currline ();
|
||||
public LINENUM currline ();
|
||||
public void lsystem ();
|
||||
public int pipe_mark ();
|
||||
public int pipe_data ();
|
||||
@ -189,8 +190,8 @@
|
||||
public void nopendopt ();
|
||||
public int getnum ();
|
||||
public void init_option ();
|
||||
public struct option * findopt ();
|
||||
public struct option * findopt_name ();
|
||||
public struct loption * findopt ();
|
||||
public struct loption * findopt_name ();
|
||||
public int iread ();
|
||||
public void intread ();
|
||||
public long get_time ();
|
||||
|
@ -22,8 +22,8 @@ constant char helpdata[] = {
|
||||
' ',' ','E','S','C','-','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',',',' ','b','u','t',' ','d','o','n','\'','t',' ','s','t','o','p',' ','a','t',' ','e','n','d','-','o','f','-','f','i','l','e','.','\n',
|
||||
' ',' ','d',' ',' ','^','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
|
||||
' ',' ','u',' ',' ','^','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
|
||||
' ',' ','E','S','C','-','(',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
|
||||
' ',' ','E','S','C','-',')',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','R','i','g','h','t',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
|
||||
' ',' ','E','S','C','-',')',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
|
||||
' ',' ','E','S','C','-','(',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','R','i','g','h','t',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
|
||||
' ',' ','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','f','o','r','e','v','e','r',';',' ','l','i','k','e',' ','"','t','a','i','l',' ','-','f','"','.','\n',
|
||||
' ',' ','r',' ',' ','^','R',' ',' ','^','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n','.','\n',
|
||||
' ',' ','R',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n',',',' ','d','i','s','c','a','r','d','i','n','g',' ','b','u','f','f','e','r','e','d',' ','i','n','p','u','t','.','\n',
|
||||
@ -146,6 +146,8 @@ constant char helpdata[] = {
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','a',' ','s','t','a','t','u','s',' ','c','o','l','u','m','n',' ','a','t',' ','l','e','f','t',' ','e','d','g','e',' ','o','f',' ','s','c','r','e','e','n','.','\n',
|
||||
' ',' ','-','k',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','e','s','s','k','e','y','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a',' ','l','e','s','s','k','e','y',' ','f','i','l','e','.','\n',
|
||||
' ',' ','-','L',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','l','e','s','s','o','p','e','n','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','t','h','e',' ','L','E','S','S','O','P','E','N',' ','e','n','v','i','r','o','n','m','e','n','t',' ','v','a','r','i','a','b','l','e','.','\n',
|
||||
' ',' ','-','m',' ',' ','-','M',' ',' ','.','.','.','.',' ',' ','-','-','l','o','n','g','-','p','r','o','m','p','t',' ',' ','-','-','L','O','N','G','-','P','R','O','M','P','T','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','p','r','o','m','p','t',' ','s','t','y','l','e','.','\n',
|
||||
' ',' ','-','n',' ',' ','-','N',' ',' ','.','.','.','.',' ',' ','-','-','l','i','n','e','-','n','u','m','b','e','r','s',' ',' ','-','-','L','I','N','E','-','N','U','M','B','E','R','S','\n',
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
@ -52,8 +52,8 @@ jump_forw()
|
||||
* Jump to line n in the file.
|
||||
*/
|
||||
public void
|
||||
jump_back(n)
|
||||
int n;
|
||||
jump_back(linenum)
|
||||
LINENUM linenum;
|
||||
{
|
||||
POSITION pos;
|
||||
PARG parg;
|
||||
@ -64,20 +64,20 @@ jump_back(n)
|
||||
* If we can't seek, but we're trying to go to line number 1,
|
||||
* use ch_beg_seek() to get as close as we can.
|
||||
*/
|
||||
pos = find_pos(n);
|
||||
pos = find_pos(linenum);
|
||||
if (pos != NULL_POSITION && ch_seek(pos) == 0)
|
||||
{
|
||||
if (show_attn)
|
||||
set_attnpos(pos);
|
||||
jump_loc(pos, jump_sline);
|
||||
} else if (n <= 1 && ch_beg_seek() == 0)
|
||||
} else if (linenum <= 1 && ch_beg_seek() == 0)
|
||||
{
|
||||
jump_loc(ch_tell(), jump_sline);
|
||||
error("Cannot seek to beginning of file", NULL_PARG);
|
||||
} else
|
||||
{
|
||||
parg.p_int = n;
|
||||
error("Cannot seek to line number %d", &parg);
|
||||
parg.p_linenum = linenum;
|
||||
error("Cannot seek to line number %n", &parg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
ESC-SPACE * Forward one window, but don't stop at end-of-file.
|
||||
d ^D * Forward one half-window (and set half-window to _N).
|
||||
u ^U * Backward one half-window (and set half-window to _N).
|
||||
ESC-( RightArrow * Left one half screen width (or _N positions).
|
||||
ESC-) LeftArrow * Right one half screen width (or _N positions).
|
||||
ESC-) RightArrow * Left one half screen width (or _N positions).
|
||||
ESC-( LeftArrow * Right one half screen width (or _N positions).
|
||||
F Forward forever; like "tail -f".
|
||||
r ^R ^L Repaint screen.
|
||||
R Repaint screen, discarding buffered input.
|
||||
@ -143,6 +143,8 @@
|
||||
Display a status column at left edge of screen.
|
||||
-k [_f_i_l_e] . --lesskey-file=[_f_i_l_e]
|
||||
Use a lesskey file.
|
||||
-L ........ --no-lessopen
|
||||
Ignore the LESSOPEN environment variable.
|
||||
-m -M .... --long-prompt --LONG-PROMPT
|
||||
Set prompt style.
|
||||
-n -N .... --line-numbers --LINE-NUMBERS
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
.TH LESS 1 "Version 371: 26 Dec 2001"
|
||||
.TH LESS 1 "Version 381: 17 Jan 2003"
|
||||
.SH NAME
|
||||
less \- opposite of more
|
||||
.SH SYNOPSIS
|
||||
@ -10,15 +10,15 @@ less \- opposite of more
|
||||
.br
|
||||
.B "less --version"
|
||||
.br
|
||||
.B "less [-[+]aBcCdeEfFgGiIJmMnNqQrRsSuUVwWX]"
|
||||
.B "less [-[+]aBcCdeEfFgGiIJLmMnNqQrRsSuUVwWX~]"
|
||||
.br
|
||||
.B " [-b \fIbufs\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]"
|
||||
.B " [-b \fIspace\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]"
|
||||
.br
|
||||
.B " [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP] [-t \fItag\fP]"
|
||||
.br
|
||||
.B " [-T \fItagsfile\fP] [-x \fItab\fP,...] [-y \fIlines\fP] [-[z] \fIlines\fP]"
|
||||
.br
|
||||
.B " [+[+]\fIcmd\fP] [--] [\fIfilename\fP]..."
|
||||
.B " [-# \fIshift\fP] [+[+]\fIcmd\fP] [--] [\fIfilename\fP]..."
|
||||
.br
|
||||
(See the OPTIONS section for alternate option syntax with long option names.)
|
||||
|
||||
@ -444,7 +444,7 @@ This option displays a summary of the commands accepted by
|
||||
.I less
|
||||
(the same as the h command).
|
||||
(Depending on how your shell interprets the question mark,
|
||||
it may be necessary to quote the question mark, thus: "-\\?".)
|
||||
it may be necessary to quote the question mark, thus: "-\e?".)
|
||||
.IP "-a or --search-skip-screen"
|
||||
Causes searches to start after the last line
|
||||
displayed on the screen,
|
||||
@ -452,19 +452,24 @@ thus skipping all lines displayed on the screen.
|
||||
By default, searches start at the second line on the screen
|
||||
(or after the last found line; see the -j option).
|
||||
.IP "-b\fIn\fP or --buffers=\fIn\fP"
|
||||
Specifies the number of buffers
|
||||
Specifies the amount of buffer space
|
||||
.I less
|
||||
will use for each file.
|
||||
Buffers are 1K, and by default 10 buffers are used for each file
|
||||
(except if the file is a pipe; see the -B option).
|
||||
The number \fIn\fP specifies a different number of buffers to use.
|
||||
will use for each file, in units of kilobytes (1024 bytes).
|
||||
By default 64K of buffer space is used for each file
|
||||
(unless the file is a pipe; see the -B option).
|
||||
The -b option specifies instead that \fIn\fP kilobytes of
|
||||
buffer space should be used for each file.
|
||||
If \fIn\fP is -1, buffer space is unlimited; that is,
|
||||
the entire file is read into memory.
|
||||
.IP "-B or --auto-buffers"
|
||||
By default, when data is read from a pipe,
|
||||
buffers are allocated automatically as needed.
|
||||
If a large amount of data is read from the pipe, this can cause
|
||||
a large amount of memory to be allocated.
|
||||
The -B option disables this automatic allocation of buffers for pipes,
|
||||
so that only the number of buffers specified by the -b option are used.
|
||||
so that only 64K
|
||||
(or the amount of space specified by the -b option)
|
||||
is used for the pipe.
|
||||
Warning: use of -B can result in erroneous display, since only the
|
||||
most recently viewed part of the file is kept in memory;
|
||||
any earlier data is lost.
|
||||
@ -481,7 +486,7 @@ that is, lacks some important capability,
|
||||
such as the ability to clear the screen or scroll backward.
|
||||
The -d option does not otherwise change the behavior of
|
||||
.I less
|
||||
on a dumb terminal).
|
||||
on a dumb terminal.
|
||||
.IP "-D\fBx\fP\fIcolor\fP or --color=\fBx\fP\fIcolor\fP"
|
||||
[MS-DOS only]
|
||||
Sets the color of the text displayed.
|
||||
@ -574,6 +579,12 @@ if a lesskey file is found in a standard place (see KEY BINDINGS),
|
||||
it is also used as a
|
||||
.I lesskey
|
||||
file.
|
||||
.IP "-L or --no-lessopen"
|
||||
Ignore the LESSOPEN environment variable
|
||||
(see the INPUT PREPROCESSOR section below).
|
||||
This option can be set from within \fIless\fP,
|
||||
but it will apply only to files opened subsequently, not to the
|
||||
file which is currently open.
|
||||
.IP "-m or --long-prompt"
|
||||
Causes
|
||||
.I less
|
||||
@ -692,7 +703,8 @@ output.
|
||||
.IP "-S or --chop-long-lines"
|
||||
Causes lines longer than the screen width to be
|
||||
chopped rather than folded.
|
||||
That is, the remainder of a long line is simply discarded.
|
||||
That is, the portion of a long line that does not fit in
|
||||
the screen width is not shown.
|
||||
The default is to fold long lines; that is, display the remainder
|
||||
on the next line.
|
||||
.IP "-t\fItag\fP or --tag=\fItag\fP"
|
||||
@ -791,7 +803,7 @@ lines less than the current screen size.
|
||||
For example, if the screen is 24 lines, \fI-z-4\fP sets the
|
||||
scrolling window to 20 lines. If the screen is resized to 40 lines,
|
||||
the scrolling window automatically changes to 36 lines.
|
||||
.IP -"\fIcc\fP\ or\ --quotes=\fIcc\fP
|
||||
.IP "-\fI\(dqcc\fP\ or\ --quotes=\fIcc\fP"
|
||||
Changes the filename quoting character.
|
||||
This may be necessary if you are trying to name a file
|
||||
which contains both spaces and quote characters.
|
||||
@ -879,7 +891,7 @@ If it matches more than one filename, the first match
|
||||
is entered into the command line.
|
||||
Repeated TABs will cycle thru the other matching filenames.
|
||||
If the completed filename is a directory, a "/" is appended to the filename.
|
||||
(On MS-DOS systems, a "\\" is appended.)
|
||||
(On MS-DOS systems, a "\e" is appended.)
|
||||
The environment variable LESSSEPARATOR can be used to specify a
|
||||
different character to append to a directory name.
|
||||
.IP "BACKTAB [ ESC-TAB ]"
|
||||
@ -947,8 +959,8 @@ On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless.
|
||||
.I less
|
||||
was built with a different sysconf directory than /usr/local/etc,
|
||||
that directory is where the sysless file is found.)
|
||||
On MS-DOS and Windows systems, the system-wide lesskey file is c:\\_sysless.
|
||||
On OS/2 systems, the system-wide lesskey file is c:\\sysless.ini.
|
||||
On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless.
|
||||
On OS/2 systems, the system-wide lesskey file is c:\esysless.ini.
|
||||
|
||||
.SH "INPUT PREPROCESSOR"
|
||||
You may define an "input preprocessor" for
|
||||
@ -1149,6 +1161,7 @@ to each of the possible values for LESSCHARSET:
|
||||
\ \ \ \ \ \ 9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
|
||||
.br
|
||||
IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
|
||||
.br
|
||||
\ \ \ \ \ \ 191.b
|
||||
.br
|
||||
iso8859 8bcccbcc18b95.33b.
|
||||
@ -1317,7 +1330,7 @@ Some examples:
|
||||
This prompt prints the filename, if known;
|
||||
otherwise the string "Standard input".
|
||||
.sp
|
||||
?f%f .?ltLine %lt:?pt%pt\\%:?btByte %bt:-...
|
||||
?f%f .?ltLine %lt:?pt%pt\e%:?btByte %bt:-...
|
||||
.sp
|
||||
This prompt would print the filename, if known.
|
||||
The filename is followed by the line number, if known,
|
||||
@ -1327,7 +1340,7 @@ Notice how each question mark has a matching period,
|
||||
and how the % after the %pt
|
||||
is included literally by escaping it with a backslash.
|
||||
.sp
|
||||
?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x..%t
|
||||
?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t
|
||||
.sp
|
||||
This prints the filename if this is the first prompt in a file,
|
||||
followed by the "file N of N" message if there is more
|
||||
@ -1341,18 +1354,18 @@ the other two prompts (-m and -M respectively).
|
||||
Each is broken into two lines here for readability only.
|
||||
.nf
|
||||
.sp
|
||||
?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x.:
|
||||
?pB%pB\\%:byte\ %bB?s/%s...%t
|
||||
?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.:
|
||||
?pB%pB\e%:byte\ %bB?s/%s...%t
|
||||
.sp
|
||||
?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ :
|
||||
byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\\:\ %x.:?pB%pB\\%..%t
|
||||
byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\e:\ %x.:?pB%pB\e%..%t
|
||||
.sp
|
||||
.fi
|
||||
And here is the default message produced by the = command:
|
||||
.nf
|
||||
.sp
|
||||
?f%f\ .?m(file\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ .
|
||||
byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\\%..%t
|
||||
byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\e%..%t
|
||||
.fi
|
||||
.PP
|
||||
The prompt expansion features are also used for another purpose:
|
||||
@ -1534,7 +1547,7 @@ See http://www.greenwoodsoftware.com/less for the latest list of known bugs in t
|
||||
version of less.
|
||||
|
||||
.SH COPYRIGHT
|
||||
Copyright (C) 2001 Mark Nudelman
|
||||
Copyright (C) 2002 Mark Nudelman
|
||||
.PP
|
||||
less is part of the GNU project and is free software.
|
||||
You can redistribute it and/or modify it
|
||||
|
@ -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.
|
||||
@ -18,23 +18,31 @@
|
||||
* -cx Specifies "x" to be the close quote character.
|
||||
* -pn Specifies "n" to be the open quote character, as an integer.
|
||||
* -dn Specifies "n" to be the close quote character, as an integer.
|
||||
* -mx Specifies "x" to be a metachar.
|
||||
* -nn Specifies "n" to be a metachar, as an integer.
|
||||
* -ex Specifies "x" to be the escape char for metachars.
|
||||
* -fn Specifies "x" to be the escape char for metachars, as an integer.
|
||||
* -a Specifies that all arguments are to be quoted.
|
||||
* The default is that only arguments containing spaces are quoted.
|
||||
*/
|
||||
|
||||
#include "less.h"
|
||||
|
||||
static char *version = "$Revision: 1.6 $";
|
||||
static char *version = "$Revision: 1.9 $";
|
||||
|
||||
static int quote_all = 0;
|
||||
static char openquote = '"';
|
||||
static char closequote = '"';
|
||||
static char *meta_escape = "\\";
|
||||
static char meta_escape_buf[2];
|
||||
static char metachars[64] = "";
|
||||
static int num_metachars = 0;
|
||||
|
||||
static void
|
||||
pr_usage()
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: lessecho [-ox] [-cx] [-pn] [-dn] [-a] file ...\n");
|
||||
"usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -169,21 +177,43 @@ main(argc, argv)
|
||||
case 'a':
|
||||
quote_all = 1;
|
||||
break;
|
||||
case 'o':
|
||||
openquote = *++arg;
|
||||
break;
|
||||
case 'c':
|
||||
closequote = *++arg;
|
||||
break;
|
||||
case 'p':
|
||||
openquote = lstrtol(++arg, 0, &s);
|
||||
if (s == arg)
|
||||
pr_error("Missing number after -O");
|
||||
break;
|
||||
case 'd':
|
||||
closequote = lstrtol(++arg, 0, &s);
|
||||
if (s == arg)
|
||||
pr_error("Missing number after -C");
|
||||
pr_error("Missing number after -d");
|
||||
break;
|
||||
case 'e':
|
||||
if (strcmp(++arg, "-") == 0)
|
||||
meta_escape = "";
|
||||
else
|
||||
meta_escape = arg;
|
||||
break;
|
||||
case 'f':
|
||||
meta_escape_buf[0] = lstrtol(++arg, 0, &s);
|
||||
meta_escape = meta_escape_buf;
|
||||
if (s == arg)
|
||||
pr_error("Missing number after -f");
|
||||
break;
|
||||
case 'o':
|
||||
openquote = *++arg;
|
||||
break;
|
||||
case 'p':
|
||||
openquote = lstrtol(++arg, 0, &s);
|
||||
if (s == arg)
|
||||
pr_error("Missing number after -p");
|
||||
break;
|
||||
case 'm':
|
||||
metachars[num_metachars++] = *++arg;
|
||||
metachars[num_metachars] = '\0';
|
||||
break;
|
||||
case 'n':
|
||||
metachars[num_metachars++] = lstrtol(++arg, 0, &s);
|
||||
if (s == arg)
|
||||
pr_error("Missing number after -n");
|
||||
metachars[num_metachars] = '\0';
|
||||
break;
|
||||
case '?':
|
||||
pr_usage();
|
||||
@ -212,11 +242,27 @@ main(argc, argv)
|
||||
|
||||
while (argc-- > 0)
|
||||
{
|
||||
int has_meta = 0;
|
||||
arg = *argv++;
|
||||
if (quote_all || strchr(arg, ' ') != NULL)
|
||||
for (s = arg; *s != '\0'; s++)
|
||||
{
|
||||
if (strchr(metachars, *s) != NULL)
|
||||
{
|
||||
has_meta = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (quote_all || (has_meta && strlen(meta_escape) == 0))
|
||||
printf("%c%s%c", openquote, arg, closequote);
|
||||
else
|
||||
printf("%s", arg);
|
||||
else
|
||||
{
|
||||
for (s = arg; *s != '\0'; s++)
|
||||
{
|
||||
if (strchr(metachars, *s) != NULL)
|
||||
printf("%s", meta_escape);
|
||||
printf("%c", *s);
|
||||
}
|
||||
}
|
||||
if (argc > 0)
|
||||
printf(" ");
|
||||
else
|
||||
|
@ -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.
|
||||
@ -93,87 +93,87 @@ struct cmdname
|
||||
|
||||
struct cmdname cmdnames[] =
|
||||
{
|
||||
"back-bracket", A_B_BRACKET,
|
||||
"back-line", A_B_LINE,
|
||||
"back-line-force", A_BF_LINE,
|
||||
"back-screen", A_B_SCREEN,
|
||||
"back-scroll", A_B_SCROLL,
|
||||
"back-search", A_B_SEARCH,
|
||||
"back-window", A_B_WINDOW,
|
||||
"debug", A_DEBUG,
|
||||
"digit", A_DIGIT,
|
||||
"display-flag", A_DISP_OPTION,
|
||||
"display-option", A_DISP_OPTION,
|
||||
"end", A_GOEND,
|
||||
"examine", A_EXAMINE,
|
||||
"first-cmd", A_FIRSTCMD,
|
||||
"firstcmd", A_FIRSTCMD,
|
||||
"flush-repaint", A_FREPAINT,
|
||||
"forw-bracket", A_F_BRACKET,
|
||||
"forw-forever", A_F_FOREVER,
|
||||
"forw-line", A_F_LINE,
|
||||
"forw-line-force", A_FF_LINE,
|
||||
"forw-screen", A_F_SCREEN,
|
||||
"forw-screen-force", A_FF_SCREEN,
|
||||
"forw-scroll", A_F_SCROLL,
|
||||
"forw-search", A_F_SEARCH,
|
||||
"forw-window", A_F_WINDOW,
|
||||
"goto-end", A_GOEND,
|
||||
"goto-line", A_GOLINE,
|
||||
"goto-mark", A_GOMARK,
|
||||
"help", A_HELP,
|
||||
"index-file", A_INDEX_FILE,
|
||||
"invalid", A_UINVALID,
|
||||
"left-scroll", A_LSHIFT,
|
||||
"next-file", A_NEXT_FILE,
|
||||
"next-tag", A_NEXT_TAG,
|
||||
"noaction", A_NOACTION,
|
||||
"percent", A_PERCENT,
|
||||
"pipe", A_PIPE,
|
||||
"prev-file", A_PREV_FILE,
|
||||
"prev-tag", A_PREV_TAG,
|
||||
"quit", A_QUIT,
|
||||
"remove-file", A_REMOVE_FILE,
|
||||
"repaint", A_REPAINT,
|
||||
"repaint-flush", A_FREPAINT,
|
||||
"repeat-search", A_AGAIN_SEARCH,
|
||||
"repeat-search-all", A_T_AGAIN_SEARCH,
|
||||
"reverse-search", A_REVERSE_SEARCH,
|
||||
"reverse-search-all", A_T_REVERSE_SEARCH,
|
||||
"right-scroll", A_RSHIFT,
|
||||
"set-mark", A_SETMARK,
|
||||
"shell", A_SHELL,
|
||||
"status", A_STAT,
|
||||
"toggle-flag", A_OPT_TOGGLE,
|
||||
"toggle-option", A_OPT_TOGGLE,
|
||||
"undo-hilite", A_UNDO_SEARCH,
|
||||
"version", A_VERSION,
|
||||
"visual", A_VISUAL,
|
||||
NULL, 0
|
||||
{ "back-bracket", A_B_BRACKET },
|
||||
{ "back-line", A_B_LINE },
|
||||
{ "back-line-force", A_BF_LINE },
|
||||
{ "back-screen", A_B_SCREEN },
|
||||
{ "back-scroll", A_B_SCROLL },
|
||||
{ "back-search", A_B_SEARCH },
|
||||
{ "back-window", A_B_WINDOW },
|
||||
{ "debug", A_DEBUG },
|
||||
{ "digit", A_DIGIT },
|
||||
{ "display-flag", A_DISP_OPTION },
|
||||
{ "display-option", A_DISP_OPTION },
|
||||
{ "end", A_GOEND },
|
||||
{ "examine", A_EXAMINE },
|
||||
{ "first-cmd", A_FIRSTCMD },
|
||||
{ "firstcmd", A_FIRSTCMD },
|
||||
{ "flush-repaint", A_FREPAINT },
|
||||
{ "forw-bracket", A_F_BRACKET },
|
||||
{ "forw-forever", A_F_FOREVER },
|
||||
{ "forw-line", A_F_LINE },
|
||||
{ "forw-line-force", A_FF_LINE },
|
||||
{ "forw-screen", A_F_SCREEN },
|
||||
{ "forw-screen-force", A_FF_SCREEN },
|
||||
{ "forw-scroll", A_F_SCROLL },
|
||||
{ "forw-search", A_F_SEARCH },
|
||||
{ "forw-window", A_F_WINDOW },
|
||||
{ "goto-end", A_GOEND },
|
||||
{ "goto-line", A_GOLINE },
|
||||
{ "goto-mark", A_GOMARK },
|
||||
{ "help", A_HELP },
|
||||
{ "index-file", A_INDEX_FILE },
|
||||
{ "invalid", A_UINVALID },
|
||||
{ "left-scroll", A_LSHIFT },
|
||||
{ "next-file", A_NEXT_FILE },
|
||||
{ "next-tag", A_NEXT_TAG },
|
||||
{ "noaction", A_NOACTION },
|
||||
{ "percent", A_PERCENT },
|
||||
{ "pipe", A_PIPE },
|
||||
{ "prev-file", A_PREV_FILE },
|
||||
{ "prev-tag", A_PREV_TAG },
|
||||
{ "quit", A_QUIT },
|
||||
{ "remove-file", A_REMOVE_FILE },
|
||||
{ "repaint", A_REPAINT },
|
||||
{ "repaint-flush", A_FREPAINT },
|
||||
{ "repeat-search", A_AGAIN_SEARCH },
|
||||
{ "repeat-search-all", A_T_AGAIN_SEARCH },
|
||||
{ "reverse-search", A_REVERSE_SEARCH },
|
||||
{ "reverse-search-all", A_T_REVERSE_SEARCH },
|
||||
{ "right-scroll", A_RSHIFT },
|
||||
{ "set-mark", A_SETMARK },
|
||||
{ "shell", A_SHELL },
|
||||
{ "status", A_STAT },
|
||||
{ "toggle-flag", A_OPT_TOGGLE },
|
||||
{ "toggle-option", A_OPT_TOGGLE },
|
||||
{ "undo-hilite", A_UNDO_SEARCH },
|
||||
{ "version", A_VERSION },
|
||||
{ "visual", A_VISUAL },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
struct cmdname editnames[] =
|
||||
{
|
||||
"back-complete", EC_B_COMPLETE,
|
||||
"backspace", EC_BACKSPACE,
|
||||
"delete", EC_DELETE,
|
||||
"down", EC_DOWN,
|
||||
"end", EC_END,
|
||||
"expand", EC_EXPAND,
|
||||
"forw-complete", EC_F_COMPLETE,
|
||||
"home", EC_HOME,
|
||||
"insert", EC_INSERT,
|
||||
"invalid", EC_UINVALID,
|
||||
"kill-line", EC_LINEKILL,
|
||||
"left", EC_LEFT,
|
||||
"literal", EC_LITERAL,
|
||||
"right", EC_RIGHT,
|
||||
"up", EC_UP,
|
||||
"word-backspace", EC_W_BACKSPACE,
|
||||
"word-delete", EC_W_DELETE,
|
||||
"word-left", EC_W_LEFT,
|
||||
"word-right", EC_W_RIGHT,
|
||||
NULL, 0
|
||||
{ "back-complete", EC_B_COMPLETE },
|
||||
{ "backspace", EC_BACKSPACE },
|
||||
{ "delete", EC_DELETE },
|
||||
{ "down", EC_DOWN },
|
||||
{ "end", EC_END },
|
||||
{ "expand", EC_EXPAND },
|
||||
{ "forw-complete", EC_F_COMPLETE },
|
||||
{ "home", EC_HOME },
|
||||
{ "insert", EC_INSERT },
|
||||
{ "invalid", EC_UINVALID },
|
||||
{ "kill-line", EC_LINEKILL },
|
||||
{ "left", EC_LEFT },
|
||||
{ "literal", EC_LITERAL },
|
||||
{ "right", EC_RIGHT },
|
||||
{ "up", EC_UP },
|
||||
{ "word-backspace", EC_W_BACKSPACE },
|
||||
{ "word-delete", EC_W_DELETE },
|
||||
{ "word-left", EC_W_LEFT },
|
||||
{ "word-right", EC_W_RIGHT },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
struct table
|
||||
@ -352,8 +352,9 @@ init_tables()
|
||||
* Parse one character of a string.
|
||||
*/
|
||||
char *
|
||||
tstr(pp)
|
||||
tstr(pp, xlate)
|
||||
char **pp;
|
||||
int xlate;
|
||||
{
|
||||
register char *p;
|
||||
register char ch;
|
||||
@ -380,7 +381,7 @@ tstr(pp)
|
||||
ch = 8*ch + (*p - '0');
|
||||
while (*++p >= '0' && *p <= '7' && ++i < 3);
|
||||
*pp = p;
|
||||
if (ch == CONTROL('K'))
|
||||
if (xlate && ch == CONTROL('K'))
|
||||
return tstr_control_k;
|
||||
buf[0] = ch;
|
||||
buf[1] = '\0';
|
||||
@ -403,31 +404,35 @@ tstr(pp)
|
||||
*pp = p+1;
|
||||
return ("\t");
|
||||
case 'k':
|
||||
switch (*++p)
|
||||
if (xlate)
|
||||
{
|
||||
case 'u': ch = SK_UP_ARROW; break;
|
||||
case 'd': ch = SK_DOWN_ARROW; break;
|
||||
case 'r': ch = SK_RIGHT_ARROW; break;
|
||||
case 'l': ch = SK_LEFT_ARROW; break;
|
||||
case 'U': ch = SK_PAGE_UP; break;
|
||||
case 'D': ch = SK_PAGE_DOWN; break;
|
||||
case 'h': ch = SK_HOME; break;
|
||||
case 'e': ch = SK_END; break;
|
||||
case 'x': ch = SK_DELETE; break;
|
||||
default:
|
||||
error("illegal char after \\k");
|
||||
switch (*++p)
|
||||
{
|
||||
case 'u': ch = SK_UP_ARROW; break;
|
||||
case 'd': ch = SK_DOWN_ARROW; break;
|
||||
case 'r': ch = SK_RIGHT_ARROW; break;
|
||||
case 'l': ch = SK_LEFT_ARROW; break;
|
||||
case 'U': ch = SK_PAGE_UP; break;
|
||||
case 'D': ch = SK_PAGE_DOWN; break;
|
||||
case 'h': ch = SK_HOME; break;
|
||||
case 'e': ch = SK_END; break;
|
||||
case 'x': ch = SK_DELETE; break;
|
||||
default:
|
||||
error("illegal char after \\k");
|
||||
*pp = p+1;
|
||||
return ("");
|
||||
}
|
||||
*pp = p+1;
|
||||
return ("");
|
||||
buf[0] = SK_SPECIAL_KEY;
|
||||
buf[1] = ch;
|
||||
buf[2] = 6;
|
||||
buf[3] = 1;
|
||||
buf[4] = 1;
|
||||
buf[5] = 1;
|
||||
buf[6] = '\0';
|
||||
return (buf);
|
||||
}
|
||||
*pp = p+1;
|
||||
buf[0] = SK_SPECIAL_KEY;
|
||||
buf[1] = ch;
|
||||
buf[2] = 6;
|
||||
buf[3] = 1;
|
||||
buf[4] = 1;
|
||||
buf[5] = 1;
|
||||
buf[6] = '\0';
|
||||
return (buf);
|
||||
/* FALLTHRU */
|
||||
default:
|
||||
/*
|
||||
* Backslash followed by any other char
|
||||
@ -436,7 +441,7 @@ tstr(pp)
|
||||
*pp = p+1;
|
||||
buf[0] = *p;
|
||||
buf[1] = '\0';
|
||||
if (buf[0] == CONTROL('K'))
|
||||
if (xlate && buf[0] == CONTROL('K'))
|
||||
return tstr_control_k;
|
||||
return (buf);
|
||||
}
|
||||
@ -454,7 +459,7 @@ tstr(pp)
|
||||
*pp = p+1;
|
||||
buf[0] = *p;
|
||||
buf[1] = '\0';
|
||||
if (buf[0] == CONTROL('K'))
|
||||
if (xlate && buf[0] == CONTROL('K'))
|
||||
return tstr_control_k;
|
||||
return (buf);
|
||||
}
|
||||
@ -639,7 +644,7 @@ parse_cmdline(p)
|
||||
cmdlen = 0;
|
||||
do
|
||||
{
|
||||
s = tstr(&p);
|
||||
s = tstr(&p, 1);
|
||||
cmdlen += strlen(s);
|
||||
if (cmdlen > MAX_CMDLEN)
|
||||
error("command too long");
|
||||
@ -688,7 +693,7 @@ parse_cmdline(p)
|
||||
*/
|
||||
add_cmd_char(action | A_EXTRA);
|
||||
while (*p != '\0')
|
||||
add_cmd_str(tstr(&p));
|
||||
add_cmd_str(tstr(&p, 0));
|
||||
add_cmd_char('\0');
|
||||
}
|
||||
}
|
||||
@ -701,7 +706,7 @@ parse_varline(p)
|
||||
|
||||
do
|
||||
{
|
||||
s = tstr(&p);
|
||||
s = tstr(&p, 0);
|
||||
add_cmd_str(s);
|
||||
} while (*p != ' ' && *p != '\t' && *p != '=' && *p != '\0');
|
||||
/*
|
||||
@ -721,7 +726,7 @@ parse_varline(p)
|
||||
p = skipsp(p);
|
||||
while (*p != '\0')
|
||||
{
|
||||
s = tstr(&p);
|
||||
s = tstr(&p, 0);
|
||||
add_cmd_str(s);
|
||||
}
|
||||
add_cmd_char('\0');
|
||||
@ -763,7 +768,7 @@ main(argc, argv)
|
||||
{
|
||||
FILE *desc;
|
||||
FILE *out;
|
||||
char line[200];
|
||||
char line[1024];
|
||||
|
||||
#ifdef WIN32
|
||||
if (getenv("HOME") == NULL)
|
||||
|
@ -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.
|
||||
|
@ -61,7 +61,7 @@ CCOOMMMMAANNDD SSEECCTTIIOONN
|
||||
|
||||
|
||||
|
||||
Version 371: 26 Dec 2001 1
|
||||
Version 381: 17 Jan 2003 1
|
||||
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ LESSKEY(1) LESSKEY(1)
|
||||
|
||||
|
||||
|
||||
Version 371: 26 Dec 2001 2
|
||||
Version 381: 17 Jan 2003 2
|
||||
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ EEXXAAMMPPLLEE
|
||||
|
||||
|
||||
|
||||
Version 371: 26 Dec 2001 3
|
||||
Version 381: 17 Jan 2003 3
|
||||
|
||||
|
||||
|
||||
@ -259,7 +259,7 @@ LESSKEY(1) LESSKEY(1)
|
||||
|
||||
|
||||
|
||||
Version 371: 26 Dec 2001 4
|
||||
Version 381: 17 Jan 2003 4
|
||||
|
||||
|
||||
|
||||
@ -325,7 +325,7 @@ EEXXAAMMPPLLEE
|
||||
|
||||
|
||||
|
||||
Version 371: 26 Dec 2001 5
|
||||
Version 381: 17 Jan 2003 5
|
||||
|
||||
|
||||
|
||||
@ -391,7 +391,7 @@ EEXXAAMMPPLLEE
|
||||
|
||||
|
||||
|
||||
Version 371: 26 Dec 2001 6
|
||||
Version 381: 17 Jan 2003 6
|
||||
|
||||
|
||||
|
||||
@ -414,7 +414,7 @@ WWAARRNNIINNGGSS
|
||||
It is not possible to specify special keys, such as upar
|
||||
row, in a keyboard-independent manner. The only way to
|
||||
specify such keys is to specify the escape sequence which
|
||||
a particular keyboard sends when such a keys is pressed.
|
||||
a particular keyboard sends when such a key is pressed.
|
||||
|
||||
On MS-DOS and OS/2 systems, certain keys send a sequence
|
||||
of characters which start with a NUL character (0). This
|
||||
@ -457,6 +457,6 @@ AAUUTTHHOORR
|
||||
|
||||
|
||||
|
||||
Version 371: 26 Dec 2001 7
|
||||
Version 381: 17 Jan 2003 7
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.TH LESSKEY 1 "Version 371: 26 Dec 2001"
|
||||
.TH LESSKEY 1 "Version 381: 17 Jan 2003"
|
||||
.SH NAME
|
||||
lesskey \- specify key bindings for less
|
||||
.SH SYNOPSIS
|
||||
@ -351,7 +351,7 @@ less(1)
|
||||
It is not possible to specify special keys, such as uparrow,
|
||||
in a keyboard-independent manner.
|
||||
The only way to specify such keys is to specify the escape sequence
|
||||
which a particular keyboard sends when such a keys is pressed.
|
||||
which a particular keyboard sends when such a key is pressed.
|
||||
.PP
|
||||
On MS-DOS and OS/2 systems, certain keys send a sequence of characters
|
||||
which start with a NUL character (0).
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
@ -18,7 +18,6 @@
|
||||
#include "less.h"
|
||||
|
||||
#define IS_CONT(c) (((c) & 0xC0) == 0x80)
|
||||
#define LINENUM_WIDTH 8 /* Chars to use for line number */
|
||||
|
||||
public char *linebuf = NULL; /* Buffer which holds the current output line */
|
||||
static char *attr = NULL; /* Extension of linebuf to hold attributes */
|
||||
@ -34,6 +33,7 @@ static int curr; /* Index into linebuf */
|
||||
static int column; /* Printable length, accounting for
|
||||
backspaces, etc. */
|
||||
static int overstrike; /* Next char should overstrike previous char */
|
||||
static int last_overstrike = AT_NORMAL;
|
||||
static int is_null_line; /* There is no current line */
|
||||
static int lmargin; /* Left margin */
|
||||
static int hilites; /* Number of hilites in this line */
|
||||
@ -92,6 +92,8 @@ expand_linebuf()
|
||||
}
|
||||
memcpy(new_buf, linebuf, size_linebuf * sizeof(char));
|
||||
memcpy(new_attr, attr, size_linebuf * sizeof(char));
|
||||
free(attr);
|
||||
free(linebuf);
|
||||
linebuf = new_buf;
|
||||
attr = new_attr;
|
||||
size_linebuf = new_size;
|
||||
@ -110,13 +112,11 @@ prewind()
|
||||
is_null_line = 0;
|
||||
pendc = '\0';
|
||||
lmargin = 0;
|
||||
if (status_col)
|
||||
lmargin += 1;
|
||||
#if HILITE_SEARCH
|
||||
hilites = 0;
|
||||
#endif
|
||||
if (status_col)
|
||||
lmargin += 1;
|
||||
if (linenums == OPT_ONPLUS)
|
||||
lmargin += LINENUM_WIDTH+1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -126,7 +126,7 @@ prewind()
|
||||
plinenum(pos)
|
||||
POSITION pos;
|
||||
{
|
||||
register int lno;
|
||||
register LINENUM linenum = 0;
|
||||
register int i;
|
||||
|
||||
if (linenums == OPT_ONPLUS)
|
||||
@ -139,7 +139,7 @@ plinenum(pos)
|
||||
* {{ Since forw_raw_line modifies linebuf, we must
|
||||
* do this first, before storing anything in linebuf. }}
|
||||
*/
|
||||
lno = find_linenum(pos);
|
||||
linenum = find_linenum(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -162,11 +162,22 @@ plinenum(pos)
|
||||
*/
|
||||
if (linenums == OPT_ONPLUS)
|
||||
{
|
||||
sprintf(&linebuf[curr], "%*d", LINENUM_WIDTH, lno);
|
||||
column += LINENUM_WIDTH;
|
||||
for (i = 0; i < LINENUM_WIDTH; i++)
|
||||
attr[curr++] = 0;
|
||||
char buf[INT_STRLEN_BOUND(pos) + 2];
|
||||
int n;
|
||||
|
||||
linenumtoa(linenum, buf);
|
||||
n = strlen(buf);
|
||||
if (n < MIN_LINENUM_WIDTH)
|
||||
n = MIN_LINENUM_WIDTH;
|
||||
sprintf(linebuf+curr, "%*s ", n, buf);
|
||||
n++; /* One space after the line number. */
|
||||
for (i = 0; i < n; i++)
|
||||
attr[curr+i] = AT_NORMAL;
|
||||
curr += n;
|
||||
column += n;
|
||||
lmargin += n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Append enough spaces to bring us to the lmargin.
|
||||
*/
|
||||
@ -401,6 +412,8 @@ store_char(c, a, pos)
|
||||
{
|
||||
register int w;
|
||||
|
||||
if (a != AT_NORMAL)
|
||||
last_overstrike = a;
|
||||
#if HILITE_SEARCH
|
||||
if (is_hilited(pos, pos+1, 0))
|
||||
{
|
||||
@ -553,6 +566,11 @@ pappend(c, pos)
|
||||
return (r);
|
||||
}
|
||||
|
||||
#define IS_UTF8_4BYTE(c) ( ((c) & 0xf8) == 0xf0 )
|
||||
#define IS_UTF8_3BYTE(c) ( ((c) & 0xf0) == 0xe0 )
|
||||
#define IS_UTF8_2BYTE(c) ( ((c) & 0xe0) == 0xc0 )
|
||||
#define IS_UTF8_TRAIL(c) ( ((c) & 0xc0) == 0x80 )
|
||||
|
||||
static int
|
||||
do_append(c, pos)
|
||||
int c;
|
||||
@ -590,37 +608,64 @@ do_append(c, pos)
|
||||
* or just deletion of the character in the buffer.
|
||||
*/
|
||||
overstrike--;
|
||||
if (utf_mode && curr > 1 && (char)c == linebuf[curr-2])
|
||||
if (utf_mode && IS_UTF8_4BYTE(c) && curr > 2 && (char)c == linebuf[curr-3])
|
||||
{
|
||||
backc();
|
||||
backc();
|
||||
backc();
|
||||
STORE_CHAR(linebuf[curr], AT_BOLD, pos);
|
||||
overstrike = 3;
|
||||
} else if (utf_mode && (IS_UTF8_3BYTE(c) || (overstrike==2 && IS_UTF8_TRAIL(c))) && curr > 1 && (char)c == linebuf[curr-2])
|
||||
{
|
||||
backc();
|
||||
backc();
|
||||
STORE_CHAR(linebuf[curr], AT_BOLD, pos);
|
||||
overstrike = 2;
|
||||
} else if (utf_mode && curr > 0 && (char)c == linebuf[curr-1])
|
||||
} else if (utf_mode && curr > 0 && (IS_UTF8_2BYTE(c) || (overstrike==1 && IS_UTF8_TRAIL(c))) && (char)c == linebuf[curr-1])
|
||||
{
|
||||
backc();
|
||||
STORE_CHAR(linebuf[curr], AT_BOLD, pos);
|
||||
overstrike = 1;
|
||||
} else if (utf_mode && curr > 0 && IS_UTF8_TRAIL(c) && attr[curr-1] == AT_UNDERLINE)
|
||||
{
|
||||
STOREC(c, AT_UNDERLINE);
|
||||
} else if ((char)c == linebuf[curr])
|
||||
{
|
||||
STOREC(c, AT_BOLD);
|
||||
/*
|
||||
* Overstriking a char with itself means make it bold.
|
||||
* But overstriking an underscore with itself is
|
||||
* ambiguous. It could mean make it bold, or
|
||||
* it could mean make it underlined.
|
||||
* Use the previous overstrike to resolve it.
|
||||
*/
|
||||
if (c == '_' && last_overstrike != AT_NORMAL)
|
||||
STOREC(c, last_overstrike);
|
||||
else
|
||||
STOREC(c, AT_BOLD);
|
||||
} else if (c == '_')
|
||||
{
|
||||
if (utf_mode)
|
||||
{
|
||||
if (curr > 0 && IS_CONT(linebuf[curr]))
|
||||
attr[curr-1] = AT_UNDERLINE;
|
||||
if (curr > 1 && IS_CONT(linebuf[curr-1]))
|
||||
attr[curr-2] = AT_UNDERLINE;
|
||||
if (curr > 2 && IS_CONT(linebuf[curr-2]))
|
||||
attr[curr-3] = AT_UNDERLINE;
|
||||
if (curr > 3 && IS_CONT(linebuf[curr-3]))
|
||||
attr[curr-4] = AT_UNDERLINE;
|
||||
if (curr > 4 && IS_CONT(linebuf[curr-4]))
|
||||
attr[curr-5] = AT_UNDERLINE;
|
||||
int i;
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
if (curr <= i || !IS_CONT(linebuf[curr-i]))
|
||||
break;
|
||||
attr[curr-i-1] = AT_UNDERLINE;
|
||||
}
|
||||
}
|
||||
STOREC(linebuf[curr], AT_UNDERLINE);
|
||||
} else if (linebuf[curr] == '_')
|
||||
{
|
||||
if (utf_mode)
|
||||
{
|
||||
if (IS_UTF8_2BYTE(c))
|
||||
overstrike = 1;
|
||||
else if (IS_UTF8_3BYTE(c))
|
||||
overstrike = 2;
|
||||
else if (IS_UTF8_4BYTE(c))
|
||||
overstrike = 3;
|
||||
}
|
||||
STOREC(c, AT_UNDERLINE);
|
||||
} else if (control_char(c))
|
||||
goto do_control_char;
|
||||
|
@ -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.
|
||||
@ -39,13 +39,13 @@
|
||||
* Structure to keep track of a line number and the associated file position.
|
||||
* A doubly-linked circular list of line numbers is kept ordered by line number.
|
||||
*/
|
||||
struct linenum
|
||||
struct linenum_info
|
||||
{
|
||||
struct linenum *next; /* Link to next in the list */
|
||||
struct linenum *prev; /* Line to previous in the list */
|
||||
struct linenum_info *next; /* Link to next in the list */
|
||||
struct linenum_info *prev; /* Line to previous in the list */
|
||||
POSITION pos; /* File position */
|
||||
POSITION gap; /* Gap between prev and next */
|
||||
int line; /* Line number */
|
||||
LINENUM line; /* Line number */
|
||||
};
|
||||
/*
|
||||
* "gap" needs some explanation: the gap of any particular line number
|
||||
@ -62,10 +62,10 @@ struct linenum
|
||||
|
||||
public int lnloop = 0; /* Are we in the line num loop? */
|
||||
|
||||
static struct linenum anchor; /* Anchor of the list */
|
||||
static struct linenum *freelist; /* Anchor of the unused entries */
|
||||
static struct linenum pool[NPOOL]; /* The pool itself */
|
||||
static struct linenum *spare; /* We always keep one spare entry */
|
||||
static struct linenum_info anchor; /* Anchor of the list */
|
||||
static struct linenum_info *freelist; /* Anchor of the unused entries */
|
||||
static struct linenum_info pool[NPOOL]; /* The pool itself */
|
||||
static struct linenum_info *spare; /* We always keep one spare entry */
|
||||
|
||||
extern int linenums;
|
||||
extern int sigs;
|
||||
@ -77,7 +77,7 @@ extern int sc_height;
|
||||
public void
|
||||
clr_linenum()
|
||||
{
|
||||
register struct linenum *p;
|
||||
register struct linenum_info *p;
|
||||
|
||||
/*
|
||||
* Put all the entries on the free list.
|
||||
@ -104,7 +104,7 @@ clr_linenum()
|
||||
*/
|
||||
static void
|
||||
calcgap(p)
|
||||
register struct linenum *p;
|
||||
register struct linenum_info *p;
|
||||
{
|
||||
/*
|
||||
* Don't bother to compute a gap for the anchor.
|
||||
@ -123,14 +123,14 @@ calcgap(p)
|
||||
* FIRST character in the specified line.
|
||||
*/
|
||||
public void
|
||||
add_lnum(lno, pos)
|
||||
int lno;
|
||||
add_lnum(linenum, pos)
|
||||
LINENUM linenum;
|
||||
POSITION pos;
|
||||
{
|
||||
register struct linenum *p;
|
||||
register struct linenum *new;
|
||||
register struct linenum *nextp;
|
||||
register struct linenum *prevp;
|
||||
register struct linenum_info *p;
|
||||
register struct linenum_info *new;
|
||||
register struct linenum_info *nextp;
|
||||
register struct linenum_info *prevp;
|
||||
register POSITION mingap;
|
||||
|
||||
/*
|
||||
@ -138,7 +138,7 @@ add_lnum(lno, pos)
|
||||
* The entries are sorted by position.
|
||||
*/
|
||||
for (p = anchor.next; p != &anchor && p->pos < pos; p = p->next)
|
||||
if (p->line == lno)
|
||||
if (p->line == linenum)
|
||||
/* We already have this one. */
|
||||
return;
|
||||
nextp = p;
|
||||
@ -169,7 +169,7 @@ add_lnum(lno, pos)
|
||||
new->next = nextp;
|
||||
new->prev = prevp;
|
||||
new->pos = pos;
|
||||
new->line = lno;
|
||||
new->line = linenum;
|
||||
|
||||
nextp->prev = new;
|
||||
prevp->next = new;
|
||||
@ -253,12 +253,12 @@ longish()
|
||||
* Find the line number associated with a given position.
|
||||
* Return 0 if we can't figure it out.
|
||||
*/
|
||||
public int
|
||||
public LINENUM
|
||||
find_linenum(pos)
|
||||
POSITION pos;
|
||||
{
|
||||
register struct linenum *p;
|
||||
register int lno;
|
||||
register struct linenum_info *p;
|
||||
register LINENUM linenum;
|
||||
POSITION cpos;
|
||||
|
||||
if (!linenums)
|
||||
@ -309,7 +309,7 @@ find_linenum(pos)
|
||||
if (ch_seek(p->pos))
|
||||
return (0);
|
||||
loopcount = 0;
|
||||
for (lno = p->line, cpos = p->pos; cpos < pos; lno++)
|
||||
for (linenum = p->line, cpos = p->pos; cpos < pos; linenum++)
|
||||
{
|
||||
/*
|
||||
* Allow a signal to abort this loop.
|
||||
@ -323,13 +323,13 @@ find_linenum(pos)
|
||||
/*
|
||||
* We might as well cache it.
|
||||
*/
|
||||
add_lnum(lno, cpos);
|
||||
add_lnum(linenum, cpos);
|
||||
/*
|
||||
* If the given position is not at the start of a line,
|
||||
* make sure we return the correct line number.
|
||||
*/
|
||||
if (cpos > pos)
|
||||
lno--;
|
||||
linenum--;
|
||||
} else
|
||||
{
|
||||
/*
|
||||
@ -338,7 +338,7 @@ find_linenum(pos)
|
||||
if (ch_seek(p->pos))
|
||||
return (0);
|
||||
loopcount = 0;
|
||||
for (lno = p->line, cpos = p->pos; cpos > pos; lno--)
|
||||
for (linenum = p->line, cpos = p->pos; cpos > pos; linenum--)
|
||||
{
|
||||
/*
|
||||
* Allow a signal to abort this loop.
|
||||
@ -352,10 +352,10 @@ find_linenum(pos)
|
||||
/*
|
||||
* We might as well cache it.
|
||||
*/
|
||||
add_lnum(lno, cpos);
|
||||
add_lnum(linenum, cpos);
|
||||
}
|
||||
|
||||
return (lno);
|
||||
return (linenum);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -363,14 +363,14 @@ find_linenum(pos)
|
||||
* Return NULL_POSITION if we can't figure it out.
|
||||
*/
|
||||
public POSITION
|
||||
find_pos(lno)
|
||||
int lno;
|
||||
find_pos(linenum)
|
||||
LINENUM linenum;
|
||||
{
|
||||
register struct linenum *p;
|
||||
register struct linenum_info *p;
|
||||
POSITION cpos;
|
||||
int clno;
|
||||
LINENUM clinenum;
|
||||
|
||||
if (lno <= 1)
|
||||
if (linenum <= 1)
|
||||
/*
|
||||
* Line number 1 is beginning of file.
|
||||
*/
|
||||
@ -379,13 +379,13 @@ find_pos(lno)
|
||||
/*
|
||||
* Find the entry nearest to the line number we want.
|
||||
*/
|
||||
for (p = anchor.next; p != &anchor && p->line < lno; p = p->next)
|
||||
for (p = anchor.next; p != &anchor && p->line < linenum; p = p->next)
|
||||
continue;
|
||||
if (p->line == lno)
|
||||
if (p->line == linenum)
|
||||
/* Found it exactly. */
|
||||
return (p->pos);
|
||||
|
||||
if (p == &anchor || lno - p->prev->line < p->line - lno)
|
||||
if (p == &anchor || linenum - p->prev->line < p->line - linenum)
|
||||
{
|
||||
/*
|
||||
* Go forward.
|
||||
@ -393,7 +393,7 @@ find_pos(lno)
|
||||
p = p->prev;
|
||||
if (ch_seek(p->pos))
|
||||
return (NULL_POSITION);
|
||||
for (clno = p->line, cpos = p->pos; clno < lno; clno++)
|
||||
for (clinenum = p->line, cpos = p->pos; clinenum < linenum; clinenum++)
|
||||
{
|
||||
/*
|
||||
* Allow a signal to abort this loop.
|
||||
@ -409,7 +409,7 @@ find_pos(lno)
|
||||
*/
|
||||
if (ch_seek(p->pos))
|
||||
return (NULL_POSITION);
|
||||
for (clno = p->line, cpos = p->pos; clno > lno; clno--)
|
||||
for (clinenum = p->line, cpos = p->pos; clinenum > linenum; clinenum--)
|
||||
{
|
||||
/*
|
||||
* Allow a signal to abort this loop.
|
||||
@ -422,7 +422,7 @@ find_pos(lno)
|
||||
/*
|
||||
* We might as well cache it.
|
||||
*/
|
||||
add_lnum(clno, cpos);
|
||||
add_lnum(clinenum, cpos);
|
||||
return (cpos);
|
||||
}
|
||||
|
||||
@ -431,13 +431,13 @@ find_pos(lno)
|
||||
* The argument "where" tells which line is to be considered
|
||||
* the "current" line (e.g. TOP, BOTTOM, MIDDLE, etc).
|
||||
*/
|
||||
public int
|
||||
public LINENUM
|
||||
currline(where)
|
||||
int where;
|
||||
{
|
||||
POSITION pos;
|
||||
POSITION len;
|
||||
int lnum;
|
||||
LINENUM linenum;
|
||||
|
||||
pos = position(where);
|
||||
len = ch_length();
|
||||
@ -445,8 +445,8 @@ currline(where)
|
||||
pos = position(++where);
|
||||
if (pos == NULL_POSITION)
|
||||
pos = len;
|
||||
lnum = find_linenum(pos);
|
||||
linenum = find_linenum(pos);
|
||||
if (pos == len)
|
||||
lnum--;
|
||||
return (lnum);
|
||||
linenum--;
|
||||
return (linenum);
|
||||
}
|
||||
|
@ -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.
|
||||
@ -130,17 +130,12 @@ lsystem(cmd, donemsg)
|
||||
p = save(shell);
|
||||
else
|
||||
{
|
||||
char *esccmd;
|
||||
if ((esccmd = esc_metachars(cmd)) == NULL)
|
||||
{
|
||||
p = (char *) ecalloc(strlen(shell) +
|
||||
strlen(cmd) + 7, sizeof(char));
|
||||
sprintf(p, "%s -c \"%s\"", shell, cmd);
|
||||
} else
|
||||
char *esccmd = shell_quote(cmd);
|
||||
if (esccmd != NULL)
|
||||
{
|
||||
p = (char *) ecalloc(strlen(shell) +
|
||||
strlen(esccmd) + 5, sizeof(char));
|
||||
sprintf(p, "%s -c %s", shell, esccmd);
|
||||
sprintf(p, "%s %s %s", shell, shell_coption(), esccmd);
|
||||
free(esccmd);
|
||||
}
|
||||
}
|
||||
@ -152,7 +147,6 @@ lsystem(cmd, donemsg)
|
||||
else
|
||||
p = save(cmd);
|
||||
}
|
||||
|
||||
system(p);
|
||||
free(p);
|
||||
#else
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
@ -29,7 +29,7 @@
|
||||
#include "option.h"
|
||||
|
||||
extern int nbufs;
|
||||
extern int cbufs;
|
||||
extern int bufspace;
|
||||
extern int pr_type;
|
||||
extern int plusoption;
|
||||
extern int swindow;
|
||||
@ -106,9 +106,8 @@ opt_o(type, s)
|
||||
error("No log file", NULL_PARG);
|
||||
else
|
||||
{
|
||||
parg.p_string = unquote_file(namelogfile);
|
||||
parg.p_string = namelogfile;
|
||||
error("Log file \"%s\"", &parg);
|
||||
free(parg.p_string);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -143,7 +142,7 @@ opt_l(type, s)
|
||||
{
|
||||
case INIT:
|
||||
t = s;
|
||||
n = getnum(&t, 'l', &err);
|
||||
n = getnum(&t, "l", &err);
|
||||
if (err || n <= 0)
|
||||
{
|
||||
error("Line number is required after -l", NULL_PARG);
|
||||
@ -168,9 +167,8 @@ opt_k(type, s)
|
||||
case INIT:
|
||||
if (lesskey(s, 0))
|
||||
{
|
||||
parg.p_string = unquote_file(s);
|
||||
parg.p_string = s;
|
||||
error("Cannot use lesskey file \"%s\"", &parg);
|
||||
free(parg.p_string);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -236,9 +234,8 @@ opt__T(type, s)
|
||||
tags = lglob(s);
|
||||
break;
|
||||
case QUERY:
|
||||
parg.p_string = unquote_file(tags);
|
||||
parg.p_string = tags;
|
||||
error("Tags file \"%s\"", &parg);
|
||||
free(parg.p_string);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -316,14 +313,14 @@ opt_b(type, s)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TOGGLE:
|
||||
case QUERY:
|
||||
/*
|
||||
* Allocate the new number of buffers.
|
||||
*/
|
||||
cbufs = ch_nbuf(cbufs);
|
||||
break;
|
||||
case INIT:
|
||||
case TOGGLE:
|
||||
/*
|
||||
* Set the new number of buffers.
|
||||
*/
|
||||
ch_setbufspace(bufspace);
|
||||
break;
|
||||
case QUERY:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -370,7 +367,7 @@ opt__V(type, s)
|
||||
any_display = 1;
|
||||
putstr("less ");
|
||||
putstr(version);
|
||||
putstr("\nCopyright (C) 2001 Mark Nudelman\n\n");
|
||||
putstr("\nCopyright (C) 2002 Mark Nudelman\n\n");
|
||||
putstr("less comes with NO WARRANTY, to the extent permitted by law.\n");
|
||||
putstr("For information about the terms of redistribution,\n");
|
||||
putstr("see the file named README in the less distribution.\n");
|
||||
@ -393,7 +390,7 @@ colordesc(s, fg_color, bg_color)
|
||||
int fg, bg;
|
||||
int err;
|
||||
|
||||
fg = getnum(&s, 'D', &err);
|
||||
fg = getnum(&s, "D", &err);
|
||||
if (err)
|
||||
{
|
||||
error("Missing fg color in -D", NULL_PARG);
|
||||
@ -404,7 +401,7 @@ colordesc(s, fg_color, bg_color)
|
||||
else
|
||||
{
|
||||
s++;
|
||||
bg = getnum(&s, 'D', &err);
|
||||
bg = getnum(&s, "D", &err);
|
||||
if (err)
|
||||
{
|
||||
error("Missing fg color in -D", NULL_PARG);
|
||||
@ -486,10 +483,12 @@ opt_x(type, s)
|
||||
for (i = 1; i < TABSTOP_MAX; )
|
||||
{
|
||||
int n = 0;
|
||||
s = skipsp(s);
|
||||
while (*s >= '0' && *s <= '9')
|
||||
n = (10 * n) + (*s++ - '0');
|
||||
if (n > tabstops[i-1])
|
||||
tabstops[i++] = n;
|
||||
s = skipsp(s);
|
||||
if (*s++ != ',')
|
||||
break;
|
||||
}
|
||||
@ -534,6 +533,11 @@ opt_quote(type, s)
|
||||
{
|
||||
case INIT:
|
||||
case TOGGLE:
|
||||
if (s[0] == '\0')
|
||||
{
|
||||
openquote = closequote = '\0';
|
||||
break;
|
||||
}
|
||||
if (s[1] != '\0' && s[2] != '\0')
|
||||
{
|
||||
error("-\" must be followed by 1 or 2 chars", NULL_PARG);
|
||||
|
@ -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.
|
||||
@ -21,7 +21,7 @@
|
||||
#include "less.h"
|
||||
#include "option.h"
|
||||
|
||||
static struct option *pendopt;
|
||||
static struct loption *pendopt;
|
||||
public int plusoption = FALSE;
|
||||
|
||||
static char *propt();
|
||||
@ -39,7 +39,7 @@ extern char *every_first_cmd;
|
||||
scan_option(s)
|
||||
char *s;
|
||||
{
|
||||
register struct option *o;
|
||||
register struct loption *o;
|
||||
register int optc;
|
||||
char *optname;
|
||||
char *printopt;
|
||||
@ -116,8 +116,7 @@ scan_option(s)
|
||||
* EVERY input file.
|
||||
*/
|
||||
plusoption = TRUE;
|
||||
str = s;
|
||||
s = optstring(s, propt('+'), NULL);
|
||||
s = optstring(s, &str, propt('+'), NULL);
|
||||
if (*str == '+')
|
||||
every_first_cmd = save(++str);
|
||||
else
|
||||
@ -225,8 +224,9 @@ scan_option(s)
|
||||
* All processing of STRING options is done by
|
||||
* the handling function.
|
||||
*/
|
||||
str = s;
|
||||
s = optstring(s, printopt, o->odesc[1]);
|
||||
while (*s == ' ')
|
||||
s++;
|
||||
s = optstring(s, &str, printopt, o->odesc[1]);
|
||||
break;
|
||||
case NUMBER:
|
||||
if (*s == '\0')
|
||||
@ -260,7 +260,7 @@ toggle_option(c, s, how_toggle)
|
||||
char *s;
|
||||
int how_toggle;
|
||||
{
|
||||
register struct option *o;
|
||||
register struct loption *o;
|
||||
register int num;
|
||||
int no_prompt;
|
||||
int err;
|
||||
@ -382,7 +382,7 @@ toggle_option(c, s, how_toggle)
|
||||
switch (how_toggle)
|
||||
{
|
||||
case OPT_TOGGLE:
|
||||
num = getnum(&s, '\0', &err);
|
||||
num = getnum(&s, NULL, &err);
|
||||
if (!err)
|
||||
*(o->ovar) = num;
|
||||
break;
|
||||
@ -480,7 +480,7 @@ propt(c)
|
||||
single_char_option(c)
|
||||
int c;
|
||||
{
|
||||
register struct option *o;
|
||||
register struct loption *o;
|
||||
|
||||
o = findopt(c);
|
||||
if (o == NULL)
|
||||
@ -496,7 +496,7 @@ single_char_option(c)
|
||||
opt_prompt(c)
|
||||
int c;
|
||||
{
|
||||
register struct option *o;
|
||||
register struct loption *o;
|
||||
|
||||
o = findopt(c);
|
||||
if (o == NULL || (o->otype & (STRING|NUMBER)) == 0)
|
||||
@ -544,20 +544,22 @@ nopendopt()
|
||||
* Return a pointer to the remainder of the string, if any.
|
||||
*/
|
||||
static char *
|
||||
optstring(s, printopt, validchars)
|
||||
optstring(s, p_str, printopt, validchars)
|
||||
char *s;
|
||||
char **p_str;
|
||||
char *printopt;
|
||||
char *validchars;
|
||||
{
|
||||
register char *p;
|
||||
PARG parg;
|
||||
|
||||
if (*s == '\0')
|
||||
{
|
||||
nostring(printopt);
|
||||
quit(QUIT_ERROR);
|
||||
}
|
||||
*p_str = s;
|
||||
for (p = s; *p != '\0'; p++)
|
||||
{
|
||||
if (*p == END_OPTION_STRING ||
|
||||
(validchars != NULL && strchr(validchars, *p) == NULL))
|
||||
{
|
||||
@ -565,15 +567,19 @@ optstring(s, printopt, validchars)
|
||||
{
|
||||
case END_OPTION_STRING:
|
||||
case ' ': case '\t': case '-':
|
||||
/* Replace the char with a null to terminate string. */
|
||||
*p++ = '\0';
|
||||
break;
|
||||
default:
|
||||
parg.p_string = p;
|
||||
error("Option string needs delimiter before %s", &parg);
|
||||
/* Cannot replace char; make a copy of the string. */
|
||||
*p_str = (char *) ecalloc(p-s+1, sizeof(char));
|
||||
strncpy(*p_str, s, p-s);
|
||||
(*p_str)[p-s] = '\0';
|
||||
break;
|
||||
}
|
||||
*p = '\0';
|
||||
return (p+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
||||
@ -607,8 +613,11 @@ getnum(sp, printopt, errp)
|
||||
*errp = TRUE;
|
||||
return (-1);
|
||||
}
|
||||
parg.p_string = printopt;
|
||||
error("Number is required after %s", &parg);
|
||||
if (printopt != NULL)
|
||||
{
|
||||
parg.p_string = printopt;
|
||||
error("Number is required after %s", &parg);
|
||||
}
|
||||
quit(QUIT_ERROR);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
@ -23,6 +23,7 @@
|
||||
#define NO_TOGGLE 0100 /* Option cannot be toggled with "-" cmd */
|
||||
#define HL_REPAINT 0200 /* Repaint hilites after toggling option */
|
||||
#define NO_QUERY 0400 /* Option cannot be queried with "_" cmd */
|
||||
#define INIT_HANDLER 01000 /* Call option handler function at startup */
|
||||
|
||||
#define OTYPE (BOOL|TRIPLE|NUMBER|STRING|NOVAR)
|
||||
|
||||
@ -49,7 +50,7 @@ struct optname
|
||||
struct optname *onext; /* List of synonymous option names */
|
||||
};
|
||||
|
||||
struct option
|
||||
struct loption
|
||||
{
|
||||
char oletter; /* The controlling letter (a-z) */
|
||||
struct optname *onames; /* Long (GNU-style) option name */
|
||||
|
@ -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.
|
||||
@ -34,8 +34,8 @@ public int back_scroll; /* Repaint screen on backwards movement */
|
||||
public int forw_scroll; /* Repaint screen on forward movement */
|
||||
public int caseless; /* Do "caseless" searches */
|
||||
public int linenums; /* Use line numbers */
|
||||
public int cbufs; /* Current number of buffers */
|
||||
public int autobuf; /* Automatically allocate buffers as needed */
|
||||
public int bufspace; /* Max buffer space per file (K) */
|
||||
public int ctldisp; /* Send control chars to screen untranslated */
|
||||
public int force_open; /* Open the file even if not regular file */
|
||||
public int swindow; /* Size of scrolling window */
|
||||
@ -47,6 +47,7 @@ public int twiddle; /* Show tildes after EOF */
|
||||
public int show_attn; /* Hilite first unread line */
|
||||
public int shift_count; /* Number of positions to shift horizontally */
|
||||
public int status_col; /* Display a status column */
|
||||
public int use_lessopen; /* Use the LESSOPEN filter */
|
||||
#if HILITE_SEARCH
|
||||
public int hilite_search; /* Highlight matched search patterns? */
|
||||
#endif
|
||||
@ -75,6 +76,7 @@ static struct optname J__optname = { "status-column", NULL };
|
||||
#if USERFILE
|
||||
static struct optname k_optname = { "lesskey-file", NULL };
|
||||
#endif
|
||||
static struct optname L__optname = { "no-lessopen", NULL };
|
||||
static struct optname m_optname = { "long-prompt", NULL };
|
||||
static struct optname n_optname = { "line-numbers", NULL };
|
||||
#if LOGFILE
|
||||
@ -118,238 +120,304 @@ static struct optname keypad_optname = { "no-keypad", NULL };
|
||||
* a new value, and odesc[1], if not NULL, is the set of characters
|
||||
* that are valid in the string.
|
||||
*/
|
||||
static struct option option[] =
|
||||
static struct loption option[] =
|
||||
{
|
||||
{ 'a', &a_optname,
|
||||
BOOL, OPT_OFF, &how_search, NULL,
|
||||
"Search includes displayed screen",
|
||||
"Search skips displayed screen",
|
||||
NULL
|
||||
{
|
||||
"Search includes displayed screen",
|
||||
"Search skips displayed screen",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
|
||||
{ 'b', &b_optname,
|
||||
NUMBER, 10, &cbufs, opt_b,
|
||||
"Buffers: ",
|
||||
"%d buffers",
|
||||
NULL
|
||||
NUMBER|INIT_HANDLER, 64, &bufspace, opt_b,
|
||||
{
|
||||
"Max buffer space per file (K): ",
|
||||
"Max buffer space per file: %dK",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'B', &B__optname,
|
||||
BOOL, OPT_ON, &autobuf, NULL,
|
||||
"Don't automatically allocate buffers",
|
||||
"Automatically allocate buffers when needed",
|
||||
NULL
|
||||
{
|
||||
"Don't automatically allocate buffers",
|
||||
"Automatically allocate buffers when needed",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'c', &c_optname,
|
||||
TRIPLE, OPT_OFF, &top_scroll, NULL,
|
||||
"Repaint by scrolling from bottom of screen",
|
||||
"Repaint by clearing each line",
|
||||
"Repaint by painting from top of screen"
|
||||
{
|
||||
"Repaint by scrolling from bottom of screen",
|
||||
"Repaint by clearing each line",
|
||||
"Repaint by painting from top of screen"
|
||||
}
|
||||
},
|
||||
{ 'd', &d_optname,
|
||||
BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL,
|
||||
"Assume intelligent terminal",
|
||||
"Assume dumb terminal",
|
||||
NULL
|
||||
{
|
||||
"Assume intelligent terminal",
|
||||
"Assume dumb terminal",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
#if MSDOS_COMPILER
|
||||
{ 'D', &D__optname,
|
||||
STRING|REPAINT|NO_QUERY, 0, NULL, opt_D,
|
||||
"color desc: ",
|
||||
"Ddknsu0123456789.",
|
||||
NULL
|
||||
{
|
||||
"color desc: ",
|
||||
"Ddknsu0123456789.",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
#endif
|
||||
{ 'e', &e_optname,
|
||||
TRIPLE, OPT_OFF, &quit_at_eof, NULL,
|
||||
"Don't quit at end-of-file",
|
||||
"Quit at end-of-file",
|
||||
"Quit immediately at end-of-file"
|
||||
{
|
||||
"Don't quit at end-of-file",
|
||||
"Quit at end-of-file",
|
||||
"Quit immediately at end-of-file"
|
||||
}
|
||||
},
|
||||
{ 'f', &f_optname,
|
||||
BOOL, OPT_OFF, &force_open, NULL,
|
||||
"Open only regular files",
|
||||
"Open even non-regular files",
|
||||
NULL
|
||||
{
|
||||
"Open only regular files",
|
||||
"Open even non-regular files",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'F', &F__optname,
|
||||
BOOL, OPT_OFF, &quit_if_one_screen, NULL,
|
||||
"Don't quit if end-of-file on first screen",
|
||||
"Quit if end-of-file on first screen",
|
||||
NULL
|
||||
{
|
||||
"Don't quit if end-of-file on first screen",
|
||||
"Quit if end-of-file on first screen",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
#if HILITE_SEARCH
|
||||
{ 'g', &g_optname,
|
||||
TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL,
|
||||
"Don't highlight search matches",
|
||||
"Highlight matches for previous search only",
|
||||
"Highlight all matches for previous search pattern",
|
||||
{
|
||||
"Don't highlight search matches",
|
||||
"Highlight matches for previous search only",
|
||||
"Highlight all matches for previous search pattern",
|
||||
}
|
||||
},
|
||||
#endif
|
||||
{ 'h', &h_optname,
|
||||
NUMBER, -1, &back_scroll, NULL,
|
||||
"Backwards scroll limit: ",
|
||||
"Backwards scroll limit is %d lines",
|
||||
NULL
|
||||
{
|
||||
"Backwards scroll limit: ",
|
||||
"Backwards scroll limit is %d lines",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'i', &i_optname,
|
||||
TRIPLE|HL_REPAINT, OPT_OFF, &caseless, opt_i,
|
||||
"Case is significant in searches",
|
||||
"Ignore case in searches",
|
||||
"Ignore case in searches and in patterns"
|
||||
{
|
||||
"Case is significant in searches",
|
||||
"Ignore case in searches",
|
||||
"Ignore case in searches and in patterns"
|
||||
}
|
||||
},
|
||||
{ 'j', &j_optname,
|
||||
NUMBER, 1, &jump_sline, NULL,
|
||||
"Target line: ",
|
||||
"Position target at screen line %d",
|
||||
NULL
|
||||
{
|
||||
"Target line: ",
|
||||
"Position target at screen line %d",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'J', &J__optname,
|
||||
BOOL|REPAINT, OPT_OFF, &status_col, NULL,
|
||||
"Don't display a status column",
|
||||
"Display a status column",
|
||||
NULL
|
||||
{
|
||||
"Don't display a status column",
|
||||
"Display a status column",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
#if USERFILE
|
||||
{ 'k', &k_optname,
|
||||
STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k,
|
||||
NULL, NULL, NULL
|
||||
{ NULL, NULL, NULL }
|
||||
},
|
||||
#endif
|
||||
{ 'l', NULL,
|
||||
STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_l,
|
||||
NULL, NULL, NULL
|
||||
{ NULL, NULL, NULL }
|
||||
},
|
||||
{ 'L', &L__optname,
|
||||
BOOL, OPT_ON, &use_lessopen, NULL,
|
||||
{
|
||||
"Don't use the LESSOPEN filter",
|
||||
"Use the LESSOPEN filter",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'm', &m_optname,
|
||||
TRIPLE, OPT_OFF, &pr_type, NULL,
|
||||
"Short prompt",
|
||||
"Medium prompt",
|
||||
"Long prompt"
|
||||
{
|
||||
"Short prompt",
|
||||
"Medium prompt",
|
||||
"Long prompt"
|
||||
}
|
||||
},
|
||||
{ 'n', &n_optname,
|
||||
TRIPLE|REPAINT, OPT_ON, &linenums, NULL,
|
||||
"Don't use line numbers",
|
||||
"Use line numbers",
|
||||
"Constantly display line numbers"
|
||||
{
|
||||
"Don't use line numbers",
|
||||
"Use line numbers",
|
||||
"Constantly display line numbers"
|
||||
}
|
||||
},
|
||||
#if LOGFILE
|
||||
{ 'o', &o_optname,
|
||||
STRING, 0, NULL, opt_o,
|
||||
"log file: ", NULL, NULL
|
||||
{ "log file: ", NULL, NULL }
|
||||
},
|
||||
{ 'O', &O__optname,
|
||||
STRING, 0, NULL, opt__O,
|
||||
"Log file: ", NULL, NULL
|
||||
{ "Log file: ", NULL, NULL }
|
||||
},
|
||||
#endif
|
||||
{ 'p', &p_optname,
|
||||
STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_p,
|
||||
NULL, NULL, NULL
|
||||
{ NULL, NULL, NULL }
|
||||
},
|
||||
{ 'P', &P__optname,
|
||||
STRING, 0, NULL, opt__P,
|
||||
"prompt: ", NULL, NULL
|
||||
{ "prompt: ", NULL, NULL }
|
||||
},
|
||||
{ 'q', &q_optname,
|
||||
TRIPLE, OPT_OFF, &quiet, NULL,
|
||||
"Ring the bell for errors AND at eof/bof",
|
||||
"Ring the bell for errors but not at eof/bof",
|
||||
"Never ring the bell"
|
||||
{
|
||||
"Ring the bell for errors AND at eof/bof",
|
||||
"Ring the bell for errors but not at eof/bof",
|
||||
"Never ring the bell"
|
||||
}
|
||||
},
|
||||
{ 'r', &r_optname,
|
||||
TRIPLE|REPAINT, OPT_OFF, &ctldisp, NULL,
|
||||
"Display control characters as ^X",
|
||||
"Display control characters directly",
|
||||
"Display control characters directly, processing ANSI sequences"
|
||||
{
|
||||
"Display control characters as ^X",
|
||||
"Display control characters directly",
|
||||
"Display control characters directly, processing ANSI sequences"
|
||||
}
|
||||
},
|
||||
{ 's', &s_optname,
|
||||
BOOL|REPAINT, OPT_OFF, &squeeze, NULL,
|
||||
"Display all blank lines",
|
||||
"Squeeze multiple blank lines",
|
||||
NULL
|
||||
{
|
||||
"Display all blank lines",
|
||||
"Squeeze multiple blank lines",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'S', &S__optname,
|
||||
BOOL|REPAINT, OPT_OFF, &chopline, NULL,
|
||||
"Fold long lines",
|
||||
"Chop long lines",
|
||||
NULL
|
||||
{
|
||||
"Fold long lines",
|
||||
"Chop long lines",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
#if TAGS
|
||||
{ 't', &t_optname,
|
||||
STRING|NO_QUERY, 0, NULL, opt_t,
|
||||
"tag: ", NULL, NULL
|
||||
{ "tag: ", NULL, NULL }
|
||||
},
|
||||
{ 'T', &T__optname,
|
||||
STRING, 0, NULL, opt__T,
|
||||
"tags file: ", NULL, NULL
|
||||
{ "tags file: ", NULL, NULL }
|
||||
},
|
||||
#endif
|
||||
{ 'u', &u_optname,
|
||||
TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL,
|
||||
"Display underlined text in underline mode",
|
||||
"Backspaces cause overstrike",
|
||||
"Print backspace as ^H"
|
||||
{
|
||||
"Display underlined text in underline mode",
|
||||
"Backspaces cause overstrike",
|
||||
"Print backspace as ^H"
|
||||
}
|
||||
},
|
||||
{ 'V', &V__optname,
|
||||
NOVAR, 0, NULL, opt__V,
|
||||
NULL, NULL, NULL
|
||||
{ NULL, NULL, NULL }
|
||||
},
|
||||
{ 'w', &w_optname,
|
||||
TRIPLE|REPAINT, OPT_OFF, &show_attn, NULL,
|
||||
"Don't highlight first unread line",
|
||||
"Highlight first unread line after forward-screen",
|
||||
"Highlight first unread line after any forward movement",
|
||||
{
|
||||
"Don't highlight first unread line",
|
||||
"Highlight first unread line after forward-screen",
|
||||
"Highlight first unread line after any forward movement",
|
||||
}
|
||||
},
|
||||
{ 'x', &x_optname,
|
||||
STRING|REPAINT, 0, NULL, opt_x,
|
||||
"Tab stops: ",
|
||||
"0123456789,",
|
||||
NULL
|
||||
{
|
||||
"Tab stops: ",
|
||||
"0123456789,",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'X', &X__optname,
|
||||
BOOL|NO_TOGGLE, OPT_OFF, &no_init, NULL,
|
||||
"Send init/deinit strings to terminal",
|
||||
"Don't use init/deinit strings",
|
||||
NULL
|
||||
{
|
||||
"Send init/deinit strings to terminal",
|
||||
"Don't use init/deinit strings",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'y', &y_optname,
|
||||
NUMBER, -1, &forw_scroll, NULL,
|
||||
"Forward scroll limit: ",
|
||||
"Forward scroll limit is %d lines",
|
||||
NULL
|
||||
{
|
||||
"Forward scroll limit: ",
|
||||
"Forward scroll limit is %d lines",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'z', &z_optname,
|
||||
NUMBER, -1, &swindow, NULL,
|
||||
"Scroll window size: ",
|
||||
"Scroll window size is %d lines",
|
||||
NULL
|
||||
{
|
||||
"Scroll window size: ",
|
||||
"Scroll window size is %d lines",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ '"', "e_optname,
|
||||
STRING, 0, NULL, opt_quote,
|
||||
"quotes: ", NULL, NULL
|
||||
{ "quotes: ", NULL, NULL }
|
||||
},
|
||||
{ '~', &tilde_optname,
|
||||
BOOL|REPAINT, OPT_ON, &twiddle, NULL,
|
||||
"Don't show tildes after end of file",
|
||||
"Show tildes after end of file",
|
||||
NULL
|
||||
{
|
||||
"Don't show tildes after end of file",
|
||||
"Show tildes after end of file",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ '?', &query_optname,
|
||||
NOVAR, 0, NULL, opt_query,
|
||||
NULL, NULL, NULL
|
||||
{ NULL, NULL, NULL }
|
||||
},
|
||||
{ '#', £_optname,
|
||||
NUMBER, 0, &shift_count, NULL,
|
||||
"Horizontal shift: ",
|
||||
"Horizontal shift %d positions",
|
||||
NULL
|
||||
{
|
||||
"Horizontal shift: ",
|
||||
"Horizontal shift %d positions",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ '.', &keypad_optname,
|
||||
BOOL|NO_TOGGLE, OPT_OFF, &no_keypad, NULL,
|
||||
"Use keypad mode",
|
||||
"Don't use keypad mode",
|
||||
NULL
|
||||
{
|
||||
"Use keypad mode",
|
||||
"Don't use keypad mode",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ '\0', NULL, NOVAR, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
{ '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } }
|
||||
};
|
||||
|
||||
|
||||
@ -359,7 +427,7 @@ static struct option option[] =
|
||||
public void
|
||||
init_option()
|
||||
{
|
||||
register struct option *o;
|
||||
register struct loption *o;
|
||||
|
||||
for (o = option; o->oletter != '\0'; o++)
|
||||
{
|
||||
@ -368,17 +436,19 @@ init_option()
|
||||
*/
|
||||
if (o->ovar != NULL)
|
||||
*(o->ovar) = o->odefault;
|
||||
if (o->otype & INIT_HANDLER)
|
||||
(*(o->ofunc))(INIT, (char *) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Find an option in the option table, given its option letter.
|
||||
*/
|
||||
public struct option *
|
||||
public struct loption *
|
||||
findopt(c)
|
||||
int c;
|
||||
{
|
||||
register struct option *o;
|
||||
register struct loption *o;
|
||||
|
||||
for (o = option; o->oletter != '\0'; o++)
|
||||
{
|
||||
@ -390,28 +460,45 @@ findopt(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
static int
|
||||
is_optchar(c)
|
||||
char c;
|
||||
{
|
||||
if (SIMPLE_IS_UPPER(c))
|
||||
return 1;
|
||||
if (SIMPLE_IS_LOWER(c))
|
||||
return 1;
|
||||
if (c == '-')
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find an option in the option table, given its option name.
|
||||
* p_optname is the (possibly partial) name to look for, and
|
||||
* is updated to point after the matched name.
|
||||
* p_oname if non-NULL is set to point to the full option name.
|
||||
*/
|
||||
public struct option *
|
||||
public struct loption *
|
||||
findopt_name(p_optname, p_oname, p_err)
|
||||
char **p_optname;
|
||||
char **p_oname;
|
||||
int *p_err;
|
||||
{
|
||||
char *optname = *p_optname;
|
||||
register struct option *o;
|
||||
register struct loption *o;
|
||||
register struct optname *oname;
|
||||
register int len;
|
||||
int uppercase;
|
||||
struct option *maxo = NULL;
|
||||
struct loption *maxo = NULL;
|
||||
struct optname *maxoname = NULL;
|
||||
int maxlen = 0;
|
||||
int ambig = 0;
|
||||
int exact = 0;
|
||||
char *eq;
|
||||
|
||||
/*
|
||||
* Check all options.
|
||||
@ -431,6 +518,13 @@ findopt_name(p_optname, p_oname, p_err)
|
||||
for (uppercase = 0; uppercase <= 1; uppercase++)
|
||||
{
|
||||
len = sprefix(optname, oname->oname, uppercase);
|
||||
if (len <= 0 || is_optchar(optname[len]))
|
||||
{
|
||||
/*
|
||||
* We didn't use all of the option name.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
if (!exact && len == maxlen)
|
||||
/*
|
||||
* Already had a partial match,
|
||||
@ -466,6 +560,6 @@ findopt_name(p_optname, p_oname, p_err)
|
||||
}
|
||||
*p_optname = optname + maxlen;
|
||||
if (p_oname != NULL)
|
||||
*p_oname = maxoname->oname;
|
||||
*p_oname = maxoname == NULL ? NULL : maxoname->oname;
|
||||
return (maxo);
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
@ -29,6 +29,15 @@ extern int screen_trashed;
|
||||
extern int any_display;
|
||||
extern int is_tty;
|
||||
|
||||
#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
|
||||
extern int ctldisp;
|
||||
extern int nm_fg_color, nm_bg_color;
|
||||
extern int bo_fg_color, bo_bg_color;
|
||||
extern int ul_fg_color, ul_bg_color;
|
||||
extern int so_fg_color, so_bg_color;
|
||||
extern int bl_fg_color, bl_bg_color;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Display the line which is in the line buffer.
|
||||
*/
|
||||
@ -149,6 +158,9 @@ flush()
|
||||
{
|
||||
col = 0;
|
||||
row++;
|
||||
} else if (*op == '\r')
|
||||
{
|
||||
col = 0;
|
||||
} else
|
||||
{
|
||||
col++;
|
||||
@ -179,7 +191,156 @@ flush()
|
||||
if (is_tty && any_display)
|
||||
{
|
||||
*ob = '\0';
|
||||
cputs(obuf);
|
||||
if (ctldisp != OPT_ONPLUS)
|
||||
cputs(obuf);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Look for SGR escape sequences, and convert them
|
||||
* to color commands. Replace bold, underline,
|
||||
* and italic escapes into colors specified via
|
||||
* the -D command-line option.
|
||||
*/
|
||||
char *anchor, *p, *p_next;
|
||||
int buflen = ob - obuf;
|
||||
unsigned char fg, bg, norm_attr;
|
||||
/*
|
||||
* Only dark colors mentioned here, so that
|
||||
* bold has visible effect.
|
||||
*/
|
||||
static enum COLORS screen_color[] = {
|
||||
BLACK, RED, GREEN, BROWN,
|
||||
BLUE, MAGENTA, CYAN, LIGHTGRAY
|
||||
};
|
||||
|
||||
/* Normal text colors are used as baseline. */
|
||||
bg = nm_bg_color & 0xf;
|
||||
fg = nm_fg_color & 0xf;
|
||||
norm_attr = (bg << 4) | fg;
|
||||
for (anchor = p_next = obuf;
|
||||
(p_next = memchr (p_next, ESC,
|
||||
buflen - (p_next - obuf)))
|
||||
!= NULL; )
|
||||
{
|
||||
p = p_next;
|
||||
|
||||
/*
|
||||
* Handle the null escape sequence
|
||||
* (ESC-[m), which is used to restore
|
||||
* the original color.
|
||||
*/
|
||||
if (p[1] == '[' && is_ansi_end(p[2]))
|
||||
{
|
||||
textattr(norm_attr);
|
||||
p += 3;
|
||||
anchor = p_next = p;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p[1] == '[') /* "Esc-[" sequence */
|
||||
{
|
||||
/*
|
||||
* If some chars seen since
|
||||
* the last escape sequence,
|
||||
* write it out to the screen
|
||||
* using current text attributes.
|
||||
*/
|
||||
if (p > anchor)
|
||||
{
|
||||
*p = '\0';
|
||||
cputs (anchor);
|
||||
*p = ESC;
|
||||
anchor = p;
|
||||
}
|
||||
p += 2;
|
||||
p_next = p;
|
||||
while (!is_ansi_end(*p))
|
||||
{
|
||||
char *q;
|
||||
long code = strtol(p, &q, 10);
|
||||
|
||||
if (!*q)
|
||||
{
|
||||
/*
|
||||
* Incomplete sequence.
|
||||
* Leave it unprocessed
|
||||
* in the buffer.
|
||||
*/
|
||||
int slop = q - anchor;
|
||||
strcpy(obuf, anchor);
|
||||
ob = &obuf[slop];
|
||||
return;
|
||||
}
|
||||
|
||||
if (q == p
|
||||
|| code > 49 || code < 0
|
||||
|| (!is_ansi_end(*q)
|
||||
&& *q != ';'))
|
||||
{
|
||||
p_next = q;
|
||||
break;
|
||||
}
|
||||
if (*q == ';')
|
||||
q++;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case 1: /* bold on */
|
||||
fg = bo_fg_color;
|
||||
bg = bo_bg_color;
|
||||
break;
|
||||
case 3: /* italic on */
|
||||
fg = so_fg_color;
|
||||
bg = so_bg_color;
|
||||
break;
|
||||
case 4: /* underline on */
|
||||
fg = ul_fg_color;
|
||||
bg = ul_bg_color;
|
||||
break;
|
||||
case 8: /* concealed on */
|
||||
fg = (bg & 7) | 8;
|
||||
break;
|
||||
case 0: /* all attrs off */
|
||||
case 22:/* bold off */
|
||||
case 23:/* italic off */
|
||||
case 24:/* underline off */
|
||||
fg = nm_fg_color;
|
||||
bg = nm_bg_color;
|
||||
break;
|
||||
case 30: case 31: case 32:
|
||||
case 33: case 34: case 35:
|
||||
case 36: case 37:
|
||||
fg = (fg & 8) | (screen_color[code - 30]);
|
||||
break;
|
||||
case 39: /* default fg */
|
||||
fg = nm_fg_color;
|
||||
break;
|
||||
case 40: case 41: case 42:
|
||||
case 43: case 44: case 45:
|
||||
case 46: case 47:
|
||||
bg = (bg & 8) | (screen_color[code - 40]);
|
||||
break;
|
||||
case 49: /* default fg */
|
||||
bg = nm_bg_color;
|
||||
break;
|
||||
}
|
||||
p = q;
|
||||
}
|
||||
if (is_ansi_end(*p) && p > p_next)
|
||||
{
|
||||
bg &= 15;
|
||||
fg &= 15;
|
||||
textattr ((bg << 4)| fg);
|
||||
p_next = anchor = p + 1;
|
||||
} else
|
||||
break;
|
||||
} else
|
||||
p_next++;
|
||||
}
|
||||
|
||||
/* Output what's left in the buffer. */
|
||||
cputs (anchor);
|
||||
}
|
||||
ob = obuf;
|
||||
return;
|
||||
}
|
||||
@ -238,36 +399,56 @@ putstr(s)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert an integral type to a string.
|
||||
*/
|
||||
#define TYPE_TO_A_FUNC(funcname, type) \
|
||||
void funcname(num, buf) \
|
||||
type num; \
|
||||
char *buf; \
|
||||
{ \
|
||||
int neg = (num < 0); \
|
||||
char tbuf[INT_STRLEN_BOUND(num)+2]; \
|
||||
register char *s = tbuf + sizeof(tbuf); \
|
||||
if (neg) num = -num; \
|
||||
*--s = '\0'; \
|
||||
do { \
|
||||
*--s = (num % 10) + '0'; \
|
||||
} while ((num /= 10) != 0); \
|
||||
if (neg) *--s = '-'; \
|
||||
strcpy(buf, s); \
|
||||
}
|
||||
|
||||
TYPE_TO_A_FUNC(postoa, POSITION)
|
||||
TYPE_TO_A_FUNC(linenumtoa, LINENUM)
|
||||
TYPE_TO_A_FUNC(inttoa, int)
|
||||
|
||||
/*
|
||||
* Output an integer in a given radix.
|
||||
*/
|
||||
static int
|
||||
iprintnum(num, radix)
|
||||
iprint_int(num)
|
||||
int num;
|
||||
int radix;
|
||||
{
|
||||
register char *s;
|
||||
int r;
|
||||
int neg;
|
||||
char buf[INT_STRLEN_BOUND(num)];
|
||||
|
||||
neg = (num < 0);
|
||||
if (neg)
|
||||
num = -num;
|
||||
inttoa(num, buf);
|
||||
putstr(buf);
|
||||
return (strlen(buf));
|
||||
}
|
||||
|
||||
s = buf;
|
||||
do
|
||||
{
|
||||
*s++ = (num % radix) + '0';
|
||||
} while ((num /= radix) != 0);
|
||||
/*
|
||||
* Output a line number in a given radix.
|
||||
*/
|
||||
static int
|
||||
iprint_linenum(num)
|
||||
LINENUM num;
|
||||
{
|
||||
char buf[INT_STRLEN_BOUND(num)];
|
||||
|
||||
if (neg)
|
||||
*s++ = '-';
|
||||
r = s - buf;
|
||||
|
||||
while (s > buf)
|
||||
putchr(*--s);
|
||||
return (r);
|
||||
linenumtoa(num, buf);
|
||||
putstr(buf);
|
||||
return (strlen(buf));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -280,7 +461,6 @@ less_printf(fmt, parg)
|
||||
PARG *parg;
|
||||
{
|
||||
register char *s;
|
||||
register int n;
|
||||
register int col;
|
||||
|
||||
col = 0;
|
||||
@ -293,7 +473,8 @@ less_printf(fmt, parg)
|
||||
} else
|
||||
{
|
||||
++fmt;
|
||||
switch (*fmt++) {
|
||||
switch (*fmt++)
|
||||
{
|
||||
case 's':
|
||||
s = parg->p_string;
|
||||
parg++;
|
||||
@ -304,9 +485,12 @@ less_printf(fmt, parg)
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
n = parg->p_int;
|
||||
col += iprint_int(parg->p_int);
|
||||
parg++;
|
||||
break;
|
||||
case 'n':
|
||||
col += iprint_linenum(parg->p_linenum);
|
||||
parg++;
|
||||
col += iprintnum(n, 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2001 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.
|
||||
|
@ -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.
|
||||
@ -68,7 +68,7 @@ static struct taglist taglist = { TAG_END, TAG_END };
|
||||
struct tag {
|
||||
struct tag *next, *prev; /* List links */
|
||||
char *tag_file; /* Source file containing the tag */
|
||||
int tag_linenum; /* Appropriate line number in source file */
|
||||
LINENUM tag_linenum; /* Appropriate line number in source file */
|
||||
char *tag_pattern; /* Pattern used to find the tag */
|
||||
char tag_endline; /* True if the pattern includes '$' */
|
||||
};
|
||||
@ -113,7 +113,7 @@ cleantags()
|
||||
maketagent(name, file, linenum, pattern, endline)
|
||||
char *name;
|
||||
char *file;
|
||||
int linenum;
|
||||
LINENUM linenum;
|
||||
char *pattern;
|
||||
int endline;
|
||||
{
|
||||
@ -217,7 +217,7 @@ tagsearch()
|
||||
nexttag(n)
|
||||
int n;
|
||||
{
|
||||
char *tagfile;
|
||||
char *tagfile = (char *) NULL;
|
||||
|
||||
while (n-- > 0)
|
||||
tagfile = nextgtag();
|
||||
@ -231,7 +231,7 @@ nexttag(n)
|
||||
prevtag(n)
|
||||
int n;
|
||||
{
|
||||
char *tagfile;
|
||||
char *tagfile = (char *) NULL;
|
||||
|
||||
while (n-- > 0)
|
||||
tagfile = prevgtag();
|
||||
@ -271,7 +271,7 @@ findctag(tag)
|
||||
char *p;
|
||||
register FILE *f;
|
||||
register int taglen;
|
||||
register int taglinenum;
|
||||
LINENUM taglinenum;
|
||||
char *tagfile;
|
||||
char *tagpattern;
|
||||
int tagendline;
|
||||
@ -280,7 +280,7 @@ findctag(tag)
|
||||
char tline[TAGLINE_SIZE];
|
||||
struct tag *tp;
|
||||
|
||||
p = unquote_file(tags);
|
||||
p = shell_unquote(tags);
|
||||
f = fopen(p, "r");
|
||||
free(p);
|
||||
if (f == NULL)
|
||||
@ -335,6 +335,7 @@ findctag(tag)
|
||||
/*
|
||||
* First see if it is a line number.
|
||||
*/
|
||||
tagendline = 0;
|
||||
taglinenum = getnum(&p, 0, &err);
|
||||
if (err)
|
||||
{
|
||||
@ -396,7 +397,7 @@ edit_tagfile()
|
||||
ctagsearch()
|
||||
{
|
||||
POSITION pos, linepos;
|
||||
int linenum;
|
||||
LINENUM linenum;
|
||||
int len;
|
||||
char *line;
|
||||
|
||||
@ -499,6 +500,7 @@ findgtag(tag, type)
|
||||
#else
|
||||
char command[512];
|
||||
char *flag;
|
||||
char *qtag;
|
||||
char *cmd = lgetenv("LESSGLOBALTAGS");
|
||||
|
||||
if (cmd == NULL || *cmd == '\0')
|
||||
@ -523,9 +525,12 @@ findgtag(tag, type)
|
||||
}
|
||||
|
||||
/* Get our data from global(1). */
|
||||
tag = esc_metachars(tag);
|
||||
sprintf(command, "%s -x%s %s", cmd, flag, tag);
|
||||
free(tag);
|
||||
qtag = shell_quote(tag);
|
||||
if (qtag == NULL)
|
||||
qtag = tag;
|
||||
sprintf(command, "%s -x%s %s", cmd, flag, qtag);
|
||||
if (qtag != tag)
|
||||
free(qtag);
|
||||
fp = popen(command, "r");
|
||||
#endif
|
||||
}
|
||||
@ -563,7 +568,7 @@ findgtag(tag, type)
|
||||
}
|
||||
|
||||
/* Make new entry and add to list. */
|
||||
tp = maketagent(name, file, atoi(line), NULL, 0);
|
||||
tp = maketagent(name, file, (LINENUM) atoi(line), NULL, 0);
|
||||
TAG_INS(tp);
|
||||
total++;
|
||||
}
|
||||
|
@ -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.
|
||||
@ -24,7 +24,7 @@ extern char WIN32getch();
|
||||
static DWORD console_mode;
|
||||
#endif
|
||||
|
||||
static int tty;
|
||||
public int tty;
|
||||
extern int sigs;
|
||||
|
||||
/*
|
||||
|
@ -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.
|
||||
@ -624,7 +624,26 @@ v370 12/23/01 Fix tags error messages.
|
||||
-----------------------------------------------------------------
|
||||
v371 12/26/01 Fix new_file bug; use popen in Windows version;
|
||||
fix some compiler warnings.
|
||||
|
||||
v372 12/29/01 Make -b be in units of 1K.
|
||||
v373 1/14/02 Improve handling of filenames containing shell metachars.
|
||||
v374 2/7/02 Fix memory leak; fix bug in -x argument parsing.
|
||||
v375 4/7/02 Fix searching for SGR sequences; fix SECURE build;
|
||||
add SGR support to DJGPP version (thanks to Eli Zaretskii).
|
||||
v376 6/10/02 Fix bug in overstriking mulitbyte UTF-8 characters
|
||||
(thanks to Jungshik Shin).
|
||||
Posted to Web page.
|
||||
-----------------------------------------------------------------
|
||||
v377 9/10/02 Fix bug in Windows version when file contains CR;
|
||||
fix bug in search highlights with -R;
|
||||
make initial buffer limit really be 64K not unlimited.
|
||||
v378 9/30/02 Misc bug fixes and compiler warning cleanup.
|
||||
Posted to Web page.
|
||||
-----------------------------------------------------------------
|
||||
v379 11/23/02 Add -L option; fix bug with ctrl-K in lesskey files;
|
||||
improve UTF-8 overstriking and underscore overstriking;
|
||||
fix minor man page problems; change to autoconf 2.54.
|
||||
v380 11/24/02 Make LINENUM same as POSITION.
|
||||
v381 11/28/02 Make -N use 7 columns for line number if possible.
|
||||
*/
|
||||
|
||||
char version[] = "371";
|
||||
char version[] = "381";
|
||||
|
Loading…
Reference in New Issue
Block a user