v07i082: New release of LESS, Part01/03

sources-request at mirror.TMC.COM sources-request at mirror.TMC.COM
Sat Dec 6 08:18:29 AEST 1986


Submitted by: rgb at nscpdc.uucp (Robert Bond)
Mod.sources: Volume 7, Issue 82
Archive-name: less3/Part01

[  A new version, from the original author.  To paraphrase Mark Twain,
   rumors of his demise are greatly exxagerated.  --r$ ]

This is the latest version of my paginator, "less".  It is now
distributed in three parts.  The changes are summarized below.  Thanks
to Casey Leedom for the very nice additions recently posted to the
net.

P.S. Apologies to anyone who has tried to reach me during the past nine
months.  I have been off the net.  I still am not receiving netnews, so
if you have any comments, suggestions, etc. which you wish me to see,
please MAIL to me at:
	tektronix!nscpdc!convgt!mark
  or	ihnp4!nsc!nscpdc!convgt!mark

	Mark Nudelman
	Convergent Technologies

 Summary of changes to this version of less:

1. Incorporated Casey Leedom's changes for boldface handling and addition
    of -z option.
2. New -l option to log input to a file.
3. E command now expands shell metacharacters in the filename.
4. Single quote command may now be followed by another single quote, as in vi.
5. New + command, similar to + command line option.
6. g command when beginning of file is lost will now go back as far as
    possible, rather than just printing an error message.
7. New -P option for finer control over the prompt messages.
8. New mechanism for help.
9. The usual minor bug fixes and prettying up.

 ---- cut here ---- cut here ---- cut here ---- cut here ---- cut here ----
: This is a shell archive.
: Unpack by running /bin/sh.
echo README
cat >README <<'_SHAR_EOF_'
This is the distribution of "less", a paginator similar to "more" or "pg".
The manual page is in less.man (nroff source in less.nro).

INSTALLATION:

1. Move the distributed source to its own directory and 
   unpack it by running "sh" on the distribution file,
   if you have not already done so.

2. Type "install" and answer the questions it asks.
   This will generate a makefile.

   If you choose not to include some features in your version,
   you may wish to edit the manual page less.nro and/or less.man
   to remove the references to the appropriate commands or options.

   (NOTE: there are some pre-generated makefiles for
    various systems, named makefile.sys5, makefile.bsd41,
    etc. which may be used if you wish.)

3. It is a good idea to look over the generated makefile 
   and make sure it looks ok.

4. Type "make" and watch the fun.

5. If the make succeeds, it will generate a program "less"
   in your current directory.  Test the generated program.

6. When satisfied that it works, if you wish to install it
   in a public place, type "make install".

If you have any problems building or running "less", 
suggestions, complaints, etc., you may mail to the 
author via USENET at:
	tektronix!nscpdc!convgt!mark
  or	ihnp4!nsc!nscpdc!convgt!mark

Note to hackers: comments noting possible improvements are enclosed
in double curly brackets {{ like this }}.
_SHAR_EOF_

echo install
cat >install <<'_SHAR_EOF_'
:
# Installation script for less.
# This script prompts the operator for various information
# and constructs a makefile.

echo "This script will build a makefile for less."
echo "If you already have a file called \"makefile\" it will be overwritten."
echo "Press RETURN to continue."
read ans

echo "I will ask you some questions about your system."
echo "If you do not know the answer to any question,"
echo "just press RETURN and I will choose a default for you."
echo "Press RETURN now."
read ans

echo "Most Unix systems are derived from either System V"
echo "or Berkeley BSD 4.1, 4.2, 4.3, etc."
echo ""
echo "Is your system closest to:"
echo "  1. System V"
echo "  2. BSD 4.1"
echo "  3. BSD 4.2 or later"
echo "  4. Xenix"
echo "Enter a number, or just RETURN if you don't know: \c"
read ans
xenix=0
case "X$ans" in
X1) sys=sys5; sysname="System V" ;;
X2) sys=bsd; bsd41=1; sysname="BSD 4.1" ;;
X3) sys=bsd; bsd41=0; sysname="BSD 4.2" ;;
X4) sys=sys5; xenix=1; sysname="Xenix" ;;
*) sys=unknown ;;
esac
echo ""

cat >makefile <<"EOF"
# Makefile for "less"
#
# Invoked as:
#	make all
#   or	make install
# Plain "make" is equivalent to "make all".
#
# If you add or delete functions, remake funcs.h by doing:
#	make newfuncs
# This depends on the coding convention of function headers looking like:
#	" \t public <function-type> \n <function-name> ( ... ) "
#
# Also provided:
#	make lint	# Runs "lint" on all the sources.
#	make clean	# Removes "less" and the .o files.
#	make clobber	# Pretty much the same as make "clean".


##########################################################################
# System-specific parameters
##########################################################################

EOF

cat >>makefile <<EOF
# Define XENIX if running under XENIX 3.0
XENIX = $xenix

EOF
echo ""



if [ "X$sys" = "Xunknown" ]
then
	alldefault=0
else
	def=yes
	alldefault=1
	echo "Do you want to use ALL the defaults for $sysname?"
	echo "  Enter \"yes\" if you have a STANDARD $sysname."
	echo "  Enter \"no\" if you want to change any of the defaults. [$def] \c"
	read ans
	case "X$ans" in
	X[yY]*) alldefault=1 ;;
	X[nN]*) alldefault=0 ;;
	esac
	echo ""
fi



def=yes
x=1
if [ $alldefault = 0 ]
then
	echo "Does your C compiler support the \"void\" type? [$def] \c"
	read ans
	case "X$ans" in
	X[yY]*) x=1 ;;
	X[nN]*) x=0 ;;
	esac
	echo ""
fi
cat >>makefile <<EOF
# VOID is 1 if your C compiler supports the "void" type,
# 0 if it does not.
VOID = $x

EOF



def=long
if [ $alldefault = 0 ]
then
	echo "What type is the \"offset\" argument to lseek? [$def] \c"
	read ans
	if [ "X$ans" != "X" ]
	then
		def=$ans
	fi
	echo ""
fi
cat >>makefile <<EOF
# off_t is the type which lseek() returns.
# It is also the type of lseek()'s second argument.
off_t = $def

EOF




if [ "$sys" = "bsd" ]
then
	def=no; x=0
else
	def=yes; x=1
fi
if [ $alldefault = 0 ]
then
	echo "Most System V systems have termio.h, while most"
	echo "Berkeley-derived systems have sgtty.h."
	echo "Does your system have termio.h? [$def] \c"
	read ans
	case "X$ans" in
	X[yY]*) x=1 ;;
	X[nN]*) x=0 ;;
	esac
	echo ""
