mirror of
https://github.com/darlinghq/darling-less.git
synced 2024-11-23 03:59:39 +00:00
less-34
This commit is contained in:
parent
5c07aa1ebf
commit
b54962c71d
@ -1,4 +1,3 @@
|
||||
ARCHS = $(ARCHS_STANDARD_32_64_BIT);
|
||||
CODE_SIGN_IDENTITY = -;
|
||||
CURRENT_PROJECT_VERSION = $(RC_ProjectSourceVersion);
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
|
32
less.plist
32
less.plist
@ -1,25 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>OpenSourceProject</key>
|
||||
<string>less</string>
|
||||
<key>OpenSourceVersion</key>
|
||||
<string>418</string>
|
||||
<key>OpenSourceWebsiteURL</key>
|
||||
<string>http://www.greenwoodsoftware.com/less/</string>
|
||||
<key>OpenSourceURL</key>
|
||||
<string>http://www.greenwoodsoftware.com/less/less-418.tar.gz</string>
|
||||
<key>OpenSourceSHA1</key>
|
||||
<string>ec4fb48680878a7ac3499c46564c47c448b0aa22</string>
|
||||
<key>OpenSourceImportDate</key>
|
||||
<string>2008-02-21</string>
|
||||
<string>2017-04-10</string>
|
||||
<key>OpenSourceLicense</key>
|
||||
<string>other</string>
|
||||
<key>OpenSourceLicenseFile</key>
|
||||
<string>less.txt</string>
|
||||
<key>OpenSourceModifications</key>
|
||||
<array>
|
||||
<string>Patched to remain compatible with more(1).</string>
|
||||
<string>call get_term() after determining that less_is_more</string>
|
||||
</array>
|
||||
<key>OpenSourceLicense</key>
|
||||
<string>Less License</string>
|
||||
<key>OpenSourceLicenseFile</key>
|
||||
<string>less.txt</string>
|
||||
<key>OpenSourceProject</key>
|
||||
<string>less</string>
|
||||
<key>OpenSourceSHA512</key>
|
||||
<string>d31274fdada570fbc6706d7c52637d1accbd18ce947ec062e10b1624c251a8533c6638bc3a1d89d3c70a0c7b9c6d45740598bec9003f281d64c587b1f829125a</string>
|
||||
<key>OpenSourceURL</key>
|
||||
<string>http://www.greenwoodsoftware.com/less/less-487.tar.gz</string>
|
||||
<key>OpenSourceVersion</key>
|
||||
<string>481</string>
|
||||
<key>OpenSourceWebsiteURL</key>
|
||||
<string>http://www.greenwoodsoftware.com/less/</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 45;
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXAggregateTarget section */
|
||||
@ -29,6 +29,8 @@
|
||||
590CF72F10323D62007112A1 /* less.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 590CF72E10323D52007112A1 /* less.1 */; };
|
||||
590CF74B103246A7007112A1 /* less.txt in OSLicense */ = {isa = PBXBuildFile; fileRef = 590CF74A103246A7007112A1 /* less.txt */; };
|
||||
590CF752103246E7007112A1 /* less.plist in OSVersion */ = {isa = PBXBuildFile; fileRef = 590CF71510323386007112A1 /* less.plist */; };
|
||||
597A0FF619AFEF9F007468CF /* cvt.c in Sources */ = {isa = PBXBuildFile; fileRef = 597A0FF519AFEF59007468CF /* cvt.c */; };
|
||||
597A0FF719AFEFA4007468CF /* pattern.c in Sources */ = {isa = PBXBuildFile; fileRef = 597A0FF319AFEF1F007468CF /* pattern.c */; };
|
||||
59DE08BE10322DAE00739622 /* lessecho.c in Sources */ = {isa = PBXBuildFile; fileRef = 59F9B4071031F8E900A58A17 /* lessecho.c */; };
|
||||
59F9B4371031F8E900A58A17 /* brac.c in Sources */ = {isa = PBXBuildFile; fileRef = 59F9B3EA1031F8E900A58A17 /* brac.c */; };
|
||||
59F9B4381031F8E900A58A17 /* ch.c in Sources */ = {isa = PBXBuildFile; fileRef = 59F9B3EB1031F8E900A58A17 /* ch.c */; };
|
||||
@ -131,6 +133,9 @@
|
||||
590CF71C10323511007112A1 /* lessecho.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = lessecho.1; sourceTree = "<group>"; };
|
||||
590CF72E10323D52007112A1 /* less.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = less.1; sourceTree = "<group>"; };
|
||||
590CF74A103246A7007112A1 /* less.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = less.txt; sourceTree = "<group>"; };
|
||||
597A0FF319AFEF1F007468CF /* pattern.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pattern.c; sourceTree = "<group>"; };
|
||||
597A0FF419AFEF1F007468CF /* pattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pattern.h; sourceTree = "<group>"; };
|
||||
597A0FF519AFEF59007468CF /* cvt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cvt.c; sourceTree = "<group>"; };
|
||||
59DE08BB10322DA000739622 /* lessecho */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lessecho; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
59DE08C210322EA000739622 /* defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = defines.h; sourceTree = "<group>"; };
|
||||
59F9B3E81031F88400A58A17 /* BSD.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = BSD.xcconfig; sourceTree = "<group>"; };
|
||||
@ -150,10 +155,6 @@
|
||||
59F9B4061031F8E900A58A17 /* less.nro */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = less.nro; sourceTree = "<group>"; };
|
||||
59F9B4071031F8E900A58A17 /* lessecho.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lessecho.c; sourceTree = "<group>"; };
|
||||
59F9B4091031F8E900A58A17 /* lessecho.nro */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = lessecho.nro; sourceTree = "<group>"; };
|
||||
59F9B40A1031F8E900A58A17 /* lesskey.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lesskey.c; sourceTree = "<group>"; };
|
||||
59F9B40B1031F8E900A58A17 /* lesskey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lesskey.h; sourceTree = "<group>"; };
|
||||
59F9B40C1031F8E900A58A17 /* lesskey.man */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = lesskey.man; sourceTree = "<group>"; };
|
||||
59F9B40D1031F8E900A58A17 /* lesskey.nro */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = lesskey.nro; sourceTree = "<group>"; };
|
||||
59F9B40E1031F8E900A58A17 /* lglob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lglob.h; sourceTree = "<group>"; };
|
||||
59F9B40F1031F8E900A58A17 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
|
||||
59F9B4101031F8E900A58A17 /* line.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = line.c; sourceTree = "<group>"; };
|
||||
@ -231,6 +232,9 @@
|
||||
59F9B3E91031F8E900A58A17 /* less */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
597A0FF519AFEF59007468CF /* cvt.c */,
|
||||
597A0FF319AFEF1F007468CF /* pattern.c */,
|
||||
597A0FF419AFEF1F007468CF /* pattern.h */,
|
||||
59F9B3EA1031F8E900A58A17 /* brac.c */,
|
||||
59F9B3EB1031F8E900A58A17 /* ch.c */,
|
||||
59F9B3EC1031F8E900A58A17 /* charset.c */,
|
||||
@ -247,10 +251,6 @@
|
||||
59F9B4061031F8E900A58A17 /* less.nro */,
|
||||
59F9B4071031F8E900A58A17 /* lessecho.c */,
|
||||
59F9B4091031F8E900A58A17 /* lessecho.nro */,
|
||||
59F9B40A1031F8E900A58A17 /* lesskey.c */,
|
||||
59F9B40B1031F8E900A58A17 /* lesskey.h */,
|
||||
59F9B40C1031F8E900A58A17 /* lesskey.man */,
|
||||
59F9B40D1031F8E900A58A17 /* lesskey.nro */,
|
||||
59F9B40E1031F8E900A58A17 /* lglob.h */,
|
||||
59F9B40F1031F8E900A58A17 /* LICENSE */,
|
||||
59F9B4101031F8E900A58A17 /* line.c */,
|
||||
@ -330,9 +330,16 @@
|
||||
/* Begin PBXProject section */
|
||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0600;
|
||||
};
|
||||
buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "less" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 08FB7794FE84155DC02AAC07 /* less */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
@ -375,6 +382,8 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
597A0FF719AFEFA4007468CF /* pattern.c in Sources */,
|
||||
597A0FF619AFEF9F007468CF /* cvt.c in Sources */,
|
||||
59F9B4371031F8E900A58A17 /* brac.c in Sources */,
|
||||
59F9B4381031F8E900A58A17 /* ch.c in Sources */,
|
||||
59F9B4391031F8E900A58A17 /* charset.c in Sources */,
|
||||
@ -444,7 +453,6 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 59F9B3E81031F88400A58A17 /* BSD.xcconfig */;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
|
0
less/INSTALL
Executable file → Normal file
0
less/INSTALL
Executable file → Normal file
2
less/LICENSE
Executable file → Normal file
2
less/LICENSE
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
------------
|
||||
|
||||
Less
|
||||
Copyright (C) 1984-2007 Mark Nudelman
|
||||
Copyright (C) 1984-2016 Mark Nudelman
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
47
less/Makefile.aut
Executable file → Normal file
47
less/Makefile.aut
Executable file → Normal file
@ -1,6 +1,6 @@
|
||||
# Makefile for authoring less.
|
||||
|
||||
EMAIL = markn@greenwoodsoftware.com
|
||||
EMAIL = bug-less@gnu.org
|
||||
HOMEPAGE = http://www.greenwoodsoftware.com/less
|
||||
SHELL = /bin/sh
|
||||
RCS = rcs
|
||||
@ -10,34 +10,47 @@ 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 \
|
||||
tags.c ttyin.c version.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 \
|
||||
defines.o2 Makefile.o2e \
|
||||
defines.o9 Makefile.o9c Makefile.o9u \
|
||||
defines.wn Makefile.wnm Makefile.wnb
|
||||
defines.wn Makefile.wnm Makefile.wnb \
|
||||
configure
|
||||
UNICODE_FILES = \
|
||||
compose.uni ubin.uni wide.uni
|
||||
DISTFILES = \
|
||||
${SRC} regexp.c regexp.h \
|
||||
COPYING INSTALL LICENSE Makefile.in Makefile.aut NEWS README \
|
||||
configure configure.ac lesskey.c lessecho.c scrsize.c \
|
||||
charset.h cmd.h funcs.h lglob.h less.h lesskey.h option.h pckeys.h position.h \
|
||||
configure.ac lesskey.c lessecho.c scrsize.c \
|
||||
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 less.man lesskey.nro lesskey.man lessecho.nro lessecho.man \
|
||||
less.hlp \
|
||||
mkfuncs.awk mkhelp.c \
|
||||
mkutable $(UNICODE_FILES) \
|
||||
${DISTFILES_W}
|
||||
|
||||
all: help.c funcs.h ${srcdir}/configure
|
||||
all: help.c funcs.h $(UNICODE_FILES) ${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
|
||||
./mkhelp < less.hlp > help.c
|
||||
if cmp -s help.c help.c.old; then mv help.c.old help.c; fi
|
||||
if cmp -s help.c help.c.old; then mv -f help.c.old help.c; fi
|
||||
|
||||
mkhelp: mkhelp.c
|
||||
${CC} -o mkhelp mkhelp.c
|
||||
@ -49,7 +62,7 @@ ${srcdir}/configure: ${srcdir}/configure.ac \
|
||||
funcs.h: ${SRC:%=${srcdir}/%}
|
||||
-mv -f ${srcdir}/funcs.h ${srcdir}/funcs.h.old
|
||||
awk -f ${srcdir}/mkfuncs.awk ${SRC:%=${srcdir}/%} >${srcdir}/funcs.h
|
||||
if cmp -s funcs.h funcs.h.old; then mv funcs.h.old funcs.h; fi
|
||||
if cmp -s funcs.h funcs.h.old; then mv -f funcs.h.old funcs.h; fi
|
||||
|
||||
lint:
|
||||
lint -I. ${CPPFLAGS} ${SRC}
|
||||
@ -66,6 +79,7 @@ REPLACE_VERSION = \
|
||||
@REL=`sed -e '/char version/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q ${srcdir}/version.c`; \
|
||||
DT=`date '+%d %h %Y'`; \
|
||||
echo "Stuffing version number $$REL into $@"; \
|
||||
rm -f $@; \
|
||||
sed \
|
||||
-e "s;@@VERSION@@;$$REL;" \
|
||||
-e "s;@@DATE@@;$$DT;" \
|
||||
@ -92,6 +106,12 @@ ${srcdir}/lesskey.man: ${srcdir}/lesskey.nro
|
||||
${srcdir}/lessecho.man: ${srcdir}/lessecho.nro
|
||||
${NROFF} ${srcdir}/lessecho.nro >${srcdir}/lessecho.man
|
||||
|
||||
compose.uni: unicode/UnicodeData.txt
|
||||
./mkutable -f2 Mn Me -- unicode/UnicodeData.txt > $@
|
||||
ubin.uni: unicode/UnicodeData.txt
|
||||
./mkutable -f2 Cc Cf Cs Co Zl Zp -- unicode/UnicodeData.txt > $@
|
||||
wide.uni: unicode/EastAsianWidth.txt
|
||||
./mkutable -f1 W F -- unicode/EastAsianWidth.txt > $@
|
||||
|
||||
distfiles: ${DISTFILES}
|
||||
|
||||
@ -103,12 +123,13 @@ dist: ${DISTFILES}
|
||||
echo "Preparing $$REL"; \
|
||||
rm -rf $$REL; mkdir $$REL; \
|
||||
for file in ${DISTFILES}; do \
|
||||
cp -p $$file $$REL; \
|
||||
chmod -w $$REL/$$file; \
|
||||
./add_copyright $$file $$REL; \
|
||||
done; \
|
||||
cd $$REL; chmod +w ${DISTFILES_W}; cd ..; \
|
||||
cd $$REL; chmod -w *; chmod +w ${DISTFILES_W}; chmod +x configure; 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
|
||||
|
13
less/Makefile.dsb
Executable file → Normal file
13
less/Makefile.dsb
Executable file → Normal file
@ -18,12 +18,13 @@ EXT = .EXE
|
||||
.c.obj:
|
||||
$(CC) -c -I. $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.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 \
|
||||
position.obj prompt.obj search.obj signal.obj tags.obj \
|
||||
ttyin.obj version.obj
|
||||
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)
|
||||
|
||||
|
7
less/Makefile.dsg
Executable file → Normal file
7
less/Makefile.dsg
Executable file → Normal file
@ -33,11 +33,12 @@ manext = 1
|
||||
.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} decode.${O} edit.${O} filename.${O} forwback.${O} \
|
||||
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} position.${O} prompt.${O} search.${O} signal.${O} \
|
||||
output.${O} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
|
||||
tags.${O} ttyin.${O} version.${O}
|
||||
|
||||
all: less lesskey lessecho
|
||||
|
13
less/Makefile.dsu
Executable file → Normal file
13
less/Makefile.dsu
Executable file → Normal file
@ -27,12 +27,13 @@ LIBS = $(LIBDIR)\llibce.lib $(LIBDIR)\graphics.lib
|
||||
.c.obj:
|
||||
$(CC) -c -I. -I$(INCDIR) $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.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 \
|
||||
position.obj prompt.obj search.obj signal.obj tags.obj \
|
||||
ttyin.obj version.obj
|
||||
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
|
||||
|
||||
|
7
less/Makefile.in
Executable file → Normal file
7
less/Makefile.in
Executable file → Normal file
@ -43,11 +43,12 @@ SHELL = /bin/sh
|
||||
.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} decode.${O} edit.${O} filename.${O} forwback.${O} \
|
||||
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} position.${O} prompt.${O} search.${O} signal.${O} \
|
||||
output.${O} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
|
||||
tags.${O} ttyin.${O} version.${O} @REGEX_O@
|
||||
|
||||
all: less$(EXEEXT) lesskey$(EXEEXT) lessecho$(EXEEXT)
|
||||
|
7
less/Makefile.o2e
Executable file → Normal file
7
less/Makefile.o2e
Executable file → Normal file
@ -18,11 +18,12 @@ O = obj
|
||||
.c.${O}:
|
||||
${CC} -c ${CPPFLAGS} ${CFLAGS} $<
|
||||
|
||||
OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
|
||||
command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
|
||||
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} position.${O} prompt.${O} search.${O} signal.${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
|
||||
|
7
less/Makefile.o9c
Executable file → Normal file
7
less/Makefile.o9c
Executable file → Normal file
@ -22,11 +22,12 @@ O = r
|
||||
.c.${O}:
|
||||
${CC} ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
|
||||
|
||||
OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
|
||||
command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
|
||||
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} position.${O} prompt.${O} search.${O} signal.${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
|
||||
|
7
less/Makefile.o9u
Executable file → Normal file
7
less/Makefile.o9u
Executable file → Normal file
@ -21,11 +21,12 @@ O = r
|
||||
.c.${O}:
|
||||
${CC} ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
|
||||
|
||||
OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
|
||||
command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
|
||||
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} position.${O} prompt.${O} search.${O} signal.${O} \
|
||||
output.${O} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \
|
||||
tags.${O} ttyin.${O} version.${O} regexp.${O}
|
||||
|
||||
all: less lesskey
|
||||
|
13
less/Makefile.wnb
Executable file → Normal file
13
less/Makefile.wnb
Executable file → Normal file
@ -25,12 +25,13 @@ LIBS = ${LIBDIR}\import32.lib ${LIBDIR}\cw32.lib
|
||||
.c.obj:
|
||||
${CC} -c -I. ${CPPFLAGS} ${CFLAGS} $<
|
||||
|
||||
OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.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 \
|
||||
position.obj prompt.obj search.obj signal.obj tags.obj \
|
||||
ttyin.obj version.obj regexp.obj
|
||||
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
|
||||
|
||||
|
26
less/Makefile.wnm
Executable file → Normal file
26
less/Makefile.wnm
Executable file → Normal file
@ -6,12 +6,12 @@
|
||||
CC = cl
|
||||
|
||||
# Normal flags
|
||||
CFLAGS = /nologo /ML /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c
|
||||
LDFLAGS = /subsystem:console /incremental:no /machine:I386
|
||||
CFLAGS = /nologo /MD /W3 /EHsc /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 = /subsystem:console /incremental:yes /debug /machine:I386
|
||||
#LDFLAGS = /nologo /subsystem:console /incremental:yes /debug /machine:I386
|
||||
|
||||
LD = link
|
||||
LIBS = user32.lib
|
||||
@ -20,23 +20,21 @@ LIBS = user32.lib
|
||||
|
||||
# This rule allows us to supply the necessary -D options
|
||||
# in addition to whatever the user asks for.
|
||||
.c.obj:
|
||||
.c.obj::
|
||||
$(CC) $(CFLAGS) $<
|
||||
|
||||
OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.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 \
|
||||
position.obj prompt.obj search.obj signal.obj tags.obj \
|
||||
ttyin.obj version.obj regexp.obj
|
||||
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:$@
|
||||
$(LD) $(LDFLAGS) $** $(LIBS) /out:$@
|
||||
|
||||
lesskey.exe: lesskey.obj version.obj
|
||||
$(LD) $(LDFLAGS) lesskey.obj version.obj $(LIBS) /out:$@
|
||||
|
198
less/NEWS
198
less/NEWS
@ -7,11 +7,205 @@
|
||||
http://www.greenwoodsoftware.com/less
|
||||
You can also download the latest version of less from there.
|
||||
|
||||
To report bugs, suggestions or comments, send email to
|
||||
bug-less@gnu.org or markn@greenwoodsoftware.com.
|
||||
To report bugs, suggestions or comments, send email to bug-less@gnu.org
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 481 and 487
|
||||
|
||||
* New commands ESC-{ and ESC-} to shift to start/end of displayed lines.
|
||||
|
||||
* Make search highlights work correctly when changing caselessness with -i.
|
||||
|
||||
* New option -Da in Windows version to enable SGR mode.
|
||||
|
||||
* Fix "nothing to search" error when top or bottom line on screen is empty.
|
||||
|
||||
* Fix bug when terminal has no "cm" termcap entry.
|
||||
|
||||
* Fix incorrect display when entering double-width chars in search string.
|
||||
|
||||
* Fix bug in Unicode handling that missed some double width characters.
|
||||
|
||||
* Update Unicode database to 9.0.0.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 458 and 481
|
||||
|
||||
* Don't overwrite history file; just append to it.
|
||||
|
||||
* New command ESC-G goes to end of currently buffered data in a pipe.
|
||||
|
||||
* Disable history feature when compiled with LESSHISTFILE set to "-".
|
||||
|
||||
* In more-compatible mode, make the -p option apply to every file opened,
|
||||
not just the first one.
|
||||
|
||||
* In more-compatible mode, change the -e option to work like -E, not -EF.
|
||||
|
||||
* Treat multiple CRs before LF are like one CR (all the CRs are hidden).
|
||||
|
||||
* Allow "extra" string in lesskey file to append to a multi-char command
|
||||
(like a search pattern), without executing the command.
|
||||
|
||||
* Ignore -u/-U setting while viewing help file, so that
|
||||
underline and bold chars are displayed correctly.
|
||||
|
||||
* Improve detection of "binary" files in UTF-8 mode.
|
||||
|
||||
* Fix bug with ++ commands.
|
||||
|
||||
* Fix bug where prompt was sometimes not displayed with +G.
|
||||
|
||||
* Fix possible memory corruption
|
||||
|
||||
* Fix bugs and improve performance in ampersand filtering.
|
||||
|
||||
* Automate construction of Unicode tables from Unicode database.
|
||||
|
||||
* Allow %% escape sequence in LESSOPEN variable.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 451 and 458
|
||||
|
||||
* Allow backslash escaping of metacharacters in LESS environment variable
|
||||
after the --use-backslash option.
|
||||
|
||||
* Don't quit if syntax errors are found in command line options.
|
||||
|
||||
* Increase sizes of some internal buffers.
|
||||
|
||||
* Fix configure bug with --with-regex=none.
|
||||
|
||||
* Fix crash with "stty rows 0".
|
||||
|
||||
* Fix Win32 attribute display bug.
|
||||
|
||||
* Fix display bug when using up/down arrow on the command line.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 444 and 451
|
||||
|
||||
* Add ESC-F command to keep reading data until a pattern is found.
|
||||
|
||||
* Use exit code of LESSOPEN script if LESSOPEN starts with "||".
|
||||
|
||||
* When up/down arrow is used on the command line immediately after
|
||||
typing text, the next command starting with that text is found.
|
||||
|
||||
* Add support for GNU regex.
|
||||
|
||||
* Add configure option --with-regex=none and fix compile errors
|
||||
when compiling with no regex library.
|
||||
|
||||
* Fix bugs handling SGR sequences in Win32.
|
||||
|
||||
* Fix possible crashes caused by malformed LESSOPEN or
|
||||
LESSCLOSE variables.
|
||||
|
||||
* Fix bug highlighting text which is discontiguous in the file
|
||||
due to backspace processing.
|
||||
|
||||
* Fix bug in displaying status column when scrolling backwards
|
||||
with -J and -S in effect.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 443 and 444
|
||||
|
||||
* Fix bug in unget handling that can cause strange effects on the
|
||||
command line.
|
||||
|
||||
* Remove vestiges of obsolete -l option that can cause a crash.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 436 and 443
|
||||
|
||||
* Change search behavior such that when a search is given an explicit
|
||||
pattern, the entire displayed screen is included in the search and
|
||||
not just the portion after the target line.
|
||||
|
||||
* Add -A option to change search behavior to the old way: only
|
||||
the portion of the screen after the target line is searched.
|
||||
|
||||
* Add %F formatting to prompt strings, replaced by the last component
|
||||
of the input file.
|
||||
|
||||
* Control-G while editing a command exits the command.
|
||||
|
||||
* Less now exits with status 2 if control-C is pressed and -K is in effect.
|
||||
|
||||
* Fix "ungetc overflow" when passing long commands via the -p option.
|
||||
|
||||
* Fix bug in using line filtering via the & command
|
||||
in combination with -i and -I.
|
||||
|
||||
* Fix bug in handling negative arguments to the -j option.
|
||||
|
||||
* Fix bug in handling %t in prompt strings.
|
||||
|
||||
* Improve handling of long option names.
|
||||
|
||||
* Improve percentage calculation for very large files.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 429 and 436
|
||||
|
||||
* Don't pass "-" to non-pipe LESSOPEN unless it starts with "-".
|
||||
|
||||
* Allow a fraction as the argument to the -# (--shift) option.
|
||||
|
||||
* Fix highlight bug when underlined/overstruck text matches at end of line.
|
||||
|
||||
* Fix non-regex searches with ctrl-R.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 424 and 429
|
||||
|
||||
* LESSOPEN pipe will now be used on standard input, if the LESSOPEN
|
||||
environment variable begins with "|-".
|
||||
|
||||
* The -D option with one number now means use the normal background color.
|
||||
|
||||
* Don't change permissions on history file if it is not a regular file.
|
||||
|
||||
* Fix non-ANSI-compliant code that caused problems with some compilers.
|
||||
|
||||
* Fix binary file detection in UTF-8 mode.
|
||||
|
||||
* Fix display problems with long lines on "ignaw" terminals.
|
||||
|
||||
* Fix problem interrupting the line number calculation for initial prompt.
|
||||
|
||||
* Fix SGR emulation when dealing with multiple attributes (eg. bold+underline).
|
||||
|
||||
* Fix highlight bug when searching for underlined/overstruck text.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 418 and 424
|
||||
|
||||
* New "&" command allows filtering of lines based on a pattern.
|
||||
|
||||
* Status column now displays a search match, even if the matched
|
||||
string is scrolled off screen because -S is in effect.
|
||||
|
||||
* Improve behavior of -F option.
|
||||
|
||||
* Allow CSI character (0x9B) to work in UTF-8 mode.
|
||||
|
||||
* Output carriage return at startup in case terminal doesn't default
|
||||
to column 1.
|
||||
|
||||
* Fix bug in '' (quote, quote) command after G command.
|
||||
|
||||
======================================================================
|
||||
|
||||
Major changes between "less" versions 416 and 418
|
||||
|
||||
|
20
less/README
20
less/README
@ -1,7 +1,7 @@
|
||||
|
||||
Less, version 418
|
||||
Less, version 487
|
||||
|
||||
This is the distribution of less, version 418, released 02 Jan 2008.
|
||||
This is the distribution of less, version 487, released 25 Oct 2016.
|
||||
This program is part of the GNU project (http://www.gnu.org).
|
||||
|
||||
This program is free software. You may redistribute it and/or
|
||||
@ -13,7 +13,7 @@
|
||||
or
|
||||
2. The Less License, in the file LICENSE.
|
||||
|
||||
Please report any problems to bug-less@gnu.org or markn@greenwoodsoftware.com.
|
||||
Please report any problems to bug-less@gnu.org.
|
||||
See http://www.greenwoodsoftware.com/less for the latest info.
|
||||
|
||||
=========================================================================
|
||||
@ -45,17 +45,19 @@ INSTALLATION (Unix systems only):
|
||||
Specifies the regular expression library used by less for pattern
|
||||
matching. The default is "auto", which means the configure program
|
||||
finds a regular expression library automatically. Other values are:
|
||||
posix Use the POSIX-compatible regcomp.
|
||||
gnu Use the GNU regex library.
|
||||
pcre Use the PCRE library.
|
||||
posix Use the POSIX-compatible regcomp.
|
||||
regcmp Use the regcmp library.
|
||||
re_comp Use the re_comp library.
|
||||
regcomp Use the V8-compatible regcomp.
|
||||
regcomp-local Use Henry Spencer's V8-compatible regcomp
|
||||
(source is supplied with less).
|
||||
none No regular expressions, only simple string matching.
|
||||
--with-secure
|
||||
Builds a "secure" version of less, with some features disabled
|
||||
to prevent users from viewing other files, accessing shell
|
||||
commands, etc.
|
||||
to prevent users from viewing other files, accessing shell
|
||||
commands, etc.
|
||||
|
||||
|
||||
3. It is a good idea to look over the generated Makefile and defines.h
|
||||
@ -88,11 +90,15 @@ INSTALLATION (Unix systems only):
|
||||
bindir and/or mandir to the appropriate directories.
|
||||
|
||||
If you have any problems building or running "less", suggestions,
|
||||
complaints, etc., you may mail to the author at markn@greenwoodsoftware.com.
|
||||
complaints, etc., you may mail to bug-less@gnu.org.
|
||||
|
||||
Note to hackers: comments noting possible improvements are enclosed
|
||||
in double curly brackets {{ like this }}.
|
||||
|
||||
(Note that the above note was originally written at a time when
|
||||
"hackers" most commonly meant "enthusiastic and dedicated computer
|
||||
programmers", not "persons who attempt to circumvent computer security".)
|
||||
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
5
less/brac.c
Executable file → Normal file
5
less/brac.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
|
299
less/ch.c
Executable file → Normal file
299
less/ch.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -37,29 +36,28 @@ public int ignore_eoi;
|
||||
* in order from most- to least-recently used.
|
||||
* The circular list is anchored by the file state "thisfile".
|
||||
*/
|
||||
struct bufnode {
|
||||
struct bufnode *next, *prev;
|
||||
struct bufnode *hnext, *hprev;
|
||||
};
|
||||
|
||||
#define LBUFSIZE 8192
|
||||
struct buf {
|
||||
struct buf *next, *prev;
|
||||
struct buf *hnext, *hprev;
|
||||
struct bufnode node;
|
||||
BLOCKNUM block;
|
||||
unsigned int datasize;
|
||||
unsigned char data[LBUFSIZE];
|
||||
};
|
||||
|
||||
struct buflist {
|
||||
/* -- Following members must match struct buf */
|
||||
struct buf *buf_next, *buf_prev;
|
||||
struct buf *buf_hnext, *buf_hprev;
|
||||
};
|
||||
#define bufnode_buf(bn) ((struct buf *) bn)
|
||||
|
||||
/*
|
||||
* The file state is maintained in a filestate structure.
|
||||
* A pointer to the filestate is kept in the ifile structure.
|
||||
*/
|
||||
#define BUFHASH_SIZE 64
|
||||
#define BUFHASH_SIZE 1024
|
||||
struct filestate {
|
||||
struct buf *buf_next, *buf_prev;
|
||||
struct buflist hashtbl[BUFHASH_SIZE];
|
||||
struct bufnode buflist;
|
||||
struct bufnode hashtbl[BUFHASH_SIZE];
|
||||
int file;
|
||||
int flags;
|
||||
POSITION fpos;
|
||||
@ -69,8 +67,8 @@ struct filestate {
|
||||
POSITION fsize;
|
||||
};
|
||||
|
||||
#define ch_bufhead thisfile->buf_next
|
||||
#define ch_buftail thisfile->buf_prev
|
||||
#define ch_bufhead thisfile->buflist.next
|
||||
#define ch_buftail thisfile->buflist.prev
|
||||
#define ch_nbufs thisfile->nbufs
|
||||
#define ch_block thisfile->block
|
||||
#define ch_offset thisfile->offset
|
||||
@ -79,23 +77,48 @@ struct filestate {
|
||||
#define ch_flags thisfile->flags
|
||||
#define ch_file thisfile->file
|
||||
|
||||
#define END_OF_CHAIN ((struct buf *)&thisfile->buf_next)
|
||||
#define END_OF_HCHAIN(h) ((struct buf *)&thisfile->hashtbl[h])
|
||||
#define END_OF_CHAIN (&thisfile->buflist)
|
||||
#define END_OF_HCHAIN(h) (&thisfile->hashtbl[h])
|
||||
#define BUFHASH(blk) ((blk) & (BUFHASH_SIZE-1))
|
||||
|
||||
#define FOR_BUFS_IN_CHAIN(h,bp) \
|
||||
for (bp = thisfile->hashtbl[h].buf_hnext; \
|
||||
bp != END_OF_HCHAIN(h); bp = bp->hnext)
|
||||
/*
|
||||
* Macros to manipulate the list of buffers in thisfile->buflist.
|
||||
*/
|
||||
#define FOR_BUFS(bn) \
|
||||
for (bn = ch_bufhead; bn != END_OF_CHAIN; bn = bn->next)
|
||||
|
||||
#define HASH_RM(bp) \
|
||||
(bp)->hnext->hprev = (bp)->hprev; \
|
||||
(bp)->hprev->hnext = (bp)->hnext;
|
||||
#define BUF_RM(bn) \
|
||||
(bn)->next->prev = (bn)->prev; \
|
||||
(bn)->prev->next = (bn)->next;
|
||||
|
||||
#define HASH_INS(bp,h) \
|
||||
(bp)->hnext = thisfile->hashtbl[h].buf_hnext; \
|
||||
(bp)->hprev = END_OF_HCHAIN(h); \
|
||||
thisfile->hashtbl[h].buf_hnext->hprev = (bp); \
|
||||
thisfile->hashtbl[h].buf_hnext = (bp);
|
||||
#define BUF_INS_HEAD(bn) \
|
||||
(bn)->next = ch_bufhead; \
|
||||
(bn)->prev = END_OF_CHAIN; \
|
||||
ch_bufhead->prev = (bn); \
|
||||
ch_bufhead = (bn);
|
||||
|
||||
#define BUF_INS_TAIL(bn) \
|
||||
(bn)->next = END_OF_CHAIN; \
|
||||
(bn)->prev = ch_buftail; \
|
||||
ch_buftail->next = (bn); \
|
||||
ch_buftail = (bn);
|
||||
|
||||
/*
|
||||
* Macros to manipulate the list of buffers in thisfile->hashtbl[n].
|
||||
*/
|
||||
#define FOR_BUFS_IN_CHAIN(h,bn) \
|
||||
for (bn = thisfile->hashtbl[h].hnext; \
|
||||
bn != END_OF_HCHAIN(h); bn = bn->hnext)
|
||||
|
||||
#define BUF_HASH_RM(bn) \
|
||||
(bn)->hnext->hprev = (bn)->hprev; \
|
||||
(bn)->hprev->hnext = (bn)->hnext;
|
||||
|
||||
#define BUF_HASH_INS(bn,h) \
|
||||
(bn)->hnext = thisfile->hashtbl[h].hnext; \
|
||||
(bn)->hprev = END_OF_HCHAIN(h); \
|
||||
thisfile->hashtbl[h].hnext->hprev = (bn); \
|
||||
thisfile->hashtbl[h].hnext = (bn);
|
||||
|
||||
static struct filestate *thisfile;
|
||||
static int ch_ungotchar = -1;
|
||||
@ -119,17 +142,12 @@ static int ch_addbuf();
|
||||
|
||||
/*
|
||||
* Get the character pointed to by the read pointer.
|
||||
* ch_get() is a macro which is more efficient to call
|
||||
* than fch_get (the function), in the usual case
|
||||
* that the block desired is at the head of the chain.
|
||||
*/
|
||||
#define ch_get() ((ch_block == ch_bufhead->block && \
|
||||
ch_offset < ch_bufhead->datasize) ? \
|
||||
ch_bufhead->data[ch_offset] : fch_get())
|
||||
int
|
||||
fch_get()
|
||||
ch_get()
|
||||
{
|
||||
register struct buf *bp;
|
||||
register struct bufnode *bn;
|
||||
register int n;
|
||||
register int slept;
|
||||
register int h;
|
||||
@ -139,52 +157,69 @@ fch_get()
|
||||
if (thisfile == NULL)
|
||||
return (EOI);
|
||||
|
||||
/*
|
||||
* Quick check for the common case where
|
||||
* the desired char is in the head buffer.
|
||||
*/
|
||||
if (ch_bufhead != END_OF_CHAIN)
|
||||
{
|
||||
bp = bufnode_buf(ch_bufhead);
|
||||
if (ch_block == bp->block && ch_offset < bp->datasize)
|
||||
return bp->data[ch_offset];
|
||||
}
|
||||
|
||||
slept = FALSE;
|
||||
|
||||
/*
|
||||
* Look for a buffer holding the desired block.
|
||||
*/
|
||||
h = BUFHASH(ch_block);
|
||||
FOR_BUFS_IN_CHAIN(h, bp)
|
||||
FOR_BUFS_IN_CHAIN(h, bn)
|
||||
{
|
||||
bp = bufnode_buf(bn);
|
||||
if (bp->block == ch_block)
|
||||
{
|
||||
if (ch_offset >= bp->datasize)
|
||||
/*
|
||||
* Need more data in this buffer.
|
||||
*/
|
||||
goto read_more;
|
||||
break;
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Block is not in a buffer.
|
||||
* Take the least recently used buffer
|
||||
* and read the desired block into it.
|
||||
* If the LRU buffer has data in it,
|
||||
* then maybe allocate a new buffer.
|
||||
*/
|
||||
if (ch_buftail == END_OF_CHAIN || ch_buftail->block != -1)
|
||||
if (bn == END_OF_HCHAIN(h))
|
||||
{
|
||||
/*
|
||||
* There is no empty buffer to use.
|
||||
* Allocate a new buffer if:
|
||||
* 1. We can't seek on this file and -b is not in effect; or
|
||||
* 2. We haven't allocated the max buffers for this file yet.
|
||||
* Block is not in a buffer.
|
||||
* Take the least recently used buffer
|
||||
* and read the desired block into it.
|
||||
* If the LRU buffer has data in it,
|
||||
* then maybe allocate a new buffer.
|
||||
*/
|
||||
if ((autobuf && !(ch_flags & CH_CANSEEK)) ||
|
||||
(maxbufs < 0 || ch_nbufs < maxbufs))
|
||||
if (ch_addbuf())
|
||||
/*
|
||||
* Allocation failed: turn off autobuf.
|
||||
*/
|
||||
autobuf = OPT_OFF;
|
||||
if (ch_buftail == END_OF_CHAIN ||
|
||||
bufnode_buf(ch_buftail)->block != -1)
|
||||
{
|
||||
/*
|
||||
* There is no empty buffer to use.
|
||||
* Allocate a new buffer if:
|
||||
* 1. We can't seek on this file and -b is not in effect; or
|
||||
* 2. We haven't allocated the max buffers for this file yet.
|
||||
*/
|
||||
if ((autobuf && !(ch_flags & CH_CANSEEK)) ||
|
||||
(maxbufs < 0 || ch_nbufs < maxbufs))
|
||||
if (ch_addbuf())
|
||||
/*
|
||||
* Allocation failed: turn off autobuf.
|
||||
*/
|
||||
autobuf = OPT_OFF;
|
||||
}
|
||||
bn = ch_buftail;
|
||||
bp = bufnode_buf(bn);
|
||||
BUF_HASH_RM(bn); /* Remove from old hash chain. */
|
||||
bp->block = ch_block;
|
||||
bp->datasize = 0;
|
||||
BUF_HASH_INS(bn, h); /* Insert into new hash chain. */
|
||||
}
|
||||
bp = ch_buftail;
|
||||
HASH_RM(bp); /* Remove from old hash chain. */
|
||||
bp->block = ch_block;
|
||||
bp->datasize = 0;
|
||||
HASH_INS(bp, h); /* Insert into new hash chain. */
|
||||
|
||||
read_more:
|
||||
pos = (ch_block * LBUFSIZE) + bp->datasize;
|
||||
@ -288,13 +323,16 @@ fch_get()
|
||||
#if HAVE_STAT_INO
|
||||
if (follow_mode == FOLLOW_NAME)
|
||||
{
|
||||
/* See whether the file's i-number has changed.
|
||||
/* See whether the file's i-number has changed,
|
||||
* or the file has shrunk.
|
||||
* If so, force the file to be closed and
|
||||
* reopened. */
|
||||
struct stat st;
|
||||
POSITION curr_pos = ch_tell();
|
||||
int r = stat(get_filename(curr_ifile), &st);
|
||||
if (r == 0 && (st.st_ino != curr_ino ||
|
||||
st.st_dev != curr_dev))
|
||||
st.st_dev != curr_dev ||
|
||||
(curr_pos != NULL_POSITION && st.st_size < curr_pos)))
|
||||
{
|
||||
/* screen_trashed=2 causes
|
||||
* make_display to reopen the file. */
|
||||
@ -309,24 +347,20 @@ fch_get()
|
||||
}
|
||||
|
||||
found:
|
||||
if (ch_bufhead != bp)
|
||||
if (ch_bufhead != bn)
|
||||
{
|
||||
/*
|
||||
* Move the buffer to the head of the buffer chain.
|
||||
* This orders the buffer chain, most- to least-recently used.
|
||||
*/
|
||||
bp->next->prev = bp->prev;
|
||||
bp->prev->next = bp->next;
|
||||
bp->next = ch_bufhead;
|
||||
bp->prev = END_OF_CHAIN;
|
||||
ch_bufhead->prev = bp;
|
||||
ch_bufhead = bp;
|
||||
BUF_RM(bn);
|
||||
BUF_INS_HEAD(bn);
|
||||
|
||||
/*
|
||||
* Move to head of hash chain too.
|
||||
*/
|
||||
HASH_RM(bp);
|
||||
HASH_INS(bp, h);
|
||||
BUF_HASH_RM(bn);
|
||||
BUF_HASH_INS(bn, h);
|
||||
}
|
||||
|
||||
if (ch_offset >= bp->datasize)
|
||||
@ -386,6 +420,7 @@ end_logfile()
|
||||
sync_logfile()
|
||||
{
|
||||
register struct buf *bp;
|
||||
register struct bufnode *bn;
|
||||
int warned = FALSE;
|
||||
BLOCKNUM block;
|
||||
BLOCKNUM nblocks;
|
||||
@ -393,24 +428,23 @@ sync_logfile()
|
||||
nblocks = (ch_fpos + LBUFSIZE - 1) / LBUFSIZE;
|
||||
for (block = 0; block < nblocks; block++)
|
||||
{
|
||||
for (bp = ch_bufhead; ; bp = bp->next)
|
||||
int wrote = FALSE;
|
||||
FOR_BUFS(bn)
|
||||
{
|
||||
if (bp == END_OF_CHAIN)
|
||||
{
|
||||
if (!warned)
|
||||
{
|
||||
error("Warning: log file is incomplete",
|
||||
NULL_PARG);
|
||||
warned = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
bp = bufnode_buf(bn);
|
||||
if (bp->block == block)
|
||||
{
|
||||
write(logfile, (char *) bp->data, bp->datasize);
|
||||
wrote = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!wrote && !warned)
|
||||
{
|
||||
error("Warning: log file is incomplete",
|
||||
NULL_PARG);
|
||||
warned = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,11 +458,13 @@ buffered(block)
|
||||
BLOCKNUM block;
|
||||
{
|
||||
register struct buf *bp;
|
||||
register struct bufnode *bn;
|
||||
register int h;
|
||||
|
||||
h = BUFHASH(block);
|
||||
FOR_BUFS_IN_CHAIN(h, bp)
|
||||
FOR_BUFS_IN_CHAIN(h, bn)
|
||||
{
|
||||
bp = bufnode_buf(bn);
|
||||
if (bp->block == block)
|
||||
return (TRUE);
|
||||
}
|
||||
@ -502,6 +538,32 @@ ch_end_seek()
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Seek to the last position in the file that is currently buffered.
|
||||
*/
|
||||
public int
|
||||
ch_end_buffer_seek()
|
||||
{
|
||||
register struct buf *bp;
|
||||
register struct bufnode *bn;
|
||||
POSITION buf_pos;
|
||||
POSITION end_pos;
|
||||
|
||||
if (thisfile == NULL || (ch_flags & CH_CANSEEK))
|
||||
return (ch_end_seek());
|
||||
|
||||
end_pos = 0;
|
||||
FOR_BUFS(bn)
|
||||
{
|
||||
bp = bufnode_buf(bn);
|
||||
buf_pos = (bp->block * LBUFSIZE) + bp->datasize;
|
||||
if (buf_pos > end_pos)
|
||||
end_pos = buf_pos;
|
||||
}
|
||||
|
||||
return (ch_seek(end_pos));
|
||||
}
|
||||
|
||||
/*
|
||||
* Seek to the beginning of the file, or as close to it as we can get.
|
||||
* We may not be able to seek there if input is a pipe and the
|
||||
@ -510,7 +572,8 @@ ch_end_seek()
|
||||
public int
|
||||
ch_beg_seek()
|
||||
{
|
||||
register struct buf *bp, *firstbp;
|
||||
register struct bufnode *bn;
|
||||
register struct bufnode *firstbn;
|
||||
|
||||
/*
|
||||
* Try a plain ch_seek first.
|
||||
@ -522,13 +585,15 @@ ch_beg_seek()
|
||||
* Can't get to position 0.
|
||||
* Look thru the buffers for the one closest to position 0.
|
||||
*/
|
||||
firstbp = bp = ch_bufhead;
|
||||
if (bp == END_OF_CHAIN)
|
||||
firstbn = ch_bufhead;
|
||||
if (firstbn == END_OF_CHAIN)
|
||||
return (1);
|
||||
while ((bp = bp->next) != END_OF_CHAIN)
|
||||
if (bp->block < firstbp->block)
|
||||
firstbp = bp;
|
||||
ch_block = firstbp->block;
|
||||
FOR_BUFS(bn)
|
||||
{
|
||||
if (bufnode_buf(bn)->block < bufnode_buf(firstbn)->block)
|
||||
firstbn = bn;
|
||||
}
|
||||
ch_block = bufnode_buf(firstbn)->block;
|
||||
ch_offset = 0;
|
||||
return (0);
|
||||
}
|
||||
@ -545,6 +610,8 @@ ch_length()
|
||||
return (NULL_POSITION);
|
||||
if (ch_flags & CH_HELPFILE)
|
||||
return (size_helpdata);
|
||||
if (ch_flags & CH_NODATA)
|
||||
return (0);
|
||||
return (ch_fsize);
|
||||
}
|
||||
|
||||
@ -628,7 +695,7 @@ ch_setbufspace(bufspace)
|
||||
public void
|
||||
ch_flush()
|
||||
{
|
||||
register struct buf *bp;
|
||||
register struct bufnode *bn;
|
||||
|
||||
if (thisfile == NULL)
|
||||
return;
|
||||
@ -646,8 +713,10 @@ ch_flush()
|
||||
/*
|
||||
* Initialize all the buffers.
|
||||
*/
|
||||
for (bp = ch_bufhead; bp != END_OF_CHAIN; bp = bp->next)
|
||||
bp->block = -1;
|
||||
FOR_BUFS(bn)
|
||||
{
|
||||
bufnode_buf(bn)->block = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Figure out the size of the file, if we can.
|
||||
@ -694,6 +763,7 @@ ch_flush()
|
||||
ch_addbuf()
|
||||
{
|
||||
register struct buf *bp;
|
||||
register struct bufnode *bn;
|
||||
|
||||
/*
|
||||
* Allocate and initialize a new buffer and link it
|
||||
@ -704,11 +774,10 @@ ch_addbuf()
|
||||
return (1);
|
||||
ch_nbufs++;
|
||||
bp->block = -1;
|
||||
bp->next = END_OF_CHAIN;
|
||||
bp->prev = ch_buftail;
|
||||
ch_buftail->next = bp;
|
||||
ch_buftail = bp;
|
||||
HASH_INS(bp, 0);
|
||||
bn = &bp->node;
|
||||
|
||||
BUF_INS_TAIL(bn);
|
||||
BUF_HASH_INS(bn, 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -722,8 +791,8 @@ init_hashtbl()
|
||||
|
||||
for (h = 0; h < BUFHASH_SIZE; h++)
|
||||
{
|
||||
thisfile->hashtbl[h].buf_hnext = END_OF_HCHAIN(h);
|
||||
thisfile->hashtbl[h].buf_hprev = END_OF_HCHAIN(h);
|
||||
thisfile->hashtbl[h].hnext = END_OF_HCHAIN(h);
|
||||
thisfile->hashtbl[h].hprev = END_OF_HCHAIN(h);
|
||||
}
|
||||
}
|
||||
|
||||
@ -733,14 +802,13 @@ init_hashtbl()
|
||||
static void
|
||||
ch_delbufs()
|
||||
{
|
||||
register struct buf *bp;
|
||||
register struct bufnode *bn;
|
||||
|
||||
while (ch_bufhead != END_OF_CHAIN)
|
||||
{
|
||||
bp = ch_bufhead;
|
||||
bp->next->prev = bp->prev;
|
||||
bp->prev->next = bp->next;
|
||||
free(bp);
|
||||
bn = ch_bufhead;
|
||||
BUF_RM(bn);
|
||||
free(bufnode_buf(bn));
|
||||
}
|
||||
ch_nbufs = 0;
|
||||
init_hashtbl();
|
||||
@ -767,6 +835,17 @@ seekable(f)
|
||||
return (lseek(f, (off_t)1, SEEK_SET) != BAD_LSEEK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Force EOF to be at the current read position.
|
||||
* This is used after an ignore_eof read, during which the EOF may change.
|
||||
*/
|
||||
public void
|
||||
ch_set_eof()
|
||||
{
|
||||
ch_fsize = ch_fpos;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize file state for a new file.
|
||||
*/
|
||||
@ -786,7 +865,7 @@ ch_init(f, flags)
|
||||
*/
|
||||
thisfile = (struct filestate *)
|
||||
calloc(1, sizeof(struct filestate));
|
||||
thisfile->buf_next = thisfile->buf_prev = END_OF_CHAIN;
|
||||
thisfile->buflist.next = thisfile->buflist.prev = END_OF_CHAIN;
|
||||
thisfile->nbufs = 0;
|
||||
thisfile->flags = 0;
|
||||
thisfile->fpos = 0;
|
||||
@ -867,6 +946,7 @@ ch_getflags()
|
||||
ch_dump(struct filestate *fs)
|
||||
{
|
||||
struct buf *bp;
|
||||
struct bufnode *bn;
|
||||
unsigned char *s;
|
||||
|
||||
if (fs == NULL)
|
||||
@ -878,8 +958,9 @@ ch_dump(struct filestate *fs)
|
||||
fs->file, fs->flags, fs->fpos,
|
||||
fs->fsize, fs->block, fs->offset);
|
||||
printf(" %d bufs:\n", fs->nbufs);
|
||||
for (bp = fs->buf_next; bp != (struct buf *)fs; bp = bp->next)
|
||||
for (bn = fs->next; bn != &fs->buflist; bn = bn->next)
|
||||
{
|
||||
bp = bufnode_buf(bn);
|
||||
printf("%x: blk %x, size %x \"",
|
||||
bp, bp->block, bp->datasize);
|
||||
for (s = bp->data; s < bp->data + 30; s++)
|
||||
|
500
less/charset.c
Executable file → Normal file
500
less/charset.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -65,6 +64,8 @@ struct cs_alias {
|
||||
char *oname;
|
||||
} cs_aliases[] = {
|
||||
{ "UTF-8", "utf-8" },
|
||||
{ "utf8", "utf-8" },
|
||||
{ "UTF8", "utf-8" },
|
||||
{ "ANSI_X3.4-1968", "ascii" },
|
||||
{ "US-ASCII", "ascii" },
|
||||
{ "latin1", "iso8859" },
|
||||
@ -393,8 +394,10 @@ init_charset()
|
||||
*/
|
||||
public int
|
||||
binary_char(c)
|
||||
unsigned char c;
|
||||
LWCHAR c;
|
||||
{
|
||||
if (utf_mode)
|
||||
return (is_ubin_char(c));
|
||||
c &= 0377;
|
||||
return (chardef[c] & IS_BINARY_CHAR);
|
||||
}
|
||||
@ -404,7 +407,7 @@ binary_char(c)
|
||||
*/
|
||||
public int
|
||||
control_char(c)
|
||||
int c;
|
||||
LWCHAR c;
|
||||
{
|
||||
c &= 0377;
|
||||
return (chardef[c] & IS_CONTROL_CHAR);
|
||||
@ -416,14 +419,14 @@ control_char(c)
|
||||
*/
|
||||
public char *
|
||||
prchar(c)
|
||||
int c;
|
||||
LWCHAR c;
|
||||
{
|
||||
/* {{ This buffer can be overrun if LESSBINFMT is a long string. }} */
|
||||
static char buf[32];
|
||||
|
||||
c &= 0377;
|
||||
if ((c < 128 || !utf_mode) && !control_char(c))
|
||||
SNPRINTF1(buf, sizeof(buf), "%c", c);
|
||||
SNPRINTF1(buf, sizeof(buf), "%c", (int) c);
|
||||
else if (c == ESC)
|
||||
strcpy(buf, "ESC");
|
||||
#if IS_EBCDIC_HOST
|
||||
@ -440,7 +443,7 @@ prchar(c)
|
||||
"..V....D....TU.Z"[c]);
|
||||
#else
|
||||
else if (c < 128 && !control_char(c ^ 0100))
|
||||
SNPRINTF1(buf, sizeof(buf), "^%c", c ^ 0100);
|
||||
SNPRINTF1(buf, sizeof(buf), "^%c", (int) (c ^ 0100));
|
||||
#endif
|
||||
else
|
||||
SNPRINTF1(buf, sizeof(buf), binfmt, c);
|
||||
@ -465,36 +468,15 @@ prutfchar(ch)
|
||||
else
|
||||
SNPRINTF1(buf, sizeof(buf), binfmt, (char) ch);
|
||||
} else if (is_ubin_char(ch))
|
||||
SNPRINTF1(buf, sizeof(buf), utfbinfmt, ch);
|
||||
else
|
||||
{
|
||||
int len;
|
||||
SNPRINTF1(buf, sizeof(buf), utfbinfmt, ch);
|
||||
} else
|
||||
{
|
||||
char *p = buf;
|
||||
if (ch >= 0x80000000)
|
||||
{
|
||||
len = 3;
|
||||
ch = 0xFFFD;
|
||||
} else
|
||||
{
|
||||
len = (ch < 0x80) ? 1
|
||||
: (ch < 0x800) ? 2
|
||||
: (ch < 0x10000) ? 3
|
||||
: (ch < 0x200000) ? 4
|
||||
: (ch < 0x4000000) ? 5
|
||||
: 6;
|
||||
}
|
||||
buf[len] = '\0';
|
||||
if (len == 1)
|
||||
*buf = (char) ch;
|
||||
else
|
||||
{
|
||||
*buf = ((1 << len) - 1) << (8 - len);
|
||||
while (--len > 0)
|
||||
{
|
||||
buf[len] = (char) (0x80 | (ch & 0x3F));
|
||||
ch >>= 6;
|
||||
}
|
||||
*buf |= ch;
|
||||
}
|
||||
ch = 0xFFFD; /* REPLACEMENT CHARACTER */
|
||||
put_wchar(&p, ch);
|
||||
*p = '\0';
|
||||
}
|
||||
return (buf);
|
||||
}
|
||||
@ -523,11 +505,12 @@ utf_len(ch)
|
||||
}
|
||||
|
||||
/*
|
||||
* Is a UTF-8 character well-formed?
|
||||
* Does the parameter point to the lead byte of a well-formed UTF-8 character?
|
||||
*/
|
||||
public int
|
||||
is_utf8_well_formed(s)
|
||||
is_utf8_well_formed(s, slen)
|
||||
unsigned char *s;
|
||||
int slen;
|
||||
{
|
||||
int i;
|
||||
int len;
|
||||
@ -536,6 +519,8 @@ is_utf8_well_formed(s)
|
||||
return (0);
|
||||
|
||||
len = utf_len((char) s[0]);
|
||||
if (len > slen)
|
||||
return (0);
|
||||
if (len == 1)
|
||||
return (1);
|
||||
if (len == 2)
|
||||
@ -556,6 +541,35 @@ is_utf8_well_formed(s)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return number of invalid UTF-8 sequences found in a buffer.
|
||||
*/
|
||||
public int
|
||||
utf_bin_count(data, len)
|
||||
unsigned char *data;
|
||||
int len;
|
||||
{
|
||||
int bin_count = 0;
|
||||
while (len > 0)
|
||||
{
|
||||
if (is_utf8_well_formed(data, len))
|
||||
{
|
||||
int clen = utf_len(*data);
|
||||
data += clen;
|
||||
len -= clen;
|
||||
} else
|
||||
{
|
||||
/* Skip to next lead byte. */
|
||||
bin_count++;
|
||||
do {
|
||||
++data;
|
||||
--len;
|
||||
} while (len > 0 && !IS_UTF8_LEAD(*data));
|
||||
}
|
||||
}
|
||||
return (bin_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the value of a UTF-8 character.
|
||||
*/
|
||||
@ -705,407 +719,51 @@ step_char(pp, dir, limit)
|
||||
|
||||
/*
|
||||
* Unicode characters data
|
||||
* Actual data is in the generated *.uni files.
|
||||
*/
|
||||
struct wchar_range { LWCHAR first, last; };
|
||||
|
||||
/*
|
||||
* Characters with general category values
|
||||
* Mn: Mark, Nonspacing
|
||||
* Me: Mark, Enclosing
|
||||
* Last synched with
|
||||
* <http://www.unicode.org/Public/5.0.0/ucd/UnicodeData-5.0.0d7.txt>
|
||||
* dated 2005-11-30T00:58:48Z
|
||||
*/
|
||||
static struct wchar_range comp_table[] = {
|
||||
{ 0x0300, 0x036F} /* Mn */, { 0x0483, 0x0486} /* Mn */,
|
||||
{ 0x0488, 0x0489} /* Me */,
|
||||
{ 0x0591, 0x05BD} /* Mn */, { 0x05BF, 0x05BF} /* Mn */,
|
||||
{ 0x05C1, 0x05C2} /* Mn */, { 0x05C4, 0x05C5} /* Mn */,
|
||||
{ 0x05C7, 0x05C7} /* Mn */, { 0x0610, 0x0615} /* Mn */,
|
||||
{ 0x064B, 0x065E} /* Mn */, { 0x0670, 0x0670} /* Mn */,
|
||||
{ 0x06D6, 0x06DC} /* Mn */,
|
||||
{ 0x06DE, 0x06DE} /* Me */,
|
||||
{ 0x06DF, 0x06E4} /* Mn */, { 0x06E7, 0x06E8} /* Mn */,
|
||||
{ 0x06EA, 0x06ED} /* Mn */, { 0x0711, 0x0711} /* Mn */,
|
||||
{ 0x0730, 0x074A} /* Mn */, { 0x07A6, 0x07B0} /* Mn */,
|
||||
{ 0x07EB, 0x07F3} /* Mn */, { 0x0901, 0x0902} /* Mn */,
|
||||
{ 0x093C, 0x093C} /* Mn */, { 0x0941, 0x0948} /* Mn */,
|
||||
{ 0x094D, 0x094D} /* Mn */, { 0x0951, 0x0954} /* Mn */,
|
||||
{ 0x0962, 0x0963} /* Mn */, { 0x0981, 0x0981} /* Mn */,
|
||||
{ 0x09BC, 0x09BC} /* Mn */, { 0x09C1, 0x09C4} /* Mn */,
|
||||
{ 0x09CD, 0x09CD} /* Mn */, { 0x09E2, 0x09E3} /* Mn */,
|
||||
{ 0x0A01, 0x0A02} /* Mn */, { 0x0A3C, 0x0A3C} /* Mn */,
|
||||
{ 0x0A41, 0x0A42} /* Mn */, { 0x0A47, 0x0A48} /* Mn */,
|
||||
{ 0x0A4B, 0x0A4D} /* Mn */, { 0x0A70, 0x0A71} /* Mn */,
|
||||
{ 0x0A81, 0x0A82} /* Mn */, { 0x0ABC, 0x0ABC} /* Mn */,
|
||||
{ 0x0AC1, 0x0AC5} /* Mn */, { 0x0AC7, 0x0AC8} /* Mn */,
|
||||
{ 0x0ACD, 0x0ACD} /* Mn */, { 0x0AE2, 0x0AE3} /* Mn */,
|
||||
{ 0x0B01, 0x0B01} /* Mn */, { 0x0B3C, 0x0B3C} /* Mn */,
|
||||
{ 0x0B3F, 0x0B3F} /* Mn */, { 0x0B41, 0x0B43} /* Mn */,
|
||||
{ 0x0B4D, 0x0B4D} /* Mn */, { 0x0B56, 0x0B56} /* Mn */,
|
||||
{ 0x0B82, 0x0B82} /* Mn */, { 0x0BC0, 0x0BC0} /* Mn */,
|
||||
{ 0x0BCD, 0x0BCD} /* Mn */, { 0x0C3E, 0x0C40} /* Mn */,
|
||||
{ 0x0C46, 0x0C48} /* Mn */, { 0x0C4A, 0x0C4D} /* Mn */,
|
||||
{ 0x0C55, 0x0C56} /* Mn */, { 0x0CBC, 0x0CBC} /* Mn */,
|
||||
{ 0x0CBF, 0x0CBF} /* Mn */, { 0x0CC6, 0x0CC6} /* Mn */,
|
||||
{ 0x0CCC, 0x0CCD} /* Mn */, { 0x0CE2, 0x0CE3} /* Mn */,
|
||||
{ 0x0D41, 0x0D43} /* Mn */, { 0x0D4D, 0x0D4D} /* Mn */,
|
||||
{ 0x0DCA, 0x0DCA} /* Mn */, { 0x0DD2, 0x0DD4} /* Mn */,
|
||||
{ 0x0DD6, 0x0DD6} /* Mn */, { 0x0E31, 0x0E31} /* Mn */,
|
||||
{ 0x0E34, 0x0E3A} /* Mn */, { 0x0E47, 0x0E4E} /* Mn */,
|
||||
{ 0x0EB1, 0x0EB1} /* Mn */, { 0x0EB4, 0x0EB9} /* Mn */,
|
||||
{ 0x0EBB, 0x0EBC} /* Mn */, { 0x0EC8, 0x0ECD} /* Mn */,
|
||||
{ 0x0F18, 0x0F19} /* Mn */, { 0x0F35, 0x0F35} /* Mn */,
|
||||
{ 0x0F37, 0x0F37} /* Mn */, { 0x0F39, 0x0F39} /* Mn */,
|
||||
{ 0x0F71, 0x0F7E} /* Mn */, { 0x0F80, 0x0F84} /* Mn */,
|
||||
{ 0x0F86, 0x0F87} /* Mn */, { 0x0F90, 0x0F97} /* Mn */,
|
||||
{ 0x0F99, 0x0FBC} /* Mn */, { 0x0FC6, 0x0FC6} /* Mn */,
|
||||
{ 0x102D, 0x1030} /* Mn */, { 0x1032, 0x1032} /* Mn */,
|
||||
{ 0x1036, 0x1037} /* Mn */, { 0x1039, 0x1039} /* Mn */,
|
||||
{ 0x1058, 0x1059} /* Mn */, { 0x135F, 0x135F} /* Mn */,
|
||||
{ 0x1712, 0x1714} /* Mn */, { 0x1732, 0x1734} /* Mn */,
|
||||
{ 0x1752, 0x1753} /* Mn */, { 0x1772, 0x1773} /* Mn */,
|
||||
{ 0x17B7, 0x17BD} /* Mn */, { 0x17C6, 0x17C6} /* Mn */,
|
||||
{ 0x17C9, 0x17D3} /* Mn */, { 0x17DD, 0x17DD} /* Mn */,
|
||||
{ 0x180B, 0x180D} /* Mn */, { 0x18A9, 0x18A9} /* Mn */,
|
||||
{ 0x1920, 0x1922} /* Mn */, { 0x1927, 0x1928} /* Mn */,
|
||||
{ 0x1932, 0x1932} /* Mn */, { 0x1939, 0x193B} /* Mn */,
|
||||
{ 0x1A17, 0x1A18} /* Mn */, { 0x1B00, 0x1B03} /* Mn */,
|
||||
{ 0x1B34, 0x1B34} /* Mn */, { 0x1B36, 0x1B3A} /* Mn */,
|
||||
{ 0x1B3C, 0x1B3C} /* Mn */, { 0x1B42, 0x1B42} /* Mn */,
|
||||
{ 0x1B6B, 0x1B73} /* Mn */, { 0x1DC0, 0x1DCA} /* Mn */,
|
||||
{ 0x1DFE, 0x1DFF} /* Mn */, { 0x20D0, 0x20DC} /* Mn */,
|
||||
{ 0x20DD, 0x20E0} /* Me */,
|
||||
{ 0x20E1, 0x20E1} /* Mn */,
|
||||
{ 0x20E2, 0x20E4} /* Me */,
|
||||
{ 0x20E5, 0x20EF} /* Mn */, { 0x302A, 0x302F} /* Mn */,
|
||||
{ 0x3099, 0x309A} /* Mn */, { 0xA806, 0xA806} /* Mn */,
|
||||
{ 0xA80B, 0xA80B} /* Mn */, { 0xA825, 0xA826} /* Mn */,
|
||||
{ 0xFB1E, 0xFB1E} /* Mn */, { 0xFE00, 0xFE0F} /* Mn */,
|
||||
{ 0xFE20, 0xFE23} /* Mn */, { 0x10A01, 0x10A03} /* Mn */,
|
||||
{ 0x10A05, 0x10A06} /* Mn */, { 0x10A0C, 0x10A0F} /* Mn */,
|
||||
{ 0x10A38, 0x10A3A} /* Mn */, { 0x10A3F, 0x10A3F} /* Mn */,
|
||||
{ 0x1D167, 0x1D169} /* Mn */, { 0x1D17B, 0x1D182} /* Mn */,
|
||||
{ 0x1D185, 0x1D18B} /* Mn */, { 0x1D1AA, 0x1D1AD} /* Mn */,
|
||||
{ 0x1D242, 0x1D244} /* Mn */, { 0xE0100, 0xE01EF} /* Mn */,
|
||||
};
|
||||
#define DECLARE_RANGE_TABLE_START(name) \
|
||||
static struct wchar_range name##_array[] = {
|
||||
#define DECLARE_RANGE_TABLE_END(name) \
|
||||
}; struct wchar_range_table name##_table = { name##_array, sizeof(name##_array)/sizeof(*name##_array) };
|
||||
|
||||
/*
|
||||
* Special pairs, not ranges.
|
||||
*/
|
||||
DECLARE_RANGE_TABLE_START(compose)
|
||||
#include "compose.uni"
|
||||
DECLARE_RANGE_TABLE_END(compose)
|
||||
|
||||
DECLARE_RANGE_TABLE_START(ubin)
|
||||
#include "ubin.uni"
|
||||
DECLARE_RANGE_TABLE_END(ubin)
|
||||
|
||||
DECLARE_RANGE_TABLE_START(wide)
|
||||
#include "wide.uni"
|
||||
DECLARE_RANGE_TABLE_END(wide)
|
||||
|
||||
/* comb_table is special pairs, not ranges. */
|
||||
static struct wchar_range comb_table[] = {
|
||||
{0x0644,0x0622}, {0x0644,0x0623}, {0x0644,0x0625}, {0x0644,0x0627},
|
||||
};
|
||||
|
||||
/*
|
||||
* Characters with general category values
|
||||
* Cc: Other, Control
|
||||
* Cf: Other, Format
|
||||
* Cs: Other, Surrogate
|
||||
* Co: Other, Private Use
|
||||
* Cn: Other, Not Assigned
|
||||
* Zl: Separator, Line
|
||||
* Zp: Separator, Paragraph
|
||||
* Last synched with
|
||||
* <http://www.unicode.org/Public/5.0.0/ucd/UnicodeData-5.0.0d7.txt>
|
||||
* dated 2005-11-30T00:58:48Z
|
||||
*/
|
||||
static struct wchar_range ubin_table[] = {
|
||||
{ 0x0000, 0x001F} /* Cc */, { 0x007F, 0x009F} /* Cc */,
|
||||
#if 0
|
||||
{ 0x00AD, 0x00AD} /* Cf */,
|
||||
#endif
|
||||
{ 0x0370, 0x0373} /* Cn */, { 0x0376, 0x0379} /* Cn */,
|
||||
{ 0x037F, 0x0383} /* Cn */, { 0x038B, 0x038B} /* Cn */,
|
||||
{ 0x038D, 0x038D} /* Cn */, { 0x03A2, 0x03A2} /* Cn */,
|
||||
{ 0x03CF, 0x03CF} /* Cn */, { 0x0487, 0x0487} /* Cn */,
|
||||
{ 0x0514, 0x0530} /* Cn */, { 0x0557, 0x0558} /* Cn */,
|
||||
{ 0x0560, 0x0560} /* Cn */, { 0x0588, 0x0588} /* Cn */,
|
||||
{ 0x058B, 0x0590} /* Cn */, { 0x05C8, 0x05CF} /* Cn */,
|
||||
{ 0x05EB, 0x05EF} /* Cn */, { 0x05F5, 0x05FF} /* Cn */,
|
||||
#if 0
|
||||
{ 0x0600, 0x0603} /* Cf */,
|
||||
#endif
|
||||
{ 0x0604, 0x060A} /* Cn */, { 0x0616, 0x061A} /* Cn */,
|
||||
{ 0x061C, 0x061D} /* Cn */, { 0x0620, 0x0620} /* Cn */,
|
||||
{ 0x063B, 0x063F} /* Cn */, { 0x065F, 0x065F} /* Cn */,
|
||||
#if 0
|
||||
{ 0x06DD, 0x06DD} /* Cf */,
|
||||
#endif
|
||||
{ 0x070E, 0x070E} /* Cn */,
|
||||
#if 0
|
||||
{ 0x070F, 0x070F} /* Cf */,
|
||||
#endif
|
||||
{ 0x074B, 0x074C} /* Cn */, { 0x076E, 0x077F} /* Cn */,
|
||||
{ 0x07B2, 0x07BF} /* Cn */, { 0x07FB, 0x0900} /* Cn */,
|
||||
{ 0x093A, 0x093B} /* Cn */, { 0x094E, 0x094F} /* Cn */,
|
||||
{ 0x0955, 0x0957} /* Cn */, { 0x0971, 0x097A} /* Cn */,
|
||||
{ 0x0980, 0x0980} /* Cn */, { 0x0984, 0x0984} /* Cn */,
|
||||
{ 0x098D, 0x098E} /* Cn */, { 0x0991, 0x0992} /* Cn */,
|
||||
{ 0x09A9, 0x09A9} /* Cn */, { 0x09B1, 0x09B1} /* Cn */,
|
||||
{ 0x09B3, 0x09B5} /* Cn */, { 0x09BA, 0x09BB} /* Cn */,
|
||||
{ 0x09C5, 0x09C6} /* Cn */, { 0x09C9, 0x09CA} /* Cn */,
|
||||
{ 0x09CF, 0x09D6} /* Cn */, { 0x09D8, 0x09DB} /* Cn */,
|
||||
{ 0x09DE, 0x09DE} /* Cn */, { 0x09E4, 0x09E5} /* Cn */,
|
||||
{ 0x09FB, 0x0A00} /* Cn */, { 0x0A04, 0x0A04} /* Cn */,
|
||||
{ 0x0A0B, 0x0A0E} /* Cn */, { 0x0A11, 0x0A12} /* Cn */,
|
||||
{ 0x0A29, 0x0A29} /* Cn */, { 0x0A31, 0x0A31} /* Cn */,
|
||||
{ 0x0A34, 0x0A34} /* Cn */, { 0x0A37, 0x0A37} /* Cn */,
|
||||
{ 0x0A3A, 0x0A3B} /* Cn */, { 0x0A3D, 0x0A3D} /* Cn */,
|
||||
{ 0x0A43, 0x0A46} /* Cn */, { 0x0A49, 0x0A4A} /* Cn */,
|
||||
{ 0x0A4E, 0x0A58} /* Cn */, { 0x0A5D, 0x0A5D} /* Cn */,
|
||||
{ 0x0A5F, 0x0A65} /* Cn */, { 0x0A75, 0x0A80} /* Cn */,
|
||||
{ 0x0A84, 0x0A84} /* Cn */, { 0x0A8E, 0x0A8E} /* Cn */,
|
||||
{ 0x0A92, 0x0A92} /* Cn */, { 0x0AA9, 0x0AA9} /* Cn */,
|
||||
{ 0x0AB1, 0x0AB1} /* Cn */, { 0x0AB4, 0x0AB4} /* Cn */,
|
||||
{ 0x0ABA, 0x0ABB} /* Cn */, { 0x0AC6, 0x0AC6} /* Cn */,
|
||||
{ 0x0ACA, 0x0ACA} /* Cn */, { 0x0ACE, 0x0ACF} /* Cn */,
|
||||
{ 0x0AD1, 0x0ADF} /* Cn */, { 0x0AE4, 0x0AE5} /* Cn */,
|
||||
{ 0x0AF0, 0x0AF0} /* Cn */, { 0x0AF2, 0x0B00} /* Cn */,
|
||||
{ 0x0B04, 0x0B04} /* Cn */, { 0x0B0D, 0x0B0E} /* Cn */,
|
||||
{ 0x0B11, 0x0B12} /* Cn */, { 0x0B29, 0x0B29} /* Cn */,
|
||||
{ 0x0B31, 0x0B31} /* Cn */, { 0x0B34, 0x0B34} /* Cn */,
|
||||
{ 0x0B3A, 0x0B3B} /* Cn */, { 0x0B44, 0x0B46} /* Cn */,
|
||||
{ 0x0B49, 0x0B4A} /* Cn */, { 0x0B4E, 0x0B55} /* Cn */,
|
||||
{ 0x0B58, 0x0B5B} /* Cn */, { 0x0B5E, 0x0B5E} /* Cn */,
|
||||
{ 0x0B62, 0x0B65} /* Cn */, { 0x0B72, 0x0B81} /* Cn */,
|
||||
{ 0x0B84, 0x0B84} /* Cn */, { 0x0B8B, 0x0B8D} /* Cn */,
|
||||
{ 0x0B91, 0x0B91} /* Cn */, { 0x0B96, 0x0B98} /* Cn */,
|
||||
{ 0x0B9B, 0x0B9B} /* Cn */, { 0x0B9D, 0x0B9D} /* Cn */,
|
||||
{ 0x0BA0, 0x0BA2} /* Cn */, { 0x0BA5, 0x0BA7} /* Cn */,
|
||||
{ 0x0BAB, 0x0BAD} /* Cn */, { 0x0BBA, 0x0BBD} /* Cn */,
|
||||
{ 0x0BC3, 0x0BC5} /* Cn */, { 0x0BC9, 0x0BC9} /* Cn */,
|
||||
{ 0x0BCE, 0x0BD6} /* Cn */, { 0x0BD8, 0x0BE5} /* Cn */,
|
||||
{ 0x0BFB, 0x0C00} /* Cn */, { 0x0C04, 0x0C04} /* Cn */,
|
||||
{ 0x0C0D, 0x0C0D} /* Cn */, { 0x0C11, 0x0C11} /* Cn */,
|
||||
{ 0x0C29, 0x0C29} /* Cn */, { 0x0C34, 0x0C34} /* Cn */,
|
||||
{ 0x0C3A, 0x0C3D} /* Cn */, { 0x0C45, 0x0C45} /* Cn */,
|
||||
{ 0x0C49, 0x0C49} /* Cn */, { 0x0C4E, 0x0C54} /* Cn */,
|
||||
{ 0x0C57, 0x0C5F} /* Cn */, { 0x0C62, 0x0C65} /* Cn */,
|
||||
{ 0x0C70, 0x0C81} /* Cn */, { 0x0C84, 0x0C84} /* Cn */,
|
||||
{ 0x0C8D, 0x0C8D} /* Cn */, { 0x0C91, 0x0C91} /* Cn */,
|
||||
{ 0x0CA9, 0x0CA9} /* Cn */, { 0x0CB4, 0x0CB4} /* Cn */,
|
||||
{ 0x0CBA, 0x0CBB} /* Cn */, { 0x0CC5, 0x0CC5} /* Cn */,
|
||||
{ 0x0CC9, 0x0CC9} /* Cn */, { 0x0CCE, 0x0CD4} /* Cn */,
|
||||
{ 0x0CD7, 0x0CDD} /* Cn */, { 0x0CDF, 0x0CDF} /* Cn */,
|
||||
{ 0x0CE4, 0x0CE5} /* Cn */, { 0x0CF0, 0x0CF0} /* Cn */,
|
||||
{ 0x0CF3, 0x0D01} /* Cn */, { 0x0D04, 0x0D04} /* Cn */,
|
||||
{ 0x0D0D, 0x0D0D} /* Cn */, { 0x0D11, 0x0D11} /* Cn */,
|
||||
{ 0x0D29, 0x0D29} /* Cn */, { 0x0D3A, 0x0D3D} /* Cn */,
|
||||
{ 0x0D44, 0x0D45} /* Cn */, { 0x0D49, 0x0D49} /* Cn */,
|
||||
{ 0x0D4E, 0x0D56} /* Cn */, { 0x0D58, 0x0D5F} /* Cn */,
|
||||
{ 0x0D62, 0x0D65} /* Cn */, { 0x0D70, 0x0D81} /* Cn */,
|
||||
{ 0x0D84, 0x0D84} /* Cn */, { 0x0D97, 0x0D99} /* Cn */,
|
||||
{ 0x0DB2, 0x0DB2} /* Cn */, { 0x0DBC, 0x0DBC} /* Cn */,
|
||||
{ 0x0DBE, 0x0DBF} /* Cn */, { 0x0DC7, 0x0DC9} /* Cn */,
|
||||
{ 0x0DCB, 0x0DCE} /* Cn */, { 0x0DD5, 0x0DD5} /* Cn */,
|
||||
{ 0x0DD7, 0x0DD7} /* Cn */, { 0x0DE0, 0x0DF1} /* Cn */,
|
||||
{ 0x0DF5, 0x0E00} /* Cn */, { 0x0E3B, 0x0E3E} /* Cn */,
|
||||
{ 0x0E5C, 0x0E80} /* Cn */, { 0x0E83, 0x0E83} /* Cn */,
|
||||
{ 0x0E85, 0x0E86} /* Cn */, { 0x0E89, 0x0E89} /* Cn */,
|
||||
{ 0x0E8B, 0x0E8C} /* Cn */, { 0x0E8E, 0x0E93} /* Cn */,
|
||||
{ 0x0E98, 0x0E98} /* Cn */, { 0x0EA0, 0x0EA0} /* Cn */,
|
||||
{ 0x0EA4, 0x0EA4} /* Cn */, { 0x0EA6, 0x0EA6} /* Cn */,
|
||||
{ 0x0EA8, 0x0EA9} /* Cn */, { 0x0EAC, 0x0EAC} /* Cn */,
|
||||
{ 0x0EBA, 0x0EBA} /* Cn */, { 0x0EBE, 0x0EBF} /* Cn */,
|
||||
{ 0x0EC5, 0x0EC5} /* Cn */, { 0x0EC7, 0x0EC7} /* Cn */,
|
||||
{ 0x0ECE, 0x0ECF} /* Cn */, { 0x0EDA, 0x0EDB} /* Cn */,
|
||||
{ 0x0EDE, 0x0EFF} /* Cn */, { 0x0F48, 0x0F48} /* Cn */,
|
||||
{ 0x0F6B, 0x0F70} /* Cn */, { 0x0F8C, 0x0F8F} /* Cn */,
|
||||
{ 0x0F98, 0x0F98} /* Cn */, { 0x0FBD, 0x0FBD} /* Cn */,
|
||||
{ 0x0FCD, 0x0FCE} /* Cn */, { 0x0FD2, 0x0FFF} /* Cn */,
|
||||
{ 0x1022, 0x1022} /* Cn */, { 0x1028, 0x1028} /* Cn */,
|
||||
{ 0x102B, 0x102B} /* Cn */, { 0x1033, 0x1035} /* Cn */,
|
||||
{ 0x103A, 0x103F} /* Cn */, { 0x105A, 0x109F} /* Cn */,
|
||||
{ 0x10C6, 0x10CF} /* Cn */, { 0x10FD, 0x10FF} /* Cn */,
|
||||
{ 0x115A, 0x115E} /* Cn */, { 0x11A3, 0x11A7} /* Cn */,
|
||||
{ 0x11FA, 0x11FF} /* Cn */, { 0x1249, 0x1249} /* Cn */,
|
||||
{ 0x124E, 0x124F} /* Cn */, { 0x1257, 0x1257} /* Cn */,
|
||||
{ 0x1259, 0x1259} /* Cn */, { 0x125E, 0x125F} /* Cn */,
|
||||
{ 0x1289, 0x1289} /* Cn */, { 0x128E, 0x128F} /* Cn */,
|
||||
{ 0x12B1, 0x12B1} /* Cn */, { 0x12B6, 0x12B7} /* Cn */,
|
||||
{ 0x12BF, 0x12BF} /* Cn */, { 0x12C1, 0x12C1} /* Cn */,
|
||||
{ 0x12C6, 0x12C7} /* Cn */, { 0x12D7, 0x12D7} /* Cn */,
|
||||
{ 0x1311, 0x1311} /* Cn */, { 0x1316, 0x1317} /* Cn */,
|
||||
{ 0x135B, 0x135E} /* Cn */, { 0x137D, 0x137F} /* Cn */,
|
||||
{ 0x139A, 0x139F} /* Cn */, { 0x13F5, 0x1400} /* Cn */,
|
||||
{ 0x1677, 0x167F} /* Cn */, { 0x169D, 0x169F} /* Cn */,
|
||||
{ 0x16F1, 0x16FF} /* Cn */, { 0x170D, 0x170D} /* Cn */,
|
||||
{ 0x1715, 0x171F} /* Cn */, { 0x1737, 0x173F} /* Cn */,
|
||||
{ 0x1754, 0x175F} /* Cn */, { 0x176D, 0x176D} /* Cn */,
|
||||
{ 0x1771, 0x1771} /* Cn */, { 0x1774, 0x177F} /* Cn */,
|
||||
#if 0
|
||||
{ 0x17B4, 0x17B5} /* Cf */,
|
||||
#endif
|
||||
{ 0x17DE, 0x17DF} /* Cn */, { 0x17EA, 0x17EF} /* Cn */,
|
||||
{ 0x17FA, 0x17FF} /* Cn */, { 0x180F, 0x180F} /* Cn */,
|
||||
{ 0x181A, 0x181F} /* Cn */, { 0x1878, 0x187F} /* Cn */,
|
||||
{ 0x18AA, 0x18FF} /* Cn */, { 0x191D, 0x191F} /* Cn */,
|
||||
{ 0x192C, 0x192F} /* Cn */, { 0x193C, 0x193F} /* Cn */,
|
||||
{ 0x1941, 0x1943} /* Cn */, { 0x196E, 0x196F} /* Cn */,
|
||||
{ 0x1975, 0x197F} /* Cn */, { 0x19AA, 0x19AF} /* Cn */,
|
||||
{ 0x19CA, 0x19CF} /* Cn */, { 0x19DA, 0x19DD} /* Cn */,
|
||||
{ 0x1A1C, 0x1A1D} /* Cn */, { 0x1A20, 0x1AFF} /* Cn */,
|
||||
{ 0x1B4C, 0x1B4F} /* Cn */, { 0x1B7D, 0x1CFF} /* Cn */,
|
||||
{ 0x1DCB, 0x1DFD} /* Cn */, { 0x1E9C, 0x1E9F} /* Cn */,
|
||||
{ 0x1EFA, 0x1EFF} /* Cn */, { 0x1F16, 0x1F17} /* Cn */,
|
||||
{ 0x1F1E, 0x1F1F} /* Cn */, { 0x1F46, 0x1F47} /* Cn */,
|
||||
{ 0x1F4E, 0x1F4F} /* Cn */, { 0x1F58, 0x1F58} /* Cn */,
|
||||
{ 0x1F5A, 0x1F5A} /* Cn */, { 0x1F5C, 0x1F5C} /* Cn */,
|
||||
{ 0x1F5E, 0x1F5E} /* Cn */, { 0x1F7E, 0x1F7F} /* Cn */,
|
||||
{ 0x1FB5, 0x1FB5} /* Cn */, { 0x1FC5, 0x1FC5} /* Cn */,
|
||||
{ 0x1FD4, 0x1FD5} /* Cn */, { 0x1FDC, 0x1FDC} /* Cn */,
|
||||
{ 0x1FF0, 0x1FF1} /* Cn */, { 0x1FF5, 0x1FF5} /* Cn */,
|
||||
{ 0x1FFF, 0x1FFF} /* Cn */,
|
||||
{ 0x200B, 0x200F} /* Cf */,
|
||||
{ 0x2028, 0x2028} /* Zl */,
|
||||
{ 0x2029, 0x2029} /* Zp */,
|
||||
{ 0x202A, 0x202E} /* Cf */,
|
||||
{ 0x2060, 0x2063} /* Cf */,
|
||||
{ 0x2064, 0x2069} /* Cn */,
|
||||
{ 0x206A, 0x206F} /* Cf */,
|
||||
{ 0x2072, 0x2073} /* Cn */, { 0x208F, 0x208F} /* Cn */,
|
||||
{ 0x2095, 0x209F} /* Cn */, { 0x20B6, 0x20CF} /* Cn */,
|
||||
{ 0x20F0, 0x20FF} /* Cn */, { 0x214F, 0x2152} /* Cn */,
|
||||
{ 0x2185, 0x218F} /* Cn */, { 0x23E8, 0x23FF} /* Cn */,
|
||||
{ 0x2427, 0x243F} /* Cn */, { 0x244B, 0x245F} /* Cn */,
|
||||
{ 0x269D, 0x269F} /* Cn */, { 0x26B3, 0x2700} /* Cn */,
|
||||
{ 0x2705, 0x2705} /* Cn */, { 0x270A, 0x270B} /* Cn */,
|
||||
{ 0x2728, 0x2728} /* Cn */, { 0x274C, 0x274C} /* Cn */,
|
||||
{ 0x274E, 0x274E} /* Cn */, { 0x2753, 0x2755} /* Cn */,
|
||||
{ 0x2757, 0x2757} /* Cn */, { 0x275F, 0x2760} /* Cn */,
|
||||
{ 0x2795, 0x2797} /* Cn */, { 0x27B0, 0x27B0} /* Cn */,
|
||||
{ 0x27BF, 0x27BF} /* Cn */, { 0x27CB, 0x27CF} /* Cn */,
|
||||
{ 0x27EC, 0x27EF} /* Cn */, { 0x2B1B, 0x2B1F} /* Cn */,
|
||||
{ 0x2B24, 0x2BFF} /* Cn */, { 0x2C2F, 0x2C2F} /* Cn */,
|
||||
{ 0x2C5F, 0x2C5F} /* Cn */, { 0x2C6D, 0x2C73} /* Cn */,
|
||||
{ 0x2C78, 0x2C7F} /* Cn */, { 0x2CEB, 0x2CF8} /* Cn */,
|
||||
{ 0x2D26, 0x2D2F} /* Cn */, { 0x2D66, 0x2D6E} /* Cn */,
|
||||
{ 0x2D70, 0x2D7F} /* Cn */, { 0x2D97, 0x2D9F} /* Cn */,
|
||||
{ 0x2DA7, 0x2DA7} /* Cn */, { 0x2DAF, 0x2DAF} /* Cn */,
|
||||
{ 0x2DB7, 0x2DB7} /* Cn */, { 0x2DBF, 0x2DBF} /* Cn */,
|
||||
{ 0x2DC7, 0x2DC7} /* Cn */, { 0x2DCF, 0x2DCF} /* Cn */,
|
||||
{ 0x2DD7, 0x2DD7} /* Cn */, { 0x2DDF, 0x2DFF} /* Cn */,
|
||||
{ 0x2E18, 0x2E1B} /* Cn */, { 0x2E1E, 0x2E7F} /* Cn */,
|
||||
{ 0x2E9A, 0x2E9A} /* Cn */, { 0x2EF4, 0x2EFF} /* Cn */,
|
||||
{ 0x2FD6, 0x2FEF} /* Cn */, { 0x2FFC, 0x2FFF} /* Cn */,
|
||||
{ 0x3040, 0x3040} /* Cn */, { 0x3097, 0x3098} /* Cn */,
|
||||
{ 0x3100, 0x3104} /* Cn */, { 0x312D, 0x3130} /* Cn */,
|
||||
{ 0x318F, 0x318F} /* Cn */, { 0x31B8, 0x31BF} /* Cn */,
|
||||
{ 0x31D0, 0x31EF} /* Cn */, { 0x321F, 0x321F} /* Cn */,
|
||||
{ 0x3244, 0x324F} /* Cn */, { 0x32FF, 0x32FF} /* Cn */,
|
||||
{ 0x4DB6, 0x4DBF} /* Cn */, { 0x9FBC, 0x9FFF} /* Cn */,
|
||||
{ 0xA48D, 0xA48F} /* Cn */, { 0xA4C7, 0xA6FF} /* Cn */,
|
||||
{ 0xA71B, 0xA71F} /* Cn */, { 0xA722, 0xA7FF} /* Cn */,
|
||||
{ 0xA82C, 0xA83F} /* Cn */, { 0xA878, 0xABFF} /* Cn */,
|
||||
{ 0xD7A4, 0xD7FF} /* Cn */,
|
||||
{ 0xD800, 0xDFFF} /* Cs */,
|
||||
{ 0xE000, 0xF8FF} /* Co */,
|
||||
{ 0xFA2E, 0xFA2F} /* Cn */, { 0xFA6B, 0xFA6F} /* Cn */,
|
||||
{ 0xFADA, 0xFAFF} /* Cn */, { 0xFB07, 0xFB12} /* Cn */,
|
||||
{ 0xFB18, 0xFB1C} /* Cn */, { 0xFB37, 0xFB37} /* Cn */,
|
||||
{ 0xFB3D, 0xFB3D} /* Cn */, { 0xFB3F, 0xFB3F} /* Cn */,
|
||||
{ 0xFB42, 0xFB42} /* Cn */, { 0xFB45, 0xFB45} /* Cn */,
|
||||
{ 0xFBB2, 0xFBD2} /* Cn */, { 0xFD40, 0xFD4F} /* Cn */,
|
||||
{ 0xFD90, 0xFD91} /* Cn */, { 0xFDC8, 0xFDEF} /* Cn */,
|
||||
{ 0xFDFE, 0xFDFF} /* Cn */, { 0xFE1A, 0xFE1F} /* Cn */,
|
||||
{ 0xFE24, 0xFE2F} /* Cn */, { 0xFE53, 0xFE53} /* Cn */,
|
||||
{ 0xFE67, 0xFE67} /* Cn */, { 0xFE6C, 0xFE6F} /* Cn */,
|
||||
{ 0xFE75, 0xFE75} /* Cn */, { 0xFEFD, 0xFEFE} /* Cn */,
|
||||
{ 0xFEFF, 0xFEFF} /* Cf */,
|
||||
{ 0xFF00, 0xFF00} /* Cn */, { 0xFFBF, 0xFFC1} /* Cn */,
|
||||
{ 0xFFC8, 0xFFC9} /* Cn */, { 0xFFD0, 0xFFD1} /* Cn */,
|
||||
{ 0xFFD8, 0xFFD9} /* Cn */, { 0xFFDD, 0xFFDF} /* Cn */,
|
||||
{ 0xFFE7, 0xFFE7} /* Cn */, { 0xFFEF, 0xFFF8} /* Cn */,
|
||||
{ 0xFFF9, 0xFFFB} /* Cf */,
|
||||
{ 0xFFFE, 0xFFFF} /* Cn */, { 0x1000C, 0x1000C} /* Cn */,
|
||||
{ 0x10027, 0x10027} /* Cn */, { 0x1003B, 0x1003B} /* Cn */,
|
||||
{ 0x1003E, 0x1003E} /* Cn */, { 0x1004E, 0x1004F} /* Cn */,
|
||||
{ 0x1005E, 0x1007F} /* Cn */, { 0x100FB, 0x100FF} /* Cn */,
|
||||
{ 0x10103, 0x10106} /* Cn */, { 0x10134, 0x10136} /* Cn */,
|
||||
{ 0x1018B, 0x102FF} /* Cn */, { 0x1031F, 0x1031F} /* Cn */,
|
||||
{ 0x10324, 0x1032F} /* Cn */, { 0x1034B, 0x1037F} /* Cn */,
|
||||
{ 0x1039E, 0x1039E} /* Cn */, { 0x103C4, 0x103C7} /* Cn */,
|
||||
{ 0x103D6, 0x103FF} /* Cn */,
|
||||
{ 0x1049E, 0x1049F} /* Cn */, { 0x104AA, 0x107FF} /* Cn */,
|
||||
{ 0x10806, 0x10807} /* Cn */, { 0x10809, 0x10809} /* Cn */,
|
||||
{ 0x10836, 0x10836} /* Cn */, { 0x10839, 0x1083B} /* Cn */,
|
||||
{ 0x1083D, 0x1083E} /* Cn */, { 0x10840, 0x108FF} /* Cn */,
|
||||
{ 0x1091A, 0x1091E} /* Cn */, { 0x10920, 0x109FF} /* Cn */,
|
||||
{ 0x10A04, 0x10A04} /* Cn */, { 0x10A07, 0x10A0B} /* Cn */,
|
||||
{ 0x10A14, 0x10A14} /* Cn */, { 0x10A18, 0x10A18} /* Cn */,
|
||||
{ 0x10A34, 0x10A37} /* Cn */, { 0x10A3B, 0x10A3E} /* Cn */,
|
||||
{ 0x10A48, 0x10A4F} /* Cn */, { 0x10A59, 0x11FFF} /* Cn */,
|
||||
{ 0x1236F, 0x123FF} /* Cn */, { 0x12463, 0x1246F} /* Cn */,
|
||||
{ 0x12474, 0x1CFFF} /* Cn */, { 0x1D0F6, 0x1D0FF} /* Cn */,
|
||||
{ 0x1D127, 0x1D129} /* Cn */,
|
||||
{ 0x1D173, 0x1D17A} /* Cf */,
|
||||
{ 0x1D1DE, 0x1D1FF} /* Cn */, { 0x1D246, 0x1D2FF} /* Cn */,
|
||||
{ 0x1D357, 0x1D35F} /* Cn */, { 0x1D372, 0x1D3FF} /* Cn */,
|
||||
{ 0x1D455, 0x1D455} /* Cn */, { 0x1D49D, 0x1D49D} /* Cn */,
|
||||
{ 0x1D4A0, 0x1D4A1} /* Cn */, { 0x1D4A3, 0x1D4A4} /* Cn */,
|
||||
{ 0x1D4A7, 0x1D4A8} /* Cn */, { 0x1D4AD, 0x1D4AD} /* Cn */,
|
||||
{ 0x1D4BA, 0x1D4BA} /* Cn */, { 0x1D4BC, 0x1D4BC} /* Cn */,
|
||||
{ 0x1D4C4, 0x1D4C4} /* Cn */, { 0x1D506, 0x1D506} /* Cn */,
|
||||
{ 0x1D50B, 0x1D50C} /* Cn */, { 0x1D515, 0x1D515} /* Cn */,
|
||||
{ 0x1D51D, 0x1D51D} /* Cn */, { 0x1D53A, 0x1D53A} /* Cn */,
|
||||
{ 0x1D53F, 0x1D53F} /* Cn */, { 0x1D545, 0x1D545} /* Cn */,
|
||||
{ 0x1D547, 0x1D549} /* Cn */, { 0x1D551, 0x1D551} /* Cn */,
|
||||
{ 0x1D6A6, 0x1D6A7} /* Cn */, { 0x1D7CC, 0x1D7CD} /* Cn */,
|
||||
{ 0x1D800, 0x1FFFF} /* Cn */, { 0x2A6D7, 0x2F7FF} /* Cn */,
|
||||
{ 0x2FA1E, 0xE0000} /* Cn */,
|
||||
{ 0xE0001, 0xE0001} /* Cf */,
|
||||
{ 0xE0002, 0xE001F} /* Cn */,
|
||||
{ 0xE0020, 0xE007F} /* Cf */,
|
||||
{ 0xE0080, 0xE00FF} /* Cn */, { 0xE01F0, 0xEFFFF} /* Cn */,
|
||||
{ 0xF0000, 0xFFFFD} /* Co */,
|
||||
{ 0xFFFFE, 0xFFFFF} /* Cn */,
|
||||
{0x100000,0x10FFFD} /* Co */,
|
||||
{0x10FFFE,0x10FFFF} /* Cn */,
|
||||
{0x110000,0x7FFFFFFF} /* ISO 10646?? */
|
||||
};
|
||||
|
||||
/*
|
||||
* Double width characters
|
||||
* W: East Asian Wide
|
||||
* F: East Asian Full-width
|
||||
* Unassigned code points may be included when they allow ranges to be merged.
|
||||
* Last synched with
|
||||
* <http://www.unicode.org/Public/5.0.0/ucd/EastAsianWidth-5.0.0d2.txt>
|
||||
* dated 2005-11-08T01:32:56Z
|
||||
*/
|
||||
static struct wchar_range wide_table[] = {
|
||||
{ 0x1100, 0x115F} /* W */, { 0x2329, 0x232A} /* W */,
|
||||
{ 0x2E80, 0x2FFB} /* W */,
|
||||
{ 0x3000, 0x3000} /* F */,
|
||||
{ 0x3001, 0x303E} /* W */, { 0x3041, 0x4DB5} /* W */,
|
||||
{ 0x4E00, 0x9FBB} /* W */, { 0xA000, 0xA4C6} /* W */,
|
||||
{ 0xAC00, 0xD7A3} /* W */, { 0xF900, 0xFAD9} /* W */,
|
||||
{ 0xFE10, 0xFE19} /* W */, { 0xFE30, 0xFE6B} /* W */,
|
||||
{ 0xFF01, 0xFF60} /* F */, { 0xFFE0, 0xFFE6} /* F */,
|
||||
{ 0x20000, 0x2FFFD} /* W */, { 0x30000, 0x3FFFD} /* W */,
|
||||
};
|
||||
|
||||
static int
|
||||
is_in_table(ch, table, tsize)
|
||||
is_in_table(ch, table)
|
||||
LWCHAR ch;
|
||||
struct wchar_range table[];
|
||||
int tsize;
|
||||
struct wchar_range_table *table;
|
||||
{
|
||||
int hi;
|
||||
int lo;
|
||||
|
||||
/* Binary search in the table. */
|
||||
if (ch < table[0].first)
|
||||
if (ch < table->table[0].first)
|
||||
return 0;
|
||||
lo = 0;
|
||||
hi = tsize - 1;
|
||||
hi = table->count - 1;
|
||||
while (lo <= hi)
|
||||
{
|
||||
int mid = (lo + hi) / 2;
|
||||
if (ch > table[mid].last)
|
||||
if (ch > table->table[mid].last)
|
||||
lo = mid + 1;
|
||||
else if (ch < table[mid].first)
|
||||
else if (ch < table->table[mid].first)
|
||||
hi = mid - 1;
|
||||
else
|
||||
return 1;
|
||||
@ -1121,7 +779,7 @@ is_in_table(ch, table, tsize)
|
||||
is_composing_char(ch)
|
||||
LWCHAR ch;
|
||||
{
|
||||
return is_in_table(ch, comp_table, (sizeof(comp_table) / sizeof(*comp_table)));
|
||||
return is_in_table(ch, &compose_table);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1131,7 +789,7 @@ is_composing_char(ch)
|
||||
is_ubin_char(ch)
|
||||
LWCHAR ch;
|
||||
{
|
||||
return is_in_table(ch, ubin_table, (sizeof(ubin_table) / sizeof(*ubin_table)));
|
||||
return is_in_table(ch, &ubin_table);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1141,7 +799,7 @@ is_ubin_char(ch)
|
||||
is_wide_char(ch)
|
||||
LWCHAR ch;
|
||||
{
|
||||
return is_in_table(ch, wide_table, (sizeof(wide_table) / sizeof(*wide_table)));
|
||||
return is_in_table(ch, &wide_table);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
#define IS_ASCII_OCTET(c) (((c) & 0x80) == 0)
|
||||
|
15
less/cmd.h
Executable file → Normal file
15
less/cmd.h
Executable file → Normal file
@ -1,15 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
#define MAX_USERCMD 500
|
||||
#define MAX_USERCMD 1000
|
||||
#define MAX_CMDLEN 16
|
||||
|
||||
#define A_B_LINE 2
|
||||
@ -65,6 +64,11 @@
|
||||
#define A_REMOVE_FILE 52
|
||||
#define A_NEXT_TAG 53
|
||||
#define A_PREV_TAG 54
|
||||
#define A_FILTER 55
|
||||
#define A_F_UNTIL_HILITE 56
|
||||
#define A_GOEND_BUF 57
|
||||
#define A_LLSHIFT 58
|
||||
#define A_RRSHIFT 59
|
||||
|
||||
#define A_INVALID 100
|
||||
#define A_NOACTION 101
|
||||
@ -77,7 +81,7 @@
|
||||
#define A_EXTRA 0200
|
||||
|
||||
|
||||
/* Line editting characters */
|
||||
/* Line editing characters */
|
||||
|
||||
#define EC_BACKSPACE 1
|
||||
#define EC_LINEKILL 2
|
||||
@ -97,6 +101,7 @@
|
||||
#define EC_F_COMPLETE 17
|
||||
#define EC_B_COMPLETE 18
|
||||
#define EC_LITERAL 19
|
||||
#define EC_ABORT 20
|
||||
|
||||
#define EC_NOACTION 101
|
||||
#define EC_UINVALID 102
|
||||
|
458
less/cmdbuf.c
Executable file → Normal file
458
less/cmdbuf.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -30,6 +29,7 @@ static int prompt_col; /* Column of cursor just after prompt */
|
||||
static char *cp; /* Pointer into cmdbuf */
|
||||
static int cmd_offset; /* Index into cmdbuf of first displayed char */
|
||||
static int literal; /* Next input char should not be interpreted */
|
||||
static int updown_match = -1; /* Prefix length in up/down movement */
|
||||
|
||||
#if TAB_COMPLETE_FILENAME
|
||||
static int cmd_complete();
|
||||
@ -122,6 +122,7 @@ cmd_reset()
|
||||
cmd_offset = 0;
|
||||
literal = 0;
|
||||
cmd_mbc_buf_len = 0;
|
||||
updown_match = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -132,6 +133,7 @@ clear_cmd()
|
||||
{
|
||||
cmd_col = prompt_col = 0;
|
||||
cmd_mbc_buf_len = 0;
|
||||
updown_match = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -147,20 +149,18 @@ cmd_putstr(s)
|
||||
while (*s != '\0')
|
||||
{
|
||||
char *ns = s;
|
||||
int width;
|
||||
ch = step_char(&ns, +1, endline);
|
||||
while (s < ns)
|
||||
putchr(*s++);
|
||||
if (!utf_mode)
|
||||
{
|
||||
cmd_col++;
|
||||
prompt_col++;
|
||||
} else if (!is_composing_char(ch) &&
|
||||
!is_combining_char(prev_ch, ch))
|
||||
{
|
||||
int width = is_wide_char(ch) ? 2 : 1;
|
||||
cmd_col += width;
|
||||
prompt_col += width;
|
||||
}
|
||||
width = 1;
|
||||
else if (is_composing_char(ch) || is_combining_char(prev_ch, ch))
|
||||
width = 0;
|
||||
else
|
||||
width = is_wide_char(ch) ? 2 : 1;
|
||||
cmd_col += width;
|
||||
prompt_col += width;
|
||||
prev_ch = ch;
|
||||
}
|
||||
}
|
||||
@ -185,6 +185,8 @@ len_cmdbuf()
|
||||
|
||||
/*
|
||||
* Common part of cmd_step_right() and cmd_step_left().
|
||||
* {{ Returning pwidth and bswidth separately is a historical artifact
|
||||
* since they're always the same. Maybe clean this up someday. }}
|
||||
*/
|
||||
static char *
|
||||
cmd_step_common(p, ch, len, pwidth, bswidth)
|
||||
@ -195,58 +197,32 @@ cmd_step_common(p, ch, len, pwidth, bswidth)
|
||||
int *bswidth;
|
||||
{
|
||||
char *pr;
|
||||
int width;
|
||||
|
||||
if (len == 1)
|
||||
{
|
||||
pr = prchar((int) ch);
|
||||
if (pwidth != NULL || bswidth != NULL)
|
||||
{
|
||||
int len = strlen(pr);
|
||||
if (pwidth != NULL)
|
||||
*pwidth = len;
|
||||
if (bswidth != NULL)
|
||||
*bswidth = len;
|
||||
}
|
||||
width = (int) strlen(pr);
|
||||
} else
|
||||
{
|
||||
pr = prutfchar(ch);
|
||||
if (pwidth != NULL || bswidth != NULL)
|
||||
if (is_composing_char(ch))
|
||||
width = 0;
|
||||
else if (is_ubin_char(ch))
|
||||
width = (int) strlen(pr);
|
||||
else
|
||||
{
|
||||
if (is_composing_char(ch))
|
||||
{
|
||||
if (pwidth != NULL)
|
||||
*pwidth = 0;
|
||||
if (bswidth != NULL)
|
||||
*bswidth = 0;
|
||||
} else if (is_ubin_char(ch))
|
||||
{
|
||||
int len = strlen(pr);
|
||||
if (pwidth != NULL)
|
||||
*pwidth = len;
|
||||
if (bswidth != NULL)
|
||||
*bswidth = len;
|
||||
} else
|
||||
{
|
||||
LWCHAR prev_ch = step_char(&p, -1, cmdbuf);
|
||||
if (is_combining_char(prev_ch, ch))
|
||||
{
|
||||
if (pwidth != NULL)
|
||||
*pwidth = 0;
|
||||
if (bswidth != NULL)
|
||||
*bswidth = 0;
|
||||
} else
|
||||
{
|
||||
if (pwidth != NULL)
|
||||
*pwidth = is_wide_char(ch)
|
||||
? 2
|
||||
: 1;
|
||||
if (bswidth != NULL)
|
||||
*bswidth = 1;
|
||||
}
|
||||
}
|
||||
LWCHAR prev_ch = step_char(&p, -1, cmdbuf);
|
||||
if (is_combining_char(prev_ch, ch))
|
||||
width = 0;
|
||||
else
|
||||
width = is_wide_char(ch) ? 2 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pwidth != NULL)
|
||||
*pwidth = width;
|
||||
if (bswidth != NULL)
|
||||
*bswidth = width;
|
||||
return (pr);
|
||||
}
|
||||
|
||||
@ -373,7 +349,7 @@ cmd_lshift()
|
||||
s = ns;
|
||||
}
|
||||
|
||||
cmd_offset = s - cmdbuf;
|
||||
cmd_offset = (int) (s - cmdbuf);
|
||||
save_cp = cp;
|
||||
cmd_home();
|
||||
cmd_repaint(save_cp);
|
||||
@ -403,7 +379,7 @@ cmd_rshift()
|
||||
cols += width;
|
||||
}
|
||||
|
||||
cmd_offset = s - cmdbuf;
|
||||
cmd_offset = (int) (s - cmdbuf);
|
||||
save_cp = cp;
|
||||
cmd_home();
|
||||
cmd_repaint(save_cp);
|
||||
@ -504,6 +480,7 @@ cmd_ichar(cs, clen)
|
||||
/*
|
||||
* Reprint the tail of the line from the inserted char.
|
||||
*/
|
||||
updown_match = -1;
|
||||
cmd_repaint(cp);
|
||||
cmd_right();
|
||||
return (CC_OK);
|
||||
@ -532,7 +509,7 @@ cmd_erase()
|
||||
*/
|
||||
s = cp;
|
||||
cmd_left();
|
||||
clen = s - cp;
|
||||
clen = (int) (s - cp);
|
||||
|
||||
/*
|
||||
* Remove the char from the buffer (shift the buffer left).
|
||||
@ -547,6 +524,7 @@ cmd_erase()
|
||||
/*
|
||||
* Repaint the buffer after the erased char.
|
||||
*/
|
||||
updown_match = -1;
|
||||
cmd_repaint(cp);
|
||||
|
||||
/*
|
||||
@ -643,6 +621,7 @@ cmd_kill()
|
||||
cmd_offset = 0;
|
||||
cmd_home();
|
||||
*cp = '\0';
|
||||
updown_match = -1;
|
||||
cmd_repaint(cp);
|
||||
|
||||
/*
|
||||
@ -662,23 +641,28 @@ set_mlist(mlist, cmdflags)
|
||||
void *mlist;
|
||||
int cmdflags;
|
||||
{
|
||||
#if CMD_HISTORY
|
||||
curr_mlist = (struct mlist *) mlist;
|
||||
curr_cmdflags = cmdflags;
|
||||
|
||||
/* Make sure the next up-arrow moves to the last string in the mlist. */
|
||||
if (curr_mlist != NULL)
|
||||
curr_mlist->curr_mp = curr_mlist;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CMD_HISTORY
|
||||
/*
|
||||
* Move up or down in the currently selected command history list.
|
||||
* Only consider entries whose first updown_match chars are equal to
|
||||
* cmdbuf's corresponding chars.
|
||||
*/
|
||||
static int
|
||||
cmd_updown(action)
|
||||
int action;
|
||||
{
|
||||
char *s;
|
||||
struct mlist *ml;
|
||||
|
||||
if (curr_mlist == NULL)
|
||||
{
|
||||
@ -688,35 +672,59 @@ cmd_updown(action)
|
||||
bell();
|
||||
return (CC_OK);
|
||||
}
|
||||
cmd_home();
|
||||
clear_eol();
|
||||
|
||||
if (updown_match < 0)
|
||||
{
|
||||
updown_match = (int) (cp - cmdbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Move curr_mp to the next/prev entry.
|
||||
* Find the next history entry which matches.
|
||||
*/
|
||||
if (action == EC_UP)
|
||||
curr_mlist->curr_mp = curr_mlist->curr_mp->prev;
|
||||
else
|
||||
curr_mlist->curr_mp = curr_mlist->curr_mp->next;
|
||||
for (ml = curr_mlist->curr_mp;;)
|
||||
{
|
||||
ml = (action == EC_UP) ? ml->prev : ml->next;
|
||||
if (ml == curr_mlist)
|
||||
{
|
||||
/*
|
||||
* We reached the end (or beginning) of the list.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
if (strncmp(cmdbuf, ml->string, updown_match) == 0)
|
||||
{
|
||||
/*
|
||||
* This entry matches; stop here.
|
||||
* Copy the entry into cmdbuf and echo it on the screen.
|
||||
*/
|
||||
curr_mlist->curr_mp = ml;
|
||||
s = ml->string;
|
||||
if (s == NULL)
|
||||
s = "";
|
||||
cmd_home();
|
||||
clear_eol();
|
||||
strcpy(cmdbuf, s);
|
||||
for (cp = cmdbuf; *cp != '\0'; )
|
||||
cmd_right();
|
||||
return (CC_OK);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copy the entry into cmdbuf and echo it on the screen.
|
||||
* We didn't find a history entry that matches.
|
||||
*/
|
||||
s = curr_mlist->curr_mp->string;
|
||||
if (s == NULL)
|
||||
s = "";
|
||||
strcpy(cmdbuf, s);
|
||||
for (cp = cmdbuf; *cp != '\0'; )
|
||||
cmd_right();
|
||||
bell();
|
||||
return (CC_OK);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Add a string to a history list.
|
||||
* Add a string to an mlist.
|
||||
*/
|
||||
public void
|
||||
cmd_addhist(mlist, cmd)
|
||||
cmd_addhist(mlist, cmd, modified)
|
||||
struct mlist *mlist;
|
||||
char *cmd;
|
||||
int modified;
|
||||
{
|
||||
#if CMD_HISTORY
|
||||
struct mlist *ml;
|
||||
@ -740,6 +748,7 @@ cmd_addhist(mlist, cmd)
|
||||
*/
|
||||
ml = (struct mlist *) ecalloc(1, sizeof(struct mlist));
|
||||
ml->string = save(cmd);
|
||||
ml->modified = modified;
|
||||
ml->next = mlist;
|
||||
ml->prev = mlist->prev;
|
||||
mlist->prev->next = ml;
|
||||
@ -766,7 +775,7 @@ cmd_accept()
|
||||
*/
|
||||
if (curr_mlist == NULL)
|
||||
return;
|
||||
cmd_addhist(curr_mlist, cmdbuf);
|
||||
cmd_addhist(curr_mlist, cmdbuf, 1);
|
||||
curr_mlist->modified = 1;
|
||||
#endif
|
||||
}
|
||||
@ -855,6 +864,10 @@ cmd_edit(c)
|
||||
case EC_LINEKILL:
|
||||
not_in_completion();
|
||||
return (cmd_kill());
|
||||
case EC_ABORT:
|
||||
not_in_completion();
|
||||
(void) cmd_kill();
|
||||
return (CC_QUIT);
|
||||
case EC_W_BACKSPACE:
|
||||
not_in_completion();
|
||||
return (cmd_werase());
|
||||
@ -928,7 +941,7 @@ delimit_word()
|
||||
int delim_quoted = 0;
|
||||
int meta_quoted = 0;
|
||||
char *esc = get_meta_escape();
|
||||
int esclen = strlen(esc);
|
||||
int esclen = (int) strlen(esc);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -1050,7 +1063,11 @@ init_compl()
|
||||
tk_text = fcomplete(word);
|
||||
} else
|
||||
{
|
||||
#if MSDOS_COMPILER
|
||||
char *qword = NULL;
|
||||
#else
|
||||
char *qword = shell_quote(word+1);
|
||||
#endif
|
||||
if (qword == NULL)
|
||||
tk_text = fcomplete(word+1);
|
||||
else
|
||||
@ -1221,7 +1238,7 @@ cmd_char(c)
|
||||
cmd_mbc_buf[cmd_mbc_buf_index++] = c;
|
||||
if (cmd_mbc_buf_index < cmd_mbc_buf_len)
|
||||
return (CC_OK);
|
||||
if (!is_utf8_well_formed(cmd_mbc_buf))
|
||||
if (!is_utf8_well_formed(cmd_mbc_buf, cmd_mbc_buf_index))
|
||||
{
|
||||
/* complete, but not well formed (non-shortest form), sequence */
|
||||
cmd_mbc_buf_len = 0;
|
||||
@ -1303,6 +1320,7 @@ get_cmdbuf()
|
||||
return (cmdbuf);
|
||||
}
|
||||
|
||||
#if CMD_HISTORY
|
||||
/*
|
||||
* Return the last (most recent) string in the current command history.
|
||||
*/
|
||||
@ -1313,8 +1331,21 @@ cmd_lastpattern()
|
||||
return (NULL);
|
||||
return (curr_mlist->curr_mp->prev->string);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CMD_HISTORY
|
||||
/*
|
||||
*/
|
||||
static int
|
||||
mlist_size(ml)
|
||||
struct mlist *ml;
|
||||
{
|
||||
int size = 0;
|
||||
for (ml = ml->next; ml->string != NULL; ml = ml->next)
|
||||
++size;
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the name of the history file.
|
||||
*/
|
||||
@ -1335,6 +1366,10 @@ histfile_name()
|
||||
return (save(name));
|
||||
}
|
||||
|
||||
/* See if history file is disabled in the build. */
|
||||
if (strcmp(LESSHISTFILE, "") == 0 || strcmp(LESSHISTFILE, "-") == 0)
|
||||
return (NULL);
|
||||
|
||||
/* Otherwise, file is in $HOME. */
|
||||
home = lgetenv("HOME");
|
||||
if (home == NULL || *home == '\0')
|
||||
@ -1345,25 +1380,28 @@ histfile_name()
|
||||
#endif
|
||||
return (NULL);
|
||||
}
|
||||
len = strlen(home) + strlen(LESSHISTFILE) + 2;
|
||||
len = (int) (strlen(home) + strlen(LESSHISTFILE) + 2);
|
||||
name = (char *) ecalloc(len, sizeof(char));
|
||||
SNPRINTF2(name, len, "%s/%s", home, LESSHISTFILE);
|
||||
return (name);
|
||||
}
|
||||
#endif /* CMD_HISTORY */
|
||||
|
||||
/*
|
||||
* Initialize history from a .lesshist file.
|
||||
* Read a .lesshst file and call a callback for each line in the file.
|
||||
*/
|
||||
public void
|
||||
init_cmdhist()
|
||||
static void
|
||||
read_cmdhist2(action, uparam, skip_search, skip_shell)
|
||||
void (*action)(void*,struct mlist*,char*);
|
||||
void *uparam;
|
||||
int skip_search;
|
||||
int skip_shell;
|
||||
{
|
||||
#if CMD_HISTORY
|
||||
struct mlist *ml = NULL;
|
||||
char line[CMDBUF_SIZE];
|
||||
char *filename;
|
||||
FILE *f;
|
||||
char *p;
|
||||
int *skip = NULL;
|
||||
|
||||
filename = histfile_name();
|
||||
if (filename == NULL)
|
||||
@ -1389,96 +1427,248 @@ init_cmdhist()
|
||||
}
|
||||
}
|
||||
if (strcmp(line, HISTFILE_SEARCH_SECTION) == 0)
|
||||
{
|
||||
ml = &mlist_search;
|
||||
else if (strcmp(line, HISTFILE_SHELL_SECTION) == 0)
|
||||
skip = &skip_search;
|
||||
} else if (strcmp(line, HISTFILE_SHELL_SECTION) == 0)
|
||||
{
|
||||
#if SHELL_ESCAPE || PIPEC
|
||||
ml = &mlist_shell;
|
||||
skip = &skip_shell;
|
||||
#else
|
||||
ml = NULL;
|
||||
skip = NULL;
|
||||
#endif
|
||||
} else if (*line == '"')
|
||||
{
|
||||
if (ml != NULL)
|
||||
cmd_addhist(ml, line+1);
|
||||
{
|
||||
if (skip != NULL && *skip > 0)
|
||||
--(*skip);
|
||||
else
|
||||
(*action)(uparam, ml, line+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void
|
||||
read_cmdhist(action, uparam, skip_search, skip_shell)
|
||||
void (*action)(void*,struct mlist*,char*);
|
||||
void *uparam;
|
||||
int skip_search;
|
||||
int skip_shell;
|
||||
{
|
||||
read_cmdhist2(action, uparam, skip_search, skip_shell);
|
||||
(*action)(uparam, NULL, NULL); /* signal end of file */
|
||||
}
|
||||
|
||||
static void
|
||||
addhist_init(void *uparam, struct mlist *ml, char *string)
|
||||
{
|
||||
if (ml == NULL || string == NULL)
|
||||
return;
|
||||
cmd_addhist(ml, string, 0);
|
||||
}
|
||||
#endif /* CMD_HISTORY */
|
||||
|
||||
/*
|
||||
* Initialize history from a .lesshist file.
|
||||
*/
|
||||
public void
|
||||
init_cmdhist()
|
||||
{
|
||||
#if CMD_HISTORY
|
||||
read_cmdhist(&addhist_init, NULL, 0, 0);
|
||||
#endif /* CMD_HISTORY */
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Write the header for a section of the history file.
|
||||
*/
|
||||
#if CMD_HISTORY
|
||||
static void
|
||||
save_mlist(ml, f)
|
||||
write_mlist_header(ml, f)
|
||||
struct mlist *ml;
|
||||
FILE *f;
|
||||
{
|
||||
int histsize = 0;
|
||||
int n;
|
||||
char *s;
|
||||
if (ml == &mlist_search)
|
||||
fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
|
||||
#if SHELL_ESCAPE || PIPEC
|
||||
else if (ml == &mlist_shell)
|
||||
fprintf(f, "%s\n", HISTFILE_SHELL_SECTION);
|
||||
#endif
|
||||
}
|
||||
|
||||
s = lgetenv("LESSHISTSIZE");
|
||||
if (s != NULL)
|
||||
histsize = atoi(s);
|
||||
if (histsize == 0)
|
||||
histsize = 100;
|
||||
|
||||
ml = ml->prev;
|
||||
for (n = 0; n < histsize; n++)
|
||||
{
|
||||
if (ml->string == NULL)
|
||||
break;
|
||||
ml = ml->prev;
|
||||
}
|
||||
/*
|
||||
* Write all modified entries in an mlist to the history file.
|
||||
*/
|
||||
static void
|
||||
write_mlist(ml, f)
|
||||
struct mlist *ml;
|
||||
FILE *f;
|
||||
{
|
||||
for (ml = ml->next; ml->string != NULL; ml = ml->next)
|
||||
{
|
||||
if (!ml->modified)
|
||||
continue;
|
||||
fprintf(f, "\"%s\n", ml->string);
|
||||
ml->modified = 0;
|
||||
}
|
||||
ml->modified = 0; /* entire mlist is now unmodified */
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a temp name in the same directory as filename.
|
||||
*/
|
||||
static char *
|
||||
make_tempname(filename)
|
||||
char *filename;
|
||||
{
|
||||
char lastch;
|
||||
char *tempname = ecalloc(1, strlen(filename)+1);
|
||||
strcpy(tempname, filename);
|
||||
lastch = tempname[strlen(tempname)-1];
|
||||
tempname[strlen(tempname)-1] = (lastch == 'Q') ? 'Z' : 'Q';
|
||||
return tempname;
|
||||
}
|
||||
|
||||
struct save_ctx
|
||||
{
|
||||
struct mlist *mlist;
|
||||
FILE *fout;
|
||||
};
|
||||
|
||||
/*
|
||||
* Copy entries from the saved history file to a new file.
|
||||
* At the end of each mlist, append any new entries
|
||||
* created during this session.
|
||||
*/
|
||||
static void
|
||||
copy_hist(void *uparam, struct mlist *ml, char *string)
|
||||
{
|
||||
struct save_ctx *ctx = (struct save_ctx *) uparam;
|
||||
|
||||
if (ml != ctx->mlist) {
|
||||
/* We're changing mlists. */
|
||||
if (ctx->mlist)
|
||||
/* Append any new entries to the end of the current mlist. */
|
||||
write_mlist(ctx->mlist, ctx->fout);
|
||||
/* Write the header for the new mlist. */
|
||||
ctx->mlist = ml;
|
||||
write_mlist_header(ctx->mlist, ctx->fout);
|
||||
}
|
||||
if (string != NULL)
|
||||
{
|
||||
/* Copy the entry. */
|
||||
fprintf(ctx->fout, "\"%s\n", string);
|
||||
}
|
||||
if (ml == NULL) /* End of file */
|
||||
{
|
||||
/* Write any sections that were not in the original file. */
|
||||
if (mlist_search.modified)
|
||||
{
|
||||
write_mlist_header(&mlist_search, ctx->fout);
|
||||
write_mlist(&mlist_search, ctx->fout);
|
||||
}
|
||||
#if SHELL_ESCAPE || PIPEC
|
||||
if (mlist_shell.modified)
|
||||
{
|
||||
write_mlist_header(&mlist_shell, ctx->fout);
|
||||
write_mlist(&mlist_shell, ctx->fout);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* CMD_HISTORY */
|
||||
|
||||
/*
|
||||
*
|
||||
* Make a file readable only by its owner.
|
||||
*/
|
||||
static void
|
||||
make_file_private(f)
|
||||
FILE *f;
|
||||
{
|
||||
#if HAVE_FCHMOD
|
||||
int do_chmod = 1;
|
||||
#if HAVE_STAT
|
||||
struct stat statbuf;
|
||||
int r = fstat(fileno(f), &statbuf);
|
||||
if (r < 0 || !S_ISREG(statbuf.st_mode))
|
||||
/* Don't chmod if not a regular file. */
|
||||
do_chmod = 0;
|
||||
#endif
|
||||
if (do_chmod)
|
||||
fchmod(fileno(f), 0600);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Does the history file need to be updated?
|
||||
*/
|
||||
static int
|
||||
histfile_modified()
|
||||
{
|
||||
if (mlist_search.modified)
|
||||
return 1;
|
||||
#if SHELL_ESCAPE || PIPEC
|
||||
if (mlist_shell.modified)
|
||||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the .lesshst file.
|
||||
*/
|
||||
public void
|
||||
save_cmdhist()
|
||||
{
|
||||
#if CMD_HISTORY
|
||||
char *filename;
|
||||
FILE *f;
|
||||
int modified = 0;
|
||||
char *histname;
|
||||
char *tempname;
|
||||
int skip_search;
|
||||
int skip_shell;
|
||||
struct save_ctx ctx;
|
||||
char *s;
|
||||
FILE *fout = NULL;
|
||||
int histsize = 0;
|
||||
|
||||
filename = histfile_name();
|
||||
if (filename == NULL)
|
||||
if (!histfile_modified())
|
||||
return;
|
||||
if (mlist_search.modified)
|
||||
modified = 1;
|
||||
histname = histfile_name();
|
||||
if (histname == NULL)
|
||||
return;
|
||||
tempname = make_tempname(histname);
|
||||
fout = fopen(tempname, "w");
|
||||
if (fout != NULL)
|
||||
{
|
||||
make_file_private(fout);
|
||||
s = lgetenv("LESSHISTSIZE");
|
||||
if (s != NULL)
|
||||
histsize = atoi(s);
|
||||
if (histsize <= 0)
|
||||
histsize = 100;
|
||||
skip_search = mlist_size(&mlist_search) - histsize;
|
||||
#if SHELL_ESCAPE || PIPEC
|
||||
if (mlist_shell.modified)
|
||||
modified = 1;
|
||||
skip_shell = mlist_size(&mlist_shell) - histsize;
|
||||
#endif
|
||||
if (!modified)
|
||||
return;
|
||||
f = fopen(filename, "w");
|
||||
free(filename);
|
||||
if (f == NULL)
|
||||
return;
|
||||
#if HAVE_FCHMOD
|
||||
/* Make history file readable only by owner. */
|
||||
fchmod(fileno(f), 0600);
|
||||
fprintf(fout, "%s\n", HISTFILE_FIRST_LINE);
|
||||
ctx.fout = fout;
|
||||
ctx.mlist = NULL;
|
||||
read_cmdhist(copy_hist, &ctx, skip_search, skip_shell);
|
||||
fclose(fout);
|
||||
#if MSDOS_COMPILER==WIN32C
|
||||
/*
|
||||
* Windows rename doesn't remove an existing file,
|
||||
* making it useless for atomic operations. Sigh.
|
||||
*/
|
||||
remove(histname);
|
||||
#endif
|
||||
|
||||
fprintf(f, "%s\n", HISTFILE_FIRST_LINE);
|
||||
|
||||
fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
|
||||
save_mlist(&mlist_search, f);
|
||||
|
||||
#if SHELL_ESCAPE || PIPEC
|
||||
fprintf(f, "%s\n", HISTFILE_SHELL_SECTION);
|
||||
save_mlist(&mlist_shell, f);
|
||||
#endif
|
||||
|
||||
fclose(f);
|
||||
rename(tempname, histname);
|
||||
}
|
||||
free(tempname);
|
||||
free(histname);
|
||||
#endif /* CMD_HISTORY */
|
||||
}
|
||||
|
748
less/command.c
Executable file → Normal file
748
less/command.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
291
less/compose.uni
Normal file
291
less/compose.uni
Normal file
@ -0,0 +1,291 @@
|
||||
/* Generated by "./mkutable -f2 Mn Me -- unicode/UnicodeData.txt" on Tue Sep 20 10:51:43 PDT 2016 */
|
||||
{ 0x0300, 0x036f }, /* Mn */
|
||||
{ 0x0483, 0x0487 }, /* Mn */
|
||||
{ 0x0488, 0x0489 }, /* Me */
|
||||
{ 0x0591, 0x05bd }, /* Mn */
|
||||
{ 0x05bf, 0x05bf }, /* Mn */
|
||||
{ 0x05c1, 0x05c2 }, /* Mn */
|
||||
{ 0x05c4, 0x05c5 }, /* Mn */
|
||||
{ 0x05c7, 0x05c7 }, /* Mn */
|
||||
{ 0x0610, 0x061a }, /* Mn */
|
||||
{ 0x064b, 0x065f }, /* Mn */
|
||||
{ 0x0670, 0x0670 }, /* Mn */
|
||||
{ 0x06d6, 0x06dc }, /* Mn */
|
||||
{ 0x06df, 0x06e4 }, /* Mn */
|
||||
{ 0x06e7, 0x06e8 }, /* Mn */
|
||||
{ 0x06ea, 0x06ed }, /* Mn */
|
||||
{ 0x0711, 0x0711 }, /* Mn */
|
||||
{ 0x0730, 0x074a }, /* Mn */
|
||||
{ 0x07a6, 0x07b0 }, /* Mn */
|
||||
{ 0x07eb, 0x07f3 }, /* Mn */
|
||||
{ 0x0816, 0x0819 }, /* Mn */
|
||||
{ 0x081b, 0x0823 }, /* Mn */
|
||||
{ 0x0825, 0x0827 }, /* Mn */
|
||||
{ 0x0829, 0x082d }, /* Mn */
|
||||
{ 0x0859, 0x085b }, /* Mn */
|
||||
{ 0x08d4, 0x08e1 }, /* Mn */
|
||||
{ 0x08e3, 0x0902 }, /* Mn */
|
||||
{ 0x093a, 0x093a }, /* Mn */
|
||||
{ 0x093c, 0x093c }, /* Mn */
|
||||
{ 0x0941, 0x0948 }, /* Mn */
|
||||
{ 0x094d, 0x094d }, /* Mn */
|
||||
{ 0x0951, 0x0957 }, /* Mn */
|
||||
{ 0x0962, 0x0963 }, /* Mn */
|
||||
{ 0x0981, 0x0981 }, /* Mn */
|
||||
{ 0x09bc, 0x09bc }, /* Mn */
|
||||
{ 0x09c1, 0x09c4 }, /* Mn */
|
||||
{ 0x09cd, 0x09cd }, /* Mn */
|
||||
{ 0x09e2, 0x09e3 }, /* Mn */
|
||||
{ 0x0a01, 0x0a02 }, /* Mn */
|
||||
{ 0x0a3c, 0x0a3c }, /* Mn */
|
||||
{ 0x0a41, 0x0a42 }, /* Mn */
|
||||
{ 0x0a47, 0x0a48 }, /* Mn */
|
||||
{ 0x0a4b, 0x0a4d }, /* Mn */
|
||||
{ 0x0a51, 0x0a51 }, /* Mn */
|
||||
{ 0x0a70, 0x0a71 }, /* Mn */
|
||||
{ 0x0a75, 0x0a75 }, /* Mn */
|
||||
{ 0x0a81, 0x0a82 }, /* Mn */
|
||||
{ 0x0abc, 0x0abc }, /* Mn */
|
||||
{ 0x0ac1, 0x0ac5 }, /* Mn */
|
||||
{ 0x0ac7, 0x0ac8 }, /* Mn */
|
||||
{ 0x0acd, 0x0acd }, /* Mn */
|
||||
{ 0x0ae2, 0x0ae3 }, /* Mn */
|
||||
{ 0x0b01, 0x0b01 }, /* Mn */
|
||||
{ 0x0b3c, 0x0b3c }, /* Mn */
|
||||
{ 0x0b3f, 0x0b3f }, /* Mn */
|
||||
{ 0x0b41, 0x0b44 }, /* Mn */
|
||||
{ 0x0b4d, 0x0b4d }, /* Mn */
|
||||
{ 0x0b56, 0x0b56 }, /* Mn */
|
||||
{ 0x0b62, 0x0b63 }, /* Mn */
|
||||
{ 0x0b82, 0x0b82 }, /* Mn */
|
||||
{ 0x0bc0, 0x0bc0 }, /* Mn */
|
||||
{ 0x0bcd, 0x0bcd }, /* Mn */
|
||||
{ 0x0c00, 0x0c00 }, /* Mn */
|
||||
{ 0x0c3e, 0x0c40 }, /* Mn */
|
||||
{ 0x0c46, 0x0c48 }, /* Mn */
|
||||
{ 0x0c4a, 0x0c4d }, /* Mn */
|
||||
{ 0x0c55, 0x0c56 }, /* Mn */
|
||||
{ 0x0c62, 0x0c63 }, /* Mn */
|
||||
{ 0x0c81, 0x0c81 }, /* Mn */
|
||||
{ 0x0cbc, 0x0cbc }, /* Mn */
|
||||
{ 0x0cbf, 0x0cbf }, /* Mn */
|
||||
{ 0x0cc6, 0x0cc6 }, /* Mn */
|
||||
{ 0x0ccc, 0x0ccd }, /* Mn */
|
||||
{ 0x0ce2, 0x0ce3 }, /* Mn */
|
||||
{ 0x0d01, 0x0d01 }, /* Mn */
|
||||
{ 0x0d41, 0x0d44 }, /* Mn */
|
||||
{ 0x0d4d, 0x0d4d }, /* Mn */
|
||||
{ 0x0d62, 0x0d63 }, /* Mn */
|
||||
{ 0x0dca, 0x0dca }, /* Mn */
|
||||
{ 0x0dd2, 0x0dd4 }, /* Mn */
|
||||
{ 0x0dd6, 0x0dd6 }, /* Mn */
|
||||
{ 0x0e31, 0x0e31 }, /* Mn */
|
||||
{ 0x0e34, 0x0e3a }, /* Mn */
|
||||
{ 0x0e47, 0x0e4e }, /* Mn */
|
||||
{ 0x0eb1, 0x0eb1 }, /* Mn */
|
||||
{ 0x0eb4, 0x0eb9 }, /* Mn */
|
||||
{ 0x0ebb, 0x0ebc }, /* Mn */
|
||||
{ 0x0ec8, 0x0ecd }, /* Mn */
|
||||
{ 0x0f18, 0x0f19 }, /* Mn */
|
||||
{ 0x0f35, 0x0f35 }, /* Mn */
|
||||
{ 0x0f37, 0x0f37 }, /* Mn */
|
||||
{ 0x0f39, 0x0f39 }, /* Mn */
|
||||
{ 0x0f71, 0x0f7e }, /* Mn */
|
||||
{ 0x0f80, 0x0f84 }, /* Mn */
|
||||
{ 0x0f86, 0x0f87 }, /* Mn */
|
||||
{ 0x0f8d, 0x0f97 }, /* Mn */
|
||||
{ 0x0f99, 0x0fbc }, /* Mn */
|
||||
{ 0x0fc6, 0x0fc6 }, /* Mn */
|
||||
{ 0x102d, 0x1030 }, /* Mn */
|
||||
{ 0x1032, 0x1037 }, /* Mn */
|
||||
{ 0x1039, 0x103a }, /* Mn */
|
||||
{ 0x103d, 0x103e }, /* Mn */
|
||||
{ 0x1058, 0x1059 }, /* Mn */
|
||||
{ 0x105e, 0x1060 }, /* Mn */
|
||||
{ 0x1071, 0x1074 }, /* Mn */
|
||||
{ 0x1082, 0x1082 }, /* Mn */
|
||||
{ 0x1085, 0x1086 }, /* Mn */
|
||||
{ 0x108d, 0x108d }, /* Mn */
|
||||
{ 0x109d, 0x109d }, /* Mn */
|
||||
{ 0x135d, 0x135f }, /* Mn */
|
||||
{ 0x1712, 0x1714 }, /* Mn */
|
||||
{ 0x1732, 0x1734 }, /* Mn */
|
||||
{ 0x1752, 0x1753 }, /* Mn */
|
||||
{ 0x1772, 0x1773 }, /* Mn */
|
||||
{ 0x17b4, 0x17b5 }, /* Mn */
|
||||
{ 0x17b7, 0x17bd }, /* Mn */
|
||||
{ 0x17c6, 0x17c6 }, /* Mn */
|
||||
{ 0x17c9, 0x17d3 }, /* Mn */
|
||||
{ 0x17dd, 0x17dd }, /* Mn */
|
||||
{ 0x180b, 0x180d }, /* Mn */
|
||||
{ 0x1885, 0x1886 }, /* Mn */
|
||||
{ 0x18a9, 0x18a9 }, /* Mn */
|
||||
{ 0x1920, 0x1922 }, /* Mn */
|
||||
{ 0x1927, 0x1928 }, /* Mn */
|
||||
{ 0x1932, 0x1932 }, /* Mn */
|
||||
{ 0x1939, 0x193b }, /* Mn */
|
||||
{ 0x1a17, 0x1a18 }, /* Mn */
|
||||
{ 0x1a1b, 0x1a1b }, /* Mn */
|
||||
{ 0x1a56, 0x1a56 }, /* Mn */
|
||||
{ 0x1a58, 0x1a5e }, /* Mn */
|
||||
{ 0x1a60, 0x1a60 }, /* Mn */
|
||||
{ 0x1a62, 0x1a62 }, /* Mn */
|
||||
{ 0x1a65, 0x1a6c }, /* Mn */
|
||||
{ 0x1a73, 0x1a7c }, /* Mn */
|
||||
{ 0x1a7f, 0x1a7f }, /* Mn */
|
||||
{ 0x1ab0, 0x1abd }, /* Mn */
|
||||
{ 0x1abe, 0x1abe }, /* Me */
|
||||
{ 0x1b00, 0x1b03 }, /* Mn */
|
||||
{ 0x1b34, 0x1b34 }, /* Mn */
|
||||
{ 0x1b36, 0x1b3a }, /* Mn */
|
||||
{ 0x1b3c, 0x1b3c }, /* Mn */
|
||||
{ 0x1b42, 0x1b42 }, /* Mn */
|
||||
{ 0x1b6b, 0x1b73 }, /* Mn */
|
||||
{ 0x1b80, 0x1b81 }, /* Mn */
|
||||
{ 0x1ba2, 0x1ba5 }, /* Mn */
|
||||
{ 0x1ba8, 0x1ba9 }, /* Mn */
|
||||
{ 0x1bab, 0x1bad }, /* Mn */
|
||||
{ 0x1be6, 0x1be6 }, /* Mn */
|
||||
{ 0x1be8, 0x1be9 }, /* Mn */
|
||||
{ 0x1bed, 0x1bed }, /* Mn */
|
||||
{ 0x1bef, 0x1bf1 }, /* Mn */
|
||||
{ 0x1c2c, 0x1c33 }, /* Mn */
|
||||
{ 0x1c36, 0x1c37 }, /* Mn */
|
||||
{ 0x1cd0, 0x1cd2 }, /* Mn */
|
||||
{ 0x1cd4, 0x1ce0 }, /* Mn */
|
||||
{ 0x1ce2, 0x1ce8 }, /* Mn */
|
||||
{ 0x1ced, 0x1ced }, /* Mn */
|
||||
{ 0x1cf4, 0x1cf4 }, /* Mn */
|
||||
{ 0x1cf8, 0x1cf9 }, /* Mn */
|
||||
{ 0x1dc0, 0x1df5 }, /* Mn */
|
||||
{ 0x1dfb, 0x1dff }, /* Mn */
|
||||
{ 0x20d0, 0x20dc }, /* Mn */
|
||||
{ 0x20dd, 0x20e0 }, /* Me */
|
||||
{ 0x20e1, 0x20e1 }, /* Mn */
|
||||
{ 0x20e2, 0x20e4 }, /* Me */
|
||||
{ 0x20e5, 0x20f0 }, /* Mn */
|
||||
{ 0x2cef, 0x2cf1 }, /* Mn */
|
||||
{ 0x2d7f, 0x2d7f }, /* Mn */
|
||||
{ 0x2de0, 0x2dff }, /* Mn */
|
||||
{ 0x302a, 0x302d }, /* Mn */
|
||||
{ 0x3099, 0x309a }, /* Mn */
|
||||
{ 0xa66f, 0xa66f }, /* Mn */
|
||||
{ 0xa670, 0xa672 }, /* Me */
|
||||
{ 0xa674, 0xa67d }, /* Mn */
|
||||
{ 0xa69e, 0xa69f }, /* Mn */
|
||||
{ 0xa6f0, 0xa6f1 }, /* Mn */
|
||||
{ 0xa802, 0xa802 }, /* Mn */
|
||||
{ 0xa806, 0xa806 }, /* Mn */
|
||||
{ 0xa80b, 0xa80b }, /* Mn */
|
||||
{ 0xa825, 0xa826 }, /* Mn */
|
||||
{ 0xa8c4, 0xa8c5 }, /* Mn */
|
||||
{ 0xa8e0, 0xa8f1 }, /* Mn */
|
||||
{ 0xa926, 0xa92d }, /* Mn */
|
||||
{ 0xa947, 0xa951 }, /* Mn */
|
||||
{ 0xa980, 0xa982 }, /* Mn */
|
||||
{ 0xa9b3, 0xa9b3 }, /* Mn */
|
||||
{ 0xa9b6, 0xa9b9 }, /* Mn */
|
||||
{ 0xa9bc, 0xa9bc }, /* Mn */
|
||||
{ 0xa9e5, 0xa9e5 }, /* Mn */
|
||||
{ 0xaa29, 0xaa2e }, /* Mn */
|
||||
{ 0xaa31, 0xaa32 }, /* Mn */
|
||||
{ 0xaa35, 0xaa36 }, /* Mn */
|
||||
{ 0xaa43, 0xaa43 }, /* Mn */
|
||||
{ 0xaa4c, 0xaa4c }, /* Mn */
|
||||
{ 0xaa7c, 0xaa7c }, /* Mn */
|
||||
{ 0xaab0, 0xaab0 }, /* Mn */
|
||||
{ 0xaab2, 0xaab4 }, /* Mn */
|
||||
{ 0xaab7, 0xaab8 }, /* Mn */
|
||||
{ 0xaabe, 0xaabf }, /* Mn */
|
||||
{ 0xaac1, 0xaac1 }, /* Mn */
|
||||
{ 0xaaec, 0xaaed }, /* Mn */
|
||||
{ 0xaaf6, 0xaaf6 }, /* Mn */
|
||||
{ 0xabe5, 0xabe5 }, /* Mn */
|
||||
{ 0xabe8, 0xabe8 }, /* Mn */
|
||||
{ 0xabed, 0xabed }, /* Mn */
|
||||
{ 0xfb1e, 0xfb1e }, /* Mn */
|
||||
{ 0xfe00, 0xfe0f }, /* Mn */
|
||||
{ 0xfe20, 0xfe2f }, /* Mn */
|
||||
{ 0x101fd, 0x101fd }, /* Mn */
|
||||
{ 0x102e0, 0x102e0 }, /* Mn */
|
||||
{ 0x10376, 0x1037a }, /* Mn */
|
||||
{ 0x10a01, 0x10a03 }, /* Mn */
|
||||
{ 0x10a05, 0x10a06 }, /* Mn */
|
||||
{ 0x10a0c, 0x10a0f }, /* Mn */
|
||||
{ 0x10a38, 0x10a3a }, /* Mn */
|
||||
{ 0x10a3f, 0x10a3f }, /* Mn */
|
||||
{ 0x10ae5, 0x10ae6 }, /* Mn */
|
||||
{ 0x11001, 0x11001 }, /* Mn */
|
||||
{ 0x11038, 0x11046 }, /* Mn */
|
||||
{ 0x1107f, 0x11081 }, /* Mn */
|
||||
{ 0x110b3, 0x110b6 }, /* Mn */
|
||||
{ 0x110b9, 0x110ba }, /* Mn */
|
||||
{ 0x11100, 0x11102 }, /* Mn */
|
||||
{ 0x11127, 0x1112b }, /* Mn */
|
||||
{ 0x1112d, 0x11134 }, /* Mn */
|
||||
{ 0x11173, 0x11173 }, /* Mn */
|
||||
{ 0x11180, 0x11181 }, /* Mn */
|
||||
{ 0x111b6, 0x111be }, /* Mn */
|
||||
{ 0x111ca, 0x111cc }, /* Mn */
|
||||
{ 0x1122f, 0x11231 }, /* Mn */
|
||||
{ 0x11234, 0x11234 }, /* Mn */
|
||||
{ 0x11236, 0x11237 }, /* Mn */
|
||||
{ 0x1123e, 0x1123e }, /* Mn */
|
||||
{ 0x112df, 0x112df }, /* Mn */
|
||||
{ 0x112e3, 0x112ea }, /* Mn */
|
||||
{ 0x11300, 0x11301 }, /* Mn */
|
||||
{ 0x1133c, 0x1133c }, /* Mn */
|
||||
{ 0x11340, 0x11340 }, /* Mn */
|
||||
{ 0x11366, 0x1136c }, /* Mn */
|
||||
{ 0x11370, 0x11374 }, /* Mn */
|
||||
{ 0x11438, 0x1143f }, /* Mn */
|
||||
{ 0x11442, 0x11444 }, /* Mn */
|
||||
{ 0x11446, 0x11446 }, /* Mn */
|
||||
{ 0x114b3, 0x114b8 }, /* Mn */
|
||||
{ 0x114ba, 0x114ba }, /* Mn */
|
||||
{ 0x114bf, 0x114c0 }, /* Mn */
|
||||
{ 0x114c2, 0x114c3 }, /* Mn */
|
||||
{ 0x115b2, 0x115b5 }, /* Mn */
|
||||
{ 0x115bc, 0x115bd }, /* Mn */
|
||||
{ 0x115bf, 0x115c0 }, /* Mn */
|
||||
{ 0x115dc, 0x115dd }, /* Mn */
|
||||
{ 0x11633, 0x1163a }, /* Mn */
|
||||
{ 0x1163d, 0x1163d }, /* Mn */
|
||||
{ 0x1163f, 0x11640 }, /* Mn */
|
||||
{ 0x116ab, 0x116ab }, /* Mn */
|
||||
{ 0x116ad, 0x116ad }, /* Mn */
|
||||
{ 0x116b0, 0x116b5 }, /* Mn */
|
||||
{ 0x116b7, 0x116b7 }, /* Mn */
|
||||
{ 0x1171d, 0x1171f }, /* Mn */
|
||||
{ 0x11722, 0x11725 }, /* Mn */
|
||||
{ 0x11727, 0x1172b }, /* Mn */
|
||||
{ 0x11c30, 0x11c36 }, /* Mn */
|
||||
{ 0x11c38, 0x11c3d }, /* Mn */
|
||||
{ 0x11c3f, 0x11c3f }, /* Mn */
|
||||
{ 0x11c92, 0x11ca7 }, /* Mn */
|
||||
{ 0x11caa, 0x11cb0 }, /* Mn */
|
||||
{ 0x11cb2, 0x11cb3 }, /* Mn */
|
||||
{ 0x11cb5, 0x11cb6 }, /* Mn */
|
||||
{ 0x16af0, 0x16af4 }, /* Mn */
|
||||
{ 0x16b30, 0x16b36 }, /* Mn */
|
||||
{ 0x16f8f, 0x16f92 }, /* Mn */
|
||||
{ 0x1bc9d, 0x1bc9e }, /* Mn */
|
||||
{ 0x1d167, 0x1d169 }, /* Mn */
|
||||
{ 0x1d17b, 0x1d182 }, /* Mn */
|
||||
{ 0x1d185, 0x1d18b }, /* Mn */
|
||||
{ 0x1d1aa, 0x1d1ad }, /* Mn */
|
||||
{ 0x1d242, 0x1d244 }, /* Mn */
|
||||
{ 0x1da00, 0x1da36 }, /* Mn */
|
||||
{ 0x1da3b, 0x1da6c }, /* Mn */
|
||||
{ 0x1da75, 0x1da75 }, /* Mn */
|
||||
{ 0x1da84, 0x1da84 }, /* Mn */
|
||||
{ 0x1da9b, 0x1da9f }, /* Mn */
|
||||
{ 0x1daa1, 0x1daaf }, /* Mn */
|
||||
{ 0x1e000, 0x1e006 }, /* Mn */
|
||||
{ 0x1e008, 0x1e018 }, /* Mn */
|
||||
{ 0x1e01b, 0x1e021 }, /* Mn */
|
||||
{ 0x1e023, 0x1e024 }, /* Mn */
|
||||
{ 0x1e026, 0x1e02a }, /* Mn */
|
||||
{ 0x1e8d0, 0x1e8d6 }, /* Mn */
|
||||
{ 0x1e944, 0x1e94a }, /* Mn */
|
||||
{ 0xe0100, 0xe01ef }, /* Mn */
|
7358
less/configure
vendored
7358
less/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1984-2007 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.
|
||||
@ -30,11 +30,9 @@ AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
|
||||
AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
|
||||
AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
|
||||
AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
|
||||
# Regular expressions (regcmp) are in -lgen on Solaris 2,
|
||||
# and in -lintl on SCO Unix.
|
||||
AC_CHECK_LIB(gen, regcmp)
|
||||
AC_CHECK_LIB(intl, regcmp)
|
||||
AC_CHECK_LIB(PW, regcmp)
|
||||
# Regular expressions (regcmp) are in -lgen on Solaris 2, (but in libc
|
||||
# at least on Solaris 10 (2.10)) and in -lintl on SCO Unix.
|
||||
AC_SEARCH_LIBS([regcmp], [gen intl PW])
|
||||
|
||||
# Checks for terminal libraries
|
||||
AC_MSG_CHECKING([for working terminal libraries])
|
||||
@ -179,6 +177,8 @@ AC_TYPE_SIZE_T
|
||||
AC_HEADER_TIME
|
||||
|
||||
# Autoheader templates for symbols defined later by AC_DEFINE.
|
||||
AH_TEMPLATE([HAVE_GNU_REGEX],
|
||||
[GNU regex library])
|
||||
AH_TEMPLATE([HAVE_POSIX_REGCOMP],
|
||||
[POSIX regcomp() and regex.h])
|
||||
AH_TEMPLATE([HAVE_PCRE],
|
||||
@ -195,6 +195,8 @@ 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],
|
||||
@ -363,24 +365,37 @@ fi
|
||||
|
||||
# Compile in secure mode?
|
||||
AC_ARG_WITH(secure,
|
||||
[ --with-secure Compile in secure mode],
|
||||
[ --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)
|
||||
supported_regex=""
|
||||
|
||||
# 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]],
|
||||
[ --with-regex=LIB select regular expression library (LIB is one of auto,none,gnu,pcre,posix,regcmp,re_comp,regcomp,regcomp-local) [[auto]]],
|
||||
WANT_REGEX="$withval")
|
||||
|
||||
if test $have_regex = no; then
|
||||
if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
|
||||
# Some versions of Solaris have a regcomp() function, but it doesn't work!
|
||||
# So we run a test program. If we're cross-compiling, do it the old way.
|
||||
AC_MSG_CHECKING(for POSIX regcomp)
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
@ -395,16 +410,16 @@ if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
|
||||
exit(0); }],
|
||||
have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
|
||||
if test $have_posix_regex = yes; then
|
||||
AC_MSG_RESULT(using POSIX regcomp)
|
||||
AC_DEFINE(HAVE_POSIX_REGCOMP)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_POSIX_REGCOMP) supported_regex="$supported_regex posix"
|
||||
have_regex=yes
|
||||
elif test $have_posix_regex = unknown; then
|
||||
AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>],
|
||||
[regex_t *r; regfree(r);],
|
||||
AC_MSG_RESULT(using POSIX regcomp)
|
||||
AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes; supported_regex="$supported_regex posix")
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
@ -414,43 +429,62 @@ fi
|
||||
if test $have_regex = no; then
|
||||
if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
|
||||
AC_CHECK_LIB(pcre, pcre_compile,
|
||||
[AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
|
||||
[AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes; supported_regex="$supported_regex pcre"], [])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $have_regex = no; then
|
||||
if test $WANT_REGEX = auto -o $WANT_REGEX = gnu; then
|
||||
AC_CHECK_LIB(c, re_compile_pattern,
|
||||
[AC_DEFINE(HAVE_GNU_REGEX) have_regex=yes; supported_regex="$supported_regex gnu"], [])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $have_regex = no; then
|
||||
if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
|
||||
AC_CHECK_FUNC(regcmp,
|
||||
AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
|
||||
[AC_DEFINE(HAVE_REGCMP) have_regex=yes; supported_regex="$supported_regex regcmp"],[])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $have_regex = no; then
|
||||
if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
|
||||
AC_MSG_CHECKING(for V8 regcomp)
|
||||
AC_TRY_LINK([
|
||||
#include "regexp.h"], [regcomp("");],
|
||||
AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
|
||||
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes; supported_regex="$supported_regex regcomp"],[AC_MSG_RESULT(no)])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $have_regex = no && test -f ${srcdir}/regexp.c; then
|
||||
if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
|
||||
AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) AC_DEFINE(HAVE_REGEXEC2) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
|
||||
AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP)
|
||||
supported_regex="$supported_regex regcomp-local"
|
||||
AC_DEFINE(HAVE_REGEXEC2) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $have_regex = no; then
|
||||
if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
|
||||
AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
|
||||
AC_MSG_CHECKING(for re_comp)
|
||||
AC_CHECK_FUNC(re_comp,
|
||||
[AC_DEFINE(HAVE_RE_COMP) have_regex=yes; supported_regex="$supported_regex re_comp"],[])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $have_regex = no; then
|
||||
AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
|
||||
if test $WANT_REGEX = auto -o $WANT_REGEX = none; then
|
||||
AC_MSG_RESULT(using no regex)
|
||||
else
|
||||
AC_MSG_WARN(cannot find regular expression library)
|
||||
fi
|
||||
AC_DEFINE(NO_REGEX) supported_regex="$supported_regex none"
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT(regular expression library: $supported_regex)
|
||||
|
||||
AC_ARG_WITH(editor,
|
||||
[ --with-editor=PROGRAM use PROGRAM as the default editor [vi]],
|
||||
[ --with-editor=PROGRAM use PROGRAM as the default editor [[vi]]],
|
||||
AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"), AC_DEFINE(EDIT_PGM, "vi"))
|
||||
|
||||
AH_TOP([
|
||||
@ -635,6 +669,7 @@ AH_TOP([
|
||||
/*
|
||||
* Sizes of various buffers.
|
||||
*/
|
||||
#if 0 /* old sizes for small memory machines */
|
||||
#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 */
|
||||
@ -644,6 +679,17 @@ AH_TOP([
|
||||
#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 */
|
||||
#else /* more reasonable sizes for modern machines */
|
||||
#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
|
||||
#define UNGOT_SIZE 200 /* Max chars to unget() */
|
||||
#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
|
||||
#define OUTBUF_SIZE 1024 /* Output buffer */
|
||||
#define PROMPT_SIZE 2048 /* 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 1024 /* Max size of line in tags file */
|
||||
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
|
||||
#endif
|
||||
|
||||
/* Settings automatically determined by configure. */
|
||||
])
|
||||
|
114
less/cvt.c
Normal file
114
less/cvt.c
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2016 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, 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 *edst = odst;
|
||||
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 = (int) (src - osrc);
|
||||
int dst_pos = (int) (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. */
|
||||
if (chpos != NULL)
|
||||
chpos[dst_pos] = src_pos;
|
||||
}
|
||||
if (dst > edst)
|
||||
edst = dst;
|
||||
}
|
||||
if ((ops & CVT_CRLF) && edst > odst && edst[-1] == '\r')
|
||||
edst--;
|
||||
*edst = '\0';
|
||||
if (lenp != NULL)
|
||||
*lenp = (int) (edst - odst);
|
||||
/* FIXME: why was this here? if (chpos != NULL) chpos[dst - odst] = src - osrc; */
|
||||
}
|
13
less/decode.c
Executable file → Normal file
13
less/decode.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -83,6 +82,7 @@ static unsigned char cmdtable[] =
|
||||
'w',0, A_B_WINDOW,
|
||||
ESC,' ',0, A_FF_SCREEN,
|
||||
'F',0, A_F_FOREVER,
|
||||
ESC,'F',0, A_F_UNTIL_HILITE,
|
||||
'R',0, A_FREPAINT,
|
||||
'r',0, A_REPAINT,
|
||||
CONTROL('R'),0, A_REPAINT,
|
||||
@ -98,8 +98,12 @@ static unsigned char cmdtable[] =
|
||||
ESC,']',0, A_RSHIFT,
|
||||
ESC,'(',0, A_LSHIFT,
|
||||
ESC,')',0, A_RSHIFT,
|
||||
ESC,'{',0, A_LLSHIFT,
|
||||
ESC,'}',0, A_RRSHIFT,
|
||||
SK(SK_RIGHT_ARROW),0, A_RSHIFT,
|
||||
SK(SK_LEFT_ARROW),0, A_LSHIFT,
|
||||
SK(SK_CTL_RIGHT_ARROW),0, A_RRSHIFT,
|
||||
SK(SK_CTL_LEFT_ARROW),0, A_LLSHIFT,
|
||||
'{',0, A_F_BRACKET|A_EXTRA, '{','}',0,
|
||||
'}',0, A_B_BRACKET|A_EXTRA, '{','}',0,
|
||||
'(',0, A_F_BRACKET|A_EXTRA, '(',')',0,
|
||||
@ -109,6 +113,7 @@ static unsigned char cmdtable[] =
|
||||
ESC,CONTROL('F'),0, A_F_BRACKET,
|
||||
ESC,CONTROL('B'),0, A_B_BRACKET,
|
||||
'G',0, A_GOEND,
|
||||
ESC,'G',0, A_GOEND_BUF,
|
||||
ESC,'>',0, A_GOEND,
|
||||
'>',0, A_GOEND,
|
||||
SK(SK_END),0, A_GOEND,
|
||||
@ -137,6 +142,7 @@ static unsigned char cmdtable[] =
|
||||
ESC,'n',0, A_T_AGAIN_SEARCH,
|
||||
'N',0, A_REVERSE_SEARCH,
|
||||
ESC,'N',0, A_T_REVERSE_SEARCH,
|
||||
'&',0, A_FILTER,
|
||||
'm',0, A_SETMARK,
|
||||
'\'',0, A_GOMARK,
|
||||
CONTROL('X'),CONTROL('X'),0, A_GOMARK,
|
||||
@ -215,6 +221,7 @@ static unsigned char edittable[] =
|
||||
SK(SK_UP_ARROW),0, EC_UP, /* UPARROW */
|
||||
ESC,'j',0, EC_DOWN, /* ESC j */
|
||||
SK(SK_DOWN_ARROW),0, EC_DOWN, /* DOWNARROW */
|
||||
CONTROL('G'),0, EC_ABORT, /* CTRL-G */
|
||||
};
|
||||
|
||||
/*
|
||||
|
20
less/defines.ds
Executable file → Normal file
20
less/defines.ds
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -186,6 +185,7 @@
|
||||
/*
|
||||
* Sizes of various buffers.
|
||||
*/
|
||||
#if 0 /* old sizes for small memory machines
|
||||
#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 */
|
||||
@ -195,6 +195,17 @@
|
||||
#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 */
|
||||
#else /* more reasonable sizes for modern machines */
|
||||
#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
|
||||
#define UNGOT_SIZE 200 /* Max chars to unget() */
|
||||
#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
|
||||
#define OUTBUF_SIZE 1024 /* Output buffer */
|
||||
#define PROMPT_SIZE 2048 /* 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 1024 /* Max size of line in tags file */
|
||||
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
|
||||
#endif
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#if MSDOS_COMPILER==BORLANDC
|
||||
@ -322,6 +333,9 @@
|
||||
/* 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
|
||||
|
||||
|
@ -182,6 +182,7 @@
|
||||
/*
|
||||
* Sizes of various buffers.
|
||||
*/
|
||||
#if 0 /* old sizes for small memory machines */
|
||||
#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 */
|
||||
@ -191,6 +192,17 @@
|
||||
#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 */
|
||||
#else /* more reasonable sizes for modern machines */
|
||||
#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
|
||||
#define UNGOT_SIZE 200 /* Max chars to unget() */
|
||||
#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
|
||||
#define OUTBUF_SIZE 1024 /* Output buffer */
|
||||
#define PROMPT_SIZE 2048 /* 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 1024 /* Max size of line in tags file */
|
||||
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
|
||||
#endif
|
||||
|
||||
/* Settings automatically determined by configure. */
|
||||
|
||||
@ -219,21 +231,18 @@
|
||||
/* Define HAVE_FILENO if you have the fileno() macro. */
|
||||
#undef HAVE_FILENO
|
||||
|
||||
/* Define HAVE_FLOAT if your compiler supports the "double" type. */
|
||||
#undef HAVE_FLOAT
|
||||
|
||||
/* Define to 1 if you have the `fsync' function. */
|
||||
#undef HAVE_FSYNC
|
||||
|
||||
/* GNU regex library */
|
||||
#undef HAVE_GNU_REGEX
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `gen' library (-lgen). */
|
||||
#undef HAVE_LIBGEN
|
||||
|
||||
/* Define to 1 if you have the `intl' library (-lintl). */
|
||||
#undef HAVE_LIBINTL
|
||||
|
||||
/* Define to 1 if you have the `PW' library (-lPW). */
|
||||
#undef HAVE_LIBPW
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
@ -386,6 +395,9 @@
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
@ -404,6 +416,11 @@
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
|
17
less/defines.o2
Executable file → Normal file
17
less/defines.o2
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -167,6 +166,7 @@
|
||||
/*
|
||||
* Sizes of various buffers.
|
||||
*/
|
||||
#if 0 /* old sizes for small memory machines
|
||||
#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 */
|
||||
@ -176,6 +176,17 @@
|
||||
#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 */
|
||||
#else /* more reasonable sizes for modern machines */
|
||||
#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
|
||||
#define UNGOT_SIZE 200 /* Max chars to unget() */
|
||||
#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
|
||||
#define OUTBUF_SIZE 1024 /* Output buffer */
|
||||
#define PROMPT_SIZE 2048 /* 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 1024 /* Max size of line in tags file */
|
||||
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
|
||||
#endif
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
/* #define off_t long */
|
||||
|
17
less/defines.o9
Executable file → Normal file
17
less/defines.o9
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -174,6 +173,7 @@
|
||||
/*
|
||||
* Sizes of various buffers.
|
||||
*/
|
||||
#if 0 /* old sizes for small memory machines
|
||||
#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 */
|
||||
@ -183,6 +183,17 @@
|
||||
#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 */
|
||||
#else /* more reasonable sizes for modern machines */
|
||||
#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
|
||||
#define UNGOT_SIZE 200 /* Max chars to unget() */
|
||||
#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
|
||||
#define OUTBUF_SIZE 1024 /* Output buffer */
|
||||
#define PROMPT_SIZE 2048 /* 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 1024 /* Max size of line in tags file */
|
||||
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
|
||||
#endif
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#define off_t long
|
||||
|
29
less/defines.wn
Executable file → Normal file
29
less/defines.wn
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -168,6 +167,7 @@
|
||||
/*
|
||||
* Sizes of various buffers.
|
||||
*/
|
||||
#if 0 /* old sizes for small memory machines
|
||||
#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 */
|
||||
@ -177,6 +177,17 @@
|
||||
#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 */
|
||||
#else /* more reasonable sizes for modern machines */
|
||||
#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
|
||||
#define UNGOT_SIZE 200 /* Max chars to unget() */
|
||||
#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
|
||||
#define OUTBUF_SIZE 1024 /* Output buffer */
|
||||
#define PROMPT_SIZE 2048 /* 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 1024 /* Max size of line in tags file */
|
||||
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
|
||||
#endif
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
/* #define off_t long */
|
||||
@ -272,7 +283,7 @@
|
||||
#define HAVE_SYSTEM 1
|
||||
|
||||
/* Define if you have the snprintf function. */
|
||||
#define HAVE_SNPRINTF 0
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Define if you have the <ctype.h> header file. */
|
||||
#define HAVE_CTYPE_H 1
|
||||
@ -286,8 +297,11 @@
|
||||
/* 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 0
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <stdio.h> header file. */
|
||||
#define HAVE_STDIO_H 1
|
||||
@ -331,3 +345,8 @@
|
||||
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
#if !defined(_MSC_VER) || (_MSC_VER < 1900)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
|
20
less/edit.c
Executable file → Normal file
20
less/edit.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -70,7 +69,7 @@ init_textlist(tlist, str)
|
||||
int meta_quoted = 0;
|
||||
int delim_quoted = 0;
|
||||
char *esc = get_meta_escape();
|
||||
int esclen = strlen(esc);
|
||||
int esclen = (int) strlen(esc);
|
||||
#endif
|
||||
|
||||
tlist->string = skipsp(str);
|
||||
@ -315,6 +314,10 @@ edit_ifile(ifile)
|
||||
*/
|
||||
__djgpp_set_ctrl_c(1);
|
||||
#endif
|
||||
} else if (strcmp(open_filename, FAKE_EMPTYFILE) == 0)
|
||||
{
|
||||
f = -1;
|
||||
chflags |= CH_NODATA;
|
||||
} else if (strcmp(open_filename, FAKE_HELPFILE) == 0)
|
||||
{
|
||||
f = -1;
|
||||
@ -419,7 +422,10 @@ edit_ifile(ifile)
|
||||
}
|
||||
#endif
|
||||
if (every_first_cmd != NULL)
|
||||
{
|
||||
ungetcc(CHAR_END_COMMAND);
|
||||
ungetsc(every_first_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
free(qopen_filename);
|
||||
@ -441,7 +447,8 @@ edit_ifile(ifile)
|
||||
#if HILITE_SEARCH
|
||||
clr_hilite();
|
||||
#endif
|
||||
cmd_addhist(ml_examine, filename);
|
||||
if (strcmp(filename, FAKE_HELPFILE) && strcmp(filename, FAKE_EMPTYFILE))
|
||||
cmd_addhist(ml_examine, filename, 1);
|
||||
if (no_display && errmsgs > 0)
|
||||
{
|
||||
/*
|
||||
@ -754,7 +761,8 @@ use_logfile(filename)
|
||||
*/
|
||||
filename = shell_unquote(filename);
|
||||
exists = open(filename, OPEN_READ);
|
||||
close(exists);
|
||||
if (exists >= 0)
|
||||
close(exists);
|
||||
exists = (exists >= 0);
|
||||
|
||||
/*
|
||||
|
150
less/filename.c
Executable file → Normal file
150
less/filename.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -87,7 +86,7 @@ shell_unquote(str)
|
||||
} else
|
||||
{
|
||||
char *esc = get_meta_escape();
|
||||
int esclen = strlen(esc);
|
||||
int esclen = (int) strlen(esc);
|
||||
while (*str != '\0')
|
||||
{
|
||||
if (esclen > 0 && strncmp(str, esc, esclen) == 0)
|
||||
@ -151,7 +150,7 @@ shell_quote(s)
|
||||
char *newstr;
|
||||
int len;
|
||||
char *esc = get_meta_escape();
|
||||
int esclen = strlen(esc);
|
||||
int esclen = (int) strlen(esc);
|
||||
int use_quotes = 0;
|
||||
int have_quotes = 0;
|
||||
|
||||
@ -189,7 +188,7 @@ shell_quote(s)
|
||||
* We can't quote a string that contains quotes.
|
||||
*/
|
||||
return (NULL);
|
||||
len = strlen(s) + 3;
|
||||
len = (int) strlen(s) + 3;
|
||||
}
|
||||
/*
|
||||
* Allocate and construct the new string.
|
||||
@ -236,7 +235,7 @@ dirfile(dirname, filename)
|
||||
/*
|
||||
* Construct the full pathname.
|
||||
*/
|
||||
len= strlen(dirname) + strlen(filename) + 2;
|
||||
len = (int) (strlen(dirname) + strlen(filename) + 2);
|
||||
pathname = (char *) calloc(len, sizeof(char));
|
||||
if (pathname == NULL)
|
||||
return (NULL);
|
||||
@ -351,7 +350,7 @@ fexpand(s)
|
||||
if (ifile == NULL_IFILE)
|
||||
n++;
|
||||
else
|
||||
n += strlen(get_filename(ifile));
|
||||
n += (int) strlen(get_filename(ifile));
|
||||
}
|
||||
/*
|
||||
* Else it is the first char in a string of
|
||||
@ -400,6 +399,7 @@ fexpand(s)
|
||||
return (e);
|
||||
}
|
||||
|
||||
|
||||
#if TAB_COMPLETE_FILENAME
|
||||
|
||||
/*
|
||||
@ -432,7 +432,7 @@ fcomplete(s)
|
||||
for (slash = s+strlen(s)-1; slash > s; slash--)
|
||||
if (*slash == *PATHNAME_SEP || *slash == '/')
|
||||
break;
|
||||
len = strlen(s) + 4;
|
||||
len = (int) strlen(s) + 4;
|
||||
fpat = (char *) ecalloc(len, sizeof(char));
|
||||
if (strchr(slash, '.') == NULL)
|
||||
SNPRINTF1(fpat, len, "%s*.*", s);
|
||||
@ -441,7 +441,7 @@ fcomplete(s)
|
||||
}
|
||||
#else
|
||||
{
|
||||
int len = strlen(s) + 2;
|
||||
int len = (int) strlen(s) + 2;
|
||||
fpat = (char *) ecalloc(len, sizeof(char));
|
||||
SNPRINTF1(fpat, len, "%s*", s);
|
||||
}
|
||||
@ -470,25 +470,36 @@ fcomplete(s)
|
||||
bin_file(f)
|
||||
int f;
|
||||
{
|
||||
int i;
|
||||
int n;
|
||||
int bin_count = 0;
|
||||
unsigned char data[256];
|
||||
char data[256];
|
||||
char* p;
|
||||
char* pend;
|
||||
|
||||
if (!seekable(f))
|
||||
return (0);
|
||||
if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
|
||||
return (0);
|
||||
n = read(f, data, sizeof(data));
|
||||
for (i = 0; i < n; i++)
|
||||
if (n <= 0)
|
||||
return (0);
|
||||
if (utf_mode)
|
||||
{
|
||||
char c = data[i];
|
||||
if (ctldisp == OPT_ONPLUS && IS_CSI_START(c))
|
||||
bin_count = utf_bin_count(data, n);
|
||||
} else
|
||||
{
|
||||
pend = &data[n];
|
||||
for (p = data; p < pend; )
|
||||
{
|
||||
while (++i < n && is_ansi_middle(data[i]))
|
||||
continue;
|
||||
} else if (binary_char(c))
|
||||
bin_count++;
|
||||
LWCHAR c = step_char(&p, +1, pend);
|
||||
if (ctldisp == OPT_ONPLUS && IS_CSI_START(c))
|
||||
{
|
||||
do {
|
||||
c = step_char(&p, +1, pend);
|
||||
} while (p < pend && is_ansi_middle(c));
|
||||
} else if (binary_char(c))
|
||||
bin_count++;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Call it a binary file if there are more than 5 binary characters
|
||||
@ -590,7 +601,7 @@ shellcmd(cmd)
|
||||
fd = popen(cmd, "r");
|
||||
} else
|
||||
{
|
||||
int len = strlen(shell) + strlen(esccmd) + 5;
|
||||
int len = (int) (strlen(shell) + strlen(esccmd) + 5);
|
||||
scmd = (char *) ecalloc(len, sizeof(char));
|
||||
SNPRINTF3(scmd, len, "%s %s %s", shell, shell_coption(), esccmd);
|
||||
free(esccmd);
|
||||
@ -698,14 +709,14 @@ lglob(filename)
|
||||
gfilename = (char *) ecalloc(len, sizeof(char));
|
||||
p = gfilename;
|
||||
do {
|
||||
n = strlen(drive) + strlen(dir) + strlen(fnd.GLOB_NAME) + 1;
|
||||
n = (int) (strlen(drive) + strlen(dir) + strlen(fnd.GLOB_NAME) + 1);
|
||||
pathname = (char *) ecalloc(n, sizeof(char));
|
||||
SNPRINTF3(pathname, n, "%s%s%s", drive, dir, fnd.GLOB_NAME);
|
||||
qpathname = shell_quote(pathname);
|
||||
free(pathname);
|
||||
if (qpathname != NULL)
|
||||
{
|
||||
n = strlen(qpathname);
|
||||
n = (int) strlen(qpathname);
|
||||
while (p - gfilename + n + 2 >= len)
|
||||
{
|
||||
/*
|
||||
@ -762,7 +773,7 @@ lglob(filename)
|
||||
/*
|
||||
* Invoke lessecho, and read its output (a globbed list of filenames).
|
||||
*/
|
||||
len = strlen(lessecho) + strlen(ofilename) + (7*strlen(metachars())) + 24;
|
||||
len = (int) (strlen(lessecho) + strlen(ofilename) + (7*strlen(metachars())) + 24);
|
||||
cmd = (char *) ecalloc(len, sizeof(char));
|
||||
SNPRINTF4(cmd, len, "%s -p0x%x -d0x%x -e%s ", lessecho, openquote, closequote, esc);
|
||||
free(esc);
|
||||
@ -802,6 +813,32 @@ lglob(filename)
|
||||
return (gfilename);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return number of %s escapes in a string.
|
||||
* Return a large number if there are any other % escapes besides %s.
|
||||
*/
|
||||
static int
|
||||
num_pct_s(lessopen)
|
||||
char *lessopen;
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
while (*lessopen != '\0')
|
||||
{
|
||||
if (*lessopen == '%')
|
||||
{
|
||||
if (lessopen[1] == '%')
|
||||
++lessopen;
|
||||
else if (lessopen[1] == 's')
|
||||
++num;
|
||||
else
|
||||
return (999);
|
||||
}
|
||||
++lessopen;
|
||||
}
|
||||
return (num);
|
||||
}
|
||||
|
||||
/*
|
||||
* See if we should open a "replacement file"
|
||||
* instead of the file we're about to open.
|
||||
@ -828,24 +865,36 @@ open_altfile(filename, pf, pfd)
|
||||
ch_ungetchar(-1);
|
||||
if ((lessopen = lgetenv("LESSOPEN")) == NULL)
|
||||
return (NULL);
|
||||
if (strcmp(filename, "-") == 0)
|
||||
return (NULL);
|
||||
if (*lessopen == '|')
|
||||
while (*lessopen == '|')
|
||||
{
|
||||
/*
|
||||
* If LESSOPEN starts with a |, it indicates
|
||||
* a "pipe preprocessor".
|
||||
*/
|
||||
#if HAVE_FILENO
|
||||
lessopen++;
|
||||
returnfd = 1;
|
||||
#else
|
||||
#if !HAVE_FILENO
|
||||
error("LESSOPEN pipe is not supported", NULL_PARG);
|
||||
return (NULL);
|
||||
#else
|
||||
lessopen++;
|
||||
returnfd++;
|
||||
#endif
|
||||
}
|
||||
if (*lessopen == '-') {
|
||||
/*
|
||||
* Lessopen preprocessor will accept "-" as a filename.
|
||||
*/
|
||||
lessopen++;
|
||||
} else {
|
||||
if (strcmp(filename, "-") == 0)
|
||||
return (NULL);
|
||||
}
|
||||
if (num_pct_s(lessopen) > 1)
|
||||
{
|
||||
error("Invalid LESSOPEN variable", NULL_PARG);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
len = strlen(lessopen) + strlen(filename) + 2;
|
||||
len = (int) (strlen(lessopen) + strlen(filename) + 2);
|
||||
cmd = (char *) ecalloc(len, sizeof(char));
|
||||
SNPRINTF1(cmd, len, lessopen, filename);
|
||||
fd = shellcmd(cmd);
|
||||
@ -872,9 +921,18 @@ open_altfile(filename, pf, pfd)
|
||||
if (read(f, &c, 1) != 1)
|
||||
{
|
||||
/*
|
||||
* Pipe is empty. This means there is no alt file.
|
||||
* Pipe is empty.
|
||||
* If more than 1 pipe char was specified,
|
||||
* the exit status tells whether the file itself
|
||||
* is empty, or if there is no alt file.
|
||||
* If only one pipe char, just assume no alt file.
|
||||
*/
|
||||
pclose(fd);
|
||||
int status = pclose(fd);
|
||||
if (returnfd > 1 && status == 0) {
|
||||
*pfd = NULL;
|
||||
*pf = -1;
|
||||
return (save(FAKE_EMPTYFILE));
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
ch_ungetchar(c);
|
||||
@ -924,7 +982,12 @@ close_altfile(altfilename, filename, pipefd)
|
||||
}
|
||||
if ((lessclose = lgetenv("LESSCLOSE")) == NULL)
|
||||
return;
|
||||
len = strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2;
|
||||
if (num_pct_s(lessclose) > 2)
|
||||
{
|
||||
error("Invalid LESSCLOSE variable", NULL_PARG);
|
||||
return;
|
||||
}
|
||||
len = (int) (strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2);
|
||||
cmd = (char *) ecalloc(len, sizeof(char));
|
||||
SNPRINTF2(cmd, len, lessclose, filename, altfilename);
|
||||
fd = shellcmd(cmd);
|
||||
@ -1047,3 +1110,22 @@ shell_coption()
|
||||
{
|
||||
return ("-c");
|
||||
}
|
||||
|
||||
/*
|
||||
* Return last component of a pathname.
|
||||
*/
|
||||
public char *
|
||||
last_component(name)
|
||||
char *name;
|
||||
{
|
||||
char *slash;
|
||||
|
||||
for (slash = name + strlen(name); slash > name; )
|
||||
{
|
||||
--slash;
|
||||
if (*slash == *PATHNAME_SEP || *slash == '/')
|
||||
return (slash + 1);
|
||||
}
|
||||
return (name);
|
||||
}
|
||||
|
||||
|
88
less/forwback.c
Executable file → Normal file
88
less/forwback.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -17,11 +16,12 @@
|
||||
#include "less.h"
|
||||
#include "position.h"
|
||||
|
||||
public int hit_eof; /* Keeps track of how many times we hit end of file */
|
||||
public int screen_trashed;
|
||||
public int squished;
|
||||
public int no_back_scroll = 0;
|
||||
public int forw_prompt;
|
||||
public int same_pos_bell = 1;
|
||||
|
||||
public int display_next_file_or_exit = 0;
|
||||
|
||||
extern int sigs;
|
||||
@ -35,6 +35,12 @@ extern int ignore_eoi;
|
||||
extern int clear_bg;
|
||||
extern int final_attr;
|
||||
extern int oldbot;
|
||||
#if HILITE_SEARCH
|
||||
extern int size_linebuf;
|
||||
extern int hilite_search;
|
||||
extern int status_col;
|
||||
#endif
|
||||
|
||||
extern int unix2003_compat;
|
||||
#if TAGS
|
||||
extern char *tagoption;
|
||||
@ -53,25 +59,47 @@ eof_bell()
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if the end of file is currently "displayed".
|
||||
* Check to see if the end of file is currently displayed.
|
||||
*/
|
||||
static void
|
||||
eof_check()
|
||||
public int
|
||||
eof_displayed()
|
||||
{
|
||||
POSITION pos;
|
||||
|
||||
if (ignore_eoi)
|
||||
return;
|
||||
if (ABORT_SIGS())
|
||||
return;
|
||||
return (0);
|
||||
|
||||
if (ch_length() == NULL_POSITION)
|
||||
/*
|
||||
* If the file length is not known,
|
||||
* we can't possibly be displaying EOF.
|
||||
*/
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* If the bottom line is empty, we are at EOF.
|
||||
* If the bottom line ends at the file length,
|
||||
* we must be just at EOF.
|
||||
*/
|
||||
pos = position(BOTTOM_PLUS_ONE);
|
||||
if (pos == NULL_POSITION || pos == ch_length())
|
||||
hit_eof++;
|
||||
return (pos == NULL_POSITION || pos == ch_length());
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if the entire file is currently displayed.
|
||||
*/
|
||||
public int
|
||||
entire_file_displayed()
|
||||
{
|
||||
POSITION pos;
|
||||
|
||||
/* Make sure last line of file is displayed. */
|
||||
if (!eof_displayed())
|
||||
return (0);
|
||||
|
||||
/* Make sure first line of file is displayed. */
|
||||
pos = position(0);
|
||||
return (pos == NULL_POSITION || pos == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -106,7 +134,6 @@ forw(n, pos, force, only_last, nblank)
|
||||
int only_last;
|
||||
int nblank;
|
||||
{
|
||||
int eof = 0;
|
||||
int nlines = 0;
|
||||
int do_repaint;
|
||||
static int first_time = 1;
|
||||
@ -125,6 +152,13 @@ forw(n, pos, force, only_last, nblank)
|
||||
do_repaint = (only_last && n > sc_height-1) ||
|
||||
(forw_scroll >= 0 && n > forw_scroll && n != sc_height-1);
|
||||
|
||||
#if HILITE_SEARCH
|
||||
if (hilite_search == OPT_ONPLUS || is_filtering() || status_col) {
|
||||
prep_hilite(pos, pos + 4*size_linebuf, ignore_eoi ? 1 : -1);
|
||||
pos = next_unfiltered(pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!do_repaint)
|
||||
{
|
||||
if (top_scroll && n >= sc_height - 1 && pos != ch_length())
|
||||
@ -186,6 +220,9 @@ forw(n, pos, force, only_last, nblank)
|
||||
* Get the next line from the file.
|
||||
*/
|
||||
pos = forw_line(pos);
|
||||
#if HILITE_SEARCH
|
||||
pos = next_unfiltered(pos);
|
||||
#endif
|
||||
if (pos == NULL_POSITION)
|
||||
{
|
||||
/*
|
||||
@ -194,7 +231,6 @@ forw(n, pos, force, only_last, nblank)
|
||||
* Even if force is true, stop when the last
|
||||
* line in the file reaches the top of screen.
|
||||
*/
|
||||
eof = 1;
|
||||
if (!force && position(TOP) != NULL_POSITION)
|
||||
break;
|
||||
if (!empty_lines(0, 0) &&
|
||||
@ -255,13 +291,7 @@ forw(n, pos, force, only_last, nblank)
|
||||
forw_prompt = 1;
|
||||
}
|
||||
|
||||
if (ignore_eoi)
|
||||
hit_eof = 0;
|
||||
else if (eof && !ABORT_SIGS())
|
||||
hit_eof++;
|
||||
else
|
||||
eof_check();
|
||||
if (nlines == 0)
|
||||
if (nlines == 0 && same_pos_bell)
|
||||
eof_bell();
|
||||
else if (do_repaint)
|
||||
repaint();
|
||||
@ -284,12 +314,20 @@ back(n, pos, force, only_last)
|
||||
|
||||
squish_check();
|
||||
do_repaint = (n > get_back_scroll() || (only_last && n > sc_height-1));
|
||||
hit_eof = 0;
|
||||
#if HILITE_SEARCH
|
||||
if (hilite_search == OPT_ONPLUS || is_filtering() || status_col) {
|
||||
prep_hilite((pos < 3*size_linebuf) ? 0 : pos - 3*size_linebuf, pos, -1);
|
||||
}
|
||||
#endif
|
||||
while (--n >= 0)
|
||||
{
|
||||
/*
|
||||
* Get the previous line of input.
|
||||
*/
|
||||
#if HILITE_SEARCH
|
||||
pos = prev_unfiltered(pos);
|
||||
#endif
|
||||
|
||||
pos = back_line(pos);
|
||||
if (pos == NULL_POSITION)
|
||||
{
|
||||
@ -313,8 +351,7 @@ back(n, pos, force, only_last)
|
||||
}
|
||||
}
|
||||
|
||||
eof_check();
|
||||
if (nlines == 0)
|
||||
if (nlines == 0 && same_pos_bell)
|
||||
eof_bell();
|
||||
else if (do_repaint)
|
||||
repaint();
|
||||
@ -335,7 +372,7 @@ forward(n, force, only_last)
|
||||
{
|
||||
POSITION pos;
|
||||
|
||||
if (get_quit_at_eof() && hit_eof && !(ch_getflags() & CH_HELPFILE))
|
||||
if (get_quit_at_eof() && eof_displayed() && !(ch_getflags() & CH_HELPFILE))
|
||||
{
|
||||
/*
|
||||
* If the -e flag is set and we're trying to go
|
||||
@ -369,7 +406,6 @@ forward(n, force, only_last)
|
||||
} else
|
||||
{
|
||||
eof_bell();
|
||||
hit_eof++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
37
less/funcs.h
37
less/funcs.h
@ -38,6 +38,7 @@
|
||||
public void sync_logfile ();
|
||||
public int ch_seek ();
|
||||
public int ch_end_seek ();
|
||||
public int ch_end_buffer_seek ();
|
||||
public int ch_beg_seek ();
|
||||
public POSITION ch_length ();
|
||||
public POSITION ch_tell ();
|
||||
@ -46,6 +47,7 @@
|
||||
public void ch_setbufspace ();
|
||||
public void ch_flush ();
|
||||
public int seekable ();
|
||||
public void ch_set_eof ();
|
||||
public void ch_init ();
|
||||
public void ch_close ();
|
||||
public int ch_getflags ();
|
||||
@ -57,6 +59,7 @@
|
||||
public char * prutfchar ();
|
||||
public int utf_len ();
|
||||
public int is_utf8_well_formed ();
|
||||
public int utf_bin_count ();
|
||||
public LWCHAR get_wchar ();
|
||||
public void put_wchar ();
|
||||
public LWCHAR step_char ();
|
||||
@ -83,6 +86,9 @@
|
||||
public void ungetcc ();
|
||||
public void ungetsc ();
|
||||
public void commands ();
|
||||
public int cvt_length ();
|
||||
public int * cvt_alloc_chpos ();
|
||||
public void cvt_text ();
|
||||
public void init_cmds ();
|
||||
public void add_UNIX03cmd_table ();
|
||||
public void add_fcmd_table ();
|
||||
@ -125,6 +131,9 @@
|
||||
public char * bad_file ();
|
||||
public POSITION filesize ();
|
||||
public char * shell_coption ();
|
||||
public char * last_component ();
|
||||
public int eof_displayed ();
|
||||
public int entire_file_displayed ();
|
||||
public void squish_check ();
|
||||
public void forw ();
|
||||
public void back ();
|
||||
@ -152,6 +161,7 @@
|
||||
public POSITION back_line ();
|
||||
public void set_attnpos ();
|
||||
public void jump_forw ();
|
||||
public void jump_forw_buffered ();
|
||||
public void jump_back ();
|
||||
public void repaint ();
|
||||
public void jump_percent ();
|
||||
@ -167,10 +177,12 @@
|
||||
public int pappend ();
|
||||
public int pflushmbc ();
|
||||
public void pdone ();
|
||||
public void set_status_col ();
|
||||
public int gline ();
|
||||
public void null_line ();
|
||||
public POSITION forw_raw_line ();
|
||||
public POSITION back_raw_line ();
|
||||
public int rrshift ();
|
||||
public void clr_linenum ();
|
||||
public void add_lnum ();
|
||||
public LINENUM find_linenum ();
|
||||
@ -188,9 +200,10 @@
|
||||
public void unmark ();
|
||||
public void opt_o ();
|
||||
public void opt__O ();
|
||||
public void opt_l ();
|
||||
public void opt_j ();
|
||||
public void calc_jump_sline ();
|
||||
public void opt_shift ();
|
||||
public void calc_shift_count ();
|
||||
public void opt_k ();
|
||||
public void opt_t ();
|
||||
public void opt__T ();
|
||||
@ -204,10 +217,10 @@
|
||||
public void opt_quote ();
|
||||
public void opt_query ();
|
||||
public int get_swindow ();
|
||||
public void opt_dashp ();
|
||||
public char * propt ();
|
||||
public void scan_option ();
|
||||
public void toggle_option ();
|
||||
public int single_char_option ();
|
||||
public int opt_has_param ();
|
||||
public char * opt_prompt ();
|
||||
public int isoptpending ();
|
||||
public void nopendopt ();
|
||||
@ -219,7 +232,7 @@
|
||||
public struct loption * findopt_name ();
|
||||
public int iread ();
|
||||
public void intread ();
|
||||
public long get_time ();
|
||||
public time_type get_time ();
|
||||
public char * errno_message ();
|
||||
public int percentage ();
|
||||
public POSITION percent_pos ();
|
||||
@ -232,6 +245,11 @@
|
||||
public void error ();
|
||||
public void ierror ();
|
||||
public int query ();
|
||||
public int compile_pattern ();
|
||||
public void uncompile_pattern ();
|
||||
public int valid_pattern ();
|
||||
public int is_null_pattern ();
|
||||
public int match_pattern ();
|
||||
public POSITION position ();
|
||||
public void add_forw_pos ();
|
||||
public void add_back_pos ();
|
||||
@ -247,15 +265,23 @@
|
||||
public char * eq_message ();
|
||||
public char * pr_string ();
|
||||
public char * wait_message ();
|
||||
public void init_search ();
|
||||
public void repaint_hilite ();
|
||||
public void clear_attn ();
|
||||
public void undo_search ();
|
||||
public void clr_hlist ();
|
||||
public void clr_hilite ();
|
||||
public void clr_filter ();
|
||||
public int is_filtered ();
|
||||
public POSITION next_unfiltered ();
|
||||
public POSITION prev_unfiltered ();
|
||||
public int is_hilited ();
|
||||
public void chg_caseless ();
|
||||
public void chg_hilite ();
|
||||
public void chg_caseless ();
|
||||
public int search ();
|
||||
public void prep_hilite ();
|
||||
public void set_filter_pattern ();
|
||||
public int is_filtering ();
|
||||
public RETSIGTYPE winch ();
|
||||
public RETSIGTYPE winch ();
|
||||
public void init_signals ();
|
||||
@ -272,3 +298,4 @@
|
||||
public void open_getchr ();
|
||||
public void close_getchr ();
|
||||
public int getchr ();
|
||||
public void opt_dashp ();
|
||||
|
63
less/help.c
63
less/help.c
@ -6,6 +6,7 @@ constant char helpdata[] = {
|
||||
'\n',
|
||||
' ',' ',' ',' ',' ',' ','C','o','m','m','a','n','d','s',' ','m','a','r','k','e','d',' ','w','i','t','h',' ','*',' ','m','a','y',' ','b','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','n','u','m','b','e','r',',',' ','_','\b','N','.','\n',
|
||||
' ',' ',' ',' ',' ',' ','N','o','t','e','s',' ','i','n',' ','p','a','r','e','n','t','h','e','s','e','s',' ','i','n','d','i','c','a','t','e',' ','t','h','e',' ','b','e','h','a','v','i','o','r',' ','i','f',' ','_','\b','N',' ','i','s',' ','g','i','v','e','n','.','\n',
|
||||
' ',' ',' ',' ',' ',' ','A',' ','k','e','y',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','c','a','r','e','t',' ','i','n','d','i','c','a','t','e','s',' ','t','h','e',' ','C','t','r','l',' ','k','e','y',';',' ','t','h','u','s',' ','^','K',' ','i','s',' ','c','t','r','l','-','K','.','\n',
|
||||
'\n',
|
||||
' ',' ','h',' ',' ','H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','i','s',' ','h','e','l','p','.','\n',
|
||||
' ',' ','q',' ',' ',':','q',' ',' ','Q',' ',' ',':','Q',' ',' ','Z','Z',' ',' ',' ',' ',' ','E','x','i','t','.','\n',
|
||||
@ -22,9 +23,12 @@ constant char helpdata[] = {
|
||||
' ',' ','E','S','C','-','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',',',' ','b','u','t',' ','d','o','n','\'','t',' ','s','t','o','p',' ','a','t',' ','e','n','d','-','o','f','-','f','i','l','e','.','\n',
|
||||
' ',' ','d',' ',' ','^','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
|
||||
' ',' ','u',' ',' ','^','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
|
||||
' ',' ','E','S','C','-',')',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
|
||||
' ',' ','E','S','C','-','(',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','R','i','g','h','t',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
|
||||
' ',' ','E','S','C','-',')',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','R','i','g','h','t',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
|
||||
' ',' ','E','S','C','-','(',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','L','e','f','t',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
|
||||
' ',' ','E','S','C','-','}',' ',' ','^','R','i','g','h','t','A','r','r','o','w',' ',' ',' ','R','i','g','h','t',' ','t','o',' ','l','a','s','t',' ','c','o','l','u','m','n',' ','d','i','s','p','l','a','y','e','d','.','\n',
|
||||
' ',' ','E','S','C','-','{',' ',' ','^','L','e','f','t','A','r','r','o','w',' ',' ',' ',' ','L','e','f','t',' ',' ','t','o',' ','f','i','r','s','t',' ','c','o','l','u','m','n','.','\n',
|
||||
' ',' ','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','f','o','r','e','v','e','r',';',' ','l','i','k','e',' ','"','t','a','i','l',' ','-','f','"','.','\n',
|
||||
' ',' ','E','S','C','-','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','L','i','k','e',' ','F',' ','b','u','t',' ','s','t','o','p',' ','w','h','e','n',' ','s','e','a','r','c','h',' ','p','a','t','t','e','r','n',' ','i','s',' ','f','o','u','n','d','.','\n',
|
||||
' ',' ','r',' ',' ','^','R',' ',' ','^','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n','.','\n',
|
||||
' ',' ','R',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n',',',' ','d','i','s','c','a','r','d','i','n','g',' ','b','u','f','f','e','r','e','d',' ','i','n','p','u','t','.','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
|
||||
@ -41,8 +45,9 @@ constant char helpdata[] = {
|
||||
' ',' ','E','S','C','-','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',',',' ','s','p','a','n','n','i','n','g',' ','f','i','l','e','s','.','\n',
|
||||
' ',' ','E','S','C','-','N',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',',',' ','r','e','v','e','r','s','e',' ','d','i','r','.',' ','&',' ','s','p','a','n','n','i','n','g',' ','f','i','l','e','s','.','\n',
|
||||
' ',' ','E','S','C','-','u',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','n','d','o',' ','(','t','o','g','g','l','e',')',' ','s','e','a','r','c','h',' ','h','i','g','h','l','i','g','h','t','i','n','g','.','\n',
|
||||
' ',' ','&','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','D','i','s','p','l','a','y',' ','o','n','l','y',' ','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','p','a','t','t','e','r','n','s',' ','m','a','y',' ','b','e',' ','m','o','d','i','f','i','e','d',' ','b','y',' ','o','n','e',' ','o','r',' ','m','o','r','e',' ','o','f',':','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','A',' ','s','e','a','r','c','h',' ','p','a','t','t','e','r','n',' ','m','a','y',' ','b','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','o','n','e',' ','o','r',' ','m','o','r','e',' ','o','f',':','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','^','N',' ','o','r',' ','!',' ',' ','S','e','a','r','c','h',' ','f','o','r',' ','N','O','N','-','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','.','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','^','E',' ','o','r',' ','*',' ',' ','S','e','a','r','c','h',' ','m','u','l','t','i','p','l','e',' ','f','i','l','e','s',' ','(','p','a','s','s',' ','t','h','r','u',' ','E','N','D',' ','O','F',' ','F','I','L','E',')','.','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','^','F',' ','o','r',' ','@',' ',' ','S','t','a','r','t',' ','s','e','a','r','c','h',' ','a','t',' ','F','I','R','S','T',' ','f','i','l','e',' ','(','f','o','r',' ','/',')',' ','o','r',' ','l','a','s','t',' ','f','i','l','e',' ','(','f','o','r',' ','?',')','.','\n',
|
||||
@ -99,6 +104,7 @@ constant char helpdata[] = {
|
||||
'\n',
|
||||
' ',' ','!','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','e','c','u','t','e',' ','t','h','e',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d',' ','w','i','t','h',' ','$','S','H','E','L','L','.','\n',
|
||||
' ',' ','|','X','\b','X','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','i','p','e',' ','f','i','l','e',' ','b','e','t','w','e','e','n',' ','c','u','r','r','e','n','t',' ','p','o','s',' ','&',' ','m','a','r','k',' ','X','\b','X',' ','t','o',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d','.','\n',
|
||||
' ',' ','s',' ','_','\b','f','_','\b','i','_','\b','l','_','\b','e',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','a','v','e',' ','i','n','p','u','t',' ','t','o',' ','a',' ','f','i','l','e','.','\n',
|
||||
' ',' ','v',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','d','i','t',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','f','i','l','e',' ','w','i','t','h',' ','$','V','I','S','U','A','L',' ','o','r',' ','$','E','D','I','T','O','R','.','\n',
|
||||
' ',' ','V',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','r','i','n','t',' ','v','e','r','s','i','o','n',' ','n','u','m','b','e','r',' ','o','f',' ','"','l','e','s','s','"','.','\n',
|
||||
' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
|
||||
@ -108,12 +114,14 @@ constant char helpdata[] = {
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','M','o','s','t',' ','o','p','t','i','o','n','s',' ','m','a','y',' ','b','e',' ','c','h','a','n','g','e','d',' ','e','i','t','h','e','r',' ','o','n',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e',',','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','o','r',' ','f','r','o','m',' ','w','i','t','h','i','n',' ','l','e','s','s',' ','b','y',' ','u','s','i','n','g',' ','t','h','e',' ','-',' ','o','r',' ','-','-',' ','c','o','m','m','a','n','d','.','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','O','p','t','i','o','n','s',' ','m','a','y',' ','b','e',' ','g','i','v','e','n',' ','i','n',' ','o','n','e',' ','o','f',' ','t','w','o',' ','f','o','r','m','s',':',' ','e','i','t','h','e','r',' ','a',' ','s','i','n','g','l','e','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','c','h','a','r','a','c','t','e','r',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','-',',',' ','o','r',' ','a',' ','n','a','m','e',' ','p','r','e','c','e','e','d','e','d',' ','b','y',' ','-','-','.','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','c','h','a','r','a','c','t','e','r',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','-',',',' ','o','r',' ','a',' ','n','a','m','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','-','-','.','\n',
|
||||
'\n',
|
||||
' ',' ','-','?',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','e','l','p','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','h','e','l','p',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n',
|
||||
' ',' ','-','a',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','e','a','r','c','h','-','s','k','i','p','-','s','c','r','e','e','n','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','e','a','r','c','h',' ','s','k','i','p','s',' ','c','u','r','r','e','n','t',' ','s','c','r','e','e','n','.','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','s','k','i','p','s',' ','c','u','r','r','e','n','t',' ','s','c','r','e','e','n','.','\n',
|
||||
' ',' ','-','A',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','S','E','A','R','C','H','-','S','K','I','P','-','S','C','R','E','E','N','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','s','t','a','r','t','s',' ','j','u','s','t',' ','a','f','t','e','r',' ','t','a','r','g','e','t',' ','l','i','n','e','.','\n',
|
||||
' ',' ','-','b',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','b','u','f','f','e','r','s','=','[','_','\b','N',']','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','N','u','m','b','e','r',' ','o','f',' ','b','u','f','f','e','r','s','.','\n',
|
||||
' ',' ','-','B',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','a','u','t','o','-','b','u','f','f','e','r','s','\n',
|
||||
@ -146,6 +154,8 @@ constant char helpdata[] = {
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','a',' ','s','t','a','t','u','s',' ','c','o','l','u','m','n',' ','a','t',' ','l','e','f','t',' ','e','d','g','e',' ','o','f',' ','s','c','r','e','e','n','.','\n',
|
||||
' ',' ','-','k',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','e','s','s','k','e','y','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a',' ','l','e','s','s','k','e','y',' ','f','i','l','e','.','\n',
|
||||
' ',' ','-','K',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','q','u','i','t','-','o','n','-','i','n','t','r','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','i','t',' ','l','e','s','s',' ','i','n',' ','r','e','s','p','o','n','s','e',' ','t','o',' ','c','t','r','l','-','C','.','\n',
|
||||
' ',' ','-','L',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','l','e','s','s','o','p','e','n','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','t','h','e',' ','L','E','S','S','O','P','E','N',' ','e','n','v','i','r','o','n','m','e','n','t',' ','v','a','r','i','a','b','l','e','.','\n',
|
||||
' ',' ','-','m',' ',' ','-','M',' ',' ','.','.','.','.',' ',' ','-','-','l','o','n','g','-','p','r','o','m','p','t',' ',' ','-','-','L','O','N','G','-','P','R','O','M','P','T','\n',
|
||||
@ -167,7 +177,7 @@ constant char helpdata[] = {
|
||||
' ',' ','-','s',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','q','u','e','e','z','e','-','b','l','a','n','k','-','l','i','n','e','s','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','q','u','e','e','z','e',' ','m','u','l','t','i','p','l','e',' ','b','l','a','n','k',' ','l','i','n','e','s','.','\n',
|
||||
' ',' ','-','S',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','c','h','o','p','-','l','o','n','g','-','l','i','n','e','s','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','o','p',' ','l','o','n','g',' ','l','i','n','e','s','.','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','o','p',' ','(','t','r','u','n','c','a','t','e',')',' ','l','o','n','g',' ','l','i','n','e','s',' ','r','a','t','h','e','r',' ','t','h','a','n',' ','w','r','a','p','p','i','n','g','.','\n',
|
||||
' ',' ','-','t',' ','[','_','\b','t','_','\b','a','_','\b','g',']',' ',' ','.','.',' ',' ','-','-','t','a','g','=','[','_','\b','t','_','\b','a','_','\b','g',']','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','i','n','d',' ','a',' ','t','a','g','.','\n',
|
||||
' ',' ','-','T',' ','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ','-','-','t','a','g','-','f','i','l','e','=','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
|
||||
@ -184,8 +194,6 @@ constant char helpdata[] = {
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','a','b',' ','s','t','o','p','s','.','\n',
|
||||
' ',' ','-','X',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','i','n','i','t','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','t','e','r','m','c','a','p',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','t','e','r','m','c','a','p',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n',
|
||||
' ',' ','-','y',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','m','a','x','-','f','o','r','w','-','s','c','r','o','l','l','=','[','_','\b','N',']','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','c','r','o','l','l',' ','l','i','m','i','t','.','\n',
|
||||
' ',' ','-','z',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','w','i','n','d','o','w','=','[','_','\b','N',']','\n',
|
||||
@ -196,6 +204,13 @@ constant char helpdata[] = {
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','d','i','s','p','l','a','y',' ','t','i','l','d','e','s',' ','a','f','t','e','r',' ','e','n','d',' ','o','f',' ','f','i','l','e','.','\n',
|
||||
' ',' ','-','#',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','s','h','i','f','t','=','[','_','\b','N',']','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','o','r','i','z','o','n','t','a','l',' ','s','c','r','o','l','l',' ','a','m','o','u','n','t',' ','(','0',' ','=',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',')','\n',
|
||||
' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','s','e','n','d',' ','t','e','r','m','c','a','p',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n',
|
||||
' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','l','l','o','w','-','n','a','m','e','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','h','e',' ','F',' ','c','o','m','m','a','n','d',' ','c','h','a','n','g','e','s',' ','f','i','l','e','s',' ','i','f',' ','t','h','e',' ','i','n','p','u','t',' ','f','i','l','e',' ','i','s',' ','r','e','n','a','m','e','d','.','\n',
|
||||
' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','u','s','e','-','b','a','c','k','s','l','a','s','h','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','u','b','s','e','q','u','e','n','t',' ','o','p','t','i','o','n','s',' ','u','s','e',' ','b','a','c','k','s','l','a','s','h',' ','a','s',' ','e','s','c','a','p','e',' ','c','h','a','r','.','\n',
|
||||
'\n',
|
||||
'\n',
|
||||
' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
|
||||
'\n',
|
||||
@ -204,22 +219,22 @@ constant char helpdata[] = {
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','T','h','e','s','e',' ','k','e','y','s',' ','c','a','n',' ','b','e',' ','u','s','e','d',' ','t','o',' ','e','d','i','t',' ','t','e','x','t',' ','b','e','i','n','g',' ','e','n','t','e','r','e','d',' ','\n',
|
||||
' ',' ',' ',' ',' ',' ',' ',' ','o','n',' ','t','h','e',' ','"','c','o','m','m','a','n','d',' ','l','i','n','e','"',' ','a','t',' ','t','h','e',' ','b','o','t','t','o','m',' ','o','f',' ','t','h','e',' ','s','c','r','e','e','n','.','\n',
|
||||
'\n',
|
||||
' ','R','i','g','h','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','l',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n',
|
||||
' ','L','e','f','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','h',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n',
|
||||
' ','C','N','T','L','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','w',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','w','o','r','d','.','\n',
|
||||
' ','C','N','T','L','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','b',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','w','o','r','d','.','\n',
|
||||
' ','H','O','M','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','0',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','s','t','a','r','t',' ','o','f',' ','l','i','n','e','.','\n',
|
||||
' ','E','N','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','$',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','e','n','d',' ','o','f',' ','l','i','n','e','.','\n',
|
||||
' ','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n',
|
||||
' ','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','x',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n',
|
||||
' ','C','N','T','L','-','B','A','C','K','S','P','A','C','E',' ',' ',' ','E','S','C','-','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n',
|
||||
' ','C','N','T','L','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','X',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n',
|
||||
' ','C','N','T','L','-','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','e','n','t','i','r','e',' ','l','i','n','e','.','\n',
|
||||
' ','U','p','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','k',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','p','r','e','v','i','o','u','s',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
|
||||
' ','D','o','w','n','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','j',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','n','e','x','t',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
|
||||
' ','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','c','y','c','l','e','.','\n',
|
||||
' ','S','H','I','F','T','-','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','T','A','B',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','r','e','v','e','r','s','e',' ','c','y','c','l','e','.','\n',
|
||||
' ','C','N','T','L','-','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',',',' ','l','i','s','t',' ','a','l','l','.','\n',
|
||||
' ','R','i','g','h','t','A','r','r','o','w',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','l',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n',
|
||||
' ','L','e','f','t','A','r','r','o','w',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','h',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n',
|
||||
' ','c','t','r','l','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','w',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','w','o','r','d','.','\n',
|
||||
' ','c','t','r','l','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','b',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','w','o','r','d','.','\n',
|
||||
' ','H','O','M','E',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','0',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','s','t','a','r','t',' ','o','f',' ','l','i','n','e','.','\n',
|
||||
' ','E','N','D',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','$',' ','.','.','.',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','e','n','d',' ','o','f',' ','l','i','n','e','.','\n',
|
||||
' ','B','A','C','K','S','P','A','C','E',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n',
|
||||
' ','D','E','L','E','T','E',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','x',' ','.','.','.',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n',
|
||||
' ','c','t','r','l','-','B','A','C','K','S','P','A','C','E',' ',' ',' ','E','S','C','-','B','A','C','K','S','P','A','C','E',' ','.','.','.','.','.','.','.','.','.','.','.',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n',
|
||||
' ','c','t','r','l','-','D','E','L','E','T','E',' ','.','.','.','.',' ','E','S','C','-','D','E','L','E','T','E',' ','.','.','.','.',' ','E','S','C','-','X',' ','.','.','.',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n',
|
||||
' ','c','t','r','l','-','U',' ','.','.','.','.','.','.','.','.','.',' ','E','S','C',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')',' ','.','.','.','.','.','.','.',' ','D','e','l','e','t','e',' ','e','n','t','i','r','e',' ','l','i','n','e','.','\n',
|
||||
' ','U','p','A','r','r','o','w',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','k',' ','.','.','.',' ','R','e','t','r','i','e','v','e',' ','p','r','e','v','i','o','u','s',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
|
||||
' ','D','o','w','n','A','r','r','o','w',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','j',' ','.','.','.',' ','R','e','t','r','i','e','v','e',' ','n','e','x','t',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
|
||||
' ','T','A','B',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','c','y','c','l','e','.','\n',
|
||||
' ','S','H','I','F','T','-','T','A','B',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','E','S','C','-','T','A','B',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','r','e','v','e','r','s','e',' ','c','y','c','l','e','.','\n',
|
||||
' ','c','t','r','l','-','L',' ','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',',',' ','l','i','s','t',' ','a','l','l','.','\n',
|
||||
'\n',
|
||||
'\n',
|
||||
0 };
|
||||
|
5
less/ifile.c
Executable file → Normal file
5
less/ifile.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
|
111
less/input.c
Executable file → Normal file
111
less/input.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -53,13 +52,15 @@ forw_line(curr_pos)
|
||||
int endline;
|
||||
int backchars;
|
||||
|
||||
get_forw_line:
|
||||
if (curr_pos == NULL_POSITION)
|
||||
{
|
||||
null_line();
|
||||
return (NULL_POSITION);
|
||||
}
|
||||
#if HILITE_SEARCH
|
||||
if (hilite_search == OPT_ONPLUS || status_col)
|
||||
if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
|
||||
{
|
||||
/*
|
||||
* If we are ignoring EOI (command F), only prepare
|
||||
* one line ahead, to avoid getting stuck waiting for
|
||||
@ -69,6 +70,8 @@ forw_line(curr_pos)
|
||||
*/
|
||||
prep_hilite(curr_pos, curr_pos + 3*size_linebuf,
|
||||
ignore_eoi ? 1 : -1);
|
||||
curr_pos = next_unfiltered(curr_pos);
|
||||
}
|
||||
#endif
|
||||
if (ch_seek(curr_pos))
|
||||
{
|
||||
@ -76,6 +79,9 @@ forw_line(curr_pos)
|
||||
return (NULL_POSITION);
|
||||
}
|
||||
|
||||
/*
|
||||
* Step back to the beginning of the line.
|
||||
*/
|
||||
base_pos = curr_pos;
|
||||
for (;;)
|
||||
{
|
||||
@ -95,10 +101,14 @@ forw_line(curr_pos)
|
||||
--base_pos;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read forward again to the position we should start at.
|
||||
*/
|
||||
prewind();
|
||||
plinenum(base_pos);
|
||||
(void) ch_seek(base_pos);
|
||||
while (base_pos < curr_pos)
|
||||
new_pos = base_pos;
|
||||
while (new_pos < curr_pos)
|
||||
{
|
||||
if (ABORT_SIGS())
|
||||
{
|
||||
@ -106,12 +116,12 @@ forw_line(curr_pos)
|
||||
return (NULL_POSITION);
|
||||
}
|
||||
c = ch_forw_get();
|
||||
backchars = pappend(c, base_pos);
|
||||
base_pos++;
|
||||
backchars = pappend(c, new_pos);
|
||||
new_pos++;
|
||||
if (backchars > 0)
|
||||
{
|
||||
pshift_all();
|
||||
base_pos -= backchars;
|
||||
new_pos -= backchars;
|
||||
while (--backchars >= 0)
|
||||
(void) ch_back_get();
|
||||
}
|
||||
@ -119,6 +129,9 @@ forw_line(curr_pos)
|
||||
(void) pflushmbc();
|
||||
pshift_all();
|
||||
|
||||
/*
|
||||
* Read the first character to display.
|
||||
*/
|
||||
c = ch_forw_get();
|
||||
if (c == EOI)
|
||||
{
|
||||
@ -127,6 +140,9 @@ forw_line(curr_pos)
|
||||
}
|
||||
blankline = (c == '\n' || c == '\r');
|
||||
|
||||
/*
|
||||
* Read each character in the line and append to the line buffer.
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
if (ABORT_SIGS())
|
||||
@ -167,6 +183,11 @@ forw_line(curr_pos)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (ABORT_SIGS())
|
||||
{
|
||||
null_line();
|
||||
return (NULL_POSITION);
|
||||
}
|
||||
c = ch_forw_get();
|
||||
} while (c != '\n' && c != EOI);
|
||||
new_pos = ch_tell();
|
||||
@ -181,7 +202,23 @@ forw_line(curr_pos)
|
||||
}
|
||||
c = ch_forw_get();
|
||||
}
|
||||
pdone(endline);
|
||||
|
||||
pdone(endline, 1);
|
||||
|
||||
#if HILITE_SEARCH
|
||||
if (is_filtered(base_pos))
|
||||
{
|
||||
/*
|
||||
* We don't want to display this line.
|
||||
* Get the next line.
|
||||
*/
|
||||
curr_pos = new_pos;
|
||||
goto get_forw_line;
|
||||
}
|
||||
|
||||
if (status_col && is_hilited(base_pos, ch_tell()-1, 1, NULL))
|
||||
set_status_col('*');
|
||||
#endif
|
||||
|
||||
if (squeeze && blankline)
|
||||
{
|
||||
@ -215,18 +252,19 @@ forw_line(curr_pos)
|
||||
back_line(curr_pos)
|
||||
POSITION curr_pos;
|
||||
{
|
||||
POSITION new_pos, begin_new_pos;
|
||||
POSITION new_pos, begin_new_pos, base_pos;
|
||||
int c;
|
||||
int endline;
|
||||
int backchars;
|
||||
|
||||
get_back_line:
|
||||
if (curr_pos == NULL_POSITION || curr_pos <= ch_zero())
|
||||
{
|
||||
null_line();
|
||||
return (NULL_POSITION);
|
||||
}
|
||||
#if HILITE_SEARCH
|
||||
if (hilite_search == OPT_ONPLUS || status_col)
|
||||
if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
|
||||
prep_hilite((curr_pos < 3*size_linebuf) ?
|
||||
0 : curr_pos - 3*size_linebuf, curr_pos, -1);
|
||||
#endif
|
||||
@ -241,9 +279,9 @@ back_line(curr_pos)
|
||||
/*
|
||||
* Find out if the "current" line was blank.
|
||||
*/
|
||||
(void) ch_forw_get(); /* Skip the newline */
|
||||
c = ch_forw_get(); /* First char of "current" line */
|
||||
(void) ch_back_get(); /* Restore our position */
|
||||
(void) ch_forw_get(); /* Skip the newline */
|
||||
c = ch_forw_get(); /* First char of "current" line */
|
||||
(void) ch_back_get(); /* Restore our position */
|
||||
(void) ch_back_get();
|
||||
|
||||
if (c == '\n' || c == '\r')
|
||||
@ -285,7 +323,7 @@ back_line(curr_pos)
|
||||
* This is the newline ending the previous line.
|
||||
* We have hit the beginning of the line.
|
||||
*/
|
||||
new_pos = ch_tell() + 1;
|
||||
base_pos = ch_tell() + 1;
|
||||
break;
|
||||
}
|
||||
if (c == EOI)
|
||||
@ -295,7 +333,7 @@ back_line(curr_pos)
|
||||
* This must be the first line in the file.
|
||||
* This must, of course, be the beginning of the line.
|
||||
*/
|
||||
new_pos = ch_tell();
|
||||
base_pos = ch_tell();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -309,6 +347,7 @@ back_line(curr_pos)
|
||||
* are much longer than the screen width,
|
||||
* but I don't know of any better way. }}
|
||||
*/
|
||||
new_pos = base_pos;
|
||||
if (ch_seek(new_pos))
|
||||
{
|
||||
null_line();
|
||||
@ -366,7 +405,22 @@ back_line(curr_pos)
|
||||
}
|
||||
} while (new_pos < curr_pos);
|
||||
|
||||
pdone(endline);
|
||||
pdone(endline, 0);
|
||||
|
||||
#if HILITE_SEARCH
|
||||
if (is_filtered(base_pos))
|
||||
{
|
||||
/*
|
||||
* We don't want to display this line.
|
||||
* Get the previous line.
|
||||
*/
|
||||
curr_pos = begin_new_pos;
|
||||
goto get_back_line;
|
||||
}
|
||||
|
||||
if (status_col && curr_pos > 0 && is_hilited(base_pos, curr_pos-1, 1, NULL))
|
||||
set_status_col('*');
|
||||
#endif
|
||||
|
||||
return (begin_new_pos);
|
||||
}
|
||||
@ -388,19 +442,22 @@ set_attnpos(pos)
|
||||
{
|
||||
c = ch_forw_get();
|
||||
if (c == EOI)
|
||||
return;
|
||||
if (c != '\n' && c != '\r')
|
||||
break;
|
||||
if (c == '\n' || c == '\r')
|
||||
{
|
||||
(void) ch_back_get();
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
end_attnpos = pos;
|
||||
for (;;)
|
||||
{
|
||||
c = ch_back_get();
|
||||
if (c == EOI || c == '\n' || c == '\r')
|
||||
break;
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
start_attnpos = pos;
|
||||
for (;;)
|
||||
{
|
||||
c = ch_forw_get();
|
||||
pos++;
|
||||
if (c == EOI || c == '\n' || c == '\r')
|
||||
break;
|
||||
}
|
||||
end_attnpos = pos;
|
||||
}
|
||||
|
46
less/jump.c
Executable file → Normal file
46
less/jump.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -16,7 +15,6 @@
|
||||
#include "less.h"
|
||||
#include "position.h"
|
||||
|
||||
extern int hit_eof;
|
||||
extern int jump_sline;
|
||||
extern int squished;
|
||||
extern int screen_trashed;
|
||||
@ -38,6 +36,12 @@ jump_forw()
|
||||
error("Cannot seek to end of file", NULL_PARG);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Note; lastmark will be called later by jump_loc, but it fails
|
||||
* because the position table has been cleared by pos_clear below.
|
||||
* So call it here before calling pos_clear.
|
||||
*/
|
||||
lastmark();
|
||||
/*
|
||||
* Position the last line in the file at the last screen line.
|
||||
* Go back one line from the end of the file
|
||||
@ -57,6 +61,24 @@ jump_forw()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Jump to the last buffered line in the file.
|
||||
*/
|
||||
public void
|
||||
jump_forw_buffered()
|
||||
{
|
||||
POSITION end;
|
||||
|
||||
if (ch_end_buffer_seek())
|
||||
{
|
||||
error("Cannot seek to end of buffers", NULL_PARG);
|
||||
return;
|
||||
}
|
||||
end = ch_tell();
|
||||
if (end != NULL_POSITION && end > 0)
|
||||
jump_line_loc(end-1, sc_height-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Jump to line n in the file.
|
||||
*/
|
||||
@ -103,7 +125,11 @@ repaint()
|
||||
*/
|
||||
get_scrpos(&scrpos);
|
||||
pos_clear();
|
||||
jump_loc(scrpos.pos, scrpos.ln);
|
||||
if (scrpos.pos == NULL_POSITION)
|
||||
/* Screen hasn't been drawn yet. */
|
||||
jump_loc(0, 0);
|
||||
else
|
||||
jump_loc(scrpos.pos, scrpos.ln);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -195,8 +221,10 @@ jump_loc(pos, sline)
|
||||
forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0);
|
||||
else
|
||||
back(-nline, position(TOP), 1, 0);
|
||||
#if HILITE_SEARCH
|
||||
if (show_attn)
|
||||
repaint_hilite(1);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -234,8 +262,10 @@ jump_loc(pos, sline)
|
||||
* that we can just scroll there after all.
|
||||
*/
|
||||
forw(sc_height-sline+nline-1, bpos, 1, 0, 0);
|
||||
#if HILITE_SEARCH
|
||||
if (show_attn)
|
||||
repaint_hilite(1);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
pos = back_line(pos);
|
||||
@ -251,7 +281,6 @@ jump_loc(pos, sline)
|
||||
}
|
||||
}
|
||||
lastmark();
|
||||
hit_eof = 0;
|
||||
squished = 0;
|
||||
screen_trashed = 0;
|
||||
forw(sc_height-1, pos, 1, 0, sline-nline);
|
||||
@ -275,6 +304,9 @@ jump_loc(pos, sline)
|
||||
*/
|
||||
break;
|
||||
}
|
||||
#if HILITE_SEARCH
|
||||
pos = next_unfiltered(pos);
|
||||
#endif
|
||||
if (pos >= tpos)
|
||||
{
|
||||
/*
|
||||
@ -283,8 +315,10 @@ jump_loc(pos, sline)
|
||||
* that we can just scroll there after all.
|
||||
*/
|
||||
back(nline+1, tpos, 1, 0);
|
||||
#if HILITE_SEARCH
|
||||
if (show_attn)
|
||||
repaint_hilite(1);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
62
less/less.h
Executable file → Normal file
62
less/less.h
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
#define NEWBOT 1
|
||||
@ -159,7 +158,7 @@ void free();
|
||||
#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
|
||||
#endif
|
||||
|
||||
#define IS_CSI_START(c) ((c) == ESC || (!utf_mode && ((unsigned char)(c)) == CSI))
|
||||
#define IS_CSI_START(c) (((LWCHAR)(c)) == ESC || (((LWCHAR)(c)) == CSI))
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
@ -296,6 +295,15 @@ struct scrpos
|
||||
int ln;
|
||||
};
|
||||
|
||||
/*
|
||||
* A mark is an ifile (input file) plus a position within the file.
|
||||
*/
|
||||
struct mark
|
||||
{
|
||||
IFILE m_ifile;
|
||||
struct scrpos m_scrpos;
|
||||
};
|
||||
|
||||
typedef union parg
|
||||
{
|
||||
char *p_string;
|
||||
@ -311,6 +319,17 @@ struct textlist
|
||||
char *endstring;
|
||||
};
|
||||
|
||||
struct wchar_range
|
||||
{
|
||||
LWCHAR first, last;
|
||||
};
|
||||
|
||||
struct wchar_range_table
|
||||
{
|
||||
struct wchar_range *table;
|
||||
int count;
|
||||
};
|
||||
|
||||
#define EOI (-1)
|
||||
|
||||
#define READ_INTR (-2)
|
||||
@ -335,14 +354,16 @@ struct textlist
|
||||
#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
|
||||
|
||||
/* How should we search? */
|
||||
#define SRCH_FORW (1 << 0) /* Search forward from current position */
|
||||
#define SRCH_BACK (1 << 1) /* Search backward from current position */
|
||||
#define SRCH_NO_MOVE (1 << 2) /* Highlight, but don't move */
|
||||
#define SRCH_FIND_ALL (1 << 4) /* Find and highlight all matches */
|
||||
#define SRCH_NO_MATCH (1 << 8) /* Search for non-matching lines */
|
||||
#define SRCH_PAST_EOF (1 << 9) /* Search past end-of-file, into next file */
|
||||
#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */
|
||||
#define SRCH_NO_REGEX (1 << 12) /* Don't use regular expressions */
|
||||
#define SRCH_FORW (1 << 0) /* Search forward from current position */
|
||||
#define SRCH_BACK (1 << 1) /* Search backward from current position */
|
||||
#define SRCH_NO_MOVE (1 << 2) /* Highlight, but don't move */
|
||||
#define SRCH_FIND_ALL (1 << 4) /* Find and highlight all matches */
|
||||
#define SRCH_NO_MATCH (1 << 8) /* Search for non-matching lines */
|
||||
#define SRCH_PAST_EOF (1 << 9) /* Search past end-of-file, into next file */
|
||||
#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */
|
||||
#define SRCH_NO_REGEX (1 << 12) /* Don't use regular expressions */
|
||||
#define SRCH_FILTER (1 << 13) /* Search is for '&' (filter) command */
|
||||
#define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */
|
||||
|
||||
#define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
|
||||
(((t) & ~SRCH_FORW) | SRCH_BACK) : \
|
||||
@ -444,6 +465,7 @@ struct textlist
|
||||
|
||||
#define ESC CONTROL('[')
|
||||
#define CSI ((unsigned char)'\233')
|
||||
#define CHAR_END_COMMAND 0x40000000
|
||||
|
||||
#if _OSK_MWC32
|
||||
#define LSIGNAL(sig,func) os9_signal(sig,func)
|
||||
@ -472,6 +494,7 @@ struct textlist
|
||||
|
||||
#define QUIT_OK 0
|
||||
#define QUIT_ERROR 1
|
||||
#define QUIT_INTERRUPT 2
|
||||
#define QUIT_SAVED_STATUS (-1)
|
||||
|
||||
#define FOLLOW_DESC 0
|
||||
@ -482,10 +505,25 @@ struct textlist
|
||||
#define CH_KEEPOPEN 002
|
||||
#define CH_POPENED 004
|
||||
#define CH_HELPFILE 010
|
||||
#define CH_NODATA 020 /* Special case for zero length files */
|
||||
|
||||
|
||||
#define ch_zero() ((POSITION)0)
|
||||
|
||||
#define FAKE_HELPFILE "@/\\less/\\help/\\file/\\@"
|
||||
#define FAKE_EMPTYFILE "@/\\less/\\empty/\\file/\\@"
|
||||
|
||||
/* Flags for cvt_text */
|
||||
#define CVT_TO_LC 01 /* Convert upper-case to lower-case */
|
||||
#define CVT_BS 02 /* Do backspace processing */
|
||||
#define CVT_CRLF 04 /* Remove CR after LF */
|
||||
#define CVT_ANSI 010 /* Remove ANSI escape sequences */
|
||||
|
||||
#if HAVE_TIME_T
|
||||
#define time_type time_t
|
||||
#else
|
||||
#define time_type long
|
||||
#endif
|
||||
|
||||
#include "funcs.h"
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
Commands marked with * may be preceded by a number, _N.
|
||||
Notes in parentheses indicate the behavior if _N is given.
|
||||
A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K.
|
||||
|
||||
h H Display this help.
|
||||
q :q Q :Q ZZ Exit.
|
||||
@ -19,9 +20,12 @@
|
||||
ESC-SPACE * Forward one window, but don't stop at end-of-file.
|
||||
d ^D * Forward one half-window (and set half-window to _N).
|
||||
u ^U * Backward one half-window (and set half-window to _N).
|
||||
ESC-) RightArrow * Left one half screen width (or _N positions).
|
||||
ESC-( LeftArrow * Right one half screen width (or _N positions).
|
||||
ESC-) RightArrow * Right one half screen width (or _N positions).
|
||||
ESC-( LeftArrow * Left one half screen width (or _N positions).
|
||||
ESC-} ^RightArrow Right to last column displayed.
|
||||
ESC-{ ^LeftArrow Left to first column.
|
||||
F Forward forever; like "tail -f".
|
||||
ESC-F Like F but stop when search pattern is found.
|
||||
r ^R ^L Repaint screen.
|
||||
R Repaint screen, discarding buffered input.
|
||||
---------------------------------------------------
|
||||
@ -38,8 +42,9 @@
|
||||
ESC-n * Repeat previous search, spanning files.
|
||||
ESC-N * Repeat previous search, reverse dir. & spanning files.
|
||||
ESC-u Undo (toggle) search highlighting.
|
||||
&_p_a_t_t_e_r_n * Display only matching lines
|
||||
---------------------------------------------------
|
||||
Search patterns may be modified by one or more of:
|
||||
A search pattern may be preceded by one or more of:
|
||||
^N or ! Search for NON-matching lines.
|
||||
^E or * Search multiple files (pass thru END OF FILE).
|
||||
^F or @ Start search at FIRST file (for /) or last file (for ?).
|
||||
@ -96,6 +101,7 @@
|
||||
|
||||
!_c_o_m_m_a_n_d Execute the shell command with $SHELL.
|
||||
|XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command.
|
||||
s _f_i_l_e Save input to a file.
|
||||
v Edit the current file with $VISUAL or $EDITOR.
|
||||
V Print version number of "less".
|
||||
---------------------------------------------------------------------------
|
||||
@ -105,12 +111,14 @@
|
||||
Most options may be changed either on the command line,
|
||||
or from within less by using the - or -- command.
|
||||
Options may be given in one of two forms: either a single
|
||||
character preceded by a -, or a name preceeded by --.
|
||||
character preceded by a -, or a name preceded by --.
|
||||
|
||||
-? ........ --help
|
||||
Display help (from command line).
|
||||
-a ........ --search-skip-screen
|
||||
Forward search skips current screen.
|
||||
Search skips current screen.
|
||||
-A ........ --SEARCH-SKIP-SCREEN
|
||||
Search starts just after target line.
|
||||
-b [_N] .... --buffers=[_N]
|
||||
Number of buffers.
|
||||
-B ........ --auto-buffers
|
||||
@ -143,6 +151,8 @@
|
||||
Display a status column at left edge of screen.
|
||||
-k [_f_i_l_e] . --lesskey-file=[_f_i_l_e]
|
||||
Use a lesskey file.
|
||||
-K --quit-on-intr
|
||||
Exit less in response to ctrl-C.
|
||||
-L ........ --no-lessopen
|
||||
Ignore the LESSOPEN environment variable.
|
||||
-m -M .... --long-prompt --LONG-PROMPT
|
||||
@ -164,7 +174,7 @@
|
||||
-s ........ --squeeze-blank-lines
|
||||
Squeeze multiple blank lines.
|
||||
-S ........ --chop-long-lines
|
||||
Chop long lines.
|
||||
Chop (truncate) long lines rather than wrapping.
|
||||
-t [_t_a_g] .. --tag=[_t_a_g]
|
||||
Find a tag.
|
||||
-T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e]
|
||||
@ -181,8 +191,6 @@
|
||||
Set tab stops.
|
||||
-X ........ --no-init
|
||||
Don't use termcap init/deinit strings.
|
||||
--no-keypad
|
||||
Don't use termcap keypad init/deinit strings.
|
||||
-y [_N] .... --max-forw-scroll=[_N]
|
||||
Forward scroll limit.
|
||||
-z [_N] .... --window=[_N]
|
||||
@ -193,6 +201,13 @@
|
||||
Don't display tildes after end of file.
|
||||
-# [_N] .... --shift=[_N]
|
||||
Horizontal scroll amount (0 = one half screen width)
|
||||
........ --no-keypad
|
||||
Don't send termcap keypad init/deinit strings.
|
||||
........ --follow-name
|
||||
The F command changes files if the input file is renamed.
|
||||
........ --use-backslash
|
||||
Subsequent options use backslash as escape char.
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
@ -201,21 +216,21 @@
|
||||
These keys can be used to edit text being entered
|
||||
on the "command line" at the bottom of the screen.
|
||||
|
||||
RightArrow ESC-l Move cursor right one character.
|
||||
LeftArrow ESC-h Move cursor left one character.
|
||||
CNTL-RightArrow ESC-RightArrow ESC-w Move cursor right one word.
|
||||
CNTL-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word.
|
||||
HOME ESC-0 Move cursor to start of line.
|
||||
END ESC-$ Move cursor to end of line.
|
||||
BACKSPACE Delete char to left of cursor.
|
||||
DELETE ESC-x Delete char under cursor.
|
||||
CNTL-BACKSPACE ESC-BACKSPACE Delete word to left of cursor.
|
||||
CNTL-DELETE ESC-DELETE ESC-X Delete word under cursor.
|
||||
CNTL-U ESC (MS-DOS only) Delete entire line.
|
||||
UpArrow ESC-k Retrieve previous command line.
|
||||
DownArrow ESC-j Retrieve next command line.
|
||||
TAB Complete filename & cycle.
|
||||
SHIFT-TAB ESC-TAB Complete filename & reverse cycle.
|
||||
CNTL-L Complete filename, list all.
|
||||
RightArrow ..................... ESC-l ... Move cursor right one character.
|
||||
LeftArrow ...................... ESC-h ... Move cursor left one character.
|
||||
ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word.
|
||||
ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word.
|
||||
HOME ........................... ESC-0 ... Move cursor to start of line.
|
||||
END ............................ ESC-$ ... Move cursor to end of line.
|
||||
BACKSPACE ................................ Delete char to left of cursor.
|
||||
DELETE ......................... ESC-x ... Delete char under cursor.
|
||||
ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor.
|
||||
ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor.
|
||||
ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line.
|
||||
UpArrow ........................ ESC-k ... Retrieve previous command line.
|
||||
DownArrow ...................... ESC-j ... Retrieve next command line.
|
||||
TAB ...................................... Complete filename & cycle.
|
||||
SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle.
|
||||
ctrl-L ................................... Complete filename, list all.
|
||||
|
||||
|
||||
|
612
less/less.man
612
less/less.man
File diff suppressed because it is too large
Load Diff
507
less/less.nro
507
less/less.nro
File diff suppressed because it is too large
Load Diff
7
less/lessecho.c
Executable file → Normal file
7
less/lessecho.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -28,7 +27,7 @@
|
||||
|
||||
#include "less.h"
|
||||
|
||||
static char *version = "$Revision: 1.11 $";
|
||||
static char *version = "$Revision: 1.15 $";
|
||||
|
||||
static int quote_all = 0;
|
||||
static char openquote = '"';
|
||||
|
@ -1,4 +1,4 @@
|
||||
LESSECHO(1) LESSECHO(1)
|
||||
LESSECHO(1) General Commands Manual LESSECHO(1)
|
||||
|
||||
|
||||
|
||||
@ -10,12 +10,18 @@ LESSECHO(1) LESSECHO(1)
|
||||
|
||||
[1mDESCRIPTION[0m
|
||||
[4mlessecho[24m is a program that simply echos its arguments on standard out-
|
||||
put. But any argument containing spaces is enclosed in quotes.
|
||||
put. But any metacharacter in the output is preceded by an "escape"
|
||||
character, which by default is a backslash.
|
||||
|
||||
[1mOPTIONS[0m
|
||||
A summary of options is included below.
|
||||
|
||||
[1m-ox [22mSpecifies "x" to be the open quote character.
|
||||
[1m-ex [22mSpecifies "x", rather than backslash, to be the escape char for
|
||||
metachars. If x is "-", no escape char is used and arguments
|
||||
containing metachars are surrounded by quotes instead.
|
||||
|
||||
[1m-ox [22mSpecifies "x", rather than double-quote, to be the open quote
|
||||
character, which is used if the -e- option is specified.
|
||||
|
||||
[1m-cx [22mSpecifies "x" to be the close quote character.
|
||||
|
||||
@ -23,27 +29,26 @@ LESSECHO(1) LESSECHO(1)
|
||||
|
||||
[1m-dn [22mSpecifies "n" to be the close quote character, as an integer.
|
||||
|
||||
[1m-mx [22mSpecifies "x" to be a metachar.
|
||||
[1m-mx [22mSpecifies "x" to be a metachar. By default, no characters are
|
||||
considered metachars.
|
||||
|
||||
[1m-nn [22mSpecifies "n" to be a metachar, as an integer.
|
||||
|
||||
[1m-ex [22mSpecifies "x" to be the escape char for metachars.
|
||||
|
||||
[1m-fn [22mSpecifies "n" to be the escape char for metachars, as an inte-
|
||||
[1m-fn [22mSpecifies "n" to be the escape char for metachars, as an inte-
|
||||
ger.
|
||||
|
||||
[1m-a [22mSpecifies that all arguments are to be quoted. The default is
|
||||
that only arguments containing spaces are quoted.
|
||||
[1m-a [22mSpecifies that all arguments are to be quoted. The default is
|
||||
that only arguments containing metacharacters are quoted
|
||||
|
||||
[1mSEE ALSO[0m
|
||||
less(1)
|
||||
|
||||
[1mAUTHOR[0m
|
||||
This manual page was written by Thomas Schoepf <schoepf@debian.org>,
|
||||
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 418: 02 Jan 2008 LESSECHO(1)
|
||||
Version 487: 25 Oct 2016 LESSECHO(1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
.TH LESSECHO 1 "Version 418: 02 Jan 2008"
|
||||
.TH LESSECHO 1 "Version 487: 25 Oct 2016"
|
||||
.SH NAME
|
||||
lessecho \- expand metacharacters
|
||||
.SH SYNOPSIS
|
||||
@ -7,12 +7,19 @@ lessecho \- expand metacharacters
|
||||
.SH "DESCRIPTION"
|
||||
.I lessecho
|
||||
is a program that simply echos its arguments on standard output.
|
||||
But any argument containing spaces is enclosed in quotes.
|
||||
But any metacharacter in the output is preceded by an "escape"
|
||||
character, which by default is a backslash.
|
||||
.SH OPTIONS
|
||||
A summary of options is included below.
|
||||
.TP
|
||||
.B \-ex
|
||||
Specifies "x", rather than backslash, to be the escape char for metachars.
|
||||
If x is "-", no escape char is used and arguments containing metachars
|
||||
are surrounded by quotes instead.
|
||||
.TP
|
||||
.B \-ox
|
||||
Specifies "x" to be the open quote character.
|
||||
Specifies "x", rather than double-quote, to be the open quote character,
|
||||
which is used if the -e- option is specified.
|
||||
.TP
|
||||
.B \-cx
|
||||
Specifies "x" to be the close quote character.
|
||||
@ -25,19 +32,17 @@ Specifies "n" to be the close quote character, as an integer.
|
||||
.TP
|
||||
.B \-mx
|
||||
Specifies "x" to be a metachar.
|
||||
By default, no characters are considered metachars.
|
||||
.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.
|
||||
The default is that only arguments containing metacharacters are quoted
|
||||
.SH "SEE ALSO"
|
||||
less(1)
|
||||
.SH AUTHOR
|
||||
|
5
less/lglob.h
Executable file → Normal file
5
less/lglob.h
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
|
138
less/line.c
Executable file → Normal file
138
less/line.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -17,6 +16,7 @@
|
||||
|
||||
#include "less.h"
|
||||
#include "charset.h"
|
||||
#include "position.h"
|
||||
|
||||
static char *linebuf = NULL; /* Buffer which holds the current output line */
|
||||
static char *attr = NULL; /* Extension of linebuf to hold attributes */
|
||||
@ -27,6 +27,7 @@ public int hshift; /* Desired left-shift of output line buffer */
|
||||
public int tabstops[TABSTOP_MAX] = { 0 }; /* Custom tabstops */
|
||||
public int ntabstops = 1; /* Number of tabstops */
|
||||
public int tabdefault = 8; /* Default repeated tabstops */
|
||||
public POSITION highest_hilite; /* Pos of last hilite in file found so far */
|
||||
|
||||
static int curr; /* Index into linebuf */
|
||||
static int column; /* Printable length, accounting for
|
||||
@ -35,8 +36,7 @@ static int overstrike; /* Next char should overstrike previous char */
|
||||
static int last_overstrike = AT_NORMAL;
|
||||
static int is_null_line; /* There is no current line */
|
||||
static int lmargin; /* Left margin */
|
||||
static int line_matches; /* Number of search matches in this line */
|
||||
static char pendc;
|
||||
static LWCHAR pendc;
|
||||
static POSITION pendpos;
|
||||
static char *end_ansi_chars;
|
||||
static char *mid_ansi_chars;
|
||||
@ -59,7 +59,6 @@ extern int bl_s_width, bl_e_width;
|
||||
extern int so_s_width, so_e_width;
|
||||
extern int sc_width, sc_height;
|
||||
extern int utf_mode;
|
||||
extern int oldbot;
|
||||
extern POSITION start_attnpos;
|
||||
extern POSITION end_attnpos;
|
||||
|
||||
@ -80,7 +79,7 @@ init_line()
|
||||
|
||||
mid_ansi_chars = lgetenv("LESSANSIMIDCHARS");
|
||||
if (mid_ansi_chars == NULL || *mid_ansi_chars == '\0')
|
||||
mid_ansi_chars = "0123456789;[?!\"'#%()*+ ";
|
||||
mid_ansi_chars = "0123456789:;[?!\"'#%()*+ ";
|
||||
|
||||
linebuf = (char *) ecalloc(LINEBUF_SIZE, sizeof(char));
|
||||
attr = (char *) ecalloc(LINEBUF_SIZE, sizeof(char));
|
||||
@ -162,9 +161,6 @@ prewind()
|
||||
lmargin = 0;
|
||||
if (status_col)
|
||||
lmargin += 1;
|
||||
#if HILITE_SEARCH
|
||||
line_matches = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -214,13 +210,13 @@ plinenum(pos)
|
||||
int n;
|
||||
|
||||
linenumtoa(linenum, buf);
|
||||
n = strlen(buf);
|
||||
n = (int) strlen(buf);
|
||||
if (n < MIN_LINENUM_WIDTH)
|
||||
n = MIN_LINENUM_WIDTH;
|
||||
sprintf(linebuf+curr, "%*s ", n, buf);
|
||||
n++; /* One space after the line number. */
|
||||
for (i = 0; i < n; i++)
|
||||
attr[curr+i] = AT_NORMAL;
|
||||
attr[curr+i] = AT_BOLD;
|
||||
curr += n;
|
||||
column += n;
|
||||
lmargin += n;
|
||||
@ -496,7 +492,7 @@ backc()
|
||||
&& column > lmargin
|
||||
&& (!(attr[curr - 1] & (AT_ANSI|AT_BINARY))))
|
||||
{
|
||||
curr = p - linebuf;
|
||||
curr = (int) (p - linebuf);
|
||||
prev_ch = step_char(&p, -1, linebuf + lmargin);
|
||||
width = pwidth(ch, attr[curr], prev_ch);
|
||||
column -= width;
|
||||
@ -590,9 +586,13 @@ store_char(ch, a, rep, pos)
|
||||
* Override the attribute passed in.
|
||||
*/
|
||||
if (a != AT_ANSI)
|
||||
{
|
||||
if (highest_hilite != NULL_POSITION &&
|
||||
pos > highest_hilite)
|
||||
highest_hilite = pos;
|
||||
a |= AT_HILITE;
|
||||
}
|
||||
}
|
||||
line_matches += matches;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -600,11 +600,12 @@ store_char(ch, a, rep, pos)
|
||||
{
|
||||
if (!is_ansi_end(ch) && !is_ansi_middle(ch)) {
|
||||
/* Remove whole unrecognized sequence. */
|
||||
char *p = &linebuf[curr];
|
||||
LWCHAR bch;
|
||||
do {
|
||||
if (curr == 0)
|
||||
break;
|
||||
--curr;
|
||||
} while (!IS_CSI_START(linebuf[curr]));
|
||||
bch = step_char(&p, -1, linebuf);
|
||||
} while (p > linebuf && !IS_CSI_START(bch));
|
||||
curr = (int) (p - linebuf);
|
||||
return 0;
|
||||
}
|
||||
a = AT_ANSI; /* Will force re-AT_'ing around it. */
|
||||
@ -697,7 +698,7 @@ store_tab(attr, pos)
|
||||
|
||||
static int
|
||||
store_prchar(c, pos)
|
||||
char c;
|
||||
LWCHAR c;
|
||||
POSITION pos;
|
||||
{
|
||||
char *s;
|
||||
@ -741,13 +742,15 @@ flush_mbc_buf(pos)
|
||||
*/
|
||||
public int
|
||||
pappend(c, pos)
|
||||
char c;
|
||||
unsigned char c;
|
||||
POSITION pos;
|
||||
{
|
||||
int r;
|
||||
|
||||
if (pendc)
|
||||
{
|
||||
if (c == '\r' && pendc == '\r')
|
||||
return (0);
|
||||
if (do_append(pendc, NULL, pendpos))
|
||||
/*
|
||||
* Oops. We've probably lost the char which
|
||||
@ -781,7 +784,7 @@ pappend(c, pos)
|
||||
|
||||
if (!utf_mode)
|
||||
{
|
||||
r = do_append((LWCHAR) c, NULL, pos);
|
||||
r = do_append(c, NULL, pos);
|
||||
} else
|
||||
{
|
||||
/* Perform strict validation in all possible cases. */
|
||||
@ -791,7 +794,7 @@ pappend(c, pos)
|
||||
mbc_buf_index = 1;
|
||||
*mbc_buf = c;
|
||||
if (IS_ASCII_OCTET(c))
|
||||
r = do_append((LWCHAR) c, NULL, pos);
|
||||
r = do_append(c, NULL, pos);
|
||||
else if (IS_UTF8_LEAD(c))
|
||||
{
|
||||
mbc_buf_len = utf_len(c);
|
||||
@ -805,7 +808,7 @@ pappend(c, pos)
|
||||
mbc_buf[mbc_buf_index++] = c;
|
||||
if (mbc_buf_index < mbc_buf_len)
|
||||
return (0);
|
||||
if (is_utf8_well_formed(mbc_buf))
|
||||
if (is_utf8_well_formed(mbc_buf, mbc_buf_index))
|
||||
r = do_append(get_wchar(mbc_buf), mbc_buf, mbc_pos);
|
||||
else
|
||||
/* Complete, but not shortest form, sequence. */
|
||||
@ -885,8 +888,14 @@ do_append(ch, rep, pos)
|
||||
* or just deletion of the character in the buffer.
|
||||
*/
|
||||
overstrike = utf_mode ? -1 : 0;
|
||||
/* To be correct, this must be a base character. */
|
||||
prev_ch = get_wchar(linebuf + curr);
|
||||
if (utf_mode)
|
||||
{
|
||||
/* To be correct, this must be a base character. */
|
||||
prev_ch = get_wchar(linebuf + curr);
|
||||
} else
|
||||
{
|
||||
prev_ch = (unsigned char) linebuf[curr];
|
||||
}
|
||||
a = attr[curr];
|
||||
if (ch == prev_ch)
|
||||
{
|
||||
@ -994,11 +1003,10 @@ pflushmbc()
|
||||
* Terminate the line in the line buffer.
|
||||
*/
|
||||
public void
|
||||
pdone(endline)
|
||||
pdone(endline, forw)
|
||||
int endline;
|
||||
int forw;
|
||||
{
|
||||
int nl;
|
||||
|
||||
(void) pflushmbc();
|
||||
|
||||
if (pendc && (pendc != '\r' || !endline))
|
||||
@ -1039,43 +1047,46 @@ pdone(endline)
|
||||
* the next line is blank. In that case the single newline output for
|
||||
* that blank line would be ignored!)
|
||||
*/
|
||||
if (!oldbot)
|
||||
nl = (column < sc_width || !auto_wrap || (endline && ignaw) || ctldisp == OPT_ON);
|
||||
else
|
||||
nl = (column < sc_width || !auto_wrap || ignaw || ctldisp == OPT_ON);
|
||||
if (nl)
|
||||
if (column < sc_width || !auto_wrap || (endline && ignaw) || ctldisp == OPT_ON)
|
||||
{
|
||||
linebuf[curr] = '\n';
|
||||
attr[curr] = AT_NORMAL;
|
||||
curr++;
|
||||
}
|
||||
else if (ignaw && !auto_wrap && column >= sc_width)
|
||||
else if (ignaw && column >= sc_width && forw)
|
||||
{
|
||||
/*
|
||||
* Big horrible kludge.
|
||||
* No-wrap terminals are too hard to deal with when they get in
|
||||
* the state where a full screen width of characters have been
|
||||
* output but the cursor is sitting on the right edge instead
|
||||
* of at the start of the next line.
|
||||
* So after we output a full line, we output an extra
|
||||
* space and backspace to force the cursor to the
|
||||
* beginning of the next line, like a sane terminal.
|
||||
* Terminals with "ignaw" don't wrap until they *really* need
|
||||
* to, i.e. when the character *after* the last one to fit on a
|
||||
* line is output. But they are too hard to deal with when they
|
||||
* get in the state where a full screen width of characters
|
||||
* have been output but the cursor is sitting on the right edge
|
||||
* instead of at the start of the next line.
|
||||
* So we nudge them into wrapping by outputting a space
|
||||
* character plus a backspace. But do this only if moving
|
||||
* forward; if we're moving backward and drawing this line at
|
||||
* the top of the screen, the space would overwrite the first
|
||||
* char on the next line. We don't need to do this "nudge"
|
||||
* at the top of the screen anyway.
|
||||
*/
|
||||
linebuf[curr] = ' ';
|
||||
linebuf[curr] = ' ';
|
||||
attr[curr++] = AT_NORMAL;
|
||||
linebuf[curr] = '\b';
|
||||
attr[curr++] = AT_NORMAL;
|
||||
}
|
||||
linebuf[curr] = '\0';
|
||||
attr[curr] = AT_NORMAL;
|
||||
}
|
||||
|
||||
#if HILITE_SEARCH
|
||||
if (status_col && line_matches > 0)
|
||||
{
|
||||
linebuf[0] = '*';
|
||||
attr[0] = AT_NORMAL|AT_HILITE;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
*
|
||||
*/
|
||||
public void
|
||||
set_status_col(c)
|
||||
char c;
|
||||
{
|
||||
linebuf[0] = c;
|
||||
attr[0] = AT_NORMAL|AT_HILITE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1245,3 +1256,30 @@ back_raw_line(curr_pos, linep, line_lenp)
|
||||
*line_lenp = size_linebuf - 1 - n;
|
||||
return (new_pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the shift necessary to show the end of the longest displayed line.
|
||||
*/
|
||||
public int
|
||||
rrshift()
|
||||
{
|
||||
POSITION pos;
|
||||
int save_width;
|
||||
int line;
|
||||
int longest = 0;
|
||||
|
||||
save_width = sc_width;
|
||||
sc_width = INT_MAX;
|
||||
hshift = 0;
|
||||
pos = position(TOP);
|
||||
for (line = 0; line < sc_height && pos != NULL_POSITION; line++)
|
||||
{
|
||||
pos = forw_line(pos);
|
||||
if (column > longest)
|
||||
longest = column;
|
||||
}
|
||||
sc_width = save_width;
|
||||
if (longest < sc_width)
|
||||
return 0;
|
||||
return longest - sc_width;
|
||||
}
|
||||
|
56
less/linenum.c
Executable file → Normal file
56
less/linenum.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -56,12 +55,10 @@ struct linenum_info
|
||||
* when we have a new one to insert and the table is full.
|
||||
*/
|
||||
|
||||
#define NPOOL 50 /* Size of line number pool */
|
||||
#define NPOOL 200 /* Size of line number pool */
|
||||
|
||||
#define LONGTIME (2) /* In seconds */
|
||||
|
||||
public int lnloop = 0; /* Are we in the line num loop? */
|
||||
|
||||
static struct linenum_info anchor; /* Anchor of the list */
|
||||
static struct linenum_info *freelist; /* Anchor of the unused entries */
|
||||
static struct linenum_info pool[NPOOL]; /* The pool itself */
|
||||
@ -70,6 +67,7 @@ static struct linenum_info *spare; /* We always keep one spare entry */
|
||||
extern int linenums;
|
||||
extern int sigs;
|
||||
extern int sc_height;
|
||||
extern int screen_trashed;
|
||||
|
||||
/*
|
||||
* Initialize the line number structures.
|
||||
@ -214,17 +212,11 @@ add_lnum(linenum, pos)
|
||||
longloopmessage()
|
||||
{
|
||||
ierror("Calculating line numbers", NULL_PARG);
|
||||
/*
|
||||
* Set the lnloop flag here, so if the user interrupts while
|
||||
* we are calculating line numbers, the signal handler will
|
||||
* turn off line numbers (linenums=0).
|
||||
*/
|
||||
lnloop = 1;
|
||||
}
|
||||
|
||||
static int loopcount;
|
||||
#if HAVE_TIME
|
||||
static long startime;
|
||||
static time_type startime;
|
||||
#endif
|
||||
|
||||
static void
|
||||
@ -249,6 +241,22 @@ longish()
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off line numbers because the user has interrupted
|
||||
* a lengthy line number calculation.
|
||||
*/
|
||||
static void
|
||||
abort_long()
|
||||
{
|
||||
if (linenums == OPT_ONPLUS)
|
||||
/*
|
||||
* We were displaying line numbers, so need to repaint.
|
||||
*/
|
||||
screen_trashed = 1;
|
||||
linenums = 0;
|
||||
error("Line numbers turned off", NULL_PARG);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the line number associated with a given position.
|
||||
* Return 0 if we can't figure it out.
|
||||
@ -315,11 +323,14 @@ find_linenum(pos)
|
||||
* Allow a signal to abort this loop.
|
||||
*/
|
||||
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
|
||||
if (ABORT_SIGS() || cpos == NULL_POSITION)
|
||||
if (ABORT_SIGS()) {
|
||||
abort_long();
|
||||
return (0);
|
||||
}
|
||||
if (cpos == NULL_POSITION)
|
||||
return (0);
|
||||
longish();
|
||||
}
|
||||
lnloop = 0;
|
||||
/*
|
||||
* We might as well cache it.
|
||||
*/
|
||||
@ -344,11 +355,14 @@ find_linenum(pos)
|
||||
* Allow a signal to abort this loop.
|
||||
*/
|
||||
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
|
||||
if (ABORT_SIGS() || cpos == NULL_POSITION)
|
||||
if (ABORT_SIGS()) {
|
||||
abort_long();
|
||||
return (0);
|
||||
}
|
||||
if (cpos == NULL_POSITION)
|
||||
return (0);
|
||||
longish();
|
||||
}
|
||||
lnloop = 0;
|
||||
/*
|
||||
* We might as well cache it.
|
||||
*/
|
||||
@ -399,7 +413,9 @@ find_pos(linenum)
|
||||
* Allow a signal to abort this loop.
|
||||
*/
|
||||
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
|
||||
if (ABORT_SIGS() || cpos == NULL_POSITION)
|
||||
if (ABORT_SIGS())
|
||||
return (NULL_POSITION);
|
||||
if (cpos == NULL_POSITION)
|
||||
return (NULL_POSITION);
|
||||
}
|
||||
} else
|
||||
@ -415,7 +431,9 @@ find_pos(linenum)
|
||||
* Allow a signal to abort this loop.
|
||||
*/
|
||||
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
|
||||
if (ABORT_SIGS() || cpos == NULL_POSITION)
|
||||
if (ABORT_SIGS())
|
||||
return (NULL_POSITION);
|
||||
if (cpos == NULL_POSITION)
|
||||
return (NULL_POSITION);
|
||||
}
|
||||
}
|
||||
|
16
less/lsystem.c
Executable file → Normal file
16
less/lsystem.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -49,7 +48,7 @@ lsystem(cmd, donemsg)
|
||||
register char *p;
|
||||
#endif
|
||||
IFILE save_ifile;
|
||||
#if MSDOS_COMPILER
|
||||
#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
|
||||
char cwd[FILENAME_MAX+1];
|
||||
#endif
|
||||
|
||||
@ -68,6 +67,10 @@ lsystem(cmd, donemsg)
|
||||
}
|
||||
|
||||
#if MSDOS_COMPILER
|
||||
#if MSDOS_COMPILER==WIN32C
|
||||
if (*cmd == '\0')
|
||||
cmd = getenv("COMSPEC");
|
||||
#else
|
||||
/*
|
||||
* Working directory is global on MSDOS.
|
||||
* The child might change the working directory, so we
|
||||
@ -76,6 +79,7 @@ lsystem(cmd, donemsg)
|
||||
* try to "reedit_ifile" it.
|
||||
*/
|
||||
getcwd(cwd, FILENAME_MAX);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -133,7 +137,7 @@ lsystem(cmd, donemsg)
|
||||
char *esccmd = shell_quote(cmd);
|
||||
if (esccmd != NULL)
|
||||
{
|
||||
int len = strlen(shell) + strlen(esccmd) + 5;
|
||||
int len = (int) (strlen(shell) + strlen(esccmd) + 5);
|
||||
p = (char *) ecalloc(len, sizeof(char));
|
||||
SNPRINTF3(p, len, "%s %s %s", shell, shell_coption(), esccmd);
|
||||
free(esccmd);
|
||||
@ -192,7 +196,7 @@ lsystem(cmd, donemsg)
|
||||
init();
|
||||
screen_trashed = 1;
|
||||
|
||||
#if MSDOS_COMPILER
|
||||
#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
|
||||
/*
|
||||
* Restore the previous directory (possibly
|
||||
* changed by the child program we just ran).
|
||||
|
18
less/main.c
Executable file → Normal file
18
less/main.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -39,13 +38,12 @@ public char * progname;
|
||||
public int quitting;
|
||||
public int secure;
|
||||
public int dohelp;
|
||||
public int less_is_more;
|
||||
|
||||
public int file_errors = 0;
|
||||
public int unix2003_compat = 0;
|
||||
public int add_newline = 0;
|
||||
public char * active_dashp_command = NULL;
|
||||
public char * dashp_commands = NULL;
|
||||
|
||||
#if LOGFILE
|
||||
public int logfile = -1;
|
||||
public int force_logfile = FALSE;
|
||||
@ -67,9 +65,9 @@ extern int jump_sline;
|
||||
static char consoleTitle[256];
|
||||
#endif
|
||||
|
||||
extern int less_is_more;
|
||||
extern int missing_cap;
|
||||
extern int know_dumb;
|
||||
extern int quit_if_one_screen;
|
||||
extern int pr_type;
|
||||
|
||||
|
||||
@ -129,6 +127,7 @@ main(argc, argv)
|
||||
init_line();
|
||||
init_cmdhist();
|
||||
init_option();
|
||||
init_search();
|
||||
|
||||
/*
|
||||
* If the name of the executable program is "more",
|
||||
@ -151,6 +150,7 @@ main(argc, argv)
|
||||
scan_option("-m");
|
||||
scan_option("-G");
|
||||
scan_option("-X"); /* avoid alternate screen */
|
||||
scan_option("-A"); /* search avoids current screen */
|
||||
}
|
||||
s = lgetenv(less_is_more ? "MORE" : "LESS");
|
||||
if (s != NULL)
|
||||
@ -177,9 +177,6 @@ main(argc, argv)
|
||||
quit(QUIT_OK);
|
||||
}
|
||||
|
||||
if (less_is_more && get_quit_at_eof())
|
||||
quit_if_one_screen = TRUE;
|
||||
|
||||
#if EDITOR
|
||||
editor = lgetenv("VISUAL");
|
||||
if (editor == NULL || *editor == '\0')
|
||||
@ -241,6 +238,7 @@ main(argc, argv)
|
||||
argv++;
|
||||
(void) get_ifile(filename, ifile);
|
||||
ifile = prev_ifile(NULL_IFILE);
|
||||
free(filename);
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
@ -459,7 +457,7 @@ quit(status)
|
||||
*/
|
||||
close(2);
|
||||
#endif
|
||||
#if WIN32
|
||||
#ifdef WIN32
|
||||
SetConsoleTitle(consoleTitle);
|
||||
#endif
|
||||
close_getchr();
|
||||
|
13
less/mark.c
Executable file → Normal file
13
less/mark.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -15,14 +14,6 @@ extern IFILE curr_ifile;
|
||||
extern int sc_height;
|
||||
extern int jump_sline;
|
||||
|
||||
/*
|
||||
* A mark is an ifile (input file) plus a position within the file.
|
||||
*/
|
||||
struct mark {
|
||||
IFILE m_ifile;
|
||||
struct scrpos m_scrpos;
|
||||
};
|
||||
|
||||
/*
|
||||
* The table of marks.
|
||||
* Each mark is identified by a lowercase or uppercase letter.
|
||||
|
5
less/mkhelp.c
Executable file → Normal file
5
less/mkhelp.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
|
85
less/mkutable
Executable file
85
less/mkutable
Executable file
@ -0,0 +1,85 @@
|
||||
#! /usr/bin/perl
|
||||
use strict;
|
||||
|
||||
my $USAGE = <<__EOF__;
|
||||
usage: mkutable [-n] [-f#] type... [--] [<] UnicodeData.txt
|
||||
-n = take non-matching types
|
||||
-f = zero-based type field (default 2)
|
||||
__EOF__
|
||||
|
||||
use vars qw( $opt_f $opt_n );
|
||||
use Getopt::Std;
|
||||
my $type_field = 2;
|
||||
|
||||
exit (main() ? 0 : 1);
|
||||
|
||||
sub main {
|
||||
my $date = `date`;
|
||||
chomp $date;
|
||||
my $args = join ' ', @ARGV;
|
||||
my $header = "/* Generated by \"$0 $args\" on $date */\n";
|
||||
|
||||
die $USAGE if not getopts('f:n');
|
||||
$type_field = $opt_f if $opt_f;
|
||||
my %types;
|
||||
my $arg;
|
||||
while ($arg = shift @ARGV) {
|
||||
last if $arg eq '--';
|
||||
$types{$arg} = 1;
|
||||
}
|
||||
my %out = ( 'types' => \%types );
|
||||
|
||||
print $header;
|
||||
my $last_code = 0;
|
||||
while (<>) {
|
||||
chomp;
|
||||
s/#.*//;
|
||||
my @fields = split /;/;
|
||||
next if not @fields;
|
||||
my ($lo_code, $hi_code);
|
||||
my $codes = $fields[0];
|
||||
if ($codes =~ /(\w+)\.\.(\w+)/) {
|
||||
$lo_code = hex $1;
|
||||
$hi_code = hex $2;
|
||||
} else {
|
||||
$lo_code = $hi_code = hex $fields[0];
|
||||
}
|
||||
my $type = $fields[$type_field];
|
||||
$type =~ s/\s//g;
|
||||
for ($last_code = $lo_code; $last_code <= $hi_code; ++$last_code) {
|
||||
output(\%out, $last_code, $type);
|
||||
}
|
||||
}
|
||||
output(\%out, $last_code);
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub output {
|
||||
my ($out, $code, $type) = @_;
|
||||
my $type_ok = ($type and ${${$out}{types}}{$type});
|
||||
$type_ok = not $type_ok if $opt_n;
|
||||
my $prev_code = $$out{prev_code};
|
||||
|
||||
if (not $type_ok) {
|
||||
end_run($out, $prev_code);
|
||||
} elsif (not $$out{in_run} or $type ne $$out{run_type} or $code != $prev_code+1) {
|
||||
end_run($out, $prev_code);
|
||||
start_run($out, $code, $type);
|
||||
}
|
||||
$$out{prev_code} = $code;
|
||||
}
|
||||
|
||||
sub start_run {
|
||||
my ($out, $code, $type) = @_;
|
||||
$$out{start_code} = $code;
|
||||
$$out{prev_code} = $code;
|
||||
$$out{run_type} = $type;
|
||||
$$out{in_run} = 1;
|
||||
}
|
||||
|
||||
sub end_run {
|
||||
my ($out, $code) = @_;
|
||||
return if not $$out{in_run};
|
||||
printf "\t{ 0x%04x, 0x%04x }, /* %s */\n", $$out{start_code}, $code, $$out{run_type};
|
||||
$$out{in_run} = 0;
|
||||
}
|
183
less/optfunc.c
Executable file → Normal file
183
less/optfunc.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -33,6 +32,7 @@ extern int bufspace;
|
||||
extern int pr_type;
|
||||
extern int plusoption;
|
||||
extern int swindow;
|
||||
extern int sc_width;
|
||||
extern int sc_height;
|
||||
extern int secure;
|
||||
extern int dohelp;
|
||||
@ -43,10 +43,13 @@ extern char *prproto[];
|
||||
extern char *eqproto;
|
||||
extern char *hproto;
|
||||
extern char *wproto;
|
||||
extern char *every_first_cmd;
|
||||
extern IFILE curr_ifile;
|
||||
extern char version[];
|
||||
extern int jump_sline;
|
||||
extern int jump_sline_fraction;
|
||||
extern int shift_count;
|
||||
extern int shift_count_fraction;
|
||||
extern int less_is_more;
|
||||
extern char* dashp_commands;
|
||||
#if LOGFILE
|
||||
@ -57,6 +60,7 @@ extern int logfile;
|
||||
#if TAGS
|
||||
public char *tagoption = NULL;
|
||||
extern char *tags;
|
||||
extern char ztags[];
|
||||
#endif
|
||||
#if MSDOS_COMPILER
|
||||
extern int nm_fg_color, nm_bg_color;
|
||||
@ -64,6 +68,7 @@ extern int bo_fg_color, bo_bg_color;
|
||||
extern int ul_fg_color, ul_bg_color;
|
||||
extern int so_fg_color, so_bg_color;
|
||||
extern int bl_fg_color, bl_bg_color;
|
||||
extern int sgr_mode;
|
||||
#endif
|
||||
|
||||
|
||||
@ -86,7 +91,7 @@ opt_o(type, s)
|
||||
switch (type)
|
||||
{
|
||||
case INIT:
|
||||
namelogfile = s;
|
||||
namelogfile = save(s);
|
||||
break;
|
||||
case TOGGLE:
|
||||
if (ch_getflags() & CH_CANSEEK)
|
||||
@ -100,6 +105,8 @@ opt_o(type, s)
|
||||
return;
|
||||
}
|
||||
s = skipsp(s);
|
||||
if (namelogfile != NULL)
|
||||
free(namelogfile);
|
||||
namelogfile = lglob(s);
|
||||
use_logfile(namelogfile);
|
||||
sync_logfile();
|
||||
@ -129,34 +136,6 @@ opt__O(type, s)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handlers for -l option.
|
||||
*/
|
||||
public void
|
||||
opt_l(type, s)
|
||||
int type;
|
||||
char *s;
|
||||
{
|
||||
int err;
|
||||
int n;
|
||||
char *t;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case INIT:
|
||||
t = s;
|
||||
n = getnum(&t, "l", &err);
|
||||
if (err || n <= 0)
|
||||
{
|
||||
error("Line number is required after -l", NULL_PARG);
|
||||
return;
|
||||
}
|
||||
plusoption = TRUE;
|
||||
ungetsc(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handlers for -j option.
|
||||
*/
|
||||
@ -203,7 +182,7 @@ opt_j(type, s)
|
||||
{
|
||||
|
||||
sprintf(buf, ".%06d", jump_sline_fraction);
|
||||
len = strlen(buf);
|
||||
len = (int) strlen(buf);
|
||||
while (len > 2 && buf[len-1] == '0')
|
||||
len--;
|
||||
buf[len] = '\0';
|
||||
@ -222,6 +201,70 @@ calc_jump_sline()
|
||||
jump_sline = sc_height * jump_sline_fraction / NUM_FRAC_DENOM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handlers for -# option.
|
||||
*/
|
||||
public void
|
||||
opt_shift(type, s)
|
||||
int type;
|
||||
char *s;
|
||||
{
|
||||
PARG parg;
|
||||
char buf[16];
|
||||
int len;
|
||||
int err;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case INIT:
|
||||
case TOGGLE:
|
||||
if (*s == '.')
|
||||
{
|
||||
s++;
|
||||
shift_count_fraction = getfraction(&s, "#", &err);
|
||||
if (err)
|
||||
error("Invalid column fraction", NULL_PARG);
|
||||
else
|
||||
calc_shift_count();
|
||||
} else
|
||||
{
|
||||
int hs = getnum(&s, "#", &err);
|
||||
if (err)
|
||||
error("Invalid column number", NULL_PARG);
|
||||
else
|
||||
{
|
||||
shift_count = hs;
|
||||
shift_count_fraction = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QUERY:
|
||||
if (shift_count_fraction < 0)
|
||||
{
|
||||
parg.p_int = shift_count;
|
||||
error("Horizontal shift %d columns", &parg);
|
||||
} else
|
||||
{
|
||||
|
||||
sprintf(buf, ".%06d", shift_count_fraction);
|
||||
len = (int) strlen(buf);
|
||||
while (len > 2 && buf[len-1] == '0')
|
||||
len--;
|
||||
buf[len] = '\0';
|
||||
parg.p_string = buf;
|
||||
error("Horizontal shift %s of screen width", &parg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void
|
||||
calc_shift_count()
|
||||
{
|
||||
if (shift_count_fraction < 0)
|
||||
return;
|
||||
shift_count = sc_width * shift_count_fraction / NUM_FRAC_DENOM;
|
||||
}
|
||||
|
||||
#if USERFILE
|
||||
public void
|
||||
opt_k(type, s)
|
||||
@ -258,7 +301,7 @@ opt_t(type, s)
|
||||
switch (type)
|
||||
{
|
||||
case INIT:
|
||||
tagoption = s;
|
||||
tagoption = save(s);
|
||||
/* Do the rest in main() */
|
||||
break;
|
||||
case TOGGLE:
|
||||
@ -298,10 +341,12 @@ opt__T(type, s)
|
||||
switch (type)
|
||||
{
|
||||
case INIT:
|
||||
tags = s;
|
||||
tags = save(s);
|
||||
break;
|
||||
case TOGGLE:
|
||||
s = skipsp(s);
|
||||
if (tags != NULL && tags != ztags)
|
||||
free(tags);
|
||||
tags = lglob(s);
|
||||
break;
|
||||
case QUERY:
|
||||
@ -324,18 +369,26 @@ opt_p(type, s)
|
||||
{
|
||||
case INIT:
|
||||
/*
|
||||
* Unget a search command for the specified string.
|
||||
* {{ This won't work if the "/" command is
|
||||
* changed or invalidated by a .lesskey file. }}
|
||||
* Unget a command for the specified string.
|
||||
*/
|
||||
plusoption = TRUE;
|
||||
ungetsc(s);
|
||||
/*
|
||||
* In "more" mode, the -p argument is a command,
|
||||
* not a search string, so we don't need a slash.
|
||||
*/
|
||||
if (!less_is_more)
|
||||
if (less_is_more)
|
||||
{
|
||||
/*
|
||||
* In "more" mode, the -p argument is a command,
|
||||
* not a search string, so we don't need a slash.
|
||||
*/
|
||||
every_first_cmd = save(s);
|
||||
} else
|
||||
{
|
||||
plusoption = TRUE;
|
||||
ungetcc(CHAR_END_COMMAND);
|
||||
ungetsc(s);
|
||||
/*
|
||||
* {{ This won't work if the "/" command is
|
||||
* changed or invalidated by a .lesskey file. }}
|
||||
*/
|
||||
ungetsc("/");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -443,7 +496,30 @@ opt__V(type, s)
|
||||
any_display = 1;
|
||||
putstr("less ");
|
||||
putstr(version);
|
||||
putstr("\nCopyright (C) 1984-2007 Mark Nudelman\n\n");
|
||||
putstr(" (");
|
||||
#if HAVE_GNU_REGEX
|
||||
putstr("GNU ");
|
||||
#endif
|
||||
#if HAVE_POSIX_REGCOMP
|
||||
putstr("POSIX ");
|
||||
#endif
|
||||
#if HAVE_PCRE
|
||||
putstr("PCRE ");
|
||||
#endif
|
||||
#if HAVE_RE_COMP
|
||||
putstr("BSD ");
|
||||
#endif
|
||||
#if HAVE_REGCMP
|
||||
putstr("V8 ");
|
||||
#endif
|
||||
#if HAVE_V8_REGCOMP
|
||||
putstr("Spencer V8 ");
|
||||
#endif
|
||||
#if !HAVE_GNU_REGEX && !HAVE_POSIX_REGCOMP && !HAVE_PCRE && !HAVE_RE_COMP && !HAVE_REGCMP && !HAVE_V8_REGCOMP
|
||||
putstr("no ");
|
||||
#endif
|
||||
putstr("regular expressions)\n");
|
||||
putstr("Copyright (C) 1984-2016 Mark Nudelman\n\n");
|
||||
putstr("less comes with NO WARRANTY, to the extent permitted by law.\n");
|
||||
putstr("For information about the terms of redistribution,\n");
|
||||
putstr("see the file named README in the less distribution.\n");
|
||||
@ -473,14 +549,14 @@ colordesc(s, fg_color, bg_color)
|
||||
return;
|
||||
}
|
||||
if (*s != '.')
|
||||
bg = 0;
|
||||
bg = nm_bg_color;
|
||||
else
|
||||
{
|
||||
s++;
|
||||
bg = getnum(&s, "D", &err);
|
||||
if (err)
|
||||
{
|
||||
error("Missing fg color in -D", NULL_PARG);
|
||||
error("Missing bg color in -D", NULL_PARG);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -499,6 +575,8 @@ opt_D(type, s)
|
||||
int type;
|
||||
char *s;
|
||||
{
|
||||
PARG p;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case INIT:
|
||||
@ -520,8 +598,11 @@ opt_D(type, s)
|
||||
case 's':
|
||||
colordesc(s, &so_fg_color, &so_bg_color);
|
||||
break;
|
||||
case 'a':
|
||||
sgr_mode = !sgr_mode;
|
||||
break;
|
||||
default:
|
||||
error("-D must be followed by n, d, u, k or s", NULL_PARG);
|
||||
error("-D must be followed by n, d, u, k, s or a", NULL_PARG);
|
||||
break;
|
||||
}
|
||||
if (type == TOGGLE)
|
||||
@ -531,6 +612,8 @@ opt_D(type, s)
|
||||
}
|
||||
break;
|
||||
case QUERY:
|
||||
p.p_string = (sgr_mode) ? "on" : "off";
|
||||
error("SGR mode is %s", &p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -674,6 +757,6 @@ opt_dashp(type,s)
|
||||
int type;
|
||||
char *s;
|
||||
{
|
||||
dashp_commands = s;
|
||||
dashp_commands = save(s);
|
||||
}
|
||||
|
||||
|
158
less/option.c
Executable file → Normal file
158
less/option.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -24,7 +23,6 @@
|
||||
static struct loption *pendopt;
|
||||
public int plusoption = FALSE;
|
||||
|
||||
static char *propt();
|
||||
static char *optstring();
|
||||
static int flip_triple();
|
||||
|
||||
@ -32,8 +30,38 @@ extern int screen_trashed;
|
||||
extern int less_is_more;
|
||||
extern int quit_at_eof;
|
||||
extern char *every_first_cmd;
|
||||
extern int opt_use_backslash;
|
||||
extern int unix2003_compat;
|
||||
|
||||
/*
|
||||
* Return a printable description of an option.
|
||||
*/
|
||||
static char *
|
||||
opt_desc(o)
|
||||
struct loption *o;
|
||||
{
|
||||
static char buf[OPTNAME_MAX + 10];
|
||||
if (o->oletter == OLETTER_NONE)
|
||||
SNPRINTF1(buf, sizeof(buf), "--%s", o->onames->oname);
|
||||
else
|
||||
SNPRINTF2(buf, sizeof(buf), "-%c (--%s)", o->oletter, o->onames->oname);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a string suitable for printing as the "name" of an option.
|
||||
* For example, if the option letter is 'x', just return "-x".
|
||||
*/
|
||||
public char *
|
||||
propt(c)
|
||||
int c;
|
||||
{
|
||||
static char buf[8];
|
||||
|
||||
sprintf(buf, "-%s", prchar(c));
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan an argument (either from the command line or from the
|
||||
* LESS environment variable) and process it.
|
||||
@ -70,7 +98,7 @@ scan_option(s)
|
||||
(*pendopt->ofunc)(INIT, s);
|
||||
break;
|
||||
case NUMBER:
|
||||
printopt = propt(pendopt->oletter);
|
||||
printopt = opt_desc(pendopt);
|
||||
*(pendopt->ovar) = getnum(&s, printopt, (int*)NULL);
|
||||
break;
|
||||
}
|
||||
@ -120,10 +148,16 @@ scan_option(s)
|
||||
*/
|
||||
plusoption = TRUE;
|
||||
s = optstring(s, &str, propt('+'), NULL);
|
||||
if (s == NULL)
|
||||
return;
|
||||
if (*str == '+')
|
||||
every_first_cmd = save(++str);
|
||||
every_first_cmd = save(str+1);
|
||||
else
|
||||
{
|
||||
ungetcc(CHAR_END_COMMAND);
|
||||
ungetsc(str);
|
||||
}
|
||||
free(str);
|
||||
continue;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
@ -192,7 +226,7 @@ scan_option(s)
|
||||
parg.p_string = printopt;
|
||||
error("The %s option should not be followed by =",
|
||||
&parg);
|
||||
quit(QUIT_ERROR);
|
||||
return;
|
||||
}
|
||||
s++;
|
||||
} else
|
||||
@ -213,7 +247,7 @@ scan_option(s)
|
||||
else
|
||||
error("There is no %s option (\"less --help\" for help)",
|
||||
&parg);
|
||||
quit(QUIT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
str = NULL;
|
||||
@ -250,6 +284,8 @@ scan_option(s)
|
||||
while (*s == ' ')
|
||||
s++;
|
||||
s = optstring(s, &str, printopt, o->odesc[1]);
|
||||
if (s == NULL)
|
||||
return;
|
||||
break;
|
||||
case NUMBER:
|
||||
if (*s == '\0')
|
||||
@ -265,6 +301,8 @@ scan_option(s)
|
||||
*/
|
||||
if (o->ofunc != NULL)
|
||||
(*o->ofunc)(INIT, str);
|
||||
if (str != NULL)
|
||||
free(str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,12 +316,12 @@ scan_option(s)
|
||||
* OPT_SET set to the inverse of the default value
|
||||
*/
|
||||
public void
|
||||
toggle_option(c, s, how_toggle)
|
||||
int c;
|
||||
toggle_option(o, lower, s, how_toggle)
|
||||
struct loption *o;
|
||||
int lower;
|
||||
char *s;
|
||||
int how_toggle;
|
||||
{
|
||||
register struct loption *o;
|
||||
register int num;
|
||||
int no_prompt;
|
||||
int err;
|
||||
@ -292,27 +330,22 @@ toggle_option(c, s, how_toggle)
|
||||
no_prompt = (how_toggle & OPT_NO_PROMPT);
|
||||
how_toggle &= ~OPT_NO_PROMPT;
|
||||
|
||||
/*
|
||||
* Look up the option letter in the option table.
|
||||
*/
|
||||
o = findopt(c);
|
||||
if (o == NULL)
|
||||
{
|
||||
parg.p_string = propt(c);
|
||||
error("There is no %s option", &parg);
|
||||
error("No such option", NULL_PARG);
|
||||
return;
|
||||
}
|
||||
|
||||
if (how_toggle == OPT_TOGGLE && (o->otype & NO_TOGGLE))
|
||||
{
|
||||
parg.p_string = propt(c);
|
||||
parg.p_string = opt_desc(o);
|
||||
error("Cannot change the %s option", &parg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (how_toggle == OPT_NO_TOGGLE && (o->otype & NO_QUERY))
|
||||
{
|
||||
parg.p_string = propt(c);
|
||||
parg.p_string = opt_desc(o);
|
||||
error("Cannot query the %s option", &parg);
|
||||
return;
|
||||
}
|
||||
@ -372,15 +405,13 @@ toggle_option(c, s, how_toggle)
|
||||
switch (how_toggle)
|
||||
{
|
||||
case OPT_TOGGLE:
|
||||
*(o->ovar) = flip_triple(*(o->ovar),
|
||||
ASCII_IS_LOWER(c));
|
||||
*(o->ovar) = flip_triple(*(o->ovar), lower);
|
||||
break;
|
||||
case OPT_UNSET:
|
||||
*(o->ovar) = o->odefault;
|
||||
break;
|
||||
case OPT_SET:
|
||||
*(o->ovar) = flip_triple(o->odefault,
|
||||
ASCII_IS_LOWER(c));
|
||||
*(o->ovar) = flip_triple(o->odefault, lower);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -482,33 +513,17 @@ flip_triple(val, lc)
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a string suitable for printing as the "name" of an option.
|
||||
* For example, if the option letter is 'x', just return "-x".
|
||||
*/
|
||||
static char *
|
||||
propt(c)
|
||||
int c;
|
||||
{
|
||||
static char buf[8];
|
||||
|
||||
sprintf(buf, "-%s", prchar(c));
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine if an option is a single character option (BOOL or TRIPLE),
|
||||
* or if it a multi-character option (NUMBER).
|
||||
* Determine if an option takes a parameter.
|
||||
*/
|
||||
public int
|
||||
single_char_option(c)
|
||||
int c;
|
||||
opt_has_param(o)
|
||||
struct loption *o;
|
||||
{
|
||||
register struct loption *o;
|
||||
|
||||
o = findopt(c);
|
||||
if (o == NULL)
|
||||
return (TRUE);
|
||||
return ((o->otype & (BOOL|TRIPLE|NOVAR|NO_TOGGLE)) != 0);
|
||||
return (0);
|
||||
if (o->otype & (BOOL|TRIPLE|NOVAR|NO_TOGGLE))
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -516,14 +531,11 @@ single_char_option(c)
|
||||
* Only string and number valued options have prompts.
|
||||
*/
|
||||
public char *
|
||||
opt_prompt(c)
|
||||
int c;
|
||||
opt_prompt(o)
|
||||
struct loption *o;
|
||||
{
|
||||
register struct loption *o;
|
||||
|
||||
o = findopt(c);
|
||||
if (o == NULL || (o->otype & (STRING|NUMBER)) == 0)
|
||||
return (NULL);
|
||||
return ("?");
|
||||
return (o->odesc[0]);
|
||||
}
|
||||
|
||||
@ -558,7 +570,7 @@ nostring(printopt)
|
||||
public void
|
||||
nopendopt()
|
||||
{
|
||||
nostring(propt(pendopt->oletter));
|
||||
nostring(opt_desc(pendopt));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -574,35 +586,33 @@ optstring(s, p_str, printopt, validchars)
|
||||
char *validchars;
|
||||
{
|
||||
register char *p;
|
||||
register char *out;
|
||||
|
||||
if (*s == '\0')
|
||||
{
|
||||
nostring(printopt);
|
||||
quit(QUIT_ERROR);
|
||||
return (NULL);
|
||||
}
|
||||
*p_str = s;
|
||||
/* Alloc could be more than needed, but not worth trimming. */
|
||||
*p_str = (char *) ecalloc(strlen(s)+1, sizeof(char));
|
||||
out = *p_str;
|
||||
|
||||
for (p = s; *p != '\0'; p++)
|
||||
{
|
||||
if (*p == END_OPTION_STRING ||
|
||||
(validchars != NULL && strchr(validchars, *p) == NULL))
|
||||
if (opt_use_backslash && *p == '\\' && p[1] != '\0')
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case END_OPTION_STRING:
|
||||
case ' ': case '\t': case '-':
|
||||
/* Replace the char with a null to terminate string. */
|
||||
*p++ = '\0';
|
||||
/* Take next char literally. */
|
||||
++p;
|
||||
} else
|
||||
{
|
||||
if (*p == END_OPTION_STRING ||
|
||||
(validchars != NULL && strchr(validchars, *p) == NULL))
|
||||
/* End of option string. */
|
||||
break;
|
||||
default:
|
||||
/* Cannot replace char; make a copy of the string. */
|
||||
*p_str = (char *) ecalloc(p-s+1, sizeof(char));
|
||||
strncpy(*p_str, s, p-s);
|
||||
(*p_str)[p-s] = '\0';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
*out++ = *p;
|
||||
}
|
||||
*out = '\0';
|
||||
return (p);
|
||||
}
|
||||
|
||||
@ -625,8 +635,6 @@ num_error(printopt, errp)
|
||||
parg.p_string = printopt;
|
||||
error("Number is required after %s", &parg);
|
||||
}
|
||||
quit(QUIT_ERROR);
|
||||
/* NOTREACHED */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -713,5 +721,5 @@ get_quit_at_eof()
|
||||
if (!less_is_more)
|
||||
return quit_at_eof;
|
||||
/* When less_is_more is set, the -e flag semantics are different. */
|
||||
return quit_at_eof ? OPT_ON : OPT_ONPLUS;
|
||||
return quit_at_eof ? OPT_ONPLUS : OPT_ON;
|
||||
}
|
||||
|
9
less/option.h
Executable file → Normal file
9
less/option.h
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -27,6 +26,8 @@
|
||||
|
||||
#define OTYPE (BOOL|TRIPLE|NUMBER|STRING|NOVAR)
|
||||
|
||||
#define OLETTER_NONE '\1' /* Invalid option letter */
|
||||
|
||||
/*
|
||||
* Argument to a handling function tells what type of activity:
|
||||
*/
|
||||
@ -50,6 +51,8 @@ struct optname
|
||||
struct optname *onext; /* List of synonymous option names */
|
||||
};
|
||||
|
||||
#define OPTNAME_MAX 32 /* Max length of long option name */
|
||||
|
||||
struct loption
|
||||
{
|
||||
char oletter; /* The controlling letter (a-z) */
|
||||
|
50
less/opttbl.c
Executable file → Normal file
50
less/opttbl.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -41,6 +40,7 @@ public int force_open; /* Open the file even if not regular file */
|
||||
public int swindow; /* Size of scrolling window */
|
||||
public int jump_sline; /* Screen line of "jump target" */
|
||||
public long jump_sline_fraction = -1;
|
||||
public long shift_count_fraction = -1;
|
||||
public int chopline; /* Truncate displayed lines at screen width */
|
||||
public int no_init; /* Disable sending ti/te termcap strings */
|
||||
public int no_keypad; /* Disable sending ks/ke termcap strings */
|
||||
@ -53,6 +53,7 @@ public int use_lessopen; /* Use the LESSOPEN filter */
|
||||
public int quit_on_intr; /* Quit on interrupt */
|
||||
public int follow_mode; /* F cmd Follows file desc or file name? */
|
||||
public int oldbot; /* Old bottom of screen behavior {{REMOVE}} */
|
||||
public int opt_use_backslash; /* Use backslash escaping in option parsing */
|
||||
#if HILITE_SEARCH
|
||||
public int hilite_search; /* Highlight matched search patterns? */
|
||||
#endif
|
||||
@ -116,6 +117,9 @@ static struct optname pound_optname = { "shift", NULL };
|
||||
static struct optname keypad_optname = { "no-keypad", NULL };
|
||||
static struct optname oldbot_optname = { "old-bot", NULL };
|
||||
static struct optname follow_optname = { "follow-name", NULL };
|
||||
static struct optname use_backslash_optname = { "use-backslash", NULL };
|
||||
static struct optname unix2003_n_optname = { "unix2003-n", NULL };
|
||||
static struct optname unix2003_p_optname = { "unix2003-p", NULL };
|
||||
|
||||
|
||||
/*
|
||||
@ -133,11 +137,11 @@ static struct optname follow_optname = { "follow-name", NULL };
|
||||
static struct loption option[] =
|
||||
{
|
||||
{ 'a', &a_optname,
|
||||
BOOL, OPT_OFF, &how_search, NULL,
|
||||
TRIPLE, OPT_ONPLUS, &how_search, NULL,
|
||||
{
|
||||
"Search includes displayed screen",
|
||||
"Search skips displayed screen",
|
||||
NULL
|
||||
"Search includes all of displayed screen"
|
||||
}
|
||||
},
|
||||
|
||||
@ -175,10 +179,10 @@ static struct loption option[] =
|
||||
},
|
||||
#if MSDOS_COMPILER
|
||||
{ 'D', &D__optname,
|
||||
STRING|REPAINT|NO_QUERY, 0, NULL, opt_D,
|
||||
STRING|REPAINT, 0, NULL, opt_D,
|
||||
{
|
||||
"color desc: ",
|
||||
"Ddknsu0123456789.",
|
||||
"Dadknsu0123456789.",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
@ -237,7 +241,7 @@ static struct loption option[] =
|
||||
STRING, 0, NULL, opt_j,
|
||||
{
|
||||
"Target line: ",
|
||||
"0123456789.",
|
||||
"0123456789.-",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
@ -263,10 +267,6 @@ static struct loption option[] =
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ 'l', NULL,
|
||||
STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_l,
|
||||
{ NULL, NULL, NULL }
|
||||
},
|
||||
{ 'L', &L__optname,
|
||||
BOOL, OPT_ON, &use_lessopen, NULL,
|
||||
{
|
||||
@ -420,14 +420,14 @@ static struct loption option[] =
|
||||
{ NULL, NULL, NULL }
|
||||
},
|
||||
{ '#', £_optname,
|
||||
NUMBER, 0, &shift_count, NULL,
|
||||
STRING, 0, NULL, opt_shift,
|
||||
{
|
||||
"Horizontal shift: ",
|
||||
"Horizontal shift %d positions",
|
||||
"0123456789.",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ '.', &keypad_optname,
|
||||
{ OLETTER_NONE, &keypad_optname,
|
||||
BOOL|NO_TOGGLE, OPT_OFF, &no_keypad, NULL,
|
||||
{
|
||||
"Use keypad mode",
|
||||
@ -435,7 +435,7 @@ static struct loption option[] =
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ '.', &oldbot_optname,
|
||||
{ OLETTER_NONE, &oldbot_optname,
|
||||
BOOL, OPT_OFF, &oldbot, NULL,
|
||||
{
|
||||
"Use new bottom of screen behavior",
|
||||
@ -443,11 +443,19 @@ static struct loption option[] =
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ '.', &follow_optname,
|
||||
{ OLETTER_NONE, &follow_optname,
|
||||
BOOL, FOLLOW_DESC, &follow_mode, NULL,
|
||||
{
|
||||
"F command Follows file descriptor",
|
||||
"F command Follows file name",
|
||||
"F command follows file descriptor",
|
||||
"F command follows file name",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ OLETTER_NONE, &use_backslash_optname,
|
||||
BOOL, OPT_OFF, &opt_use_backslash, NULL,
|
||||
{
|
||||
"Use backslash escaping in command line parameters",
|
||||
"Don't use backslash escaping in command line parameters",
|
||||
NULL
|
||||
}
|
||||
},
|
||||
@ -455,7 +463,7 @@ static struct loption option[] =
|
||||
compatibility. Each is used because the original option
|
||||
was already defined in "less".
|
||||
*/
|
||||
{ ']', NULL,
|
||||
{ ']', &unix2003_n_optname,
|
||||
NUMBER, 0, &dashn_numline_count, NULL,
|
||||
{ /* This entry maps from the -n option */
|
||||
NULL,
|
||||
@ -463,7 +471,7 @@ static struct loption option[] =
|
||||
NULL
|
||||
}
|
||||
},
|
||||
{ '}', NULL,
|
||||
{ '}', &unix2003_p_optname,
|
||||
STRING, 0, NULL, opt_dashp,
|
||||
{ /* This entry maps from the -p option */
|
||||
NULL,
|
||||
|
56
less/os.c
Executable file → Normal file
56
less/os.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -34,12 +33,6 @@
|
||||
#include <values.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_TIME_T
|
||||
#define time_type time_t
|
||||
#else
|
||||
#define time_type long
|
||||
#endif
|
||||
|
||||
/*
|
||||
* BSD setjmp() saves (and longjmp() restores) the signal mask.
|
||||
* This costs a system call or two per setjmp(), so if possible we clear the
|
||||
@ -192,7 +185,7 @@ intread()
|
||||
* Return the current time.
|
||||
*/
|
||||
#if HAVE_TIME
|
||||
public long
|
||||
public time_type
|
||||
get_time()
|
||||
{
|
||||
time_type t;
|
||||
@ -244,12 +237,34 @@ errno_message(filename)
|
||||
#else
|
||||
p = "cannot open";
|
||||
#endif
|
||||
len = strlen(filename) + strlen(p) + 3;
|
||||
len = (int) (strlen(filename) + strlen(p) + 3);
|
||||
m = (char *) ecalloc(len, sizeof(char));
|
||||
SNPRINTF2(m, len, "%s: %s", filename, p);
|
||||
return (m);
|
||||
}
|
||||
|
||||
/* #define HAVE_FLOAT 0 */
|
||||
|
||||
static POSITION
|
||||
muldiv(val, num, den)
|
||||
POSITION val, num, den;
|
||||
{
|
||||
#if HAVE_FLOAT
|
||||
double v = (((double) val) * num) / den;
|
||||
return ((POSITION) (v + 0.5));
|
||||
#else
|
||||
POSITION v = ((POSITION) val) * num;
|
||||
|
||||
if (v / num == val)
|
||||
/* No overflow */
|
||||
return (POSITION) (v / den);
|
||||
else
|
||||
/* Above calculation overflows;
|
||||
* use a method that is less precise but won't overflow. */
|
||||
return (POSITION) (val / (den / num));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the ratio of two POSITIONS, as a percentage.
|
||||
* {{ Assumes a POSITION is a long int. }}
|
||||
@ -258,12 +273,7 @@ errno_message(filename)
|
||||
percentage(num, den)
|
||||
POSITION num, den;
|
||||
{
|
||||
POSITION num100 = num * 100;
|
||||
|
||||
if (num100 / 100 == num)
|
||||
return (num100 / den);
|
||||
else
|
||||
return (num / (den / 100));
|
||||
return (int) muldiv(num, (POSITION) 100, den);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -276,19 +286,11 @@ percent_pos(pos, percent, fraction)
|
||||
long fraction;
|
||||
{
|
||||
/* Change percent (parts per 100) to perden (parts per NUM_FRAC_DENOM). */
|
||||
long perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
|
||||
POSITION temp;
|
||||
POSITION perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
|
||||
|
||||
if (perden == 0)
|
||||
return (0);
|
||||
temp = pos * perden; /* This might overflow. */
|
||||
if (temp / perden == pos)
|
||||
/* No overflow */
|
||||
return (temp / NUM_FRAC_DENOM);
|
||||
else
|
||||
/* Above calculation overflows;
|
||||
* use a method that is less precise but won't overflow. */
|
||||
return (perden * (pos / NUM_FRAC_DENOM));
|
||||
return (POSITION) muldiv(pos, perden, (POSITION) NUM_FRAC_DENOM);
|
||||
}
|
||||
|
||||
#if !HAVE_STRCHR
|
||||
|
158
less/output.c
Executable file → Normal file
158
less/output.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -38,6 +37,7 @@ extern int bo_fg_color, bo_bg_color;
|
||||
extern int ul_fg_color, ul_bg_color;
|
||||
extern int so_fg_color, so_bg_color;
|
||||
extern int bl_fg_color, bl_bg_color;
|
||||
extern int sgr_mode;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -99,7 +99,7 @@ flush()
|
||||
register int n;
|
||||
register int fd;
|
||||
|
||||
n = ob - obuf;
|
||||
n = (int) (ob - obuf);
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
@ -127,7 +127,9 @@ flush()
|
||||
* the -D command-line option.
|
||||
*/
|
||||
char *anchor, *p, *p_next;
|
||||
unsigned char fg, bg;
|
||||
static unsigned char fg, fgi, bg, bgi;
|
||||
static unsigned char at;
|
||||
unsigned char f, b;
|
||||
#if MSDOS_COMPILER==WIN32C
|
||||
/* Screen colors used by 3x and 4x SGR commands. */
|
||||
static unsigned char screen_color[] = {
|
||||
@ -147,6 +149,13 @@ flush()
|
||||
};
|
||||
#endif
|
||||
|
||||
if (fg == 0 && bg == 0)
|
||||
{
|
||||
fg = nm_fg_color & 7;
|
||||
fgi = nm_fg_color & 8;
|
||||
bg = nm_bg_color & 7;
|
||||
bgi = nm_bg_color & 8;
|
||||
}
|
||||
for (anchor = p_next = obuf;
|
||||
(p_next = memchr(p_next, ESC, ob - p_next)) != NULL; )
|
||||
{
|
||||
@ -173,17 +182,21 @@ flush()
|
||||
*/
|
||||
p++;
|
||||
anchor = p_next = p;
|
||||
fg = nm_fg_color & 7;
|
||||
fgi = nm_fg_color & 8;
|
||||
bg = nm_bg_color & 7;
|
||||
bgi = nm_bg_color & 8;
|
||||
at = 0;
|
||||
WIN32setcolors(nm_fg_color, nm_bg_color);
|
||||
continue;
|
||||
}
|
||||
p_next = p;
|
||||
at &= ~32;
|
||||
|
||||
/*
|
||||
* Select foreground/background colors
|
||||
* based on the escape sequence.
|
||||
*/
|
||||
fg = nm_fg_color;
|
||||
bg = nm_bg_color;
|
||||
while (!is_ansi_end(*p))
|
||||
{
|
||||
char *q;
|
||||
@ -196,7 +209,7 @@ flush()
|
||||
* Leave it unprocessed
|
||||
* in the buffer.
|
||||
*/
|
||||
int slop = q - anchor;
|
||||
int slop = (int) (q - anchor);
|
||||
/* {{ strcpy args overlap! }} */
|
||||
strcpy(obuf, anchor);
|
||||
ob = &obuf[slop];
|
||||
@ -211,64 +224,140 @@ flush()
|
||||
break;
|
||||
}
|
||||
if (*q == ';')
|
||||
{
|
||||
q++;
|
||||
at |= 32;
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
default:
|
||||
/* case 0: all attrs off */
|
||||
/* case 22: bold off */
|
||||
/* case 23: italic off */
|
||||
/* case 24: underline off */
|
||||
/* case 27: inverse off */
|
||||
fg = nm_fg_color;
|
||||
bg = nm_bg_color;
|
||||
/* case 0: all attrs off */
|
||||
fg = nm_fg_color & 7;
|
||||
bg = nm_bg_color & 7;
|
||||
at &= 32;
|
||||
/*
|
||||
* \e[0m use normal
|
||||
* intensities, but
|
||||
* \e[0;...m resets them
|
||||
*/
|
||||
if (at & 32)
|
||||
{
|
||||
fgi = 0;
|
||||
bgi = 0;
|
||||
} else
|
||||
{
|
||||
fgi = nm_fg_color & 8;
|
||||
bgi = nm_bg_color & 8;
|
||||
}
|
||||
break;
|
||||
case 1: /* bold on */
|
||||
fg = bo_fg_color;
|
||||
bg = bo_bg_color;
|
||||
fgi = 8;
|
||||
at |= 1;
|
||||
break;
|
||||
case 3: /* italic on */
|
||||
case 7: /* inverse on */
|
||||
fg = so_fg_color;
|
||||
bg = so_bg_color;
|
||||
at |= 2;
|
||||
break;
|
||||
case 4: /* underline on */
|
||||
fg = ul_fg_color;
|
||||
bg = ul_bg_color;
|
||||
bgi = 8;
|
||||
at |= 4;
|
||||
break;
|
||||
case 5: /* slow blink on */
|
||||
case 6: /* fast blink on */
|
||||
fg = bl_fg_color;
|
||||
bg = bl_bg_color;
|
||||
bgi = 8;
|
||||
at |= 8;
|
||||
break;
|
||||
case 8: /* concealed on */
|
||||
fg = (bg & 7) | 8;
|
||||
at |= 16;
|
||||
break;
|
||||
case 22: /* bold off */
|
||||
fgi = 0;
|
||||
at &= ~1;
|
||||
break;
|
||||
case 23: /* italic off */
|
||||
case 27: /* inverse off */
|
||||
at &= ~2;
|
||||
break;
|
||||
case 24: /* underline off */
|
||||
bgi = 0;
|
||||
at &= ~4;
|
||||
break;
|
||||
case 28: /* concealed off */
|
||||
at &= ~16;
|
||||
break;
|
||||
case 30: case 31: case 32:
|
||||
case 33: case 34: case 35:
|
||||
case 36: case 37:
|
||||
fg = (fg & 8) | (screen_color[code - 30]);
|
||||
fg = screen_color[code - 30];
|
||||
at |= 32;
|
||||
break;
|
||||
case 39: /* default fg */
|
||||
fg = nm_fg_color;
|
||||
fg = nm_fg_color & 7;
|
||||
at |= 32;
|
||||
break;
|
||||
case 40: case 41: case 42:
|
||||
case 43: case 44: case 45:
|
||||
case 46: case 47:
|
||||
bg = (bg & 8) | (screen_color[code - 40]);
|
||||
bg = screen_color[code - 40];
|
||||
at |= 32;
|
||||
break;
|
||||
case 49: /* default fg */
|
||||
bg = nm_bg_color;
|
||||
case 49: /* default bg */
|
||||
bg = nm_bg_color & 7;
|
||||
at |= 32;
|
||||
break;
|
||||
}
|
||||
p = q;
|
||||
}
|
||||
if (!is_ansi_end(*p) || p == p_next)
|
||||
break;
|
||||
fg &= 0xf;
|
||||
bg &= 0xf;
|
||||
WIN32setcolors(fg, bg);
|
||||
/*
|
||||
* In SGR mode, the ANSI sequence is
|
||||
* always honored; otherwise if an attr
|
||||
* is used by itself ("\e[1m" versus
|
||||
* "\e[1;33m", for example), set the
|
||||
* color assigned to that attribute.
|
||||
*/
|
||||
if (sgr_mode || (at & 32))
|
||||
{
|
||||
if (at & 2)
|
||||
{
|
||||
f = bg | bgi;
|
||||
b = fg | fgi;
|
||||
} else
|
||||
{
|
||||
f = fg | fgi;
|
||||
b = bg | bgi;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (at & 1)
|
||||
{
|
||||
f = bo_fg_color;
|
||||
b = bo_bg_color;
|
||||
} else if (at & 2)
|
||||
{
|
||||
f = so_fg_color;
|
||||
b = so_bg_color;
|
||||
} else if (at & 4)
|
||||
{
|
||||
f = ul_fg_color;
|
||||
b = ul_bg_color;
|
||||
} else if (at & 8)
|
||||
{
|
||||
f = bl_fg_color;
|
||||
b = bl_bg_color;
|
||||
} else
|
||||
{
|
||||
f = nm_fg_color;
|
||||
b = nm_bg_color;
|
||||
}
|
||||
}
|
||||
if (at & 16)
|
||||
f = b ^ 8;
|
||||
f &= 0xf;
|
||||
b &= 0xf;
|
||||
WIN32setcolors(f, b);
|
||||
p_next = anchor = p + 1;
|
||||
} else
|
||||
p_next++;
|
||||
@ -389,7 +478,7 @@ iprint_int(num)
|
||||
|
||||
inttoa(num, buf);
|
||||
putstr(buf);
|
||||
return (strlen(buf));
|
||||
return ((int) strlen(buf));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -403,7 +492,7 @@ iprint_linenum(num)
|
||||
|
||||
linenumtoa(num, buf);
|
||||
putstr(buf);
|
||||
return (strlen(buf));
|
||||
return ((int) strlen(buf));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -511,6 +600,7 @@ error(fmt, parg)
|
||||
|
||||
get_return();
|
||||
lower_left();
|
||||
clear_eol();
|
||||
|
||||
if (col >= sc_width)
|
||||
/*
|
||||
|
405
less/pattern.c
Normal file
405
less/pattern.c
Normal file
@ -0,0 +1,405 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2016 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, see the README file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Routines to do pattern matching.
|
||||
*/
|
||||
|
||||
#include "less.h"
|
||||
extern int less_is_more;
|
||||
#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, show_error)
|
||||
char *pattern;
|
||||
int search_type;
|
||||
void **comp_pattern;
|
||||
int show_error;
|
||||
{
|
||||
if (search_type & SRCH_NO_REGEX)
|
||||
return (0);
|
||||
{
|
||||
#if HAVE_GNU_REGEX
|
||||
struct re_pattern_buffer *comp = (struct re_pattern_buffer *)
|
||||
ecalloc(1, sizeof(struct re_pattern_buffer));
|
||||
struct re_pattern_buffer **pcomp =
|
||||
(struct re_pattern_buffer **) comp_pattern;
|
||||
re_set_syntax(RE_SYNTAX_POSIX_EXTENDED);
|
||||
if (re_compile_pattern(pattern, strlen(pattern), comp))
|
||||
{
|
||||
free(comp);
|
||||
if (show_error)
|
||||
error("Invalid pattern", NULL_PARG);
|
||||
return (-1);
|
||||
}
|
||||
if (*pcomp != NULL)
|
||||
regfree(*pcomp);
|
||||
*pcomp = comp;
|
||||
#endif
|
||||
#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);
|
||||
if (show_error)
|
||||
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;
|
||||
constant char *errstring;
|
||||
int erroffset;
|
||||
PARG parg;
|
||||
comp = pcre_compile(pattern, 0,
|
||||
&errstring, &erroffset, NULL);
|
||||
if (comp == NULL)
|
||||
{
|
||||
parg.p_string = (char *) errstring;
|
||||
if (show_error)
|
||||
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)
|
||||
{
|
||||
if (show_error)
|
||||
error("%s", &parg);
|
||||
return (-1);
|
||||
}
|
||||
*pcomp = 1;
|
||||
#endif
|
||||
#if HAVE_REGCMP
|
||||
char *comp;
|
||||
char **pcomp = (char **) comp_pattern;
|
||||
if ((comp = regcmp(pattern, 0)) == NULL)
|
||||
{
|
||||
if (show_error)
|
||||
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;
|
||||
reg_show_error = show_error;
|
||||
comp = regcomp(pattern);
|
||||
reg_show_error = 1;
|
||||
if (comp == 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, 1);
|
||||
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_GNU_REGEX
|
||||
struct re_pattern_buffer **pcomp = (struct re_pattern_buffer **) pattern;
|
||||
if (*pcomp != NULL)
|
||||
regfree(*pcomp);
|
||||
*pcomp = NULL;
|
||||
#endif
|
||||
#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
|
||||
}
|
||||
|
||||
/*
|
||||
* Can a pattern be successfully compiled?
|
||||
*/
|
||||
public int
|
||||
valid_pattern(pattern)
|
||||
char *pattern;
|
||||
{
|
||||
void *comp_pattern;
|
||||
int result;
|
||||
|
||||
CLEAR_PATTERN(comp_pattern);
|
||||
result = compile_pattern2(pattern, 0, &comp_pattern, 0);
|
||||
if (result != 0)
|
||||
return (0);
|
||||
uncompile_pattern(&comp_pattern);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Is a compiled pattern null?
|
||||
*/
|
||||
public int
|
||||
is_null_pattern(pattern)
|
||||
void *pattern;
|
||||
{
|
||||
#if HAVE_GNU_REGEX
|
||||
return (pattern == NULL);
|
||||
#endif
|
||||
#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 (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++)
|
||||
{
|
||||
char cp = *pp;
|
||||
char cl = *lp;
|
||||
if (caseless == OPT_ONPLUS && ASCII_IS_UPPER(cp))
|
||||
cp = ASCII_TO_LOWER(cp);
|
||||
if (cp != cl)
|
||||
break;
|
||||
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_GNU_REGEX
|
||||
struct re_pattern_buffer *spattern = (struct re_pattern_buffer *) pattern;
|
||||
#endif
|
||||
#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
|
||||
|
||||
*sp = *ep = NULL;
|
||||
#if NO_REGEX
|
||||
search_type |= SRCH_NO_REGEX;
|
||||
#endif
|
||||
if (search_type & SRCH_NO_REGEX)
|
||||
matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep);
|
||||
else
|
||||
{
|
||||
#if HAVE_GNU_REGEX
|
||||
{
|
||||
struct re_registers search_regs;
|
||||
spattern->not_bol = notbol;
|
||||
spattern->regs_allocated = REGS_UNALLOCATED;
|
||||
matched = re_search(spattern, line, line_len, 0, line_len, &search_regs) >= 0;
|
||||
if (matched)
|
||||
{
|
||||
*sp = line + search_regs.start[0];
|
||||
*ep = line + search_regs.end[0];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if HAVE_POSIX_REGCOMP
|
||||
{
|
||||
regmatch_t rm;
|
||||
int flags = (notbol) ? REG_NOTBOL : 0;
|
||||
#ifdef REG_STARTEND
|
||||
flags |= REG_STARTEND;
|
||||
rm.rm_so = 0;
|
||||
rm.rm_eo = line_len;
|
||||
#endif
|
||||
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
|
||||
}
|
||||
matched = (!(search_type & SRCH_NO_MATCH) && matched) ||
|
||||
((search_type & SRCH_NO_MATCH) && !matched);
|
||||
return (matched);
|
||||
}
|
||||
|
59
less/pattern.h
Normal file
59
less/pattern.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2016 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, see the README file.
|
||||
*/
|
||||
|
||||
#if HAVE_GNU_REGEX
|
||||
#define __USE_GNU 1
|
||||
#include <regex.h>
|
||||
#define DEFINE_PATTERN(name) struct re_pattern_buffer *name
|
||||
#define CLEAR_PATTERN(name) name = NULL
|
||||
#endif
|
||||
|
||||
#if HAVE_POSIX_REGCOMP
|
||||
#include <regex.h>
|
||||
#ifdef REG_EXTENDED
|
||||
#define REGCOMP_FLAG (less_is_more ? 0 : 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"
|
||||
extern int reg_show_error;
|
||||
#define DEFINE_PATTERN(name) struct regexp *name
|
||||
#define CLEAR_PATTERN(name) name = NULL
|
||||
#endif
|
||||
|
||||
#if NO_REGEX
|
||||
#define DEFINE_PATTERN(name)
|
||||
#define CLEAR_PATTERN(name)
|
||||
#endif
|
5
less/pckeys.h
Executable file → Normal file
5
less/pckeys.h
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
|
7
less/position.c
Executable file → Normal file
7
less/position.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -163,7 +162,7 @@ empty_lines(s, e)
|
||||
register int i;
|
||||
|
||||
for (i = s; i <= e; i++)
|
||||
if (table[i] != NULL_POSITION)
|
||||
if (table[i] != NULL_POSITION && table[i] != 0)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
5
less/position.h
Executable file → Normal file
5
less/position.h
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
|
28
less/prompt.c
Executable file → Normal file
28
less/prompt.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -22,7 +21,6 @@
|
||||
#include "position.h"
|
||||
|
||||
extern int pr_type;
|
||||
extern int hit_eof;
|
||||
extern int new_file;
|
||||
extern int sc_width;
|
||||
extern int so_s_width, so_e_width;
|
||||
@ -87,9 +85,9 @@ ap_str(s)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = strlen(s);
|
||||
len = (int) strlen(s);
|
||||
if (mp + len >= message + PROMPT_SIZE)
|
||||
len = message + PROMPT_SIZE - mp - 1;
|
||||
len = (int) (message + PROMPT_SIZE - mp - 1);
|
||||
strncpy(mp, s, len);
|
||||
mp += len;
|
||||
*mp = '\0';
|
||||
@ -196,7 +194,7 @@ cond(c, where)
|
||||
case 'c':
|
||||
return (hshift != 0);
|
||||
case 'e': /* At end of file? */
|
||||
return (hit_eof);
|
||||
return (eof_displayed());
|
||||
case 'f': /* Filename known? */
|
||||
return (strcmp(get_filename(curr_ifile), "-") != 0);
|
||||
case 'l': /* Line number known? */
|
||||
@ -304,6 +302,9 @@ protochar(c, where, iseditproto)
|
||||
case 'f': /* File name */
|
||||
ap_str(get_filename(curr_ifile));
|
||||
break;
|
||||
case 'F': /* Last component of file name */
|
||||
ap_str(last_component(get_filename(curr_ifile)));
|
||||
break;
|
||||
case 'i': /* Index into list of files */
|
||||
#if TAGS
|
||||
if (ntags())
|
||||
@ -364,6 +365,7 @@ protochar(c, where, iseditproto)
|
||||
case 't': /* Truncate trailing spaces in the message */
|
||||
while (mp > message && mp[-1] == ' ')
|
||||
mp--;
|
||||
*mp = '\0';
|
||||
break;
|
||||
case 'T': /* Type of list */
|
||||
#if TAGS
|
||||
@ -390,9 +392,9 @@ protochar(c, where, iseditproto)
|
||||
* where to resume parsing the string.
|
||||
* We must keep track of nested IFs and skip them properly.
|
||||
*/
|
||||
static char *
|
||||
static constant char *
|
||||
skipcond(p)
|
||||
register char *p;
|
||||
register constant char *p;
|
||||
{
|
||||
register int iflevel;
|
||||
|
||||
@ -448,9 +450,9 @@ skipcond(p)
|
||||
/*
|
||||
* Decode a char that represents a position on the screen.
|
||||
*/
|
||||
static char *
|
||||
static constant char *
|
||||
wherechar(p, wp)
|
||||
char *p;
|
||||
char constant *p;
|
||||
int *wp;
|
||||
{
|
||||
switch (*p)
|
||||
@ -474,10 +476,10 @@ wherechar(p, wp)
|
||||
*/
|
||||
public char *
|
||||
pr_expand(proto, maxwidth)
|
||||
char *proto;
|
||||
constant char *proto;
|
||||
int maxwidth;
|
||||
{
|
||||
register char *p;
|
||||
register constant char *p;
|
||||
register int c;
|
||||
int where;
|
||||
|
||||
|
15
less/regexp.c
Executable file → Normal file
15
less/regexp.c
Executable file → Normal file
@ -243,7 +243,10 @@ char *exp;
|
||||
regcode = r->program;
|
||||
regc(MAGIC);
|
||||
if (reg(0, &flags) == NULL)
|
||||
{
|
||||
free(r);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Dig out information for optimizations. */
|
||||
r->regstart = '\0'; /* Worst-case defaults. */
|
||||
@ -274,7 +277,7 @@ char *exp;
|
||||
for (; scan != NULL; scan = regnext(scan))
|
||||
if (OP(scan) == EXACTLY && ((int) strlen(OPERAND(scan))) >= len) {
|
||||
longest = OPERAND(scan);
|
||||
len = strlen(OPERAND(scan));
|
||||
len = (int) strlen(OPERAND(scan));
|
||||
}
|
||||
r->regmust = longest;
|
||||
r->regmlen = len;
|
||||
@ -554,7 +557,7 @@ int *flagp;
|
||||
register char ender;
|
||||
|
||||
regparse--;
|
||||
len = strcspn(regparse, META);
|
||||
len = (int) strcspn(regparse, META);
|
||||
if (len <= 0)
|
||||
FAIL("internal disaster");
|
||||
ender = *(regparse+len);
|
||||
@ -670,9 +673,9 @@ char *val;
|
||||
}
|
||||
|
||||
if (OP(scan) == BACK)
|
||||
offset = scan - val;
|
||||
offset = (int) (scan - val);
|
||||
else
|
||||
offset = val - scan;
|
||||
offset = (int) (val - scan);
|
||||
*(scan+1) = (offset>>8)&0377;
|
||||
*(scan+2) = offset&0377;
|
||||
}
|
||||
@ -870,7 +873,7 @@ char *prog;
|
||||
/* Inline the first character, for speed. */
|
||||
if (*opnd != *reginput)
|
||||
return(0);
|
||||
len = strlen(opnd);
|
||||
len = (int) strlen(opnd);
|
||||
if (len > 1 && strncmp(opnd, reginput, len) != 0)
|
||||
return(0);
|
||||
reginput += len;
|
||||
@ -1034,7 +1037,7 @@ char *p;
|
||||
opnd = OPERAND(p);
|
||||
switch (OP(p)) {
|
||||
case ANY:
|
||||
count = strlen(scan);
|
||||
count = (int) strlen(scan);
|
||||
scan += count;
|
||||
break;
|
||||
case EXACTLY:
|
||||
|
0
less/regexp.h
Executable file → Normal file
0
less/regexp.h
Executable file → Normal file
105
less/screen.c
Executable file → Normal file
105
less/screen.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -152,6 +151,7 @@ public int bl_fg_color; /* Color of blinking text */
|
||||
public int bl_bg_color;
|
||||
static int sy_fg_color; /* Color of system text (before less) */
|
||||
static int sy_bg_color;
|
||||
public int sgr_mode; /* Honor ANSI sequences rather than using above */
|
||||
|
||||
#else
|
||||
|
||||
@ -799,55 +799,41 @@ scrsize()
|
||||
#endif
|
||||
|
||||
if (unix2003_compat) {
|
||||
if (dashn_numline_count) /* Overrides all other sources */
|
||||
if (dashn_numline_count) { /* Overrides all other sources */
|
||||
sc_height = dashn_numline_count;
|
||||
else {
|
||||
if (sys_height > 0)
|
||||
sc_height = sys_height;
|
||||
/* don't override LINES/COLUMNS if conforming to UNIX 03 */
|
||||
if ((s = lgetenv("LINES")) != NULL)
|
||||
sc_height = atoi(s);
|
||||
#if !MSDOS_COMPILER
|
||||
else if ((n = ltgetnum("li")) > 0)
|
||||
sc_height = n;
|
||||
#endif
|
||||
else
|
||||
sc_height = DEF_SC_HEIGHT;
|
||||
goto done_height;
|
||||
}
|
||||
|
||||
if (sys_width > 0)
|
||||
sc_width = sys_width;
|
||||
if ((s = lgetenv("COLUMNS")) != NULL)
|
||||
sc_width = atoi(s);
|
||||
#if !MSDOS_COMPILER
|
||||
else if ((n = ltgetnum("co")) > 0)
|
||||
sc_width = n;
|
||||
#endif
|
||||
else
|
||||
sc_width = DEF_SC_WIDTH;
|
||||
} else {
|
||||
if (sys_height > 0)
|
||||
sc_height = sys_height;
|
||||
else if ((s = lgetenv("LINES")) != NULL)
|
||||
sc_height = atoi(s);
|
||||
#if !MSDOS_COMPILER
|
||||
else if ((n = ltgetnum("li")) > 0)
|
||||
sc_height = n;
|
||||
#endif
|
||||
else
|
||||
sc_height = DEF_SC_HEIGHT;
|
||||
|
||||
if (sys_width > 0)
|
||||
sc_width = sys_width;
|
||||
else if ((s = lgetenv("COLUMNS")) != NULL)
|
||||
sc_width = atoi(s);
|
||||
#if !MSDOS_COMPILER
|
||||
else if ((n = ltgetnum("co")) > 0)
|
||||
sc_width = n;
|
||||
#endif
|
||||
else
|
||||
sc_width = DEF_SC_WIDTH;
|
||||
}
|
||||
if (sys_height > 0) {
|
||||
sc_height = sys_height;
|
||||
if (!unix2003_compat) {
|
||||
goto done_height;
|
||||
}
|
||||
}
|
||||
if ((s = lgetenv("LINES")) != NULL)
|
||||
sc_height = atoi(s);
|
||||
#if !MSDOS_COMPILER
|
||||
else if ((n = ltgetnum("li")) > 0)
|
||||
sc_height = n;
|
||||
#endif
|
||||
done_height:
|
||||
if (sc_height <= 0)
|
||||
sc_height = DEF_SC_HEIGHT;
|
||||
if (sys_width > 0) {
|
||||
sc_width = sys_width;
|
||||
if (!unix2003_compat) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if ((s = lgetenv("COLUMNS")) != NULL)
|
||||
sc_width = atoi(s);
|
||||
#if !MSDOS_COMPILER
|
||||
else if ((n = ltgetnum("co")) > 0)
|
||||
sc_width = n;
|
||||
#endif
|
||||
done:
|
||||
if (sc_width <= 0)
|
||||
sc_width = DEF_SC_WIDTH;
|
||||
}
|
||||
|
||||
#if MSDOS_COMPILER==MSOFTC
|
||||
@ -1140,6 +1126,7 @@ get_term()
|
||||
so_bg_color = 9;
|
||||
bl_fg_color = 15;
|
||||
bl_bg_color = 0;
|
||||
sgr_mode = 0;
|
||||
|
||||
/*
|
||||
* Get size of the screen.
|
||||
@ -1482,6 +1469,9 @@ _settextposition(int row, int col)
|
||||
static void
|
||||
initcolor()
|
||||
{
|
||||
#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
|
||||
intensevideo();
|
||||
#endif
|
||||
SETCOLORS(nm_fg_color, nm_bg_color);
|
||||
#if 0
|
||||
/*
|
||||
@ -1583,7 +1573,8 @@ init()
|
||||
*/
|
||||
for (i = 1; i < sc_height; i++)
|
||||
putchr('\n');
|
||||
}
|
||||
} else
|
||||
line_left();
|
||||
#else
|
||||
#if MSDOS_COMPILER==WIN32C
|
||||
if (!no_init)
|
||||
@ -1820,7 +1811,7 @@ win32_scroll_up(n)
|
||||
|
||||
/* Move the source text to the top of the screen. */
|
||||
new_org.X = rcSrc.Left;
|
||||
new_org.Y = 0;
|
||||
new_org.Y = rcClip.Top;
|
||||
|
||||
/* Fill the right character and attributes. */
|
||||
fillchar.Char.AsciiChar = ' ';
|
||||
@ -2465,7 +2456,16 @@ win32_kbhit(tty)
|
||||
currentKey.scan = PCK_CTL_DELETE;
|
||||
break;
|
||||
}
|
||||
} else if (ip.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED)
|
||||
{
|
||||
switch (currentKey.scan)
|
||||
{
|
||||
case PCK_SHIFT_TAB: /* tab */
|
||||
currentKey.ascii = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -2522,7 +2522,8 @@ WIN32textout(text, len)
|
||||
int len;
|
||||
{
|
||||
#if MSDOS_COMPILER==WIN32C
|
||||
WriteConsole(con_out, text, len, NULL, NULL);
|
||||
DWORD written;
|
||||
WriteConsole(con_out, text, len, &written, NULL);
|
||||
#else
|
||||
char c = text[len];
|
||||
text[len] = '\0';
|
||||
|
5
less/scrsize.c
Executable file → Normal file
5
less/scrsize.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
1627
less/search.c
Executable file → Normal file
1627
less/search.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
30
less/signal.c
Executable file → Normal file
30
less/signal.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -45,6 +44,7 @@ extern long jump_sline_fraction;
|
||||
u_interrupt(type)
|
||||
int type;
|
||||
{
|
||||
bell();
|
||||
#if OS2
|
||||
LSIGNAL(SIGINT, SIG_ACK);
|
||||
#endif
|
||||
@ -62,7 +62,7 @@ u_interrupt(type)
|
||||
if (less_is_more)
|
||||
quit(0);
|
||||
if (reading)
|
||||
intread();
|
||||
intread(); /* May longjmp */
|
||||
}
|
||||
|
||||
#ifdef SIGTSTP
|
||||
@ -246,6 +246,7 @@ psignals()
|
||||
{
|
||||
wscroll = (sc_height + 1) / 2;
|
||||
calc_jump_sline();
|
||||
calc_shift_count();
|
||||
screen_trashed = 1;
|
||||
}
|
||||
}
|
||||
@ -253,25 +254,6 @@ psignals()
|
||||
if (tsignals & S_INTERRUPT)
|
||||
{
|
||||
if (quit_on_intr)
|
||||
quit(QUIT_OK);
|
||||
bell();
|
||||
/*
|
||||
* {{ You may wish to replace the bell() with
|
||||
* error("Interrupt", NULL_PARG); }}
|
||||
*/
|
||||
|
||||
/*
|
||||
* If we were interrupted while in the "calculating
|
||||
* line numbers" loop, turn off line numbers.
|
||||
*/
|
||||
if (lnloop)
|
||||
{
|
||||
lnloop = 0;
|
||||
if (linenums == 2)
|
||||
screen_trashed = 1;
|
||||
linenums = 0;
|
||||
error("Line numbers turned off", NULL_PARG);
|
||||
}
|
||||
|
||||
quit(QUIT_INTERRUPT);
|
||||
}
|
||||
}
|
||||
|
16
less/tags.c
Executable file → Normal file
16
less/tags.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -15,7 +14,8 @@
|
||||
|
||||
#if TAGS
|
||||
|
||||
public char *tags = "tags";
|
||||
public char ztags[] = "tags";
|
||||
public char *tags = ztags;
|
||||
|
||||
static int total;
|
||||
static int curseq;
|
||||
@ -289,7 +289,7 @@ findctag(tag)
|
||||
|
||||
cleantags();
|
||||
total = 0;
|
||||
taglen = strlen(tag);
|
||||
taglen = (int) strlen(tag);
|
||||
|
||||
/*
|
||||
* Search the tags file for the desired tag.
|
||||
@ -448,7 +448,7 @@ ctagsearch()
|
||||
* If tagendline is set, make sure we match all
|
||||
* the way to end of line (no extra chars after the match).
|
||||
*/
|
||||
len = strlen(curtag->tag_pattern);
|
||||
len = (int)strlen(curtag->tag_pattern);
|
||||
if (unix2003_compat) {
|
||||
/* this should probably be the else case too */
|
||||
found_string_match = strstr(line, curtag->tag_pattern) != NULL;
|
||||
@ -500,7 +500,7 @@ findgtag(tag, type)
|
||||
{
|
||||
fp = stdin;
|
||||
/* Set tag default because we cannot read stdin again. */
|
||||
tags = "tags";
|
||||
tags = ztags;
|
||||
} else
|
||||
{
|
||||
#if !HAVE_POPEN
|
||||
@ -560,7 +560,7 @@ findgtag(tag, type)
|
||||
#endif
|
||||
return TAG_INTR;
|
||||
}
|
||||
len = strlen(buf);
|
||||
len = (int) strlen(buf);
|
||||
if (len > 0 && buf[len-1] == '\n')
|
||||
buf[len-1] = '\0';
|
||||
else
|
||||
|
9
less/ttyin.c
Executable file → Normal file
9
less/ttyin.c
Executable file → Normal file
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 1984-2007 Mark Nudelman
|
||||
* Copyright (C) 1984-2016 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.
|
||||
* For more information, see the README file.
|
||||
*/
|
||||
|
||||
|
||||
@ -152,8 +151,8 @@ getchr()
|
||||
#if 0 /* allow entering arbitrary hex chars for testing */
|
||||
/* ctrl-A followed by two hex chars makes a byte */
|
||||
{
|
||||
int hex_in = 0;
|
||||
int hex_value = 0;
|
||||
static int hex_in = 0;
|
||||
static int hex_value = 0;
|
||||
if (c == CONTROL('A'))
|
||||
{
|
||||
hex_in = 2;
|
||||
|
33
less/ubin.uni
Normal file
33
less/ubin.uni
Normal file
@ -0,0 +1,33 @@
|
||||
/* Generated by "./mkutable -f2 Cc Cf Cs Co Zl Zp -- unicode/UnicodeData.txt" on Tue Sep 20 10:51:43 PDT 2016 */
|
||||
{ 0x0000, 0x001f }, /* Cc */
|
||||
{ 0x007f, 0x009f }, /* Cc */
|
||||
{ 0x00ad, 0x00ad }, /* Cf */
|
||||
{ 0x0600, 0x0605 }, /* Cf */
|
||||
{ 0x061c, 0x061c }, /* Cf */
|
||||
{ 0x06dd, 0x06dd }, /* Cf */
|
||||
{ 0x070f, 0x070f }, /* Cf */
|
||||
{ 0x08e2, 0x08e2 }, /* Cf */
|
||||
{ 0x180e, 0x180e }, /* Cf */
|
||||
{ 0x200b, 0x200f }, /* Cf */
|
||||
{ 0x2028, 0x2028 }, /* Zl */
|
||||
{ 0x2029, 0x2029 }, /* Zp */
|
||||
{ 0x202a, 0x202e }, /* Cf */
|
||||
{ 0x2060, 0x2064 }, /* Cf */
|
||||
{ 0x2066, 0x206f }, /* Cf */
|
||||
{ 0xd800, 0xd800 }, /* Cs */
|
||||
{ 0xdb7f, 0xdb80 }, /* Cs */
|
||||
{ 0xdbff, 0xdc00 }, /* Cs */
|
||||
{ 0xdfff, 0xdfff }, /* Cs */
|
||||
{ 0xe000, 0xe000 }, /* Co */
|
||||
{ 0xf8ff, 0xf8ff }, /* Co */
|
||||
{ 0xfeff, 0xfeff }, /* Cf */
|
||||
{ 0xfff9, 0xfffb }, /* Cf */
|
||||
{ 0x110bd, 0x110bd }, /* Cf */
|
||||
{ 0x1bca0, 0x1bca3 }, /* Cf */
|
||||
{ 0x1d173, 0x1d17a }, /* Cf */
|
||||
{ 0xe0001, 0xe0001 }, /* Cf */
|
||||
{ 0xe0020, 0xe007f }, /* Cf */
|
||||
{ 0xf0000, 0xf0000 }, /* Co */
|
||||
{ 0xffffd, 0xffffd }, /* Co */
|
||||
{ 0x100000, 0x100000 }, /* Co */
|
||||
{ 0x10fffd, 0x10fffd }, /* Co */
|
1404
less/version.c
Executable file → Normal file
1404
less/version.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
108
less/wide.uni
Normal file
108
less/wide.uni
Normal file
@ -0,0 +1,108 @@
|
||||
/* Generated by "./mkutable -f1 W F -- unicode/EastAsianWidth.txt" on Tue Sep 20 10:51:43 PDT 2016 */
|
||||
{ 0x1100, 0x115f }, /* W */
|
||||
{ 0x231a, 0x231b }, /* W */
|
||||
{ 0x2329, 0x232a }, /* W */
|
||||
{ 0x23e9, 0x23ec }, /* W */
|
||||
{ 0x23f0, 0x23f0 }, /* W */
|
||||
{ 0x23f3, 0x23f3 }, /* W */
|
||||
{ 0x25fd, 0x25fe }, /* W */
|
||||
{ 0x2614, 0x2615 }, /* W */
|
||||
{ 0x2648, 0x2653 }, /* W */
|
||||
{ 0x267f, 0x267f }, /* W */
|
||||
{ 0x2693, 0x2693 }, /* W */
|
||||
{ 0x26a1, 0x26a1 }, /* W */
|
||||
{ 0x26aa, 0x26ab }, /* W */
|
||||
{ 0x26bd, 0x26be }, /* W */
|
||||
{ 0x26c4, 0x26c5 }, /* W */
|
||||
{ 0x26ce, 0x26ce }, /* W */
|
||||
{ 0x26d4, 0x26d4 }, /* W */
|
||||
{ 0x26ea, 0x26ea }, /* W */
|
||||
{ 0x26f2, 0x26f3 }, /* W */
|
||||
{ 0x26f5, 0x26f5 }, /* W */
|
||||
{ 0x26fa, 0x26fa }, /* W */
|
||||
{ 0x26fd, 0x26fd }, /* W */
|
||||
{ 0x2705, 0x2705 }, /* W */
|
||||
{ 0x270a, 0x270b }, /* W */
|
||||
{ 0x2728, 0x2728 }, /* W */
|
||||
{ 0x274c, 0x274c }, /* W */
|
||||
{ 0x274e, 0x274e }, /* W */
|
||||
{ 0x2753, 0x2755 }, /* W */
|
||||
{ 0x2757, 0x2757 }, /* W */
|
||||
{ 0x2795, 0x2797 }, /* W */
|
||||
{ 0x27b0, 0x27b0 }, /* W */
|
||||
{ 0x27bf, 0x27bf }, /* W */
|
||||
{ 0x2b1b, 0x2b1c }, /* W */
|
||||
{ 0x2b50, 0x2b50 }, /* W */
|
||||
{ 0x2b55, 0x2b55 }, /* W */
|
||||
{ 0x2e80, 0x2e99 }, /* W */
|
||||
{ 0x2e9b, 0x2ef3 }, /* W */
|
||||
{ 0x2f00, 0x2fd5 }, /* W */
|
||||
{ 0x2ff0, 0x2ffb }, /* W */
|
||||
{ 0x3000, 0x3000 }, /* F */
|
||||
{ 0x3001, 0x303e }, /* W */
|
||||
{ 0x3041, 0x3096 }, /* W */
|
||||
{ 0x3099, 0x30ff }, /* W */
|
||||
{ 0x3105, 0x312d }, /* W */
|
||||
{ 0x3131, 0x318e }, /* W */
|
||||
{ 0x3190, 0x31ba }, /* W */
|
||||
{ 0x31c0, 0x31e3 }, /* W */
|
||||
{ 0x31f0, 0x321e }, /* W */
|
||||
{ 0x3220, 0x3247 }, /* W */
|
||||
{ 0x3250, 0x32fe }, /* W */
|
||||
{ 0x3300, 0x4dbf }, /* W */
|
||||
{ 0x4e00, 0xa48c }, /* W */
|
||||
{ 0xa490, 0xa4c6 }, /* W */
|
||||
{ 0xa960, 0xa97c }, /* W */
|
||||
{ 0xac00, 0xd7a3 }, /* W */
|
||||
{ 0xf900, 0xfaff }, /* W */
|
||||
{ 0xfe10, 0xfe19 }, /* W */
|
||||
{ 0xfe30, 0xfe52 }, /* W */
|
||||
{ 0xfe54, 0xfe66 }, /* W */
|
||||
{ 0xfe68, 0xfe6b }, /* W */
|
||||
{ 0xff01, 0xff60 }, /* F */
|
||||
{ 0xffe0, 0xffe6 }, /* F */
|
||||
{ 0x16fe0, 0x16fe0 }, /* W */
|
||||
{ 0x17000, 0x187ec }, /* W */
|
||||
{ 0x18800, 0x18af2 }, /* W */
|
||||
{ 0x1b000, 0x1b001 }, /* W */
|
||||
{ 0x1f004, 0x1f004 }, /* W */
|
||||
{ 0x1f0cf, 0x1f0cf }, /* W */
|
||||
{ 0x1f18e, 0x1f18e }, /* W */
|
||||
{ 0x1f191, 0x1f19a }, /* W */
|
||||
{ 0x1f200, 0x1f202 }, /* W */
|
||||
{ 0x1f210, 0x1f23b }, /* W */
|
||||
{ 0x1f240, 0x1f248 }, /* W */
|
||||
{ 0x1f250, 0x1f251 }, /* W */
|
||||
{ 0x1f300, 0x1f320 }, /* W */
|
||||
{ 0x1f32d, 0x1f335 }, /* W */
|
||||
{ 0x1f337, 0x1f37c }, /* W */
|
||||
{ 0x1f37e, 0x1f393 }, /* W */
|
||||
{ 0x1f3a0, 0x1f3ca }, /* W */
|
||||
{ 0x1f3cf, 0x1f3d3 }, /* W */
|
||||
{ 0x1f3e0, 0x1f3f0 }, /* W */
|
||||
{ 0x1f3f4, 0x1f3f4 }, /* W */
|
||||
{ 0x1f3f8, 0x1f43e }, /* W */
|
||||
{ 0x1f440, 0x1f440 }, /* W */
|
||||
{ 0x1f442, 0x1f4fc }, /* W */
|
||||
{ 0x1f4ff, 0x1f53d }, /* W */
|
||||
{ 0x1f54b, 0x1f54e }, /* W */
|
||||
{ 0x1f550, 0x1f567 }, /* W */
|
||||
{ 0x1f57a, 0x1f57a }, /* W */
|
||||
{ 0x1f595, 0x1f596 }, /* W */
|
||||
{ 0x1f5a4, 0x1f5a4 }, /* W */
|
||||
{ 0x1f5fb, 0x1f64f }, /* W */
|
||||
{ 0x1f680, 0x1f6c5 }, /* W */
|
||||
{ 0x1f6cc, 0x1f6cc }, /* W */
|
||||
{ 0x1f6d0, 0x1f6d2 }, /* W */
|
||||
{ 0x1f6eb, 0x1f6ec }, /* W */
|
||||
{ 0x1f6f4, 0x1f6f6 }, /* W */
|
||||
{ 0x1f910, 0x1f91e }, /* W */
|
||||
{ 0x1f920, 0x1f927 }, /* W */
|
||||
{ 0x1f930, 0x1f930 }, /* W */
|
||||
{ 0x1f933, 0x1f93e }, /* W */
|
||||
{ 0x1f940, 0x1f94b }, /* W */
|
||||
{ 0x1f950, 0x1f95e }, /* W */
|
||||
{ 0x1f980, 0x1f991 }, /* W */
|
||||
{ 0x1f9c0, 0x1f9c0 }, /* W */
|
||||
{ 0x20000, 0x2fffd }, /* W */
|
||||
{ 0x30000, 0x3fffd }, /* W */
|
47
lessecho.1
47
lessecho.1
@ -1,47 +0,0 @@
|
||||
.TH LESSECHO 1 "Version 418: 02 Jan 2008"
|
||||
.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.
|
1
lessecho.1
Symbolic link
1
lessecho.1
Symbolic link
@ -0,0 +1 @@
|
||||
less/lessecho.nro
|
Loading…
Reference in New Issue
Block a user