summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/less/LICENSE2
-rw-r--r--usr.bin/less/Makefile.aut27
-rw-r--r--usr.bin/less/Makefile.dsb51
-rw-r--r--usr.bin/less/Makefile.dsg92
-rw-r--r--usr.bin/less/Makefile.dsu59
-rw-r--r--usr.bin/less/Makefile.o2e43
-rw-r--r--usr.bin/less/Makefile.o9c47
-rw-r--r--usr.bin/less/Makefile.o9u43
-rw-r--r--usr.bin/less/Makefile.wnb71
-rw-r--r--usr.bin/less/Makefile.wnm56
-rw-r--r--usr.bin/less/charset.h19
-rw-r--r--usr.bin/less/configure.ac125
-rw-r--r--usr.bin/less/cvt.c120
-rw-r--r--usr.bin/less/defines.ds400
-rw-r--r--usr.bin/less/defines.o2328
-rw-r--r--usr.bin/less/defines.o9340
-rw-r--r--usr.bin/less/defines.wn339
-rw-r--r--usr.bin/less/lessecho.man49
-rw-r--r--usr.bin/less/lessecho.nro47
-rw-r--r--usr.bin/less/pattern.c322
-rw-r--r--usr.bin/less/pattern.h48
-rw-r--r--usr.bin/less/pckeys.h2
-rw-r--r--usr.bin/less/scrsize.c2
23 files changed, 2613 insertions, 19 deletions
diff --git a/usr.bin/less/LICENSE b/usr.bin/less/LICENSE
index dd154f6771d..c7168e71827 100644
--- a/usr.bin/less/LICENSE
+++ b/usr.bin/less/LICENSE
@@ -2,7 +2,7 @@
------------
Less
-Copyright (C) 1984-2002 Mark Nudelman
+Copyright (C) 1984-2011 Mark Nudelman
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
diff --git a/usr.bin/less/Makefile.aut b/usr.bin/less/Makefile.aut
index f105d6902f0..b3ee3f4639d 100644
--- a/usr.bin/less/Makefile.aut
+++ b/usr.bin/less/Makefile.aut
@@ -10,10 +10,10 @@ srcdir = .
SRC = \
main.c screen.c brac.c ch.c charset.c cmdbuf.c \
- command.c decode.c edit.c filename.c forwback.c \
+ command.c cvt.c decode.c edit.c filename.c forwback.c \
help.c ifile.c input.c jump.c line.c linenum.c \
lsystem.c mark.c optfunc.c option.c opttbl.c os.c \
- output.c position.c prompt.c search.c signal.c \
+ output.c pattern.c position.c prompt.c search.c signal.c \
tags.c ttyin.c version.c
DISTFILES_W = \
defines.ds Makefile.dsb Makefile.dsg Makefile.dsu \
@@ -24,14 +24,24 @@ DISTFILES = \
${SRC} regexp.c regexp.h \
COPYING INSTALL LICENSE Makefile.in Makefile.aut NEWS README \
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 \
+ charset.h cmd.h funcs.h lglob.h less.h lesskey.h option.h \
+ pckeys.h pattern.h position.h \
install.sh defines.h.in mkinstalldirs \
- less.nro lesskey.nro less.man lesskey.man less.hlp \
+ less.nro less.man lesskey.nro lesskey.man lessecho.nro lessecho.man \
+ less.hlp \
mkfuncs.awk mkhelp.c \
${DISTFILES_W}
all: help.c funcs.h ${srcdir}/configure
+release: .FORCE
+ ${MAKE} -f Makefile.aut tagall
+ ${MAKE} -f Makefile.aut all
+ ${MAKE} -f Makefile.aut clean
+ ${MAKE} -f Makefile.aut dist
+
+.FORCE:
+
help.c: less.hlp mkhelp
-mv -f ${srcdir}/help.c ${srcdir}/help.c.old
rm -rf help.c
@@ -55,7 +65,8 @@ lint:
clean:
rm -f Makefile config.status config.log config.cache defines.h stamp-h \
- README NEWS less.nro lesskey.nro less.man lesskey.man
+ README NEWS \
+ less.nro less.man lesskey.nro lesskey.man lessecho.nro lessecho.man
distclean: clean
realclean: clean
@@ -78,6 +89,8 @@ ${srcdir}/less.nro: ${srcdir}/less.nro.VER ${srcdir}/version.c
${REPLACE_VERSION} ${srcdir}/less.nro.VER
${srcdir}/lesskey.nro: ${srcdir}/lesskey.nro.VER ${srcdir}/version.c
${REPLACE_VERSION} ${srcdir}/lesskey.nro.VER
+${srcdir}/lessecho.nro: ${srcdir}/lessecho.nro.VER ${srcdir}/version.c
+ ${REPLACE_VERSION} ${srcdir}/lessecho.nro.VER
${srcdir}/less.hlp: ${srcdir}/less.hlp.VER ${srcdir}/version.c
${REPLACE_VERSION} ${srcdir}/less.hlp.VER
@@ -85,6 +98,8 @@ ${srcdir}/less.man: ${srcdir}/less.nro
${NROFF} ${srcdir}/less.nro >${srcdir}/less.man
${srcdir}/lesskey.man: ${srcdir}/lesskey.nro
${NROFF} ${srcdir}/lesskey.nro >${srcdir}/lesskey.man
+${srcdir}/lessecho.man: ${srcdir}/lessecho.nro
+ ${NROFF} ${srcdir}/lessecho.nro >${srcdir}/lessecho.man
distfiles: ${DISTFILES}
@@ -103,6 +118,8 @@ dist: ${DISTFILES}
cd $$REL; chmod +w ${DISTFILES_W}; cd ..; \
echo "Creating release/$$REL/$$REL.tar.gz"; \
tar -cf - $$REL | gzip -c >release/$$REL/$$REL.tar.gz; \
+ echo "Signing release/$$REL/$$REL.tar.gz"; \
+ gpg --detach-sign release/$$REL/$$REL.tar.gz; \
echo "Creating release/$$REL/$$REL.zip"; \
zip -rq release/$$REL/$$REL.zip $$REL; \
rm -rf $$REL
diff --git a/usr.bin/less/Makefile.dsb b/usr.bin/less/Makefile.dsb
new file mode 100644
index 00000000000..e45b6025cf4
--- /dev/null
+++ b/usr.bin/less/Makefile.dsb
@@ -0,0 +1,51 @@
+# Makefile for less.
+# MS-DOS version (Borland C/C++ 4.02)
+
+#### Start of system configuration section. ####
+
+CC = bcc
+LIBDIR = \bc\lib
+
+CFLAGS = -A- -mm -O2 -w- -1- -2- -a -d -Z
+LDFLAGS = -mm
+LIBS =
+EXT = .EXE
+
+#### End of system configuration section. ####
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.obj:
+ $(CC) -c -I. $(CPPFLAGS) $(CFLAGS) $<
+
+OBJ = \
+ main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj \
+ command.obj cvt.obj decode.obj edit.obj filename.obj forwback.obj \
+ help.obj ifile.obj input.obj jump.obj line.obj linenum.obj \
+ lsystem.obj mark.obj optfunc.obj option.obj opttbl.obj os.obj \
+ output.obj pattern.obj position.obj prompt.obj search.obj signal.obj \
+ tags.obj ttyin.obj version.obj
+
+all: less$(EXT) lesskey$(EXT)
+
+# This is really horrible, but the command line is too long for
+# MS-DOS if we try to link $(OBJ).
+less$(EXT): $(OBJ)
+ ren lesskey.obj lesskey.obo
+ $(CC) $(LDFLAGS) -e$@ *.obj $(LIBS)
+ ren lesskey.obo lesskey.obj
+
+lesskey$(EXT): lesskey.obj version.obj
+ $(CC) $(LDFLAGS) -e$@ lesskey.obj version.obj $(LIBS)
+
+defines.h: defines.ds
+ -del defines.h
+ -copy defines.ds defines.h
+
+$(OBJ): less.h defines.h
+
+clean:
+ -del *.obj
+ -del less.exe
+ -del lesskey.exe
+
diff --git a/usr.bin/less/Makefile.dsg b/usr.bin/less/Makefile.dsg
new file mode 100644
index 00000000000..b921b5dec9b
--- /dev/null
+++ b/usr.bin/less/Makefile.dsg
@@ -0,0 +1,92 @@
+# Makefile for less under DJGPP v2.0 or later.
+
+#### Start of system configuration section. ####
+
+srcdir = .
+VPATH = .
+
+CC = gcc
+INSTALL = ginstall -c
+INSTALL_PROGRAM = ginstall
+INSTALL_DATA = ginstall -m 644
+AWK = gawk
+
+CFLAGS = -O2 -g
+CFLAGS_COMPILE_ONLY = -c
+#LDFLAGS = -s
+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} -DBINDIR=\"${bindir}\" -DSYSDIR=\"${sysconfdir}\" ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = \
+ main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} cvt.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O}
+
+all: less lesskey lessecho
+
+less: ${OBJ}
+ ${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
+
+lesskey: lesskey.${O} version.${O}
+ ${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O}
+
+lessecho: lessecho.${O} version.${O}
+ ${CC} ${LDFLAGS} -o $@ lessecho.${O} version.${O}
+
+defines.h: defines.ds
+ command.com /c copy $< $@
+
+${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:
+dvi:
+check:
+installcheck:
+
+TAGS:
+ etags *.c *.h
+
+newfuncs:
+ command.com /c if exist funcs.h del funcs.h
+ ${AWK} -f mkfuncs.awk ${OBJ:.${O}=.c} > funcs.h
+
+clean:
+ command.com /c for %f in (*.${O} less lesskey lessecho *.exe) do if exist %f del %f
+
+mostlyclean: clean
+
+distclean: clean
+ command.com /c if not exist Makefile.dsg ren Makefile Makefile.dsg
+ command.com /c if not exist defines.ds ren defines.h defines.ds
+ command.com /c for %f in (Makefile defines.h) do if exist %f del %f
+
+realclean: distclean
+ command.com /c if exist TAGS del TAGS
+
diff --git a/usr.bin/less/Makefile.dsu b/usr.bin/less/Makefile.dsu
new file mode 100644
index 00000000000..40a253848f6
--- /dev/null
+++ b/usr.bin/less/Makefile.dsu
@@ -0,0 +1,59 @@
+# Makefile for less.
+# MS-DOS version
+
+#### Start of system configuration section. ####
+
+CC = cl
+# Change the following directories to match your installation.
+LIBDIR = c:\msvc\lib
+INCDIR = c:\msvc\include
+
+# CFLAGS are compile-time options and LDFLAGS are link-time options. They are
+# customized for MSVC 1.0 (MSC 8.0). If you have a different version of the
+# compiler, you may need to change some of the options to their equivalents.
+# -Ot optimize for speed
+# -AL large memory model
+# -Za ANSI C conformance
+# -nologo suppress MSVC banners
+# -onerror:noexe no .EXE file if link errors occur
+CFLAGS = -Ot -AL -Za -nologo
+LDFLAGS = -onerror:noexe -nologo
+LIBS = $(LIBDIR)\llibce.lib $(LIBDIR)\graphics.lib
+
+#### End of system configuration section. ####
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.obj:
+ $(CC) -c -I. -I$(INCDIR) $(CPPFLAGS) $(CFLAGS) $<
+
+OBJ = \
+ main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj \
+ command.obj cvt.obj decode.obj edit.obj filename.obj forwback.obj \
+ help.obj ifile.obj input.obj jump.obj line.obj linenum.obj \
+ lsystem.obj mark.obj optfunc.obj option.obj opttbl.obj os.obj \
+ output.obj pattern.obj position.obj prompt.obj search.obj signal.obj \
+ tags.obj ttyin.obj version.obj
+
+all: less lesskey
+
+# This is really horrible, but the command line is too long for
+# MS-DOS if we try to link $(OBJ).
+less: $(OBJ)
+ -if exist lesskey.obj del lesskey.obj
+ $(CC) $(LDFLAGS) -o $@ *.obj $(LIBS)
+
+lesskey: lesskey.obj version.obj
+ $(CC) $(LDFLAGS) -o $@ lesskey.obj version.obj $(LIBS)
+
+defines.h: defines.ds
+ -del defines.h
+ -copy defines.ds defines.h
+
+$(OBJ): less.h defines.h
+
+clean:
+ -del *.obj
+ -del less.exe
+ -del lesskey.exe
+
diff --git a/usr.bin/less/Makefile.o2e b/usr.bin/less/Makefile.o2e
new file mode 100644
index 00000000000..3bb6dfc4eb5
--- /dev/null
+++ b/usr.bin/less/Makefile.o2e
@@ -0,0 +1,43 @@
+# Makefile for less.
+# OS/2 version, for emx+gcc compiler
+
+#### Start of system configuration section. ####
+
+CC = gcc -Zomf
+CFLAGS = -I. -O2 -Wall
+LDFLAGS = -s -Zcrtdll
+LIBS = -ltermcap
+O = obj
+
+#### End of system configuration section. ####
+
+.SUFFIXES: .c .${O}
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.${O}:
+ ${CC} -c ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = \
+ main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} cvt.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O} regexp.${O}
+
+all: less.exe lesskey.exe scrsize.exe
+
+less.exe: ${OBJ}
+ ${CC} ${OBJ} -o $@ ${LDFLAGS} ${LIBS}
+
+lesskey.exe: lesskey.${O} version.${O}
+ ${CC} lesskey.${O} version.${O} -o $@ ${LDFLAGS}
+
+scrsize.exe: scrsize.c
+ ${CC} ${CFLAGS} -D__ST_MT_ERRNO__ -s -Zmtd -lX11 $<
+
+${OBJ}: defines.h less.h
+
+defines.h: defines.o2
+ copy defines.o2 defines.h
diff --git a/usr.bin/less/Makefile.o9c b/usr.bin/less/Makefile.o9c
new file mode 100644
index 00000000000..e107f55946b
--- /dev/null
+++ b/usr.bin/less/Makefile.o9c
@@ -0,0 +1,47 @@
+# Makefile for less.
+# OS-9 version for Microware C 3.2.
+
+#### Start of system configuration section. ####
+
+CC = cc
+CPPFLAGS = -D_OSK_MWC32 -DDEBUG=0 -DSTRCSPN
+CFLAGS = -k=0 -v=.
+CFLAGS_COMPILE_ONLY = -r
+LDFLAGS = -igm=8
+LIBS = -l=/dd/lib/termlib.l
+O = r
+
+
+#### End of system configuration section. ####
+
+.SUFFIXES: .c .${O}
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+
+.c.${O}:
+ ${CC} ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = \
+ main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} cvt.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O} regexp.${O}
+
+all: less lessecho lesskey
+
+less: ${OBJ}
+ ${CC} ${OBJ} -f=$@ ${LDFLAGS} ${LIBS}
+
+lesskey: lesskey.${O} version.${O}
+ ${CC} lesskey.${O} version.${O} -f=$@ ${LDFLAGS}
+
+lessecho: lessecho.${O} version.${O}
+ ${CC} lessecho.${O} version.${O} -f=$@ ${LDFLAGS}
+
+${OBJ}: defines.h less.h
+
+defines.h: defines.o9
+ copy defines.o9 defines.h -rf
diff --git a/usr.bin/less/Makefile.o9u b/usr.bin/less/Makefile.o9u
new file mode 100644
index 00000000000..8ca84c89725
--- /dev/null
+++ b/usr.bin/less/Makefile.o9u
@@ -0,0 +1,43 @@
+# Makefile for less.
+# OS-9 version for Ultra C.
+
+#### Start of system configuration section. ####
+
+CC = cc
+CPPFLAGS =
+CFLAGS = -v=.
+CFLAGS_COMPILE_ONLY = -eas
+LDFLAGS = -olM=24k
+LIBS = -ltermlib.l -lsys_clib.l -lunix.l
+O = r
+
+
+#### End of system configuration section. ####
+
+.SUFFIXES: .c .${O}
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.${O}:
+ ${CC} ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = \
+ main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ command.${O} cvt.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ output.${O} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ tags.${O} ttyin.${O} version.${O} regexp.${O}
+
+all: less lesskey
+
+less: ${OBJ}
+ ${CC} ${OBJ} -f=$@ ${LDFLAGS} ${LIBS}
+
+lesskey: lesskey.${O} version.${O}
+ ${CC} lesskey.${O} version.${O} -f=$@ ${LDFLAGS}
+
+${OBJ}: defines.h less.h
+
+defines.h: defines.o9
+ copy defines.o9 defines.h -rf
diff --git a/usr.bin/less/Makefile.wnb b/usr.bin/less/Makefile.wnb
new file mode 100644
index 00000000000..75a65cdd2c5
--- /dev/null
+++ b/usr.bin/less/Makefile.wnb
@@ -0,0 +1,71 @@
+# Makefile for less.
+# Windows version
+# Bolarnd C++ 5.5.1 free command line tools
+
+#### Start of system configuration section. ####
+#
+# Borland's make knows its own location in the
+# filesystem.
+#
+
+CC = bcc32
+LIBDIR = $(MAKEDIR)\..\lib
+
+CFLAGS = -O2 -w-pro -TWC -P-c -v- -d -f- -ff- -vi
+LDFLAGS = -Tpe -v- -ap -c -x -V4.0 -GF:AGGRESSIVE
+LD = ilink32
+LIBS = ${LIBDIR}\import32.lib ${LIBDIR}\cw32.lib
+
+#### End of system configuration section. ####
+
+#
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+#
+.c.obj:
+ ${CC} -c -I. ${CPPFLAGS} ${CFLAGS} $<
+
+OBJ = \
+ main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj \
+ command.obj cvt.obj decode.obj edit.obj filename.obj forwback.obj \
+ help.obj ifile.obj input.obj jump.obj line.obj linenum.obj \
+ lsystem.obj mark.obj optfunc.obj option.obj opttbl.obj os.obj \
+ output.obj pattern.obj position.obj prompt.obj search.obj signal.obj \
+ tags.obj ttyin.obj version.obj regexp.obj
+
+all: less lesskey lessecho
+
+#
+# This is really horrible, but the command line is too long for
+# MS-DOS if we try to link ${OBJ}.
+#
+less: ${OBJ}
+ ${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj $**, $@,,${LIBS}
+
+lesskey: lesskey.obj version.obj
+ ${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj $**, $@,,${LIBS}
+
+lessecho: lessecho.obj version.obj
+ ${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj $**, $@,,${LIBS}
+
+defines.h: defines.wn
+ -del defines.h
+ -copy defines.wn defines.h
+
+${OBJ}: less.h defines.h funcs.h cmd.h
+
+clean:
+ -del *.obj
+ -del *.il?
+ -del *.tds
+ -del defines.h
+
+spotless: clean
+ -del less.exe
+ -del lesskey.exe
+ -del lessecho.exe
+
+realclean: spotless
+
+distclean: spotless
+
diff --git a/usr.bin/less/Makefile.wnm b/usr.bin/less/Makefile.wnm
new file mode 100644
index 00000000000..7b33833837d
--- /dev/null
+++ b/usr.bin/less/Makefile.wnm
@@ -0,0 +1,56 @@
+# Makefile for less.
+# Windows 32 Visual C++ version
+
+#### Start of system configuration section. ####
+
+CC = cl
+
+# Normal flags
+CFLAGS = /nologo /ML /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c
+LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386
+
+# Debugging flags
+#CFLAGS = /nologo /MDd /W3 /GX /Od /Gm /Zi /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c
+#LDFLAGS = /nologo /subsystem:console /incremental:yes /debug /machine:I386
+
+LD = link
+LIBS = user32.lib
+
+#### End of system configuration section. ####
+
+# This rule allows us to supply the necessary -D options
+# in addition to whatever the user asks for.
+.c.obj:
+ $(CC) $(CFLAGS) $<
+
+OBJ = \
+ main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj \
+ command.obj cvt.obj decode.obj edit.obj filename.obj forwback.obj \
+ help.obj ifile.obj input.obj jump.obj line.obj linenum.obj \
+ lsystem.obj mark.obj optfunc.obj option.obj opttbl.obj os.obj \
+ output.obj pattern.obj position.obj prompt.obj search.obj signal.obj \
+ tags.obj ttyin.obj version.obj regexp.obj
+
+all: less.exe lesskey.exe
+
+# This is really horrible, but the command line is too long for
+# MS-DOS if we try to link ${OBJ}.
+less.exe: $(OBJ)
+ -del lesskey.obj
+ $(LD) $(LDFLAGS) *.obj $(LIBS) /out:$@
+
+lesskey.exe: lesskey.obj version.obj
+ $(LD) $(LDFLAGS) lesskey.obj version.obj $(LIBS) /out:$@
+
+defines.h: defines.wn
+ -del defines.h
+ -copy defines.wn defines.h
+
+$(OBJ): less.h defines.h funcs.h cmd.h
+
+clean:
+ -del *.obj
+ -del less.exe
+ -del lesskey.exe
+
+
diff --git a/usr.bin/less/charset.h b/usr.bin/less/charset.h
new file mode 100644
index 00000000000..8ccf748df09
--- /dev/null
+++ b/usr.bin/less/charset.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2005-2011 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.
+ */
+
+#define IS_ASCII_OCTET(c) (((c) & 0x80) == 0)
+#define IS_UTF8_TRAIL(c) (((c) & 0xC0) == 0x80)
+#define IS_UTF8_LEAD2(c) (((c) & 0xE0) == 0xC0)
+#define IS_UTF8_LEAD3(c) (((c) & 0xF0) == 0xE0)
+#define IS_UTF8_LEAD4(c) (((c) & 0xF8) == 0xF0)
+#define IS_UTF8_LEAD5(c) (((c) & 0xFC) == 0xF8)
+#define IS_UTF8_LEAD6(c) (((c) & 0xFE) == 0xFC)
+#define IS_UTF8_INVALID(c) (((c) & 0xFE) == 0xFE)
+#define IS_UTF8_LEAD(c) (((c) & 0xC0) == 0xC0 && !IS_UTF8_INVALID(c))
diff --git a/usr.bin/less/configure.ac b/usr.bin/less/configure.ac
index d9e6ccab6ec..0b386b07572 100644
--- a/usr.bin/less/configure.ac
+++ b/usr.bin/less/configure.ac
@@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script.
-# Copyright (C) 1984-2002 Mark Nudelman
+# Copyright (C) 1984-2011 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,7 +23,9 @@ AC_PROG_INSTALL
AC_SYS_LARGEFILE
# Checks for general libraries.
+AC_CHECK_LIB(tinfo, tgoto, [have_tinfo=yes], [have_tinfo=no])
AC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
+AC_CHECK_LIB(ncursesw, initscr, [have_ncursesw=yes], [have_ncursesw=no])
AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
@@ -50,6 +52,20 @@ fi
fi
if test $curses_broken = 0; then
+
+# -- Try tinfo.
+if test "x$TERMLIBS" = x; then
+ if test $have_tinfo = yes; then
+ TERMLIBS="-ltinfo"
+ SAVE_LIBS=$LIBS
+ LIBS="$LIBS $TERMLIBS"
+ AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
+ [termok=yes], [termok=no])
+ LIBS=$SAVE_LIBS
+ if test $termok = no; then TERMLIBS=""; fi
+ fi
+fi
+
# -- Try xcurses.
if test "x$TERMLIBS" = x; then
if test $have_xcurses = yes; then
@@ -63,6 +79,19 @@ if test "x$TERMLIBS" = x; then
fi
fi
+# -- Try ncursesw.
+if test "x$TERMLIBS" = x; then
+ if test $have_ncursesw = yes; then
+ TERMLIBS="-lncursesw"
+ 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
@@ -140,7 +169,7 @@ LIBS="$LIBS $TERMLIBS"
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h])
+AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
@@ -166,8 +195,12 @@ AH_TEMPLATE([HAVE_REGEXEC2],
[])
AH_TEMPLATE([HAVE_VOID],
[Define HAVE_VOID if your compiler supports the "void" type.])
+AH_TEMPLATE([HAVE_FLOAT],
+ [Define HAVE_FLOAT if your compiler supports the "double" type.])
AH_TEMPLATE([HAVE_CONST],
[Define HAVE_CONST if your compiler supports the "const" modifier.])
+AH_TEMPLATE([HAVE_STAT_INO],
+ [Define HAVE_STAT_INO if your struct stat has st_ino and st_dev.])
AH_TEMPLATE([HAVE_TIME_T],
[Define HAVE_TIME_T if your system supports the "time_t" type.])
AH_TEMPLATE([HAVE_STRERROR],
@@ -190,12 +223,16 @@ AH_TEMPLATE([HAVE_TERMIOS_FUNCS],
[Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr.])
AH_TEMPLATE([HAVE_UPPER_LOWER],
[Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower.])
+AH_TEMPLATE([HAVE_WCTYPE],
+ [Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower.])
AH_TEMPLATE([HAVE_SIGSET_T],
[Define HAVE_SIGSET_T you have the sigset_t type.])
AH_TEMPLATE([HAVE_SIGEMPTYSET],
[Define HAVE_SIGEMPTYSET if you have the sigemptyset macro.])
AH_TEMPLATE([EDIT_PGM],
[Define EDIT_PGM to your editor.])
+AH_TEMPLATE([SECURE_COMPILE],
+ [Define SECURE_COMPILE=1 to build a secure version of less.])
# Checks for identifiers.
AC_TYPE_OFF_T
@@ -208,10 +245,37 @@ AC_TRY_COMPILE(, [const int foo = 0;],
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)])
+AC_MSG_CHECKING(for st_ino in struct stat)
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/stat.h>],
+ [struct stat s; dev_t dev = s.st_dev; ino_t ino = s.st_ino;],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STAT_INO)], [AC_MSG_RESULT(no)])
# Checks for library functions.
AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system])
+AC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
+
+# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
+AC_MSG_CHECKING(for memcpy)
+AC_TRY_LINK([
+#if HAVE_STRING_H
+#include <string.h>
+#endif], [memcpy(0,0,0);],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MEMCPY)], [AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING(for strchr)
+AC_TRY_LINK([
+#if HAVE_STRING_H
+#include <string.h>
+#endif], [strchr("x",'x');],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRCHR)], [AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING(for strstr)
+AC_TRY_LINK([
+#if HAVE_STRING_H
+#include <string.h>
+#endif], [strstr("x","x");],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRSTR)], [AC_MSG_RESULT(no)])
# Some systems have termios.h but not the corresponding functions.
AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
@@ -240,11 +304,7 @@ 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_CHECK_TYPES([sigset_t],,,[#include <signal.h>])
AC_MSG_CHECKING(for sigemptyset)
AC_TRY_LINK([
@@ -270,8 +330,10 @@ fi
AC_MSG_CHECKING(for locale)
AC_TRY_LINK([#include <locale.h>
-#include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
+#include <ctype.h>
+#include <langinfo.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
+
AC_MSG_CHECKING(for ctype functions)
AC_TRY_LINK([
#if HAVE_CTYPE_H
@@ -279,6 +341,10 @@ AC_TRY_LINK([
#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
+AC_MSG_CHECKING(for wctype functions)
+AC_TRY_LINK([#include <wctype.h>], [iswlower(0); iswupper(0); towlower(0); towupper(0);],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WCTYPE)], [AC_MSG_RESULT(no)])
+
# Checks for external variable ospeed in the termcap library.
have_ospeed=no
AC_MSG_CHECKING(termcap for ospeed)
@@ -297,11 +363,29 @@ AC_TRY_LINK(, [extern short ospeed; ospeed = 0;],
[AC_MSG_RESULT(no)])
fi
+# Compile in secure mode?
+AC_ARG_WITH(secure,
+ [ --with-secure Compile in secure mode],
+ AC_DEFINE(SECURE_COMPILE, 1), AC_DEFINE(SECURE_COMPILE, 0))
+
+# Should we use floating point?
+AC_MSG_CHECKING(for floating point)
+AC_ARG_WITH(no-float,
+ [ --with-no-float Do not use floating point],
+ WANT_NO_FLOAT=1, WANT_NO_FLOAT=0)
+if test $WANT_NO_FLOAT = 0; then
+ AC_TRY_LINK(, [double f1 = 12.5; double f2 = f1*f1/2.5;],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT)], [AC_MSG_RESULT(no)])
+else
+ AC_MSG_RESULT(disabled by user)
+fi
+
# Checks for regular expression functions.
have_regex=no
have_posix_regex=unknown
AC_MSG_CHECKING(for regcomp)
+# Select a regular expression library.
WANT_REGEX=auto
AC_ARG_WITH(regex,
[ --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} Select a regular expression library [auto]],
@@ -401,8 +485,9 @@ AH_TOP([
/*
* SECURE is 1 if you wish to disable a bunch of features in order to
* be safe to run by unprivileged users.
+ * SECURE_COMPILE is set by the --with-secure configure option.
*/
-#define SECURE 0
+#define SECURE SECURE_COMPILE
/*
* SHELL_ESCAPE is 1 if you wish to allow shell escapes.
@@ -488,10 +573,13 @@ AH_TOP([
* 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).
+ * LESSHISTFILE is the filename of the history file
+ * (in the HOME directory).
*/
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
+#define LESSHISTFILE ".lesshst"
/* Settings always true on Unix. */
@@ -507,6 +595,12 @@ AH_TOP([
#define PATHNAME_SEP "/"
/*
+ * The value returned from tgetent on success.
+ * Some HP-UX systems return 0 on success.
+ */
+#define TGETENT_OK 1
+
+/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
#define HAVE_SYS_TYPES_H 1
@@ -535,7 +629,7 @@ AH_TOP([
/*
* Default shell metacharacters and meta-escape character.
*/
-#define DEF_METACHARS "; *?\t\n'\"()<>|&^`#\\"
+#define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~"
#define DEF_METAESCAPE "\\"
/*
@@ -543,6 +637,15 @@ AH_TOP([
*/
#define HAVE_DUP 1
+/* Define to 1 if you have the memcpy() function. */
+#define HAVE_MEMCPY 1
+
+/* Define to 1 if you have the strchr() function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the strstr() function. */
+#define HAVE_STRSTR 1
+
/*
* Sizes of various buffers.
*/
diff --git a/usr.bin/less/cvt.c b/usr.bin/less/cvt.c
new file mode 100644
index 00000000000..74439847e01
--- /dev/null
+++ b/usr.bin/less/cvt.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 1984-2011 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.
+ */
+
+/*
+ * Routines to convert text in various ways. Used by search.
+ */
+
+#include "less.h"
+#include "charset.h"
+
+extern int utf_mode;
+
+/*
+ * Get the length of a buffer needed to convert a string.
+ */
+ public int
+cvt_length(len, ops)
+ int len;
+ int ops;
+{
+ if (utf_mode)
+ /*
+ * Just copying a string in UTF-8 mode can cause it to grow
+ * in length.
+ * Four output bytes for one input byte is the worst case.
+ */
+ len *= 4;
+ return (len + 1);
+}
+
+/*
+ * Allocate a chpos array for use by cvt_text.
+ */
+ public int *
+cvt_alloc_chpos(len)
+ int len;
+{
+ int i;
+ int *chpos = (int *) ecalloc(sizeof(int), len);
+ /* Initialize all entries to an invalid position. */
+ for (i = 0; i < len; i++)
+ chpos[i] = -1;
+ return (chpos);
+}
+
+/*
+ * Convert text. Perform the transformations specified by ops.
+ * Returns converted text in odst. The original offset of each
+ * odst character (when it was in osrc) is returned in the chpos array.
+ */
+ public void
+cvt_text(odst, osrc, chpos, lenp, ops)
+ char *odst;
+ char *osrc;
+ int *chpos;
+ int *lenp;
+ int ops;
+{
+ char *dst;
+ char *src;
+ register char *src_end;
+ LWCHAR ch;
+
+ if (lenp != NULL)
+ src_end = osrc + *lenp;
+ else
+ src_end = osrc + strlen(osrc);
+
+ for (src = osrc, dst = odst; src < src_end; )
+ {
+ int src_pos = src - osrc;
+ int dst_pos = dst - odst;
+ ch = step_char(&src, +1, src_end);
+ if ((ops & CVT_BS) && ch == '\b' && dst > odst)
+ {
+ /* Delete backspace and preceding char. */
+ do {
+ dst--;
+ } while (dst > odst &&
+ !IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst));
+ } else if ((ops & CVT_ANSI) && IS_CSI_START(ch))
+ {
+ /* Skip to end of ANSI escape sequence. */
+ src++; /* skip the CSI start char */
+ while (src < src_end)
+ if (!is_ansi_middle(*src++))
+ break;
+ } else
+ {
+ /* Just copy the char to the destination buffer. */
+ if ((ops & CVT_TO_LC) && IS_UPPER(ch))
+ ch = TO_LOWER(ch);
+ put_wchar(&dst, ch);
+ /*
+ * Record the original position of the char.
+ * But if we've already recorded a position
+ * for this char (due to a backspace), leave
+ * it alone; if multiple source chars map to
+ * one destination char, we want the position
+ * of the first one.
+ */
+ if (chpos != NULL && chpos[dst_pos] < 0)
+ chpos[dst_pos] = src_pos;
+ }
+ }
+ if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r')
+ dst--;
+ *dst = '\0';
+ if (lenp != NULL)
+ *lenp = dst - odst;
+ if (chpos != NULL)
+ chpos[dst - odst] = src - osrc;
+}
diff --git a/usr.bin/less/defines.ds b/usr.bin/less/defines.ds
new file mode 100644
index 00000000000..4dbbd6518a1
--- /dev/null
+++ b/usr.bin/less/defines.ds
@@ -0,0 +1,400 @@
+/*
+ * Copyright (C) 1984-2011 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.
+ */
+
+
+/* DOS definition file for less. */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for MS-DOS systems.
+ */
+
+/* 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)
+#define EDIT_PGM "vi"
+
+/*
+ * 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.
+ */
+#ifdef __DJGPP__
+#define GLOB (!SECURE)
+#else
+#define GLOB 0
+#endif
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#ifdef __DJGPP__
+#define PIPEC (!SECURE)
+#else
+#define PIPEC 0
+#endif
+
+/*
+ * 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).
+ * LESSHISTFILE is the filename of the history file
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE "_less"
+#define LESSKEYFILE_SYS "c:\\_sysless"
+#define DEF_LESSKEYINFILE "_lesskey"
+#define LESSHISTFILE "_lesshst"
+
+
+/* Settings always true for MS-DOS systems. */
+
+/*
+ * Define MSDOS_COMPILER if compiling for MS-DOS.
+ */
+#ifdef __DJGPP__
+#define MSDOS_COMPILER DJGPPC
+#else
+#ifdef __BORLANDC__
+#define MSDOS_COMPILER BORLANDC
+#else
+#define MSDOS_COMPILER MSOFTC
+#endif
+#endif
+
+/*
+ * 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.
+ */
+#define HAVE_SGSTAT_H 0
+
+/*
+ * 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 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.
+ */
+#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 */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#if MSDOS_COMPILER==BORLANDC
+#define off_t long
+#endif
+
+/* 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). */
+#define RETSIGTYPE void
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * 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_RE_COMP */
+/* #undef HAVE_REGCMP */
+/* #undef HAVE_V8_REGCOMP */
+#if MSDOS_COMPILER==DJGPPC
+#define HAVE_POSIX_REGCOMP 1
+#else
+#define NO_REGEX 1
+#endif
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 1
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 1
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* Define HAVE_ERRNO if you have the errno variable */
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not defined
+ * in errno.h */
+#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 0
+#else
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 1
+#endif
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 1
+
+/* 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. */
+#define HAVE_OSPEED 0
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 0
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 0
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function. */
+#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
+#define HAVE__SETJMP 0
+#else
+#define HAVE__SETJMP 1
+#endif
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function. */
+#if MSDOS_COMPILER==DJGPPC
+#define HAVE_POPEN 1
+#else
+#define HAVE_POPEN 0
+#endif
+
+/* Define if you have the sigsetmask function. */
+#define HAVE_SIGSETMASK 0
+
+/* Define if you have the sigprocmask function. */
+#define HAVE_SIGPROCMASK 0
+
+/* Define if you have the sigset_t type and sigemptyset macro */
+#define HAVE_SIGSET_T 0
+#define HAVE_SIGEMPTYSET 0
+
+/* Define if you have the stat function. */
+#define HAVE_STAT 1
+
+/* Define if you have the strchr function. */
+#define HAVE_STRCHR 1
+
+/* Define if you have the system function. */
+#define HAVE_SYSTEM 1
+
+/* Define if you have the snprintf function. */
+#define HAVE_SNPRINTF 0
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 0
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <stdlib> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 0
+
+/* Define if you have the <sys/ptem.h> header file. */
+#define HAVE_SYS_PTEM_H 0
+
+/* Define if you have the <sys/stream.h> header file. */
+#define HAVE_SYS_STREAM_H 0
+
+/* Define if you have the <termcap.h> header file. */
+#define HAVE_TERMCAP_H 0
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 0
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 0
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#if MSDOS_COMPILER==DJGPPC
+#define HAVE_UNISTD_H 1
+#else
+#define HAVE_UNISTD_H 0
+#endif
+
+/* Define if you have the <values.h> header file. */
+#if MSDOS_COMPILER==MSOFTC
+#define HAVE_VALUES_H 0
+#else
+#define HAVE_VALUES_H 1
+#endif
+
+#if MSDOS_COMPILER == MSOFTC && _MSC_VER >= 700
+/*
+ * The names of these things changed in Microsoft C version 7.0.
+ */
+#define videoconfig _videoconfig
+#define rccoord _rccoord
+#define O_RDONLY _O_RDONLY
+#define O_WRONLY _O_WRONLY
+#define O_APPEND _O_APPEND
+#define O_BINARY _O_BINARY
+#define O_TEXT _O_TEXT
+#define find_t _find_t
+#define stat _stat
+#define S_IFMT _S_IFMT
+#define S_IFDIR _S_IFDIR
+#define S_IFREG _S_IFREG
+#define dup _dup
+#define open _open
+#define lseek _lseek
+#define write _write
+#define creat _creat
+#define fstat _fstat
+#define isatty _isatty
+#define close _close
+#define read _read
+#define ungetch _ungetch
+#define kbhit _kbhit
+#define getch _getch
+#endif
diff --git a/usr.bin/less/defines.o2 b/usr.bin/less/defines.o2
new file mode 100644
index 00000000000..0fd8cc73503
--- /dev/null
+++ b/usr.bin/less/defines.o2
@@ -0,0 +1,328 @@
+/*
+ * Copyright (C) 1984-2011 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.
+ */
+
+
+/* OS/2 definition file for less. */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for the emx compiler for OS/2 systems.
+ */
+
+
+/* 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)
+#define EDIT_PGM "vi"
+
+/*
+ * 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).
+ * LESSHISTFILE is the filename of the history file
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE "less.ini"
+#define LESSKEYFILE_SYS "C:\\sysless.ini"
+#define DEF_LESSKEYINFILE "lesskey.ini"
+#define LESSHISTFILE "lesshst.ini"
+
+
+/* Settings always true for the emx compiler for OS/2 systems. */
+#define OS2 1
+
+/*
+ * 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.
+ */
+#define HAVE_SGSTAT_H 0
+
+/*
+ * 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 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.
+ */
+#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 */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+/* #define off_t long */
+
+/* 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). */
+#define RETSIGTYPE void
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * 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_RE_COMP */
+/* #undef HAVE_REGCMP */
+#define HAVE_V8_REGCOMP 1
+/* #undef NO_REGEX */
+#define HAVE_REGEXEC2 1
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 1
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 1
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* 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 */
+#define HAVE_ERRNO 1
+/* #undef MUST_DEFINE_ERRNO */
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 1
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+#define HAVE_OSPEED 1
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 1
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 1
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function. */
+#define HAVE__SETJMP 0
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function. */
+#define HAVE_POPEN 1
+
+/* Define if you have the sigsetmask function. */
+#define HAVE_SIGSETMASK 0
+
+/* Define if you have the sigprocmask function. */
+#define HAVE_SIGPROCMASK 1
+
+/* Define if you have the sigset_t type and sigemptyset macro */
+#define HAVE_SIGSET_T 1
+#define HAVE_SIGEMPTYSET 1
+
+/* Define if you have the stat function. */
+#define HAVE_STAT 1
+
+/* Define if you have the strchr function. */
+#define HAVE_STRCHR 1
+
+/* Define if you have the strstr function. */
+#define HAVE_STRSTR 1
+
+/* Define if you have the system function. */
+#define HAVE_SYSTEM 1
+
+/* Define if you have the snprintf function. */
+#define HAVE_SNPRINTF 0
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 0
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <stdlib> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define if you have the <sys/ptem.h> header file. */
+#define HAVE_SYS_PTEM_H 0
+
+/* Define if you have the <sys/stream.h> header file. */
+#define HAVE_SYS_STREAM_H 0
+
+/* Define if you have the <termcap.h> header file. */
+#define HAVE_TERMCAP_H 1
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 1
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 1
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define if you have the <values.h> header file. */
+#define HAVE_VALUES_H 0
diff --git a/usr.bin/less/defines.o9 b/usr.bin/less/defines.o9
new file mode 100644
index 00000000000..3bb1d2cb8ca
--- /dev/null
+++ b/usr.bin/less/defines.o9
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 1984-2011 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.
+ */
+
+
+/* OS/9 definition file for less. */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for OS-9 systems.
+ */
+
+/* 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 1
+
+/*
+ * 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)
+#define EDIT_PGM "umacs"
+
+/*
+ * 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).
+ * LESSHISTFILE is the filename of the history file
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE ".less"
+#define LESSKEYFILE_SYS "/.sysless"
+#define DEF_LESSKEYINFILE ".lesskey"
+#define LESSHISTFILE ".lesshst"
+
+
+/* Settings always true for OS-9. */
+
+/* This is not needed; it is defined by the compiler. */
+/* #define _OSK 1 */
+#define OS2 0
+#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 0
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#define HAVE_SGSTAT_H 1
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#if _OSK_MWC32
+#define HAVE_PERROR 0
+#else
+#define HAVE_PERROR 1
+#endif
+
+/*
+ * 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 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.
+ */
+#define HAVE_DUP 0
+
+/*
+ * 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 */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#define off_t long
+
+/* Define if you need to in order for stat and other things to work. */
+#define _POSIX_SOURCE 0
+
+/* Define as the return type of signal handlers (int or void). */
+#if _OSK_MWC32
+#define RETSIGTYPE int
+#else
+#define RETSIGTYPE void
+#endif
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * 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.
+ */
+#define HAVE_POSIX_REGCOMP 0
+#define HAVE_RE_COMP 0
+#define HAVE_REGCMP 0
+#define HAVE_V8_REGCOMP 1
+#define NO_REGEX 0
+#define HAVE_REGEXEC2 1
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 0
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 0
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* 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 */
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 0
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 0
+
+/* 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. */
+#define HAVE_OSPEED 0
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 0
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 0
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function. */
+#define HAVE__SETJMP 1
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function. */
+#define HAVE_POPEN 1
+
+/* Define if you have the sigsetmask function. */
+#define HAVE_SIGSETMASK 0
+
+/* Define if you have the sigprocmask function. */
+#define HAVE_SIGPROCMASK 0
+
+/* Define if you have the sigset_t type and sigemptyset macro */
+#define HAVE_SIGSET_T 0
+#define HAVE_SIGEMPTYSET 0
+
+/* Define if you have the stat function. */
+#define HAVE_STAT 0
+
+/* Define if you have the strchr function. */
+#define HAVE_STRCHR 0
+
+/* Define if you have the system function. */
+#define HAVE_SYSTEM 1
+
+/* Define if you have the snprintf function. */
+#define HAVE_SNPRINTF 0
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 0
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 0
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 0
+
+/* Define if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <stdlib> header file. */
+#if _OSK_MWC32
+#define HAVE_STDLIB_H 0
+#else
+#define HAVE_STDLIB_H 1
+#endif
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 0
+
+/* Define if you have the <sys/ptem.h> header file. */
+#define HAVE_SYS_PTEM_H 0
+
+/* Define if you have the <sys/stream.h> header file. */
+#define HAVE_SYS_STREAM_H 0
+
+/* Define if you have the <termcap.h> header file. */
+#define HAVE_TERMCAP_H 1
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 0
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 0
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 0
+
+/* Define if you have the <values.h> header file. */
+#define HAVE_VALUES_H 0
diff --git a/usr.bin/less/defines.wn b/usr.bin/less/defines.wn
new file mode 100644
index 00000000000..416a548e745
--- /dev/null
+++ b/usr.bin/less/defines.wn
@@ -0,0 +1,339 @@
+/*
+ * Copyright (C) 1984-2011 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.
+ */
+
+
+/* Windows definition file for less. */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for Windows systems.
+ */
+
+
+/* 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)
+#define EDIT_PGM "edit"
+
+/*
+ * 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 0
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#define PIPEC 1
+
+/*
+ * 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).
+ * LESSHISTFILE is the filename of the history file
+ * (in the HOME directory).
+ */
+#define LESSKEYFILE "_less"
+#define LESSKEYFILE_SYS "c:\\_sysless"
+#define DEF_LESSKEYINFILE "_lesskey"
+#define LESSHISTFILE "_lesshst"
+
+
+/* Settings always true for Windows systems. */
+
+#define MSDOS_COMPILER WIN32C
+
+/*
+ * 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.
+ */
+#define HAVE_SGSTAT_H 0
+
+/*
+ * 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 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.
+ */
+#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 */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+/* #define off_t long */
+
+/* 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). */
+#define RETSIGTYPE void
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * 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_RE_COMP */
+/* #undef HAVE_REGCMP */
+#define HAVE_V8_REGCOMP 1
+/* #undef NO_REGEX */
+#define HAVE_REGEXEC2 1
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 1
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 1
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* 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 */
+#define HAVE_ERRNO 1
+#define MUST_DEFINE_ERRNO 1
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 1
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+#define HAVE_OSPEED 0
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 0
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 0
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function. */
+#define HAVE__SETJMP 1
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function. */
+#define HAVE_POPEN 1
+
+/* Define if you have the sigsetmask function. */
+#define HAVE_SIGSETMASK 0
+
+/* Define if you have the sigprocmask function. */
+#define HAVE_SIGPROCMASK 0
+
+/* Define if you have the sigset_t type and sigemptyset macro */
+#define HAVE_SIGSET_T 0
+#define HAVE_SIGEMPTYSET 0
+
+/* Define if you have the stat function. */
+#define HAVE_STAT 1
+
+/* Define if you have the strchr function. */
+#define HAVE_STRCHR 1
+
+/* Define if you have the system function. */
+#define HAVE_SYSTEM 1
+
+/* Define if you have the snprintf function. */
+#define HAVE_SNPRINTF 1
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define HAVE_FLOAT if your compiler supports the "double" type. */
+#define HAVE_FLOAT 1
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <stdlib> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 0
+
+/* Define if you have the <sys/ptem.h> header file. */
+#define HAVE_SYS_PTEM_H 0
+
+/* Define if you have the <sys/stream.h> header file. */
+#define HAVE_SYS_STREAM_H 0
+
+/* Define if you have the <termcap.h> header file. */
+#define HAVE_TERMCAP_H 0
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 0
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 0
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 0
+
+/* Define if you have the <values.h> header file. */
+#ifdef _MSC_VER
+#define HAVE_VALUES_H 0
+#else
+#define HAVE_VALUES_H 1
+#endif
+
+#define popen _popen
+#define pclose _pclose
+#define snprintf _snprintf
+
+#pragma warning(disable:4996)
diff --git a/usr.bin/less/lessecho.man b/usr.bin/less/lessecho.man
new file mode 100644
index 00000000000..682b0bd835e
--- /dev/null
+++ b/usr.bin/less/lessecho.man
@@ -0,0 +1,49 @@
+LESSECHO(1) LESSECHO(1)
+
+
+
+NAME
+ lessecho - expand metacharacters
+
+SYNOPSIS
+ lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-a] file ...
+
+DESCRIPTION
+ lessecho is a program that simply echos its arguments on standard out-
+ put. But any argument containing spaces is enclosed in quotes.
+
+OPTIONS
+ A summary of options is included below.
+
+ -ox Specifies "x" to be the open quote character.
+
+ -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 "n" to be the escape char for metachars, as an inte-
+ ger.
+
+ -a Specifies that all arguments are to be quoted. The default is
+ that only arguments containing spaces are quoted.
+
+SEE ALSO
+ less(1)
+
+AUTHOR
+ This manual page was written by Thomas Schoepf <schoepf@debian.org>,
+ for the Debian GNU/Linux system (but may be used by others).
+
+ Send bug reports or comments to bug-less@gnu.org.
+
+
+
+ Version 444: 09 Jun 2011 LESSECHO(1)
diff --git a/usr.bin/less/lessecho.nro b/usr.bin/less/lessecho.nro
new file mode 100644
index 00000000000..46540e8bcca
--- /dev/null
+++ b/usr.bin/less/lessecho.nro
@@ -0,0 +1,47 @@
+.TH LESSECHO 1 "Version 444: 09 Jun 2011"
+.SH NAME
+lessecho \- expand metacharacters
+.SH SYNOPSIS
+.B lessecho
+.I "[-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-a] file ..."
+.SH "DESCRIPTION"
+.I lessecho
+is a program that simply echos its arguments on standard output.
+But any argument containing spaces is enclosed in quotes.
+.SH OPTIONS
+A summary of options is included below.
+.TP
+.B \-ox
+Specifies "x" to be the open quote character.
+.TP
+.B \-cx
+Specifies "x" to be the close quote character.
+.TP
+.B \-pn
+Specifies "n" to be the open quote character, as an integer.
+.TP
+.B \-dn
+Specifies "n" to be the close quote character, as an integer.
+.TP
+.B \-mx
+Specifies "x" to be a metachar.
+.TP
+.B \-nn
+Specifies "n" to be a metachar, as an integer.
+.TP
+.B \-ex
+Specifies "x" to be the escape char for metachars.
+.TP
+.B \-fn
+Specifies "n" to be the escape char for metachars, as an integer.
+.TP
+.B \-a
+Specifies that all arguments are to be quoted.
+The default is that only arguments containing spaces are quoted.
+.SH "SEE ALSO"
+less(1)
+.SH AUTHOR
+This manual page was written by Thomas Schoepf <schoepf@debian.org>,
+for the Debian GNU/Linux system (but may be used by others).
+.PP
+Send bug reports or comments to bug-less@gnu.org.
diff --git a/usr.bin/less/pattern.c b/usr.bin/less/pattern.c
new file mode 100644
index 00000000000..ca349b6c192
--- /dev/null
+++ b/usr.bin/less/pattern.c
@@ -0,0 +1,322 @@
+/*
+ * Copyright (C) 1984-2011 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.
+ */
+
+/*
+ * Routines to do pattern matching.
+ */
+
+#include "less.h"
+#include "pattern.h"
+
+extern int caseless;
+
+/*
+ * Compile a search pattern, for future use by match_pattern.
+ */
+ static int
+compile_pattern2(pattern, search_type, comp_pattern)
+ char *pattern;
+ int search_type;
+ void **comp_pattern;
+{
+ if ((search_type & SRCH_NO_REGEX) == 0)
+ {
+#if HAVE_POSIX_REGCOMP
+ regex_t *comp = (regex_t *) ecalloc(1, sizeof(regex_t));
+ regex_t **pcomp = (regex_t **) comp_pattern;
+ if (regcomp(comp, pattern, REGCOMP_FLAG))
+ {
+ free(comp);
+ error("Invalid pattern", NULL_PARG);
+ return (-1);
+ }
+ if (*pcomp != NULL)
+ regfree(*pcomp);
+ *pcomp = comp;
+#endif
+#if HAVE_PCRE
+ pcre *comp;
+ pcre **pcomp = (pcre **) comp_pattern;
+ const char *errstring;
+ int erroffset;
+ PARG parg;
+ comp = pcre_compile(pattern, 0,
+ &errstring, &erroffset, NULL);
+ if (comp == NULL)
+ {
+ parg.p_string = (char *) errstring;
+ error("%s", &parg);
+ return (-1);
+ }
+ *pcomp = comp;
+#endif
+#if HAVE_RE_COMP
+ PARG parg;
+ int *pcomp = (int *) comp_pattern;
+ if ((parg.p_string = re_comp(pattern)) != NULL)
+ {
+ error("%s", &parg);
+ return (-1);
+ }
+ *pcomp = 1;
+#endif
+#if HAVE_REGCMP
+ char *comp;
+ char **pcomp = (char **) comp_pattern;
+ if ((comp = regcmp(pattern, 0)) == NULL)
+ {
+ error("Invalid pattern", NULL_PARG);
+ return (-1);
+ }
+ if (pcomp != NULL)
+ free(*pcomp);
+ *pcomp = comp;
+#endif
+#if HAVE_V8_REGCOMP
+ struct regexp *comp;
+ struct regexp **pcomp = (struct regexp **) comp_pattern;
+ if ((comp = regcomp(pattern)) == NULL)
+ {
+ /*
+ * regcomp has already printed an error message
+ * via regerror().
+ */
+ return (-1);
+ }
+ if (*pcomp != NULL)
+ free(*pcomp);
+ *pcomp = comp;
+#endif
+ }
+ return (0);
+}
+
+/*
+ * Like compile_pattern2, but convert the pattern to lowercase if necessary.
+ */
+ public int
+compile_pattern(pattern, search_type, comp_pattern)
+ char *pattern;
+ int search_type;
+ void **comp_pattern;
+{
+ char *cvt_pattern;
+ int result;
+
+ if (caseless != OPT_ONPLUS)
+ cvt_pattern = pattern;
+ else
+ {
+ cvt_pattern = (char*) ecalloc(1, cvt_length(strlen(pattern), CVT_TO_LC));
+ cvt_text(cvt_pattern, pattern, (int *)NULL, (int *)NULL, CVT_TO_LC);
+ }
+ result = compile_pattern2(cvt_pattern, search_type, comp_pattern);
+ if (cvt_pattern != pattern)
+ free(cvt_pattern);
+ return (result);
+}
+
+/*
+ * Forget that we have a compiled pattern.
+ */
+ public void
+uncompile_pattern(pattern)
+ void **pattern;
+{
+#if HAVE_POSIX_REGCOMP
+ regex_t **pcomp = (regex_t **) pattern;
+ if (*pcomp != NULL)
+ regfree(*pcomp);
+ *pcomp = NULL;
+#endif
+#if HAVE_PCRE
+ pcre **pcomp = (pcre **) pattern;
+ if (*pcomp != NULL)
+ pcre_free(*pcomp);
+ *pcomp = NULL;
+#endif
+#if HAVE_RE_COMP
+ int *pcomp = (int *) pattern;
+ *pcomp = 0;
+#endif
+#if HAVE_REGCMP
+ char **pcomp = (char **) pattern;
+ if (*pcomp != NULL)
+ free(*pcomp);
+ *pcomp = NULL;
+#endif
+#if HAVE_V8_REGCOMP
+ struct regexp **pcomp = (struct regexp **) pattern;
+ if (*pcomp != NULL)
+ free(*pcomp);
+ *pcomp = NULL;
+#endif
+}
+
+/*
+ * Is a compiled pattern null?
+ */
+ public int
+is_null_pattern(pattern)
+ void *pattern;
+{
+#if HAVE_POSIX_REGCOMP
+ return (pattern == NULL);
+#endif
+#if HAVE_PCRE
+ return (pattern == NULL);
+#endif
+#if HAVE_RE_COMP
+ return (pattern == 0);
+#endif
+#if HAVE_REGCMP
+ return (pattern == NULL);
+#endif
+#if HAVE_V8_REGCOMP
+ return (pattern == NULL);
+#endif
+#if NO_REGEX
+ return (search_pattern != NULL);
+#endif
+}
+
+/*
+ * Simple pattern matching function.
+ * It supports no metacharacters like *, etc.
+ */
+ static int
+match(pattern, pattern_len, buf, buf_len, pfound, pend)
+ char *pattern;
+ int pattern_len;
+ char *buf;
+ int buf_len;
+ char **pfound, **pend;
+{
+ register char *pp, *lp;
+ register char *pattern_end = pattern + pattern_len;
+ register char *buf_end = buf + buf_len;
+
+ for ( ; buf < buf_end; buf++)
+ {
+ for (pp = pattern, lp = buf; *pp == *lp; pp++, lp++)
+ if (pp == pattern_end || lp == buf_end)
+ break;
+ if (pp == pattern_end)
+ {
+ if (pfound != NULL)
+ *pfound = buf;
+ if (pend != NULL)
+ *pend = lp;
+ return (1);
+ }
+ }
+ return (0);
+}
+
+/*
+ * Perform a pattern match with the previously compiled pattern.
+ * Set sp and ep to the start and end of the matched string.
+ */
+ public int
+match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type)
+ void *pattern;
+ char *tpattern;
+ char *line;
+ int line_len;
+ char **sp;
+ char **ep;
+ int notbol;
+ int search_type;
+{
+ int matched;
+#if HAVE_POSIX_REGCOMP
+ regex_t *spattern = (regex_t *) pattern;
+#endif
+#if HAVE_PCRE
+ pcre *spattern = (pcre *) pattern;
+#endif
+#if HAVE_RE_COMP
+ int spattern = (int) pattern;
+#endif
+#if HAVE_REGCMP
+ char *spattern = (char *) pattern;
+#endif
+#if HAVE_V8_REGCOMP
+ struct regexp *spattern = (struct regexp *) pattern;
+#endif
+
+ if (search_type & SRCH_NO_REGEX)
+ matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep);
+ else
+ {
+#if HAVE_POSIX_REGCOMP
+ {
+ regmatch_t rm;
+ int flags = (notbol) ? REG_NOTBOL : 0;
+ matched = !regexec(spattern, line, 1, &rm, flags);
+ if (matched)
+ {
+#ifndef __WATCOMC__
+ *sp = line + rm.rm_so;
+ *ep = line + rm.rm_eo;
+#else
+ *sp = rm.rm_sp;
+ *ep = rm.rm_ep;
+#endif
+ }
+ }
+#endif
+#if HAVE_PCRE
+ {
+ int flags = (notbol) ? PCRE_NOTBOL : 0;
+ int ovector[3];
+ matched = pcre_exec(spattern, NULL, line, line_len,
+ 0, flags, ovector, 3) >= 0;
+ if (matched)
+ {
+ *sp = line + ovector[0];
+ *ep = line + ovector[1];
+ }
+ }
+#endif
+#if HAVE_RE_COMP
+ matched = (re_exec(line) == 1);
+ /*
+ * re_exec doesn't seem to provide a way to get the matched string.
+ */
+ *sp = *ep = NULL;
+#endif
+#if HAVE_REGCMP
+ *ep = regex(spattern, line);
+ matched = (*ep != NULL);
+ if (matched)
+ *sp = __loc1;
+#endif
+#if HAVE_V8_REGCOMP
+#if HAVE_REGEXEC2
+ matched = regexec2(spattern, line, notbol);
+#else
+ matched = regexec(spattern, line);
+#endif
+ if (matched)
+ {
+ *sp = spattern->startp[0];
+ *ep = spattern->endp[0];
+ }
+#endif
+#if NO_REGEX
+ matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep);
+#endif
+ }
+ matched = (!(search_type & SRCH_NO_MATCH) && matched) ||
+ ((search_type & SRCH_NO_MATCH) && !matched);
+ return (matched);
+}
+
diff --git a/usr.bin/less/pattern.h b/usr.bin/less/pattern.h
new file mode 100644
index 00000000000..3b44e2ddedb
--- /dev/null
+++ b/usr.bin/less/pattern.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 1984-2011 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.
+ */
+
+#if HAVE_POSIX_REGCOMP
+#include <regex.h>
+#ifdef REG_EXTENDED
+#define REGCOMP_FLAG REG_EXTENDED
+#else
+#define REGCOMP_FLAG 0
+#endif
+#define DEFINE_PATTERN(name) regex_t *name
+#define CLEAR_PATTERN(name) name = NULL
+#endif
+
+#if HAVE_PCRE
+#include <pcre.h>
+#define DEFINE_PATTERN(name) pcre *name
+#define CLEAR_PATTERN(name) name = NULL
+#endif
+
+#if HAVE_RE_COMP
+char *re_comp();
+int re_exec();
+#define DEFINE_PATTERN(name) int name
+#define CLEAR_PATTERN(name) name = 0
+#endif
+
+#if HAVE_REGCMP
+char *regcmp();
+char *regex();
+extern char *__loc1;
+#define DEFINE_PATTERN(name) char *name
+#define CLEAR_PATTERN(name) name = NULL
+#endif
+
+#if HAVE_V8_REGCOMP
+#include "regexp.h"
+#define DEFINE_PATTERN(name) struct regexp *name
+#define CLEAR_PATTERN(name) name = NULL
+#endif
+
diff --git a/usr.bin/less/pckeys.h b/usr.bin/less/pckeys.h
index 723df550f98..3708d85f43d 100644
--- a/usr.bin/less/pckeys.h
+++ b/usr.bin/less/pckeys.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2002 Mark Nudelman
+ * Copyright (C) 1984-2011 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.
diff --git a/usr.bin/less/scrsize.c b/usr.bin/less/scrsize.c
index 9af7e345cae..05d041ee5fb 100644
--- a/usr.bin/less/scrsize.c
+++ b/usr.bin/less/scrsize.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2002 Mark Nudelman
+ * Copyright (C) 1984-2011 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.