fi
cat >>makefile <<EOF
# TERMIO is 1 if your system has /usr/include/termio.h.
# This is normally the case for System 5.
# If TERMIO is 0 your system must have /usr/include/sgtty.h.
# This is normally the case for BSD.
TERMIO = $x

EOF




if [ "$sys" = "bsd" -a "$bsd41" = "0" ]
then
	def=yes; x=1
else
	def=no; x=0
fi
if [ $alldefault = 0 ]
then
	echo "Most BSD 4.2 and 4.3 systems have the sigsetmask() call."
	echo "Most System V and BSD 4.1 systems do not."
	echo "Does your system have sigsetmask()? [$def] \c"
	read ans
	case "X$ans" in
	X[yY]*) x=1 ;;
	X[nN]*) x=0 ;;
	esac
	echo ""
fi
cat >>makefile <<EOF
# SIGSETMASK is 1 if your system has the sigsetmask() call.
# This is normally the case only for BSD 4.2,
# not for BSD 4.1 or System 5.
SIGSETMASK = $x

EOF

cat >>makefile <<EOF
##########################################################################
# Optional and semi-optional features
##########################################################################

EOF




if [ "$sys" = "bsd" ]
then
	def=2; REGCMP=0;RECOMP=1
else
	def=1; REGCMP=1;RECOMP=0
fi
if [ $alldefault = 0 ]
then
	echo "Most System V systems have the regcmp() function."
	echo "Most Berkeley-derived systems have the re_comp() function."
	echo "Does your system have:"
	echo "  1. regcmp"
	echo "  2. re_comp"
	echo "  3. neither   [$def] \c"
	read ans
	case "X$ans" in
	X1) REGCMP=1;RECOMP=0 ;;
	X2) REGCMP=0;RECOMP=1 ;;
	X3) REGCMP=0;RECOMP=0 ;;
	esac
	echo ""
fi
cat >>makefile <<EOF
# REGCMP is 1 if your system has the regcmp() function.
# This is normally the case for System 5.
# RECOMP is 1 if your system has the re_comp() function.
# This is normally the case for BSD.
# If neither is 1, pattern matching is supported, but without metacharacters.
REGCMP = $REGCMP
RECOMP = $RECOMP

EOF




def=yes
x=1
if [ $alldefault = 0 ]
then
	echo "Do you wish to allow shell escapes? [$def] \c"
	read ans
	case "X$ans" in
	X[yY]*) x=1 ;;
	X[nN]*) x=0 ;;
	esac
	echo ""
fi
cat >>makefile <<EOF
# SHELL_ESCAPE is 1 if you wish to allow shell escapes.
# (This is possible only if your system supplies the system() function.)
SHELL_ESCAPE = $x

EOF



def=yes
x=1
edname="vi"
if [ $alldefault = 0 ]
then
	echo "Do you wish to allow editor escapes? [$def] \c"
	read ans
	case "X$ans" in
	X[nN]*) x=0; edname="" ;;
	X[yY]*) x=1
		echo "What is the pathname of the default editor? [$edname] \c"
		read ans 
		if [ "x$ans" != "x" ]
		then
			edname=$ans
		fi
		;;
	esac
	echo ""
fi
cat >>makefile <<EOF
# 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.
EDITOR = $x
EDIT_PGM = $edname

EOF



def=yes
x=1
if [ $alldefault = 0 ]
then
	echo "If your system provides the popen() function and"
	echo "the \"echo\" shell command, you may allow shell metacharacters" 
	echo "to be expanded in filenames."
	echo "Do you wish to allow shell metacharacters in filenames? [$def] \c"
	read ans
	case "X$ans" in
	X[yY]*) x=1 ;;
	X[nN]*) x=0 ;;
	esac
	echo ""
fi
cat >>makefile <<EOF
# 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.
GLOB = $x

EOF



def=yes
x=1
if [ $alldefault = 0 ]
then
	echo "Do you wish to allow log files (-l option)? [$def] \c"
	read ans
	case "X$ans" in
	X[yY]*) x=1 ;;
	X[nN]*) x=0 ;;
	esac
	echo ""
fi
cat >>makefile <<EOF
# LOGFILE is 1 if you wish to allow the -l option (to create log files).
LOGFILE = $x

EOF

cat >>makefile <<EOF
# 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.
ONLY_RETURN = 0


##########################################################################
# Compilation environment.
##########################################################################

EOF



if [ "$xenix" = "1" ]
then
	LIBS="-ltermlib"
elif [ "$sys" = "bsd" ]
then
	LIBS="-ltermcap"
else
	LIBS="-lcurses -ltermcap -lPW"
fi
if [ $alldefault = 0 ]
then
	echo "To build \"less\", you must link with libraries supplied by your system."
	echo "(If this needs to be changed later, edit the makefile"
	echo "and change the definition of LIBS.)"
	echo "What libraries should be used [$LIBS] \c"
	read ans
	if [ "X$ans" != "X" ]
	then
		LIBS="$ans"
	fi
	echo ""
fi
cat >>makefile <<EOF
# LIBS is the list of libraries needed.
LIBS = $LIBS

EOF



INSTALL_LESS="/usr/local/bin/less"
INSTALL_HELP="/usr/local/bin/less.help"
INSTALL_MAN="/usr/man/man1/less.1"
MANUAL="less.nro"
if [ $alldefault = 0 ]
then
	echo "What is the name of the \"public\" (installed) version of less?"
	echo " [$INSTALL_LESS] \c"
	read ans
	if [ "X$ans" != "X" ]
	then
		INSTALL_LESS="$ans"
	fi
	echo "What is the name of the \"public\" (installed) version of the help file?"
	echo " [$INSTALL_HELP] \c"
	read ans
	if [ "X$ans" != "X" ]
	then
		INSTALL_HELP="$ans"
	fi
	echo "What is the name of the \"public\" (installed) version of the manual page?"
	echo " [$INSTALL_MAN] \c"
	read ans
	if [ "X$ans" != "X" ]
	then
		INSTALL_MAN="$ans"
	fi
	echo ""
fi
cat >>makefile <<EOF
# INSTALL_LESS is a list of the public versions of less.
# INSTALL_HELP is a list of the public version of the help file.
# INSTALL_MAN is a list of the public versions of the manual page.
INSTALL_LESS =	$INSTALL_LESS
INSTALL_HELP =	$INSTALL_HELP
INSTALL_MAN =	$INSTALL_MAN
MANUAL =	$MANUAL
HELPFILE =	$INSTALL_HELP


EOF



cat >>makefile <<"EOF"
# OPTIM is passed to the compiler and the loader.
# It is normally "-O" but may be, for example, "-g".
OPTIM = -O


##########################################################################
# Files
##########################################################################

SRC1 =	main.c option.c prim.c ch.c position.c input.c output.c 
SRC2 =	screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
SRC =	$(SRC1) $(SRC2)
OBJ =	main.o option.o prim.o ch.o position.o input.o output.o screen.o \
	prompt.o line.o signal.o help.o ttyin.o command.o version.o


##########################################################################
# Rules
##########################################################################

DEFS =	"-DTERMIO=$(TERMIO)" \
	"-DSIGSETMASK=$(SIGSETMASK)" \
	"-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
	"-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
	"-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
	"-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
	"-DHELPFILE=\"$(HELPFILE)\"" \
	"-DLOGFILE=$(LOGFILE)" \
	"-DONLY_RETURN=$(ONLY_RETURN)" \
	"-DGLOB=$(GLOB)" \
	"-DXENIX=$(XENIX)"

CFLAGS = $(OPTIM) $(DEFS)


all: less

less: $(OBJ)
	cc $(OPTIM) -o less $(OBJ) $(LIBS)

install: install_man install_less install_help

install_less: less
	for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
	touch install_less

install_help: less.help
	for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
	touch install_help

install_man: $(MANUAL)
	for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
	touch install_man

$(OBJ): less.h funcs.h

# help.o depends on makefile for the definition of HELPFILE.
help.o: makefile

lint:
	lint -hp $(DEFS) $(SRC)

newfuncs:
	mv funcs.h funcs.h.OLD
	awk -f mkfuncs.awk $(SRC) >funcs.h

clean:
	rm -f $(OBJ) less

clobber:
	rm -f *.o less install_less install_man

shar:
	shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
	shar -v less.nro $(SRC1) > less.shar.b
	shar -v $(SRC2) > less.shar.c
EOF
echo ""

echo "The makefile has been built."
echo "You should check it to make sure everything is as you want it to be."
echo "When you are satisfied with the makefile, just type \"make\""
echo "and \"less\" will be built."
_SHAR_EOF_

echo less.man
cat >less.man <<'_SHAR_EOF_'



     LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))



     NNNNAAAAMMMMEEEE
          less - opposite of more

     SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
          lllleeeessssssss [[[[----ccccddddeeeeppppssssttttwwwwmmmmMMMMqqqqQQQQuuuuUUUU]]]] [[[[----hhhh_N]]]] [[[[----bbbb[[[[ffffpppp]]]]_N]]]] [[[[--





--xxxx_N]]]] [[[[----[[[[zzzz]]]]_N]]]]
               [[[[----PPPP[[[[mmmmMMMM]]]]_s_t_r_i_n_g]]]] [[[[----llll_l_o_g_f_i_l_e]]]] [[[[++++_c_m_d]]]]  [[[[_f_i_l_e_n_a_m_e]]]]............

     DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
          _L_e_s_s is a program similar to _m_o_r_e (1), but which allows
          backwards movement in the file as well as forward movement.
          Also, _l_e_s_s does not have to read the entire input file
          before starting, so with large input files it starts up
          faster than text editors like _v_i (1).  _L_e_s_s uses termcap, so
          it can run on a variety of terminals.  There is even limited
          support for hardcopy terminals.  (On a hardcopy terminal,
          lines which should be printed at the top of the screen are
          prefixed with an up-arrow.)

          Commands are based on both _m_o_r_e and _v_i. Commands may be
          preceeded by a decimal number, called N in the descriptions
          below.  The number is used by some commands, as indicated.


     CCCCOOOOMMMMMMMMAAAANNNNDDDDSSSS
          In the following descriptions, ^X means control-X.

          h    Help: display a summary of these commands.  If you
               forget all the other commands, remember this one.

          SPACE
               Scroll forward N lines, default one window (see option
               -z below).  If N is more than the screen size, only the
               final screenful is displayed.

          f or ^F
               Same as SPACE.

          b or ^B
               Scroll backward N lines, default one window (see option
               -z below).  If N is more than the screen size, only the
               final screenful is displayed.

          RETURN
               Scroll forward N lines, default 1.  The entire N lines
               are displayed, even if N is more than the screen size.

          e or ^E
               Same as RETURN.

          j or ^J
               Also the same as RETURN.




     Page 1                                          (printed 9/30/86)






     LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))



          y or ^Y
               Scroll backward N lines, default 1.  The entire N lines
               are displayed, even if N is more than the screen size.

          k or ^K
               Same as y.

          d or ^D
               Scroll forward N lines, default 10.  If N is specified,
               it becomes the new default for subsequent d and u
               commands.

          u or ^U
               Scroll backward N lines, default 10.  If N is
               specified, it becomes the new default for subsequent d
               and u commands.

          r or ^R or ^L
               Repaint the screen.

          R    Repaint the screen, discarding any buffered input.
               Useful if the file is changing while it is being
               viewed.

          g    Go to line N in the file, default 1 (beginning of
               file).  (Warning: this may be slow if N is large.)

          G    Go to line N in the file, default the end of the file.
               (Warning: this may be slow if standard input, rather
               than a file, is being read.)

          p    Go to a position N percent into the file.  N should be
               between 0 and 100.  (This is possible if standard input
               is being read, but only if _l_e_s_s has already read to the
               end of the file.  It is always fast, but not always
               useful.)

          %    Same as p.

          m    Followed by any lowercase letter, marks the current
               position with that letter.

          '    (Single quote.) Followed by any lowercase letter,
               returns to the position which was previously marked
               with that letter.  Followed by another single quote,
               returns to the postion at which the last "large"
               movement command was executed.  All marks are lost when
               a new file is examined.

          /pattern
               Search forward in the file for the N-th line containing
               the pattern.  N defaults to 1.  The pattern is a



     Page 2                                          (printed 9/30/86)






     LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))



               regular expression, as recognized by _e_d. The search
               starts at the second line displayed (but see the -t
               option, which changes this).

          ?pattern
               Search backward in the file for the N-th line
               containing the pattern.  The search starts at the line
               immediately before the top line displayed.

          n    Repeat previous search, for N-th line containing the
               last pattern.

          E    Examine a new file.  If the filename is missing, the
               "current" file (see the N and P commands below) from
               the list of files in the command line is re-examined.

          N    Examine the next file (from the list of files given in
               the command line).  If a number N is specified (not to
               be confused with the command N), the N-th next file is
               examined.

          P    Examine the previous file.  If a number N is specified,
               the N-th previous file is examined.

          = or ^G
               Prints some information about the file being viewed,
               including its name and the byte offset of the bottom
               line being displayed.  If possible, it also prints the
               length of the file and the percent of the file above
               the last displayed line.

          -    Followed by one of the command line option letters (see
               below), this will toggle the setting of that option and
               print a message describing the new setting.

          +cmd Causes the specified cmd to be executed each time a new
               file is examined.  For example, +G causes _l_e_s_s to
               initially display each file starting at the end rather
               than the beginning.

          V    Prints the version number of _l_e_s_s being run.

          q    Exits _l_e_s_s.

          The following two commands may or may not be valid,
          depending on your particular installation.

          v    Invokes an editor to edit the current file being
               viewed.  The editor is taken from the environment
               variable EDITOR, or defaults to "vi".

          ! shell-command



     Page 3                                          (printed 9/30/86)






     LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))



               Invokes a shell to run the shell-command given.

     OOOOPPPPTTTTIIIIOOOONNNNSSSS
          Command line options are described below.  Most options may
          be changed while _l_e_s_s is running, via the "-" command.

          Options are also taken from the environment variable "LESS".
          For example, if you like more-style prompting, to avoid
          typing "less -m ..." each time _l_e_s_s is invoked, you might
          tell _c_s_h:

          setenv LESS m

          or if you use _s_h:

          LESS=m; export LESS

          The environment variable is parsed before the command line,
          so command line options override the LESS environment
          variable.  A dollar sign ($) may be used to signal the end
          of an option string.  This is important only for options
          like -P which take a following string.

          -s   The -s option causes consecutive blank lines to be
               squeezed into a single blank line.  This is useful when
               viewing _n_r_o_f_f output.

          -t   Normally, forward searches start just after the top
               displayed line (that is, at the second displayed line).
               Thus forward searches include the currently displayed
               screen.  The -t option causes forward searches to start
               just after the bottom line displayed, thus skipping the
               currently displayed screen.

          -m   Normally, _l_e_s_s prompts with a colon.  The -m option
               causes _l_e_s_s to prompt verbosely (like _m_o_r_e), with the
               percent into the file.

          -M   The -M option causes _l_e_s_s to prompt even more verbosely
               than _m_o_r_e.

          -P   The -P option provides a way to tailor the three prompt
               styles to your own preference.  You would normally put
               this option in your LESS environment variable, rather
               than type it in with each less command.  Such an option
               must either be the last option in the LESS variable, or
               be terminated by a dollar sign.  -P followed by a
               string changes the default (short) prompt to that
               string.  -Pm changes the medium (-m) prompt to the
               string, and -PM changes the long (-M) prompt.  The
               string consists of a sequence of letters which are
               replaced with certain predefined strings, as follows:



     Page 4                                          (printed 9/30/86)






     LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))



                    F    file name
                    f    file name, only once
                    O    file n of n
                    o    file n of n, only once
                    b    byte offset
                    p    percent into file
                    P    percent if known, else byte offset
               Angle brackets, < and >, may be used to surround a
               literal string to be included in the prompt.  The
               defaults are "fo" for the short prompt, "foP" for the
               medium prompt, and "Fobp" for the long prompt.
               Example: Setting your LESS variable to "PmFOP$PMFObp"
               would change the medium and long prompts to always
               include the file name and "file n of n" message.
               Another example: Setting your LESS variable to
               "mPm<--Less-->FoPe" would change the medium prompt to
               the string "--Less--" followed by the file name and
               percent into the file.  It also selects the medium
               prompt as the default prompt (because of the first
               "m").

          -q   Normally, if an attempt is made to scroll past the end
               of the file or before the beginning of the file, the
               terminal bell is rung to indicate this fact.  The -q
               option tells _l_e_s_s not to ring the bell at such times.
               If the terminal has a "visual bell", it is used
               instead.

          -Q   Even if -q is given, _l_e_s_s will ring the bell on certain
               other errors, such as typing an invalid character.  The
               -Q option tells _l_e_s_s to be quiet all the time; that is,
               never ring the terminal bell.  If the terminal has a
               "visual bell", it is used instead.

          -e   Normally the only way to exit less is via the "q"
               command.  The -e option tells less to automatically
               exit the second time it reaches end-of-file.

          -u   If the -u option is given, backspaces are treated as
               printable characters; that is, they are sent to the
               terminal when they appear in the input.

          -U   If the -U option is given, backspaces are printed as
               the two character sequence "^H".

               If neither -u nor -U is given, backspaces which appear
               adjacent to an underscore character are treated
               specially: the underlined text is displayed using the
               terminal's hardware underlining capability.  Also,
               backspaces which appear between two identical
               characters are treated specially: the overstruck text
               is printed using the terminal's hardware boldface



     Page 5                                          (printed 9/30/86)






     LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))



               capability.  Other backspaces are deleted, along with
               the preceeding character.

          -w   Normally, _l_e_s_s uses a tilde character to represent
               lines past the end of the file.  The -w option causes
               blank lines to be used instead.

          -d   Normally, _l_e_s_s will complain if the terminal is dumb;
               that is, lacks some important capability, such as the
               ability to clear the screen or scroll backwards.  The
               -d option suppresses this complaint (but does not
               otherwise change the behavior of the program on a dumb
               terminal).

          -p   Normally, _l_e_s_s will repaint the screen by scrolling
               from the bottom of the screen.  If the -p option is
               set, when _l_e_s_s needs to change the entire display, it
               will clear the screen and paint from the top line down.

          -h   Normally, _l_e_s_s will scroll backwards when backwards
               movement is necessary.  The -h option specifies a
               maximum number of lines to scroll backwards.  If it is
               necessary to move backwards more than this many lines,
               the screen is repainted in a forward direction.  (If
               the terminal does not have the ability to scroll
               backwards, -h0 is implied.)

          -[z] When given a backwards or forwards window command, _l_e_s_s
               will by default scroll backwards or forwards one
               screenful of lines. The -z_n option changes the default
               scrolling window size to _n lines.  If _n is greater than
               the screen size, the scrolling window size will be set
               to one screenful. Note that the "z" is optional for
               compatibility with _m_o_r_e.

          -x   The -x_n option sets tab stops every _n positions.  The
               default for _n is 8.

          -l   The -l option, followed immediately by a filename, will
               cause _l_e_s_s to copy its input to the named file as it is
               being viewed.  This applies only when the input file is
               a pipe, not an ordinary file.

          -b   The -b_n option tells _l_e_s_s to use a non-standard buffer
               size.  There are two standard (default) buffer sizes,
               one is used when a file is being read and the other
               when a pipe (standard input) is being read.  The
               current defaults are 5 buffers for files and 12 for
               pipes.  (Buffers are 1024 bytes.) The number _n
               specifies a different number of buffers to use.  The -b
               may be followed by "f", in which case only the file
               default is changed, or by "p" in which case only the



     Page 6                                          (printed 9/30/86)






     LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))



               pipe default is changed.  Otherwise, both are changed.

          -c   Normally, when data is read by _l_e_s_s, it is scanned to
               ensure that bit 7 (the high order bit) is turned off in
               each byte read, and to ensure that there are no null
               (zero) bytes in the data (null bytes are turned into
               "@" characters).  If the data is known to be "clean",
               the -c option will tell _l_e_s_s to skip this checking,
               causing an imperceptible speed improvement.  (However,
               if the data is not "clean", unpredicatable results may
               occur.)

          +    If a command line option begins with ++++, the remainder
               of that option is taken to be an initial command to
               _l_e_s_s. For example, +G tells _l_e_s_s to start at the end of
               the file rather than the beginning, and +/xyz tells it
               to start at the first occurence of "xyz" in the file.
               As a special case, +<number> acts like +<number>g; that
               is, it starts the display at the specified line number
               (however, see the caveat under the "g" command above).
               If the option starts with ++++++++, the initial command
               applies to every file being viewed, not just the first
               one.  The + command described previously may also be
               used to set (or change) an initial command for every
               file.


     BBBBUUUUGGGGSSSS
          When used on standard input (rather than a file), you can
          move backwards only a finite amount, corresponding to that
          portion of the file which is still buffered.  The -b option
          may be used to expand the buffer space.























     Page 7                                          (printed 9/30/86)



_SHAR_EOF_

echo less.help
cat >less.help <<'_SHAR_EOF_'

      Commands marked with * may be preceeded by a number, N.

  h              Display this help.
  q              Exit.

  f, SPACE    *  Forward  N lines, default one screen.
  b           *  Backward N lines, default one screen.
  e, j, CR    *  Forward  N lines, default 1 line.
  y, k        *  Backward N lines, default 1 line.
  d           *  Forward  N lines, default 10 or last N to d or u command.
  u           *  Backward N lines, default 10 or last N to d or u command.
  r              Repaint screen.
  R              Repaint screen, discarding buffered input.

  /pattern    *  Search forward for N-th line containing the pattern.
  ?pattern    *  Search backward for N-th line containing the pattern.
  n           *  Repeat previous search (for N-th occurence).

  g           *  Go to line N, default 1.
  G           *  Like g, but default is last line in file.
  p, %        *  Position to N percent into the file.
  m<letter>      Mark the current position with <letter>.
  '<letter>      Return to a previously marked position.
  ''             Return to previous position.

  E [file]       Examine a new file.
  N           *  Examine the next file (from the command line).
  P           *  Examine the previous file (from the command line).
  =              Print current file name.
  V              Print version number of "less".

  -<flag>        Toggle a command line flag.
  +cmd           Execute the less cmd each time a new file is examined.

  !command       Passes the command to a shell to be executed.
  v              Edit the current file with $EDITOR.
_SHAR_EOF_

echo makefile.bsd41
cat >makefile.bsd41 <<'_SHAR_EOF_'
# Makefile for "less"
#
# Invoked as:
#	make all
#   or	make install
# Plain "make" is equivalent to "make all".
#
# If you add or delete functions, remake funcs.h by doing:
#	make newfuncs
# This depends on the coding convention of function headers looking like:
#	" \t public <function-type> \n <function-name> ( ... ) "
#
# Also provided:
#	make lint	# Runs "lint" on all the sources.
#	make clean	# Removes "less" and the .o files.
#	make clobber	# Pretty much the same as make "clean".


##########################################################################
# System-specific parameters
##########################################################################

# Define XENIX if running under XENIX 3.0
XENIX = 0

# VOID is 1 if your C compiler supports the "void" type,
# 0 if it does not.
VOID = 1

# off_t is the type which lseek() returns.
# It is also the type of lseek()'s second argument.
off_t = long

# TERMIO is 1 if your system has /usr/include/termio.h.
# This is normally the case for System 5.
# If TERMIO is 0 your system must have /usr/include/sgtty.h.
# This is normally the case for BSD.
TERMIO = 0

# SIGSETMASK is 1 if your system has the sigsetmask() call.
# This is normally the case only for BSD 4.2,
# not for BSD 4.1 or System 5.
SIGSETMASK = 0

##########################################################################
# Optional and semi-optional features
##########################################################################

# REGCMP is 1 if your system has the regcmp() function.
# This is normally the case for System 5.
# RECOMP is 1 if your system has the re_comp() function.
# This is normally the case for BSD.
# If neither is 1, pattern matching is supported, but without metacharacters.
REGCMP = 0
RECOMP = 1

# SHELL_ESCAPE is 1 if you wish to allow shell escapes.
# (This is possible only if your system supplies the system() function.)
SHELL_ESCAPE = 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.
EDITOR = 1
EDIT_PGM = vi

# 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.
GLOB = 1

# LOGFILE is 1 if you wish to allow the -l option (to create log files).
LOGFILE = 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.
ONLY_RETURN = 0


##########################################################################
# Compilation environment.
##########################################################################

# LIBS is the list of libraries needed.
LIBS = -ltermcap

# INSTALL_LESS is a list of the public versions of less.
# INSTALL_HELP is a list of the public version of the help file.
# INSTALL_MAN is a list of the public versions of the manual page.
INSTALL_LESS =	/usr/local/bin/less
INSTALL_HELP =	/usr/local/bin/less.help
INSTALL_MAN =	/usr/man/man1/less.1
MANUAL =	less.nro
HELPFILE =	/usr/local/bin/less.help


# OPTIM is passed to the compiler and the loader.
# It is normally "-O" but may be, for example, "-g".
OPTIM = -O


##########################################################################
# Files
##########################################################################

SRC1 =	main.c option.c prim.c ch.c position.c input.c output.c 
SRC2 =	screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
SRC =	$(SRC1) $(SRC2)
OBJ =	main.o option.o prim.o ch.o position.o input.o output.o screen.o \
	prompt.o line.o signal.o help.o ttyin.o command.o version.o


##########################################################################
# Rules
##########################################################################

DEFS =	"-DTERMIO=$(TERMIO)" \
	"-DSIGSETMASK=$(SIGSETMASK)" \
	"-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
	"-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
	"-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
	"-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
	"-DHELPFILE=\"$(HELPFILE)\"" \
	"-DLOGFILE=$(LOGFILE)" \
	"-DONLY_RETURN=$(ONLY_RETURN)" \
	"-DGLOB=$(GLOB)" \
	"-DXENIX=$(XENIX)"

CFLAGS = $(OPTIM) $(DEFS)


all: less

less: $(OBJ)
	cc $(OPTIM) -o less $(OBJ) $(LIBS)

install: install_man install_less install_help

install_less: less
	for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
	touch install_less

install_help: less.help
	for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
	touch install_help

install_man: $(MANUAL)
	for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
	touch install_man

$(OBJ): less.h funcs.h

# help.o depends on makefile for the definition of HELPFILE.
help.o: makefile

lint:
	lint -hp $(DEFS) $(SRC)

newfuncs:
	mv funcs.h funcs.h.OLD
	awk -f mkfuncs.awk $(SRC) >funcs.h

clean:
	rm -f $(OBJ) less

clobber:
	rm -f *.o less install_less install_man

shar:
	shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
	shar -v less.nro $(SRC1) > less.shar.b
	shar -v $(SRC2) > less.shar.c
_SHAR_EOF_

echo makefile.bsd42
cat >makefile.bsd42 <<'_SHAR_EOF_'
# Makefile for "less"
#
# Invoked as:
#	make all
#   or	make install
# Plain "make" is equivalent to "make all".
#
# If you add or delete functions, remake funcs.h by doing:
#	make newfuncs
# This depends on the coding convention of function headers looking like:
#	" \t public <function-type> \n <function-name> ( ... ) "
#
# Also provided:
#	make lint	# Runs "lint" on all the sources.
#	make clean	# Removes "less" and the .o files.
#	make clobber	# Pretty much the same as make "clean".


##########################################################################
# System-specific parameters
##########################################################################

# Define XENIX if running under XENIX 3.0
XENIX = 0

# VOID is 1 if your C compiler supports the "void" type,
# 0 if it does not.
VOID = 1

# off_t is the type which lseek() returns.
# It is also the type of lseek()'s second argument.
off_t = long

# TERMIO is 1 if your system has /usr/include/termio.h.
# This is normally the case for System 5.
# If TERMIO is 0 your system must have /usr/include/sgtty.h.
# This is normally the case for BSD.
TERMIO = 0

# SIGSETMASK is 1 if your system has the sigsetmask() call.
# This is normally the case only for BSD 4.2,
# not for BSD 4.1 or System 5.
SIGSETMASK = 1

##########################################################################
# Optional and semi-optional features
##########################################################################

# REGCMP is 1 if your system has the regcmp() function.
# This is normally the case for System 5.
# RECOMP is 1 if your system has the re_comp() function.
# This is normally the case for BSD.
# If neither is 1, pattern matching is supported, but without metacharacters.
REGCMP = 0
RECOMP = 1

# SHELL_ESCAPE is 1 if you wish to allow shell escapes.
# (This is possible only if your system supplies the system() function.)
SHELL_ESCAPE = 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.
EDITOR = 1
EDIT_PGM = vi

# 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.
GLOB = 1

# LOGFILE is 1 if you wish to allow the -l option (to create log files).
LOGFILE = 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.
ONLY_RETURN = 0


##########################################################################
# Compilation environment.
##########################################################################

# LIBS is the list of libraries needed.
LIBS = -ltermcap

# INSTALL_LESS is a list of the public versions of less.
# INSTALL_HELP is a list of the public version of the help file.
# INSTALL_MAN is a list of the public versions of the manual page.
INSTALL_LESS =	/usr/local/bin/less
INSTALL_HELP =	/usr/local/bin/less.help
INSTALL_MAN =	/usr/man/man1/less.1
MANUAL =	less.nro
HELPFILE =	/usr/local/bin/less.help


# OPTIM is passed to the compiler and the loader.
# It is normally "-O" but may be, for example, "-g".
OPTIM = -O


##########################################################################
# Files
##########################################################################

SRC1 =	main.c option.c prim.c ch.c position.c input.c output.c 
SRC2 =	screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
SRC =	$(SRC1) $(SRC2)
OBJ =	main.o option.o prim.o ch.o position.o input.o output.o screen.o \
	prompt.o line.o signal.o help.o ttyin.o command.o version.o


##########################################################################
# Rules
##########################################################################

DEFS =	"-DTERMIO=$(TERMIO)" \
	"-DSIGSETMASK=$(SIGSETMASK)" \
	"-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
	"-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
	"-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
	"-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
	"-DHELPFILE=\"$(HELPFILE)\"" \
	"-DLOGFILE=$(LOGFILE)" \
	"-DONLY_RETURN=$(ONLY_RETURN)" \
	"-DGLOB=$(GLOB)" \
	"-DXENIX=$(XENIX)"

CFLAGS = $(OPTIM) $(DEFS)


all: less

less: $(OBJ)
	cc $(OPTIM) -o less $(OBJ) $(LIBS)

install: install_man install_less install_help

install_less: less
	for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
	touch install_less

install_help: less.help
	for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
	touch install_help

install_man: $(MANUAL)
	for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
	touch install_man

$(OBJ): less.h funcs.h

# help.o depends on makefile for the definition of HELPFILE.
help.o: makefile

lint:
	lint -hp $(DEFS) $(SRC)

newfuncs:
	mv funcs.h funcs.h.OLD
	awk -f mkfuncs.awk $(SRC) >funcs.h

clean:
	rm -f $(OBJ) less

clobber:
	rm -f *.o less install_less install_man

shar:
	shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
	shar -v less.nro $(SRC1) > less.shar.b
	shar -v $(SRC2) > less.shar.c
_SHAR_EOF_

echo makefile.sys5
cat >makefile.sys5 <<'_SHAR_EOF_'
# Makefile for "less"
#
# Invoked as:
#	make all
#   or	make install
# Plain "make" is equivalent to "make all".
#
# If you add or delete functions, remake funcs.h by doing:
#	make newfuncs
# This depends on the coding convention of function headers looking like:
#	" \t public <function-type> \n <function-name> ( ... ) "
#
# Also provided:
#	make lint	# Runs "lint" on all the sources.
#	make clean	# Removes "less" and the .o files.
#	make clobber	# Pretty much the same as make "clean".


##########################################################################
# System-specific parameters
##########################################################################

# Define XENIX if running under XENIX 3.0
XENIX = 0

# VOID is 1 if your C compiler supports the "void" type,
# 0 if it does not.
VOID = 1

# off_t is the type which lseek() returns.
# It is also the type of lseek()'s second argument.
off_t = long

# TERMIO is 1 if your system has /usr/include/termio.h.
# This is normally the case for System 5.
# If TERMIO is 0 your system must have /usr/include/sgtty.h.
# This is normally the case for BSD.
TERMIO = 1

# SIGSETMASK is 1 if your system has the sigsetmask() call.
# This is normally the case only for BSD 4.2,
# not for BSD 4.1 or System 5.
SIGSETMASK = 0

##########################################################################
# Optional and semi-optional features
##########################################################################

# REGCMP is 1 if your system has the regcmp() function.
# This is normally the case for System 5.
# RECOMP is 1 if your system has the re_comp() function.
# This is normally the case for BSD.
# If neither is 1, pattern matching is supported, but without metacharacters.
REGCMP = 1
RECOMP = 0

# SHELL_ESCAPE is 1 if you wish to allow shell escapes.
# (This is possible only if your system supplies the system() function.)
SHELL_ESCAPE = 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.
EDITOR = 1
EDIT_PGM = vi

# 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.
GLOB = 1

# LOGFILE is 1 if you wish to allow the -l option (to create log files).
LOGFILE = 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.
ONLY_RETURN = 0


##########################################################################
# Compilation environment.
##########################################################################

# LIBS is the list of libraries needed.
LIBS = -lcurses -ltermcap -lPW

# INSTALL_LESS is a list of the public versions of less.
# INSTALL_HELP is a list of the public version of the help file.
# INSTALL_MAN is a list of the public versions of the manual page.
INSTALL_LESS =	/usr/local/bin/less
INSTALL_HELP =	/usr/local/bin/less.help
INSTALL_MAN =	/usr/man/man1/less.1
MANUAL =	less.nro
HELPFILE =	/usr/local/bin/less.help


# OPTIM is passed to the compiler and the loader.
# It is normally "-O" but may be, for example, "-g".
OPTIM = -O


##########################################################################
# Files
##########################################################################

SRC1 =	main.c option.c prim.c ch.c position.c input.c output.c 
SRC2 =	screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
SRC =	$(SRC1) $(SRC2)
OBJ =	main.o option.o prim.o ch.o position.o input.o output.o screen.o \
	prompt.o line.o signal.o help.o ttyin.o command.o version.o


##########################################################################
# Rules
##########################################################################

DEFS =	"-DTERMIO=$(TERMIO)" \
	"-DSIGSETMASK=$(SIGSETMASK)" \
	"-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
	"-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
	"-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
	"-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
	"-DHELPFILE=\"$(HELPFILE)\"" \
	"-DLOGFILE=$(LOGFILE)" \
	"-DONLY_RETURN=$(ONLY_RETURN)" \
	"-DGLOB=$(GLOB)" \
	"-DXENIX=$(XENIX)"

CFLAGS = $(OPTIM) $(DEFS)


all: less

less: $(OBJ)
	cc $(OPTIM) -o less $(OBJ) $(LIBS)

install: install_man install_less install_help

install_less: less
	for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
	touch install_less

install_help: less.help
	for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
	touch install_help

install_man: $(MANUAL)
	for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
	touch install_man

$(OBJ): less.h funcs.h

# help.o depends on makefile for the definition of HELPFILE.
help.o: makefile

lint:
	lint -hp $(DEFS) $(SRC)

newfuncs:
	mv funcs.h funcs.h.OLD
	awk -f mkfuncs.awk $(SRC) >funcs.h

clean:
	rm -f $(OBJ) less

clobber:
	rm -f *.o less install_less install_man

shar:
	shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
	shar -v less.nro $(SRC1) > less.shar.b
	shar -v $(SRC2) > less.shar.c
_SHAR_EOF_

echo makefile.xen
cat >makefile.xen <<'_SHAR_EOF_'
# Makefile for "less"
#
# Invoked as:
#	make all
#   or	make install
# Plain "make" is equivalent to "make all".
#
# If you add or delete functions, remake funcs.h by doing:
#	make newfuncs
# This depends on the coding convention of function headers looking like:
#	" \t public <function-type> \n <function-name> ( ... ) "
#
# Also provided:
#	make lint	# Runs "lint" on all the sources.
#	make clean	# Removes "less" and the .o files.
#	make clobber	# Pretty much the same as make "clean".


##########################################################################
# System-specific parameters
##########################################################################

# Define XENIX if running under XENIX 3.0
XENIX = 1

# VOID is 1 if your C compiler supports the "void" type,
# 0 if it does not.
VOID = 1

# off_t is the type which lseek() returns.
# It is also the type of lseek()'s second argument.
off_t = long

# TERMIO is 1 if your system has /usr/include/termio.h.
# This is normally the case for System 5.
# If TERMIO is 0 your system must have /usr/include/sgtty.h.
# This is normally the case for BSD.
TERMIO = 1

# SIGSETMASK is 1 if your system has the sigsetmask() call.
# This is normally the case only for BSD 4.2,
# not for BSD 4.1 or System 5.
SIGSETMASK = 0

##########################################################################
# Optional and semi-optional features
##########################################################################

# REGCMP is 1 if your system has the regcmp() function.
# This is normally the case for System 5.
# RECOMP is 1 if your system has the re_comp() function.
# This is normally the case for BSD.
# If neither is 1, pattern matching is supported, but without metacharacters.
REGCMP = 1
RECOMP = 0

# SHELL_ESCAPE is 1 if you wish to allow shell escapes.
# (This is possible only if your system supplies the system() function.)
SHELL_ESCAPE = 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.
EDITOR = 1
EDIT_PGM = vi

# 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.
GLOB = 1

# LOGFILE is 1 if you wish to allow the -l option (to create log files).
LOGFILE = 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.
ONLY_RETURN = 0


##########################################################################
# Compilation environment.
##########################################################################

# LIBS is the list of libraries needed.
LIBS = -ltermlib

# INSTALL_LESS is a list of the public versions of less.
# INSTALL_HELP is a list of the public version of the help file.
# INSTALL_MAN is a list of the public versions of the manual page.
INSTALL_LESS =	/usr/local/bin/less
INSTALL_HELP =	/usr/local/bin/less.help
INSTALL_MAN =	/usr/man/man1/less.1
MANUAL =	less.nro
HELPFILE =	/usr/local/bin/less.help


# OPTIM is passed to the compiler and the loader.
# It is normally "-O" but may be, for example, "-g".
OPTIM = -O


##########################################################################
# Files
##########################################################################

SRC1 =	main.c option.c prim.c ch.c position.c input.c output.c 
SRC2 =	screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
SRC =	$(SRC1) $(SRC2)
OBJ =	main.o option.o prim.o ch.o position.o input.o output.o screen.o \
	prompt.o line.o signal.o help.o ttyin.o command.o version.o


##########################################################################
# Rules
##########################################################################

DEFS =	"-DTERMIO=$(TERMIO)" \
	"-DSIGSETMASK=$(SIGSETMASK)" \
	"-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
	"-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
	"-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
	"-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
	"-DHELPFILE=\"$(HELPFILE)\"" \
	"-DLOGFILE=$(LOGFILE)" \
	"-DONLY_RETURN=$(ONLY_RETURN)" \
	"-DGLOB=$(GLOB)" \
	"-DXENIX=$(XENIX)"

CFLAGS = $(OPTIM) $(DEFS)


all: less

less: $(OBJ)
	cc $(OPTIM) -o less $(OBJ) $(LIBS)

install: install_man install_less install_help

install_less: less
	for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
	touch install_less

install_help: less.help
	for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
	touch install_help

install_man: $(MANUAL)
	for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
	touch install_man

$(OBJ): less.h funcs.h

# help.o depends on makefile for the definition of HELPFILE.
help.o: makefile

lint:
	lint -hp $(DEFS) $(SRC)

newfuncs:
	mv funcs.h funcs.h.OLD
	awk -f mkfuncs.awk $(SRC) >funcs.h

clean:
	rm -f $(OBJ) less

clobber:
	rm -f *.o less install_less install_man

shar:
	shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
	shar -v less.nro $(SRC1) > less.shar.b
	shar -v $(SRC2) > less.shar.c
_SHAR_EOF_

echo funcs.h
cat >funcs.h <<'_SHAR_EOF_'
	public void edit ();
	public void next_file ();
	public void prev_file ();
	public void quit ();
	public void init_option ();
	public void toggle_option ();
	public void scan_option ();
	public void forward ();
	public void backward ();
	public void repaint ();
	public void jump_forw ();
	public void jump_back ();
	public void jump_percent ();
	public void jump_loc ();
	public void init_mark ();
	public void setmark ();
	public void lastmark ();
	public void gomark ();
	public int get_back_scroll ();
	public void search ();
	public void end_logfile ();
	public int ch_seek ();
	public int ch_end_seek ();
	public int ch_beg_seek ();
	public POSITION ch_length ();
	public POSITION ch_tell ();
	public int ch_forw_get ();
	public int ch_back_get ();
	public void ch_init ();
	public POSITION position ();
	public void add_forw_pos ();
	public void add_back_pos ();
	public void pos_clear ();
	public int onscreen ();
	public POSITION forw_line ();
	public POSITION back_line ();
	public void put_line ();
	public int control_char ();
	public int carat_char ();
	public void flush ();
	public void dropout ();
	public void putc ();
	public void puts ();
	public void error ();
	public int error_width ();
	public void raw_mode ();
	public void get_term ();
	public void init ();
	public void deinit ();
	public void home ();
	public void add_line ();
	public void lower_left ();
	public void bell ();
	public void vbell ();
	public void clear ();
	public void clear_eol ();
	public void so_enter ();
	public void so_exit ();
	public void ul_enter ();
	public void ul_exit ();
	public void bo_enter ();
	public void bo_exit ();
	public void backspace ();
	public void putbs ();
	public char * eq_message ();
	public char * pr_string ();
	public void prewind ();
	public int pappend ();
	public POSITION forw_raw_line ();
	public POSITION back_raw_line ();
	public void init_signals ();
	public void  psignals ();
	public void lsystem ();
	public void help ();
	public void open_getc ();
	public int getc ();
	public void commands ();
_SHAR_EOF_

echo less.h
cat >less.h <<'_SHAR_EOF_'
/*
 * Standard include file for "less".
 */

/*
 * Language details.
 */
#if !VOID
#define	void  int
#endif
#define	public		/* PUBLIC FUNCTION */

/*
 * Special types and constants.
 */
typedef long		POSITION;
/*
 * {{ Warning: if POSITION is changed to other than "long",
 *    you may have to change some of the printfs which use "%ld"
 *    to print a variable of type POSITION. }}
 */

#define	NULL_POSITION	((POSITION)(-1))

#define	EOF		(0)
#define	NULL		(0)

/* How quiet should we be? */
#define	NOT_QUIET	0	/* Ring bell at eof and for errors */
#define	LITTLE_QUIET	1	/* Ring bell only for errors */
#define	VERY_QUIET	2	/* Never ring bell */

/* How should we prompt? */
#define	PR_SHORT	0	/* Prompt with colon */
#define	PR_MEDIUM	1	/* Prompt with message */
#define	PR_LONG		2	/* Prompt with longer message */

/* How should we handle backspaces? */
#define	BS_SPECIAL	0	/* Do special things for underlining and bold */
#define	BS_NORMAL	1	/* \b treated as normal char; actually output */
#define	BS_CONTROL	2	/* \b treated as control char; prints as ^H */

/* Special chars used to tell put_line() to do something special */
#define	UL_CHAR		'\201'	/* Enter underline mode */
#define	UE_CHAR		'\202'	/* Exit underline mode */
#define	BO_CHAR		'\203'	/* Enter boldface mode */
#define	BE_CHAR		'\204'	/* Exit boldface mode */

#define	CONTROL(c)		((c)&037)
#define	SIGNAL(sig,func)	signal(sig,func)

/* Library function declarations */
off_t lseek();

#include "funcs.h"
_SHAR_EOF_

echo position.h
cat >position.h <<'_SHAR_EOF_'
/*
 * Include file for interfacing to position.c modules.
 */
#define	TOP		0
#define	TOP_PLUS_ONE	1
#define	BOTTOM		-1
#define	BOTTOM_PLUS_ONE	-2
_SHAR_EOF_

echo mkfuncs.awk
cat >mkfuncs.awk <<'_SHAR_EOF_'
BEGIN { FS="("; state = 0 }

/^	public/ { ftype = $0; state = 1 }

{ if (state == 1)
	state = 2
  else if (state == 2)
	{ print ftype,$1,"();"; state = 0 }
}
_SHAR_EOF_



More information about the Mod.sources mailing list