updating less with version 418, based on a checked patch from Scott.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27093 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2008-08-20 23:24:01 +00:00
parent 3658735727
commit 5e29d55ee6
68 changed files with 10912 additions and 6298 deletions
+591 -257
View File
@@ -1,285 +1,626 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
TERMS AND CONDITIONS
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
0. Definitions.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
"This License" refers to version 3 of the GNU General Public License.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
A "covered work" means either the unmodified Program or a work based
on the Program.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
1. Source Code.
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
The Corresponding Source for a work in source code form is that
same work.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
13. Use with the GNU Affero General Public License.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
14. Revised Versions of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
NO WARRANTY
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
15. Disclaimer of Warranty.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -304,37 +645,30 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+1 -1
View File
@@ -2,7 +2,7 @@
------------
Less
Copyright (C) 1984-2002 Mark Nudelman
Copyright (C) 1984-2007 Mark Nudelman
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
-112
View File
@@ -1,112 +0,0 @@
# Makefile for less.
#### Start of system configuration section. ####
srcdir = .
CC = gcc
INSTALL = /bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
CFLAGS = -g -O2
CFLAGS_COMPILE_ONLY = -c
LDFLAGS =
O=o
LIBS = -ltermcap
prefix = /usr/local
exec_prefix = ${prefix}
# Where the installed binary goes.
bindir = ${exec_prefix}/bin
binprefix =
sysconfdir = ${prefix}/etc
mandir = ${prefix}/man
manext = 1
manprefix =
#### End of system configuration section. ####
SHELL = /bin/sh
# This rule allows us to supply the necessary -D options
# in addition to whatever the user asks for.
.c.o:
${CC} -I. ${CFLAGS_COMPILE_ONLY} -DBINDIR=\"${bindir}\" -DSYSDIR=\"${sysconfdir}\" ${CPPFLAGS} ${CFLAGS} $<
OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
command.${O} 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} \
tags.${O} ttyin.${O} version.${O}
all: less lesskey lessecho
less: ${OBJ}
${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
lesskey: lesskey.${O} version.${O}
${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O}
lessecho: lessecho.${O} version.${O}
${CC} ${LDFLAGS} -o $@ lessecho.${O} version.${O}
${OBJ}: ${srcdir}/less.h ${srcdir}/funcs.h defines.h
install: all ${srcdir}/less.nro ${srcdir}/lesskey.nro installdirs
${INSTALL_PROGRAM} less ${bindir}/${binprefix}less
${INSTALL_PROGRAM} lesskey ${bindir}/${binprefix}lesskey
${INSTALL_PROGRAM} lessecho ${bindir}/${binprefix}lessecho
${INSTALL_DATA} ${srcdir}/less.nro ${mandir}/man${manext}/${manprefix}less.${manext}
${INSTALL_DATA} ${srcdir}/lesskey.nro ${mandir}/man${manext}/${manprefix}lesskey.${manext}
install-strip:
${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' install
installdirs: mkinstalldirs
${srcdir}/mkinstalldirs ${bindir} ${mandir}/man${manext}
uninstall:
rm -f ${bindir}/${binprefix}less ${bindir}/${binprefix}lesskey ${bindir}/${binprefix}lessecho
rm -f ${mandir}/man${manext}/${manprefix}less.${manext} ${mandir}/man${manext}/${manprefix}lesskey.${manext}
info:
install-info:
dvi:
check:
installcheck:
TAGS:
cd ${srcdir} && etags *.c *.h
# config.status might not change defines.h
# Don't rerun config.status if we just configured (so there's no stamp-h).
defines.h: stamp-h
stamp-h: defines.h.in config.status
test ! -f stamp-h || CONFIG_FILES= CONFIG_HEADERS=defines.h ./config.status
touch stamp-h
Makefile: ${srcdir}/Makefile.in config.status
CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status
config.status: ${srcdir}/configure
./config.status --recheck
${srcdir}/configure: ${srcdir}/configure.ac
cd ${srcdir}; autoheader; autoconf
clean:
rm -f *.${O} core less lesskey lessecho
mostlyclean: clean
distclean: clean
rm -f Makefile config.status config.log config.cache defines.h stamp-h
realclean: distclean
rm -f TAGS
+9 -3
View File
@@ -24,9 +24,10 @@ DISTFILES = \
${SRC} regexp.c regexp.h \
COPYING INSTALL LICENSE Makefile.in Makefile.aut NEWS README \
configure configure.ac lesskey.c lessecho.c scrsize.c \
cmd.h funcs.h lglob.h less.h lesskey.h option.h pckeys.h position.h \
charset.h cmd.h funcs.h lglob.h less.h lesskey.h option.h pckeys.h position.h \
install.sh defines.h.in mkinstalldirs \
less.nro lesskey.nro less.man lesskey.man less.hlp \
less.nro less.man lesskey.nro lesskey.man lessecho.nro lessecho.man \
less.hlp \
mkfuncs.awk mkhelp.c \
${DISTFILES_W}
@@ -55,7 +56,8 @@ lint:
clean:
rm -f Makefile config.status config.log config.cache defines.h stamp-h \
README NEWS less.nro lesskey.nro less.man lesskey.man
README NEWS \
less.nro less.man lesskey.nro lesskey.man lessecho.nro lessecho.man
distclean: clean
realclean: clean
@@ -78,6 +80,8 @@ ${srcdir}/less.nro: ${srcdir}/less.nro.VER ${srcdir}/version.c
${REPLACE_VERSION} ${srcdir}/less.nro.VER
${srcdir}/lesskey.nro: ${srcdir}/lesskey.nro.VER ${srcdir}/version.c
${REPLACE_VERSION} ${srcdir}/lesskey.nro.VER
${srcdir}/lessecho.nro: ${srcdir}/lessecho.nro.VER ${srcdir}/version.c
${REPLACE_VERSION} ${srcdir}/lessecho.nro.VER
${srcdir}/less.hlp: ${srcdir}/less.hlp.VER ${srcdir}/version.c
${REPLACE_VERSION} ${srcdir}/less.hlp.VER
@@ -85,6 +89,8 @@ ${srcdir}/less.man: ${srcdir}/less.nro
${NROFF} ${srcdir}/less.nro >${srcdir}/less.man
${srcdir}/lesskey.man: ${srcdir}/lesskey.nro
${NROFF} ${srcdir}/lesskey.nro >${srcdir}/lesskey.man
${srcdir}/lessecho.man: ${srcdir}/lessecho.nro
${NROFF} ${srcdir}/lessecho.nro >${srcdir}/lessecho.man
distfiles: ${DISTFILES}
+23 -14
View File
@@ -13,6 +13,8 @@ INSTALL_DATA = @INSTALL_DATA@
CFLAGS = @CFLAGS@
CFLAGS_COMPILE_ONLY = -c
LDFLAGS = @LDFLAGS@
CPPFLAGS = @CPPFLAGS@
EXEEXT = @EXEEXT@
O=o
LIBS = @LIBS@
@@ -25,10 +27,12 @@ bindir = @bindir@
binprefix =
sysconfdir = @sysconfdir@
datarootdir = @datarootdir@
mandir = @mandir@
manext = 1
manprefix =
DESTDIR =
#### End of system configuration section. ####
@@ -46,35 +50,40 @@ OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
tags.${O} ttyin.${O} version.${O} @REGEX_O@
all: less lesskey lessecho
all: less$(EXEEXT) lesskey$(EXEEXT) lessecho$(EXEEXT)
less: ${OBJ}
less$(EXEEXT): ${OBJ}
${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
lesskey: lesskey.${O} version.${O}
lesskey$(EXEEXT): lesskey.${O} version.${O}
${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O}
lessecho: lessecho.${O} version.${O}
lessecho$(EXEEXT): lessecho.${O} version.${O}
${CC} ${LDFLAGS} -o $@ lessecho.${O} version.${O}
${OBJ}: ${srcdir}/less.h ${srcdir}/funcs.h defines.h
install: all ${srcdir}/less.nro ${srcdir}/lesskey.nro installdirs
${INSTALL_PROGRAM} less ${bindir}/${binprefix}less
${INSTALL_PROGRAM} lesskey ${bindir}/${binprefix}lesskey
${INSTALL_PROGRAM} lessecho ${bindir}/${binprefix}lessecho
${INSTALL_DATA} ${srcdir}/less.nro ${mandir}/man${manext}/${manprefix}less.${manext}
${INSTALL_DATA} ${srcdir}/lesskey.nro ${mandir}/man${manext}/${manprefix}lesskey.${manext}
install: all ${srcdir}/less.nro ${srcdir}/lesskey.nro ${srcdir}/lessecho.nro installdirs
${INSTALL_PROGRAM} less$(EXEEXT) ${DESTDIR}${bindir}/${binprefix}less$(EXEEXT)
${INSTALL_PROGRAM} lesskey$(EXEEXT) ${DESTDIR}${bindir}/${binprefix}lesskey$(EXEEXT)
${INSTALL_PROGRAM} lessecho$(EXEEXT) ${DESTDIR}${bindir}/${binprefix}lessecho$(EXEEXT)
${INSTALL_DATA} ${srcdir}/less.nro ${DESTDIR}${mandir}/man${manext}/${manprefix}less.${manext}
${INSTALL_DATA} ${srcdir}/lesskey.nro ${DESTDIR}${mandir}/man${manext}/${manprefix}lesskey.${manext}
${INSTALL_DATA} ${srcdir}/lessecho.nro ${DESTDIR}${mandir}/man${manext}/${manprefix}lessecho.${manext}
install-strip:
${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' install
installdirs: mkinstalldirs
${srcdir}/mkinstalldirs ${bindir} ${mandir}/man${manext}
${srcdir}/mkinstalldirs ${DESTDIR}${bindir} ${DESTDIR}${mandir}/man${manext}
uninstall:
rm -f ${bindir}/${binprefix}less ${bindir}/${binprefix}lesskey ${bindir}/${binprefix}lessecho
rm -f ${mandir}/man${manext}/${manprefix}less.${manext} ${mandir}/man${manext}/${manprefix}lesskey.${manext}
rm -f ${DESTDIR}${bindir}/${binprefix}less$(EXEEXT)
rm -f ${DESTDIR}${bindir}/${binprefix}lesskey$(EXEEXT)
rm -f ${DESTDIR}${bindir}/${binprefix}lessecho$(EXEEXT)
rm -f ${DESTDIR}${mandir}/man${manext}/${manprefix}less.${manext}
rm -f ${DESTDIR}${mandir}/man${manext}/${manprefix}lesskey.${manext}
rm -f ${DESTDIR}${mandir}/man${manext}/${manprefix}lessecho.${manext}
info:
install-info:
@@ -100,7 +109,7 @@ ${srcdir}/configure: ${srcdir}/configure.ac
cd ${srcdir}; autoheader; autoconf
clean:
rm -f *.${O} core less lesskey lessecho
rm -f *.${O} core less$(EXEEXT) lesskey$(EXEEXT) lessecho$(EXEEXT)
mostlyclean: clean
+28 -7
View File
@@ -1,20 +1,27 @@
# Makefile for less.
# Windows version
# Bolarnd C++ 5.5.1 free command line tools
#### Start of system configuration section. ####
#
# Borland's make knows its own location in the
# filesystem.
#
CC = bcc32
LIBDIR = d:\bc45\lib
LIBDIR = $(MAKEDIR)\..\lib
CFLAGS = -O2 -w-pro -TWC -P-c -v- -d -f- -ff- -vi
LDFLAGS = /Tpe /v- /ap /c /x
LD = tlink32
LDFLAGS = -Tpe -v- -ap -c -x -V4.0 -GF:AGGRESSIVE
LD = ilink32
LIBS = ${LIBDIR}\import32.lib ${LIBDIR}\cw32.lib
#### End of system configuration section. ####
#
# This rule allows us to supply the necessary -D options
# in addition to whatever the user asks for.
#
.c.obj:
${CC} -c -I. ${CPPFLAGS} ${CFLAGS} $<
@@ -25,16 +32,20 @@ OBJ = main.obj screen.obj brac.obj ch.obj charset.obj cmdbuf.obj command.obj \
position.obj prompt.obj search.obj signal.obj tags.obj \
ttyin.obj version.obj regexp.obj
all: less lesskey
all: less lesskey lessecho
#
# This is really horrible, but the command line is too long for
# MS-DOS if we try to link ${OBJ}.
#
less: ${OBJ}
-del lesskey.obj
${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj *.obj, $@,,${LIBS}
${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj $**, $@,,${LIBS}
lesskey: lesskey.obj version.obj
${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj lesskey.obj version.obj, $@,,${LIBS}
${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj $**, $@,,${LIBS}
lessecho: lessecho.obj version.obj
${LD} ${LDFLAGS} ${LIBDIR}\c0x32.obj $**, $@,,${LIBS}
defines.h: defines.wn
-del defines.h
@@ -44,6 +55,16 @@ ${OBJ}: less.h defines.h funcs.h cmd.h
clean:
-del *.obj
-del *.il?
-del *.tds
-del defines.h
spotless: clean
-del less.exe
-del lesskey.exe
-del lessecho.exe
realclean: spotless
distclean: spotless
+142
View File
@@ -13,6 +13,143 @@
======================================================================
Major changes between "less" versions 416 and 418
* Color escape sequences are now supported in WIN32 build.
* Makefile now uses EXEEXT feature of autoconf.
* Fix search bug when using -R and text contains ANSI color escape sequences.
* Fix crash when using -r with UTF-8 text containing 0x9B bytes.
* Fix display bug when using ' command to move less than one page forward.
* Update GPL to version 3.
======================================================================
Major changes between "less" versions 409 and 416
* New --follow-name option makes F command follow the name of a file
rather than the file descriptor if an open file is renamed.
* Make searching with -i/-I work correctly with non-ASCII text.
* Fix DJGPP build.
======================================================================
Major changes between "less" versions 406 and 409
* Support CSI escape sequences, like SGR escape sequences.
* Fix bug which caused screen to fail to repaint when window is resized.
* Fix bug in using -i and -I flags with non-ASCII text.
* Fix configure bug on systems which don't support langinfo.h.
* Fix crash when searching text containing certain invalid UTF-8 sequences.
======================================================================
Major changes between "less" versions 394 and 406
* Allow decimal point in number for % (percent) command.
* Allow decimal point in number for -j option (fraction of screen height).
* Make n command fetch previous pattern from history file on first search.
* Don't rewrite history file if it has not changed.
* Don't move to bottom of screen on first page.
* Don't output extraneous newlines, so copy & pasting lines from the
output works better.
* The -c option has been made identical with the -C option.
* Allow "/dev/null" as synomym for "-" in LESSHISTFILE to indicate
that no history file should be used.
* Search can now find text which follows a null byte, if the PCRE
library is used, or if no-regex searching (ctrl-R) is used.
* Better compatibility with POSIX more specification.
* Make -f work for directories.
* Make "t" cmd traverse tags in the correct order.
* Allow a few binary characters in the input file before warning
that the file is binary.
* Don't warn that file is binary if it merely contains ANSI color sequences
and -R is in effect.
* Update Unicode character tables.
* Support DESTDIR in Makefile.
* Fix bug when filename contains certain shell metacharacters such as "$".
* Fix bug when resizing the window while waiting for input from a pipe.
* Fix configure bugs.
======================================================================
Major changes between "less" versions 382 and 394
* Add history file to save search and shell command history between
invocations of less.
* Improve behavior of history list for search and shell commands.
* Add -K (or --quit-on-intr) option to make less exit immediately on ctrl-C.
* Improve handling of UTF-8 files and commands, including better
line wrapping and handling double-width chars.
* Added LESSUTFBINFMT environment variable to control display of
non-printable characters in a UTF-8 file.
* Add --with-secure option to configure, to make it easier to
build a secure version of less.
* Show search matches in the status column even if search highlights
are disabled via the -G option or the ESC-u command.
* Improve performance when the file contains very long lines.
* Add "windows" charset.
* Add man page for lessecho.
* Add support for erase2 character, treated same as erase.
* Use ASCII lowercase/uppercase logic when operating on the command line.
* Update makefile for Borland C++ 5.5.1.
* Fix bug in calculating number of pages for %D prompt.
* Fix bug in handling tag file error.
* Fix obscure bug if input file is deleted while viewing help.
* Fix bug handling filenames which include square brackets.
* Fix possible buffer overflow in "global" tag search.
* Fix possible buffer overflow in usage of LESSOPEN and LESSCLOSE.
* Fix buffer overflow in reverse search.
======================================================================
Major changes between "less" versions 381 and 382
* Removed some old copyrighted code.
@@ -584,3 +721,8 @@
* Lesskey files may now include characters after the action as
extra input to be parsed after the action; for example:
"toggle-option X" to toggle a specific option X.
+9 -12
View File
@@ -1,26 +1,20 @@
Less, version 382
Less, version 418
This is the distribution of less, version 382, released 03 Feb 2004.
This is the distribution of less, version 418, released 02 Jan 2008.
This program is part of the GNU project (http://www.gnu.org).
This program is free software. You may redistribute it and/or
modify it under the terms of either:
1. The GNU General Public License, as published by the Free
Software Foundation; either version 2, or (at your option) any
Software Foundation; either version 3, or (at your option) any
later version. A copy of this license is in the file COPYING.
or
2. The Less License, in the file LICENSE.
Please report any problems to [email protected] or [email protected].
See http://www.greenwoodsoftware.com/less for the latest info.
You may also contact the author at:
Mark Nudelman
Greenwood Software
PO Box 2402
El Granada, CA 94018
USA
=========================================================================
@@ -46,6 +40,7 @@ INSTALLATION (Unix systems only):
--with-editor=program
Specifies the default editor program used by the "v" command.
The default is "vi".
--with-regex=lib
Specifies the regular expression library used by less for pattern
matching. The default is "auto", which means the configure program
@@ -57,6 +52,11 @@ INSTALLATION (Unix systems only):
regcomp Use the V8-compatible regcomp.
regcomp-local Use Henry Spencer's V8-compatible regcomp
(source is supplied with less).
--with-secure
Builds a "secure" version of less, with some features disabled
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
and make sure they look ok. If you know of any peculiarities of
@@ -67,9 +67,6 @@ INSTALLATION (Unix systems only):
-lncurses -lcurses -ltermcap -ltermlib
If you wish, you may edit defines.h to remove some optional features.
If you wish to build a "secure" version of less (which disables all
features which might allow a user to do unintended things to the system
on which less is running), edit defines.h and define SECURE to 1.
If you choose not to include some features in your version, you may
wish to edit the manual page "less.nro" and the help page "less.hlp"
to remove the descriptions of the features which you are removing.
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+57 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -21,6 +21,12 @@
#include <windows.h>
#endif
#if HAVE_STAT_INO
#include <sys/stat.h>
extern dev_t curr_dev;
extern ino_t curr_ino;
#endif
typedef POSITION BLOCKNUM;
public int ignore_eoi;
@@ -98,6 +104,8 @@ static int maxbufs = -1;
extern int autobuf;
extern int sigs;
extern int secure;
extern int screen_trashed;
extern int follow_mode;
extern constant char helpdata[];
extern constant int size_helpdata;
extern IFILE curr_ifile;
@@ -128,6 +136,9 @@ fch_get()
POSITION pos;
POSITION len;
if (thisfile == NULL)
return (EOI);
slept = FALSE;
/*
@@ -192,7 +203,7 @@ fch_get()
*/
if (!(ch_flags & CH_CANSEEK))
return ('?');
if (lseek(ch_file, (off_t)pos, 0) == BAD_LSEEK)
if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK)
{
error("seek error", NULL_PARG);
clear_eol();
@@ -273,6 +284,25 @@ fch_get()
#endif
#endif
slept = TRUE;
#if HAVE_STAT_INO
if (follow_mode == FOLLOW_NAME)
{
/* See whether the file's i-number has changed.
* If so, force the file to be closed and
* reopened. */
struct stat st;
int r = stat(get_filename(curr_ifile), &st);
if (r == 0 && (st.st_ino != curr_ino ||
st.st_dev != curr_dev))
{
/* screen_trashed=2 causes
* make_display to reopen the file. */
screen_trashed = 2;
return (EOI);
}
}
#endif
}
if (sigs)
return (EOI);
@@ -416,6 +446,9 @@ ch_seek(pos)
BLOCKNUM new_block;
POSITION len;
if (thisfile == NULL)
return (0);
len = ch_length();
if (pos < ch_zero() || (len != NULL_POSITION && pos > len))
return (1);
@@ -450,6 +483,9 @@ ch_end_seek()
{
POSITION len;
if (thisfile == NULL)
return (0);
if (ch_flags & CH_CANSEEK)
ch_fsize = filesize(ch_file);
@@ -503,6 +539,8 @@ ch_beg_seek()
public POSITION
ch_length()
{
if (thisfile == NULL)
return (NULL_POSITION);
if (ignore_eoi)
return (NULL_POSITION);
if (ch_flags & CH_HELPFILE)
@@ -516,6 +554,8 @@ ch_length()
public POSITION
ch_tell()
{
if (thisfile == NULL)
return (NULL_POSITION);
return (ch_block * LBUFSIZE) + ch_offset;
}
@@ -527,6 +567,8 @@ ch_forw_get()
{
register int c;
if (thisfile == NULL)
return (EOI);
c = ch_get();
if (c == EOI)
return (EOI);
@@ -546,6 +588,8 @@ ch_forw_get()
public int
ch_back_get()
{
if (thisfile == NULL)
return (EOI);
if (ch_offset > 0)
ch_offset --;
else
@@ -586,6 +630,9 @@ ch_flush()
{
register struct buf *bp;
if (thisfile == NULL)
return;
if (!(ch_flags & CH_CANSEEK))
{
/*
@@ -628,7 +675,7 @@ ch_flush()
}
#endif
if (lseek(ch_file, (off_t)0, 0) == BAD_LSEEK)
if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK)
{
/*
* Warning only; even if the seek fails for some reason,
@@ -691,7 +738,7 @@ ch_delbufs()
while (ch_bufhead != END_OF_CHAIN)
{
bp = ch_bufhead;
bp->next->prev = bp->prev;;
bp->next->prev = bp->prev;
bp->prev->next = bp->next;
free(bp);
}
@@ -717,7 +764,7 @@ seekable(f)
return (0);
}
#endif
return (lseek(f, (off_t)1, 0) != BAD_LSEEK);
return (lseek(f, (off_t)1, SEEK_SET) != BAD_LSEEK);
}
/*
@@ -769,6 +816,9 @@ ch_close()
{
int keepstate = FALSE;
if (thisfile == NULL)
return;
if (ch_flags & (CH_CANSEEK|CH_POPENED|CH_HELPFILE))
{
/*
@@ -807,6 +857,8 @@ ch_close()
public int
ch_getflags()
{
if (thisfile == NULL)
return (0);
return (ch_flags);
}
+874 -43
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2005-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
*
* For more information about less, or for information on how to
* contact the author, see the README file.
*/
#define IS_ASCII_OCTET(c) (((c) & 0x80) == 0)
#define IS_UTF8_TRAIL(c) (((c) & 0xC0) == 0x80)
#define IS_UTF8_LEAD2(c) (((c) & 0xE0) == 0xC0)
#define IS_UTF8_LEAD3(c) (((c) & 0xF0) == 0xE0)
#define IS_UTF8_LEAD4(c) (((c) & 0xF8) == 0xF0)
#define IS_UTF8_LEAD5(c) (((c) & 0xFC) == 0xF8)
#define IS_UTF8_LEAD6(c) (((c) & 0xFE) == 0xFC)
#define IS_UTF8_INVALID(c) (((c) & 0xFE) == 0xFE)
#define IS_UTF8_LEAD(c) (((c) & 0xC0) == 0xC0 && !IS_UTF8_INVALID(c))
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+513 -80
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -16,8 +16,13 @@
#include "less.h"
#include "cmd.h"
#include "charset.h"
#if HAVE_STAT
#include <sys/stat.h>
#endif
extern int sc_width;
extern int utf_mode;
static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */
static int cmd_col; /* Current column of the cursor */
@@ -48,6 +53,12 @@ public char closequote = '"';
#endif
#if CMD_HISTORY
/* History file */
#define HISTFILE_FIRST_LINE ".less-history-file:"
#define HISTFILE_SEARCH_SECTION ".search"
#define HISTFILE_SHELL_SECTION ".shell"
/*
* A mlist structure represents a command history.
*/
@@ -57,22 +68,23 @@ struct mlist
struct mlist *prev;
struct mlist *curr_mp;
char *string;
int modified;
};
/*
* These are the various command histories that exist.
*/
struct mlist mlist_search =
{ &mlist_search, &mlist_search, &mlist_search, NULL };
{ &mlist_search, &mlist_search, &mlist_search, NULL, 0 };
public void * constant ml_search = (void *) &mlist_search;
struct mlist mlist_examine =
{ &mlist_examine, &mlist_examine, &mlist_examine, NULL };
{ &mlist_examine, &mlist_examine, &mlist_examine, NULL, 0 };
public void * constant ml_examine = (void *) &mlist_examine;
#if SHELL_ESCAPE || PIPEC
struct mlist mlist_shell =
{ &mlist_shell, &mlist_shell, &mlist_shell, NULL };
{ &mlist_shell, &mlist_shell, &mlist_shell, NULL, 0 };
public void * constant ml_shell = (void *) &mlist_shell;
#endif
@@ -93,6 +105,10 @@ public void * constant ml_shell = (void *)3;
static struct mlist *curr_mlist = NULL;
static int curr_cmdflags;
static char cmd_mbc_buf[MAX_UTF_CHAR_LEN];
static int cmd_mbc_buf_len;
static int cmd_mbc_buf_index;
/*
* Reset command buffer (to empty).
@@ -105,16 +121,17 @@ cmd_reset()
cmd_col = 0;
cmd_offset = 0;
literal = 0;
cmd_mbc_buf_len = 0;
}
/*
* Clear command line on display.
* Clear command line.
*/
public void
clear_cmd()
{
clear_bot();
cmd_col = prompt_col = 0;
cmd_mbc_buf_len = 0;
}
/*
@@ -124,9 +141,28 @@ clear_cmd()
cmd_putstr(s)
char *s;
{
putstr(s);
cmd_col += strlen(s);
prompt_col += strlen(s);
LWCHAR prev_ch = 0;
LWCHAR ch;
char *endline = s + strlen(s);
while (*s != '\0')
{
char *ns = s;
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;
}
prev_ch = ch;
}
}
/*
@@ -135,7 +171,113 @@ cmd_putstr(s)
public int
len_cmdbuf()
{
return (strlen(cmdbuf));
char *s = cmdbuf;
char *endline = s + strlen(s);
int len = 0;
while (*s != '\0')
{
step_char(&s, +1, endline);
len++;
}
return (len);
}
/*
* Common part of cmd_step_right() and cmd_step_left().
*/
static char *
cmd_step_common(p, ch, len, pwidth, bswidth)
char *p;
LWCHAR ch;
int len;
int *pwidth;
int *bswidth;
{
char *pr;
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;
}
} else
{
pr = prutfchar(ch);
if (pwidth != NULL || bswidth != NULL)
{
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;
}
}
}
}
return (pr);
}
/*
* Step a pointer one character right in the command buffer.
*/
static char *
cmd_step_right(pp, pwidth, bswidth)
char **pp;
int *pwidth;
int *bswidth;
{
char *p = *pp;
LWCHAR ch = step_char(pp, +1, p + strlen(p));
return cmd_step_common(p, ch, *pp - p, pwidth, bswidth);
}
/*
* Step a pointer one character left in the command buffer.
*/
static char *
cmd_step_left(pp, pwidth, bswidth)
char **pp;
int *pwidth;
int *bswidth;
{
char *p = *pp;
LWCHAR ch = step_char(pp, -1, cmdbuf);
return cmd_step_common(*pp, ch, p - *pp, pwidth, bswidth);
}
/*
@@ -146,19 +288,30 @@ len_cmdbuf()
cmd_repaint(old_cp)
char *old_cp;
{
char *p;
/*
* Repaint the line from the current position.
*/
clear_eol();
for ( ; *cp != '\0'; cp++)
while (*cp != '\0')
{
p = prchar(*cp);
if (cmd_col + (int)strlen(p) >= sc_width)
char *np = cp;
int width;
char *pr = cmd_step_right(&np, &width, NULL);
if (cmd_col + width >= sc_width)
break;
putstr(p);
cmd_col += strlen(p);
cp = np;
putstr(pr);
cmd_col += width;
}
while (*cp != '\0')
{
char *np = cp;
int width;
char *pr = cmd_step_right(&np, &width, NULL);
if (width > 0)
break;
cp = np;
putstr(pr);
}
/*
@@ -177,8 +330,12 @@ cmd_home()
{
while (cmd_col > prompt_col)
{
putbs();
cmd_col--;
int width, bswidth;
cmd_step_left(&cp, &width, &bswidth);
while (bswidth-- > 0)
putbs();
cmd_col -= width;
}
cp = &cmdbuf[cmd_offset];
@@ -201,7 +358,20 @@ cmd_lshift()
s = cmdbuf + cmd_offset;
cols = 0;
while (cols < (sc_width - prompt_col) / 2 && *s != '\0')
cols += strlen(prchar(*s++));
{
int width;
cmd_step_right(&s, &width, NULL);
cols += width;
}
while (*s != '\0')
{
int width;
char *ns = s;
cmd_step_right(&ns, &width, NULL);
if (width > 0)
break;
s = ns;
}
cmd_offset = s - cmdbuf;
save_cp = cp;
@@ -216,7 +386,6 @@ cmd_lshift()
cmd_rshift()
{
char *s;
char *p;
char *save_cp;
int cols;
@@ -229,8 +398,9 @@ cmd_rshift()
cols = 0;
while (cols < (sc_width - prompt_col) / 2 && s > cmdbuf)
{
p = prchar(*--s);
cols += strlen(p);
int width;
cmd_step_left(&s, &width, NULL);
cols += width;
}
cmd_offset = s - cmdbuf;
@@ -245,23 +415,32 @@ cmd_rshift()
static int
cmd_right()
{
char *p;
char *pr;
char *ncp;
int width;
if (*cp == '\0')
{
/*
* Already at the end of the line.
*/
/* Already at the end of the line. */
return (CC_OK);
}
p = prchar(*cp);
if (cmd_col + (int)strlen(p) >= sc_width)
ncp = cp;
pr = cmd_step_right(&ncp, &width, NULL);
if (cmd_col + width >= sc_width)
cmd_lshift();
else if (cmd_col + (int)strlen(p) == sc_width - 1 && cp[1] != '\0')
else if (cmd_col + width == sc_width - 1 && cp[1] != '\0')
cmd_lshift();
cp++;
putstr(p);
cmd_col += strlen(p);
cp = ncp;
cmd_col += width;
putstr(pr);
while (*cp != '\0')
{
pr = cmd_step_right(&ncp, &width, NULL);
if (width > 0)
break;
putstr(pr);
cp = ncp;
}
return (CC_OK);
}
@@ -271,19 +450,26 @@ cmd_right()
static int
cmd_left()
{
char *p;
char *ncp;
int width, bswidth;
if (cp <= cmdbuf)
{
/* Already at the beginning of the line */
return (CC_OK);
}
p = prchar(cp[-1]);
if (cmd_col < prompt_col + (int)strlen(p))
ncp = cp;
while (ncp > cmdbuf)
{
cmd_step_left(&ncp, &width, &bswidth);
if (width > 0)
break;
}
if (cmd_col < prompt_col + width)
cmd_rshift();
cp--;
cmd_col -= strlen(p);
while (*p++ != '\0')
cp = ncp;
cmd_col -= width;
while (bswidth-- > 0)
putbs();
return (CC_OK);
}
@@ -292,26 +478,29 @@ cmd_left()
* Insert a char into the command buffer, at the current position.
*/
static int
cmd_ichar(c)
int c;
cmd_ichar(cs, clen)
char *cs;
int clen;
{
char *s;
if (strlen(cmdbuf) >= sizeof(cmdbuf)-2)
if (strlen(cmdbuf) + clen >= sizeof(cmdbuf)-1)
{
/*
* No room in the command buffer for another char.
*/
/* No room in the command buffer for another char. */
bell();
return (CC_ERROR);
}
/*
* Insert the character into the buffer.
* Make room for the new character (shift the tail of the buffer right).
*/
for (s = &cmdbuf[strlen(cmdbuf)]; s >= cp; s--)
s[1] = s[0];
*cp = c;
s[clen] = s[0];
/*
* Insert the character into the buffer.
*/
for (s = cp; s < cp + clen; s++)
*s = *cs++;
/*
* Reprint the tail of the line from the inserted char.
*/
@@ -328,6 +517,7 @@ cmd_ichar(c)
cmd_erase()
{
register char *s;
int clen;
if (cp == cmdbuf)
{
@@ -340,12 +530,20 @@ cmd_erase()
/*
* Move cursor left (to the char being erased).
*/
s = cp;
cmd_left();
clen = s - cp;
/*
* Remove the char from the buffer (shift the buffer left).
*/
for (s = cp; *s != '\0'; s++)
s[0] = s[1];
for (s = cp; ; s++)
{
s[0] = s[clen];
if (s[0] == '\0')
break;
}
/*
* Repaint the buffer after the erased char.
*/
@@ -368,9 +566,7 @@ cmd_delete()
{
if (*cp == '\0')
{
/*
* At end of string; there is no char under the cursor.
*/
/* At end of string; there is no char under the cursor. */
return (CC_OK);
}
/*
@@ -441,9 +637,7 @@ cmd_kill()
{
if (cmdbuf[0] == '\0')
{
/*
* Buffer is already empty; abort the current command.
*/
/* Buffer is already empty; abort the current command. */
return (CC_QUIT);
}
cmd_offset = 0;
@@ -470,6 +664,10 @@ set_mlist(mlist, cmdflags)
{
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;
}
#if CMD_HISTORY
@@ -505,12 +703,9 @@ cmd_updown(action)
s = curr_mlist->curr_mp->string;
if (s == NULL)
s = "";
for (cp = cmdbuf; *s != '\0'; s++)
{
*cp = *s;
strcpy(cmdbuf, s);
for (cp = cmdbuf; *cp != '\0'; )
cmd_right();
}
*cp = '\0';
return (CC_OK);
}
#endif
@@ -531,17 +726,13 @@ cmd_addhist(mlist, cmd)
*/
if (strlen(cmd) == 0)
return;
/*
* Don't save if a duplicate of a command which is already
* in the history.
* But select the one already in the history to be current.
* Save the command unless it's a duplicate of the
* last command in the history.
*/
for (ml = mlist->next; ml != mlist; ml = ml->next)
{
if (strcmp(ml->string, cmd) == 0)
break;
}
if (ml == mlist)
ml = mlist->prev;
if (ml == mlist || strcmp(ml->string, cmd) != 0)
{
/*
* Did not find command in history.
@@ -576,6 +767,7 @@ cmd_accept()
if (curr_mlist == NULL)
return;
cmd_addhist(curr_mlist, cmdbuf);
curr_mlist->modified = 1;
#endif
}
@@ -705,10 +897,13 @@ cmd_istr(str)
{
char *s;
int action;
char *endline = str + strlen(str);
for (s = str; *s != '\0'; s++)
for (s = str; *s != '\0'; )
{
action = cmd_ichar(*s);
char *os = s;
step_char(&s, +1, endline);
action = cmd_ichar(os, s - os);
if (action != CC_OK)
{
bell();
@@ -995,6 +1190,56 @@ cmd_char(c)
int c;
{
int action;
int len;
if (!utf_mode)
{
cmd_mbc_buf[0] = c;
len = 1;
} else
{
/* Perform strict validation in all possible cases. */
if (cmd_mbc_buf_len == 0)
{
retry:
cmd_mbc_buf_index = 1;
*cmd_mbc_buf = c;
if (IS_ASCII_OCTET(c))
cmd_mbc_buf_len = 1;
else if (IS_UTF8_LEAD(c))
{
cmd_mbc_buf_len = utf_len(c);
return (CC_OK);
} else
{
/* UTF8_INVALID or stray UTF8_TRAIL */
bell();
return (CC_ERROR);
}
} else if (IS_UTF8_TRAIL(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))
{
/* complete, but not well formed (non-shortest form), sequence */
cmd_mbc_buf_len = 0;
bell();
return (CC_ERROR);
}
} else
{
/* Flush incomplete (truncated) sequence. */
cmd_mbc_buf_len = 0;
bell();
/* Handle new char. */
goto retry;
}
len = cmd_mbc_buf_len;
cmd_mbc_buf_len = 0;
}
if (literal)
{
@@ -1002,13 +1247,13 @@ cmd_char(c)
* Insert the char, even if it is a line-editing char.
*/
literal = 0;
return (cmd_ichar(c));
return (cmd_ichar(cmd_mbc_buf, len));
}
/*
* See if it is a special line-editing character.
* See if it is a line-editing character.
*/
if (in_mca())
if (in_mca() && len == 1)
{
action = cmd_edit(c);
switch (action)
@@ -1024,20 +1269,28 @@ cmd_char(c)
/*
* Insert the char into the command buffer.
*/
return (cmd_ichar(c));
return (cmd_ichar(cmd_mbc_buf, len));
}
/*
* Return the number currently in the command buffer.
*/
public LINENUM
cmd_int()
cmd_int(frac)
long *frac;
{
register char *p;
char *p;
LINENUM n = 0;
int err;
for (p = cmdbuf; *p != '\0'; p++)
n = (10 * n) + (*p - '0');
for (p = cmdbuf; *p >= '0' && *p <= '9'; p++)
n = (n * 10) + (*p - '0');
*frac = 0;
if (*p++ == '.')
{
*frac = getfraction(&p, NULL, &err);
/* {{ do something if err is set? }} */
}
return (n);
}
@@ -1049,3 +1302,183 @@ get_cmdbuf()
{
return (cmdbuf);
}
/*
* Return the last (most recent) string in the current command history.
*/
public char *
cmd_lastpattern()
{
if (curr_mlist == NULL)
return (NULL);
return (curr_mlist->curr_mp->prev->string);
}
#if CMD_HISTORY
/*
* Get the name of the history file.
*/
static char *
histfile_name()
{
char *home;
char *name;
int len;
/* See if filename is explicitly specified by $LESSHISTFILE. */
name = lgetenv("LESSHISTFILE");
if (name != NULL && *name != '\0')
{
if (strcmp(name, "-") == 0 || strcmp(name, "/dev/null") == 0)
/* $LESSHISTFILE == "-" means don't use a history file. */
return (NULL);
return (save(name));
}
/* Otherwise, file is in $HOME. */
home = lgetenv("HOME");
if (home == NULL || *home == '\0')
{
#if OS2
home = lgetenv("INIT");
if (home == NULL || *home == '\0')
#endif
return (NULL);
}
len = 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.
*/
public void
init_cmdhist()
{
#if CMD_HISTORY
struct mlist *ml = NULL;
char line[CMDBUF_SIZE];
char *filename;
FILE *f;
char *p;
filename = histfile_name();
if (filename == NULL)
return;
f = fopen(filename, "r");
free(filename);
if (f == NULL)
return;
if (fgets(line, sizeof(line), f) == NULL ||
strncmp(line, HISTFILE_FIRST_LINE, strlen(HISTFILE_FIRST_LINE)) != 0)
{
fclose(f);
return;
}
while (fgets(line, sizeof(line), f) != NULL)
{
for (p = line; *p != '\0'; p++)
{
if (*p == '\n' || *p == '\r')
{
*p = '\0';
break;
}
}
if (strcmp(line, HISTFILE_SEARCH_SECTION) == 0)
ml = &mlist_search;
else if (strcmp(line, HISTFILE_SHELL_SECTION) == 0)
{
#if SHELL_ESCAPE || PIPEC
ml = &mlist_shell;
#else
ml = NULL;
#endif
} else if (*line == '"')
{
if (ml != NULL)
cmd_addhist(ml, line+1);
}
}
fclose(f);
#endif /* CMD_HISTORY */
}
/*
*
*/
#if CMD_HISTORY
static void
save_mlist(ml, f)
struct mlist *ml;
FILE *f;
{
int histsize = 0;
int n;
char *s;
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;
}
for (ml = ml->next; ml->string != NULL; ml = ml->next)
fprintf(f, "\"%s\n", ml->string);
}
#endif /* CMD_HISTORY */
/*
*
*/
public void
save_cmdhist()
{
#if CMD_HISTORY
char *filename;
FILE *f;
int modified = 0;
filename = histfile_name();
if (filename == NULL)
return;
if (mlist_search.modified)
modified = 1;
#if SHELL_ESCAPE || PIPEC
if (mlist_shell.modified)
modified = 1;
#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);
#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);
#endif /* CMD_HISTORY */
}
+98 -40
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -21,9 +21,8 @@
#include "option.h"
#include "cmd.h"
extern int erase_char, kill_char;
extern int erase_char, erase2_char, kill_char;
extern int sigs;
extern int quit_at_eof;
extern int quit_if_one_screen;
extern int squished;
extern int hit_eof;
@@ -54,6 +53,8 @@ extern char *editproto;
#endif
extern int screen_trashed; /* The screen has been overwritten */
extern int shift_count;
extern int oldbot;
extern int forw_prompt;
static char ungot[UNGOT_SIZE];
static char *ungotp = NULL;
@@ -63,10 +64,12 @@ static char *shellcmd = NULL; /* For holding last shell command for "!!" */
static int mca; /* The multicharacter command (action) */
static int search_type; /* The previous type of search */
static LINENUM number; /* The number typed by the user */
static long fraction; /* The fractional part of the number */
static char optchar;
static int optflag;
static int optgetname;
static POSITION bottompos;
static int save_hshift;
#if PIPEC
static char pipec;
#endif
@@ -74,7 +77,7 @@ static char pipec;
static void multi_search();
/*
* Move the cursor to lower left before executing a command.
* Move the cursor to start of prompt line before executing a command.
* This looks nicer if the command takes a long time before
* updating the screen.
*/
@@ -82,7 +85,7 @@ static void multi_search();
cmd_exec()
{
clear_attn();
lower_left();
clear_bot();
flush();
}
@@ -97,6 +100,7 @@ start_mca(action, prompt, mlist, cmdflags)
int cmdflags;
{
mca = action;
clear_bot();
clear_cmd();
cmd_putstr(prompt);
set_mlist(mlist, cmdflags);
@@ -119,6 +123,7 @@ mca_search()
else
mca = A_B_SEARCH;
clear_bot();
clear_cmd();
if (search_type & SRCH_NO_MATCH)
@@ -154,6 +159,7 @@ mca_opt_toggle()
dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";
mca = A_OPT_TOGGLE;
clear_bot();
clear_cmd();
cmd_putstr(dash);
if (optgetname)
@@ -290,14 +296,14 @@ mca_char(c)
* Entering digits of a number.
* Terminated by a non-digit.
*/
if ((c < '0' || c > '9') &&
if (!((c >= '0' && c <= '9') || c == '.') &&
editchar(c, EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE|EC_NORIGHTLEFT) == A_INVALID)
{
/*
* Not part of the number.
* Treat as a normal command character.
*/
number = cmd_int();
number = cmd_int(&fraction);
mca = 0;
cmd_accept();
return (NO_MCA);
@@ -392,7 +398,9 @@ mca_char(c)
* Already have a match for the name.
* Don't accept anything but erase/kill.
*/
if (c == erase_char || c == kill_char)
if (c == erase_char ||
c == erase2_char ||
c == kill_char)
return (MCA_DONE);
return (MCA_MORE);
}
@@ -403,7 +411,7 @@ mca_char(c)
if (cmd_char(c) == CC_QUIT)
return (MCA_DONE);
p = get_cmdbuf();
lc = islower(p[0]);
lc = ASCII_IS_LOWER(p[0]);
o = findopt_name(&p, &oname, NULL);
if (o != NULL)
{
@@ -413,15 +421,15 @@ mca_char(c)
* display the full option name.
*/
optchar = o->oletter;
if (!lc && islower(optchar))
optchar = toupper(optchar);
if (!lc && ASCII_IS_LOWER(optchar))
optchar = ASCII_TO_UPPER(optchar);
cmd_reset();
mca_opt_toggle();
for (p = oname; *p != '\0'; p++)
{
c = *p;
if (!lc && islower(c))
c = toupper(c);
if (!lc && ASCII_IS_LOWER(c))
c = ASCII_TO_UPPER(c);
if (cmd_char(c) != CC_OK)
return (MCA_DONE);
}
@@ -430,7 +438,7 @@ mca_char(c)
}
} else
{
if (c == erase_char || c == kill_char)
if (c == erase_char || c == erase2_char || c == kill_char)
break;
if (optchar != '\0')
/* We already have the option letter. */
@@ -543,6 +551,21 @@ mca_char(c)
return (MCA_MORE);
}
/*
* Discard any buffered file data.
*/
static void
clear_buffers()
{
if (!(ch_getflags() & CH_CANSEEK))
return;
ch_flush();
clr_linenum();
#if HILITE_SEARCH
clr_hilite();
#endif
}
/*
* Make sure the screen is displayed.
*/
@@ -566,11 +589,20 @@ make_display()
jump_loc(initial_scrpos.pos, initial_scrpos.ln);
} else if (screen_trashed)
{
int save_top_scroll;
save_top_scroll = top_scroll;
int save_top_scroll = top_scroll;
int save_ignore_eoi = ignore_eoi;
top_scroll = 1;
ignore_eoi = 0;
if (screen_trashed == 2)
{
/* Special case used by ignore_eoi: re-open the input file
* and jump to the end of the file. */
reopen_curr_ifile();
jump_forw();
}
repaint();
top_scroll = save_top_scroll;
ignore_eoi = save_ignore_eoi;
}
}
@@ -598,9 +630,12 @@ prompt()
bottompos = position(BOTTOM_PLUS_ONE);
/*
* If the -E flag is set and we've hit EOF on the last file, quit.
* If we've hit EOF on the last file, and the -E flag is set
* (or -F is set and this is the first prompt), then quit.
* {{ Relying on "first prompt" to detect a single-screen file
* fails if +G is used, for example. }}
*/
if ((quit_at_eof == OPT_ONPLUS || quit_if_one_screen) &&
if ((get_quit_at_eof() == OPT_ONPLUS || quit_if_one_screen) &&
hit_eof && !(ch_getflags() & CH_HELPFILE) &&
next_ifile(curr_ifile) == NULL_IFILE)
quit(QUIT_OK);
@@ -610,7 +645,7 @@ prompt()
* If the -e flag is set and we've hit EOF on the last file,
* and the file is squished (shorter than the screen), quit.
*/
if (quit_at_eof && squished &&
if (get_quit_at_eof() && squished &&
next_ifile(curr_ifile) == NULL_IFILE)
quit(QUIT_OK);
#endif
@@ -625,16 +660,30 @@ prompt()
/*
* Select the proper prompt and display it.
*/
/*
* If the previous action was a forward movement,
* don't clear the bottom line of the display;
* just print the prompt since the forward movement guarantees
* that we're in the right position to display the prompt.
* Clearing the line could cause a problem: for example, if the last
* line displayed ended at the right screen edge without a newline,
* then clearing would clear the last displayed line rather than
* the prompt line.
*/
if (!forw_prompt)
clear_bot();
clear_cmd();
forw_prompt = 0;
p = pr_string();
if (p == NULL)
if (p == NULL || *p == '\0')
putchr(':');
else
{
so_enter();
at_enter(AT_STANDOUT);
putstr(p);
so_exit();
at_exit();
}
clear_eol();
}
/*
@@ -826,6 +875,9 @@ multi_search(pattern, n)
* Restore the file we were originally viewing.
*/
reedit_ifile(save_ifile);
} else
{
unsave_ifile(save_ifile);
}
}
@@ -1081,7 +1133,10 @@ commands()
ignore_eoi = 1;
hit_eof = 0;
while (!sigs)
{
make_display();
forward(1, 0, 0);
}
ignore_eoi = 0;
/*
* This gets us back in "F mode" after processing
@@ -1120,14 +1175,7 @@ commands()
* Flush buffers, then repaint screen.
* Don't flush the buffers on a pipe!
*/
if (ch_getflags() & CH_CANSEEK)
{
ch_flush();
clr_linenum();
#if HILITE_SEARCH
clr_hilite();
#endif
}
clear_buffers();
/* FALLTHRU */
case A_REPAINT:
/*
@@ -1152,11 +1200,17 @@ commands()
* Go to a specified percentage into the file.
*/
if (number < 0)
{
number = 0;
fraction = 0;
}
if (number > 100)
{
number = 100;
fraction = 0;
}
cmd_exec();
jump_percent((int) number);
jump_percent((int) number, fraction);
break;
case A_GOEND:
@@ -1211,6 +1265,7 @@ commands()
* just means return to viewing the
* previous file.
*/
hshift = save_hshift;
if (edit_prev(1) == 0)
break;
}
@@ -1222,7 +1277,8 @@ commands()
/*
* Define abbreviation for a commonly used sequence below.
*/
#define DO_SEARCH() if (number <= 0) number = 1; \
#define DO_SEARCH() \
if (number <= 0) number = 1; \
mca_search(); \
cmd_exec(); \
multi_search((char *)NULL, (int) number);
@@ -1300,6 +1356,8 @@ commands()
if (ch_getflags() & CH_HELPFILE)
break;
cmd_exec();
save_hshift = hshift;
hshift = 0;
(void) edit(FAKE_HELPFILE);
break;
@@ -1340,9 +1398,8 @@ commands()
}
if (curr_altfilename != NULL)
{
error("Cannot edit file processed with LESSOPEN",
error("WARNING: This file was viewed via LESSOPEN",
NULL_PARG);
break;
}
start_mca(A_SHELL, "!", ml_shell, 0);
/*
@@ -1375,7 +1432,7 @@ commands()
number = 1;
if (edit_next((int) number))
{
if (quit_at_eof && hit_eof &&
if (get_quit_at_eof() && hit_eof &&
!(ch_getflags() & CH_HELPFILE))
quit(QUIT_OK);
parg.p_string = (number > 1) ? "(N-th) " : "";
@@ -1524,8 +1581,8 @@ commands()
break;
start_mca(A_SETMARK, "mark: ", (void*)NULL, 0);
c = getcc();
if (c == erase_char || c == kill_char ||
c == '\n' || c == '\r')
if (c == erase_char || c == erase2_char ||
c == kill_char || c == '\n' || c == '\r')
break;
setmark(c);
break;
@@ -1536,9 +1593,10 @@ commands()
*/
start_mca(A_GOMARK, "goto mark: ", (void*)NULL, 0);
c = getcc();
if (c == erase_char || c == kill_char ||
c == '\n' || c == '\r')
if (c == erase_char || c == erase2_char ||
c == kill_char || c == '\n' || c == '\r')
break;
cmd_exec();
gomark(c);
break;
@@ -1551,7 +1609,7 @@ commands()
}
start_mca(A_PIPE, "|mark: ", (void*)NULL, 0);
c = getcc();
if (c == erase_char || c == kill_char)
if (c == erase_char || c == erase2_char || c == kill_char)
break;
if (c == '\n' || c == '\r')
c = '.';
+4823 -2811
View File
File diff suppressed because it is too large Load Diff
+100 -11
View File
@@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script.
# Copyright (C) 1984-2002 Mark Nudelman
# Copyright (C) 1984-2007 Mark Nudelman
#
# You may distribute under the terms of either the GNU General Public
# License or the Less License, as specified in the README file.
@@ -23,7 +23,9 @@ AC_PROG_INSTALL
AC_SYS_LARGEFILE
# Checks for general libraries.
AC_CHECK_LIB(tinfo, tgoto, [have_tinfo=yes], [have_tinfo=no])
AC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
AC_CHECK_LIB(ncursesw, initscr, [have_ncursesw=yes], [have_ncursesw=no])
AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
@@ -50,6 +52,20 @@ fi
fi
if test $curses_broken = 0; then
# -- Try tinfo.
if test "x$TERMLIBS" = x; then
if test $have_tinfo = yes; then
TERMLIBS="-ltinfo"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
[termok=yes], [termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
fi
# -- Try xcurses.
if test "x$TERMLIBS" = x; then
if test $have_xcurses = yes; then
@@ -63,6 +79,19 @@ if test "x$TERMLIBS" = x; then
fi
fi
# -- Try ncursesw.
if test "x$TERMLIBS" = x; then
if test $have_ncursesw = yes; then
TERMLIBS="-lncursesw"
SAVE_LIBS=$LIBS
LIBS="$LIBS $TERMLIBS"
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
[termok=yes], [termok=no])
LIBS=$SAVE_LIBS
if test $termok = no; then TERMLIBS=""; fi
fi
fi
# -- Try ncurses.
if test "x$TERMLIBS" = x; then
if test $have_ncurses = yes; then
@@ -140,7 +169,7 @@ LIBS="$LIBS $TERMLIBS"
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h])
AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
@@ -168,6 +197,8 @@ AH_TEMPLATE([HAVE_VOID],
[Define HAVE_VOID if your compiler supports the "void" type.])
AH_TEMPLATE([HAVE_CONST],
[Define HAVE_CONST if your compiler supports the "const" modifier.])
AH_TEMPLATE([HAVE_STAT_INO],
[Define HAVE_STAT_INO if your struct stat has st_ino and st_dev.])
AH_TEMPLATE([HAVE_TIME_T],
[Define HAVE_TIME_T if your system supports the "time_t" type.])
AH_TEMPLATE([HAVE_STRERROR],
@@ -190,12 +221,16 @@ AH_TEMPLATE([HAVE_TERMIOS_FUNCS],
[Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr.])
AH_TEMPLATE([HAVE_UPPER_LOWER],
[Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower.])
AH_TEMPLATE([HAVE_WCTYPE],
[Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower.])
AH_TEMPLATE([HAVE_SIGSET_T],
[Define HAVE_SIGSET_T you have the sigset_t type.])
AH_TEMPLATE([HAVE_SIGEMPTYSET],
[Define HAVE_SIGEMPTYSET if you have the sigemptyset macro.])
AH_TEMPLATE([EDIT_PGM],
[Define EDIT_PGM to your editor.])
AH_TEMPLATE([SECURE_COMPILE],
[Define SECURE_COMPILE=1 to build a secure version of less.])
# Checks for identifiers.
AC_TYPE_OFF_T
@@ -208,10 +243,37 @@ AC_TRY_COMPILE(, [const int foo = 0;],
AC_MSG_CHECKING(for time_t)
AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for st_ino in struct stat)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/stat.h>],
[struct stat s; dev_t dev = s.st_dev; ino_t ino = s.st_ino;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STAT_INO)], [AC_MSG_RESULT(no)])
# Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system])
AC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
AC_MSG_CHECKING(for memcpy)
AC_TRY_LINK([
#if HAVE_STRING_H
#include <string.h>
#endif], [memcpy(0,0,0);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MEMCPY)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for strchr)
AC_TRY_LINK([
#if HAVE_STRING_H
#include <string.h>
#endif], [strchr("x",'x');],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRCHR)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for strstr)
AC_TRY_LINK([
#if HAVE_STRING_H
#include <string.h>
#endif], [strstr("x","x");],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRSTR)], [AC_MSG_RESULT(no)])
# Some systems have termios.h but not the corresponding functions.
AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
@@ -240,11 +302,7 @@ AC_MSG_CHECKING(for sys_errlist)
AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for sigset_t)
AC_TRY_LINK([
#include <signal.h>
], [sigset_t s; s = 0;],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGSET_T)], [AC_MSG_RESULT(no)])
AC_CHECK_TYPES([sigset_t],,,[#include <signal.h>])
AC_MSG_CHECKING(for sigemptyset)
AC_TRY_LINK([
@@ -270,8 +328,10 @@ fi
AC_MSG_CHECKING(for locale)
AC_TRY_LINK([#include <locale.h>
#include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
#include <ctype.h>
#include <langinfo.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for ctype functions)
AC_TRY_LINK([
#if HAVE_CTYPE_H
@@ -279,6 +339,10 @@ AC_TRY_LINK([
#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for wctype functions)
AC_TRY_LINK([#include <wctype.h>], [iswlower(0); iswupper(0); towlower(0); towupper(0);],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WCTYPE)], [AC_MSG_RESULT(no)])
# Checks for external variable ospeed in the termcap library.
have_ospeed=no
AC_MSG_CHECKING(termcap for ospeed)
@@ -297,11 +361,17 @@ AC_TRY_LINK(, [extern short ospeed; ospeed = 0;],
[AC_MSG_RESULT(no)])
fi
# Compile in secure mode?
AC_ARG_WITH(secure,
[ --with-secure Compile in secure mode],
AC_DEFINE(SECURE_COMPILE, 1), AC_DEFINE(SECURE_COMPILE, 0))
# Checks for regular expression functions.
have_regex=no
have_posix_regex=unknown
AC_MSG_CHECKING(for regcomp)
# Select a regular expression library.
WANT_REGEX=auto
AC_ARG_WITH(regex,
[ --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} Select a regular expression library [auto]],
@@ -401,8 +471,9 @@ AH_TOP([
/*
* SECURE is 1 if you wish to disable a bunch of features in order to
* be safe to run by unprivileged users.
* SECURE_COMPILE is set by the --with-secure configure option.
*/
#define SECURE 0
#define SECURE SECURE_COMPILE
/*
* SHELL_ESCAPE is 1 if you wish to allow shell escapes.
@@ -488,10 +559,13 @@ AH_TOP([
* LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
#define LESSHISTFILE ".lesshst"
/* Settings always true on Unix. */
@@ -506,6 +580,12 @@ AH_TOP([
*/
#define PATHNAME_SEP "/"
/*
* The value returned from tgetent on success.
* Some HP-UX systems return 0 on success.
*/
#define TGETENT_OK 1
/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
@@ -535,7 +615,7 @@ AH_TOP([
/*
* Default shell metacharacters and meta-escape character.
*/
#define DEF_METACHARS "; *?\t\n'\"()<>|&^`#\\"
#define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~"
#define DEF_METAESCAPE "\\"
/*
@@ -543,6 +623,15 @@ AH_TOP([
*/
#define HAVE_DUP 1
/* Define to 1 if you have the memcpy() function. */
#define HAVE_MEMCPY 1
/* Define to 1 if you have the strchr() function. */
#define HAVE_STRCHR 1
/* Define to 1 if you have the strstr() function. */
#define HAVE_STRSTR 1
/*
* Sizes of various buffers.
*/
+5 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -34,7 +34,7 @@
#include "cmd.h"
#include "lesskey.h"
extern int erase_char, kill_char;
extern int erase_char, erase2_char, kill_char;
extern int secure;
#define SK(k) \
@@ -120,6 +120,7 @@ static unsigned char cmdtable[] =
'7',0, A_DIGIT,
'8',0, A_DIGIT,
'9',0, A_DIGIT,
'.',0, A_DIGIT,
'=',0, A_STAT,
CONTROL('G'),0, A_STAT,
@@ -681,7 +682,7 @@ lesskey(filename, sysvar)
close(f);
return (-1);
}
if (lseek(f, (off_t)0, 0) == BAD_LSEEK)
if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
{
free(buf);
close(f);
@@ -754,7 +755,7 @@ editchar(c, flags)
* but give it the edit-commands command table
* This table is constructed to match the user's keyboard.
*/
if (c == erase_char)
if (c == erase_char || c == erase2_char)
return (EC_BACKSPACE);
if (c == kill_char)
return (EC_LINEKILL);
+10 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -117,10 +117,13 @@
* LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
#define LESSKEYFILE "_less"
#define LESSKEYFILE_SYS "c:\\_sysless"
#define DEF_LESSKEYINFILE "_lesskey"
#define LESSHISTFILE "_lesshst"
/* Settings always true for MS-DOS systems. */
@@ -304,9 +307,15 @@
/* Define if you have the system function. */
#define HAVE_SYSTEM 1
/* Define if you have the snprintf function. */
#define HAVE_SNPRINTF 0
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 0
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
+50 -25
View File
@@ -1,4 +1,4 @@
/* defines.h. Generated by configure. */
/* defines.h. Generated from defines.h.in by configure. */
/* defines.h.in. Generated from configure.ac by autoheader. */
@@ -19,8 +19,9 @@
/*
* SECURE is 1 if you wish to disable a bunch of features in order to
* be safe to run by unprivileged users.
* SECURE_COMPILE is set by the --with-secure configure option.
*/
#define SECURE 0
#define SECURE SECURE_COMPILE
/*
* SHELL_ESCAPE is 1 if you wish to allow shell escapes.
@@ -46,7 +47,7 @@
#define CMD_HISTORY 1
/*
* HILITE_SEARCH is 1 if you wish to have search targets to be
* HILITE_SEARCH is 1 if you wish to have search targets to be
* displayed in standout mode.
*/
#define HILITE_SEARCH 1
@@ -64,7 +65,7 @@
#define TAGS (!SECURE)
/*
* USERFILE is 1 if you wish to allow a .less file to specify
* USERFILE is 1 if you wish to allow a .less file to specify
* user-defined key bindings.
*/
#define USERFILE (!SECURE)
@@ -101,15 +102,18 @@
#define ONLY_RETURN 0
/*
* LESSKEYFILE is the filename of the default lesskey output file
* LESSKEYFILE is the filename of the default lesskey output file
* (in the HOME directory).
* LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
#define LESSHISTFILE ".lesshst"
/* Settings always true on Unix. */
@@ -124,6 +128,12 @@
*/
#define PATHNAME_SEP "/"
/*
* The value returned from tgetent on success.
* Some HP-UX systems return 0 on success.
*/
#define TGETENT_OK 1
/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
@@ -153,14 +163,23 @@
/*
* Default shell metacharacters and meta-escape character.
*/
#define DEF_METACHARS "; *?\t\n'\"()<>|&^`#\\"
#define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~"
#define DEF_METAESCAPE "\\"
/*
/*
* HAVE_DUP is 1 if your system has the dup() call.
*/
#define HAVE_DUP 1
/* Define to 1 if you have the memcpy() function. */
#define HAVE_MEMCPY 1
/* Define to 1 if you have the strchr() function. */
#define HAVE_STRCHR 1
/* Define to 1 if you have the strstr() function. */
#define HAVE_STRSTR 1
/*
* Sizes of various buffers.
*/
@@ -192,6 +211,9 @@
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the `fchmod' function. */
#define HAVE_FCHMOD 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
@@ -217,10 +239,7 @@
#define HAVE_LIMITS_H 1
/* Define HAVE_LOCALE if you have locale.h and setlocale. */
#define HAVE_LOCALE 1
/* Define to 1 if you have the `memcpy' function. */
#define HAVE_MEMCPY 1
/* #undef HAVE_LOCALE */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
@@ -255,12 +274,18 @@
/* Define to 1 if you have the `sigsetmask' function. */
/* #undef HAVE_SIGSETMASK */
/* Define HAVE_SIGSET_T you have the sigset_t type. */
/* Define to 1 if the system has the type `sigset_t'. */
#define HAVE_SIGSET_T 1
/* Define to 1 if you have the `snprintf' function. */
#define HAVE_SNPRINTF 1
/* Define to 1 if you have the `stat' function. */
#define HAVE_STAT 1
/* Define HAVE_STAT_INO if your struct stat has st_ino and st_dev. */
#define HAVE_STAT_INO 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@@ -270,9 +295,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strchr' function. */
#define HAVE_STRCHR 1
/* Define HAVE_STRERROR if you have the strerror() function. */
#define HAVE_STRERROR 1
@@ -282,9 +304,6 @@
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strstr' function. */
#define HAVE_STRSTR 1
/* Define to 1 if you have the `system' function. */
#define HAVE_SYSTEM 1
@@ -294,9 +313,6 @@
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/ptem.h> header file. */
/* #undef HAVE_SYS_PTEM_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
@@ -339,8 +355,14 @@
/* Define HAVE_VOID if your compiler supports the "void" type. */
#define HAVE_VOID 1
/* Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower. */
#define HAVE_WCTYPE 1
/* Define to 1 if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 1
/* Define to 1 if you have the `_setjmp' function. */
#define HAVE__SETJMP 1
/* #undef HAVE__SETJMP */
/* Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.
*/
@@ -371,6 +393,9 @@
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
/* Define SECURE_COMPILE=1 to build a secure version of less. */
#define SECURE_COMPILE 0
/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
/* #undef STAT_MACROS_BROKEN */
@@ -389,8 +414,8 @@
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `long' if <sys/types.h> does not define. */
/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define to `unsigned' if <sys/types.h> does not define. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
+10 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -110,10 +110,13 @@
* LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
#define LESSKEYFILE "less.ini"
#define LESSKEYFILE_SYS "C:\\sysless.ini"
#define DEF_LESSKEYINFILE "lesskey.ini"
#define LESSHISTFILE "lesshst.ini"
/* Settings always true for the emx compiler for OS/2 systems. */
@@ -270,9 +273,15 @@
/* Define if you have the system function. */
#define HAVE_SYSTEM 1
/* Define if you have the snprintf function. */
#define HAVE_SNPRINTF 0
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 0
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
+10 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -109,10 +109,13 @@
* LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS "/.sysless"
#define DEF_LESSKEYINFILE ".lesskey"
#define LESSHISTFILE ".lesshst"
/* Settings always true for OS-9. */
@@ -278,9 +281,15 @@
/* Define if you have the system function. */
#define HAVE_SYSTEM 1
/* Define if you have the snprintf function. */
#define HAVE_SNPRINTF 0
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 0
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
+10 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2000 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -110,10 +110,13 @@
* LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
#define LESSKEYFILE "_less"
#define LESSKEYFILE_SYS "c:\\_sysless"
#define DEF_LESSKEYINFILE "_lesskey"
#define LESSHISTFILE "_lesshst"
/* Settings always true for Windows systems. */
@@ -268,9 +271,15 @@
/* Define if you have the system function. */
#define HAVE_SYSTEM 1
/* Define if you have the snprintf function. */
#define HAVE_SNPRINTF 0
/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 1
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
+45 -6
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -10,6 +10,9 @@
#include "less.h"
#if HAVE_STAT
#include <sys/stat.h>
#endif
public int fd0 = 0;
@@ -36,6 +39,11 @@ extern int force_logfile;
extern char *namelogfile;
#endif
#if HAVE_STAT_INO
public dev_t curr_dev;
public ino_t curr_ino;
#endif
char *curr_altfilename = NULL;
static void *curr_altpipe;
@@ -178,6 +186,9 @@ close_file()
curr_altfilename = NULL;
}
curr_ifile = NULL_IFILE;
#if HAVE_STAT_INO
curr_ino = curr_dev = 0;
#endif
}
/*
@@ -322,6 +333,14 @@ edit_ifile(ifile)
/*
* Re-open the current file.
*/
if (was_curr_ifile == ifile)
{
/*
* Whoops. The "current" ifile is the one we just deleted.
* Just give up.
*/
quit(QUIT_ERROR);
}
reedit_ifile(was_curr_ifile);
return (1);
} else if ((f = open(qopen_filename, OPEN_READ)) < 0)
@@ -352,7 +371,6 @@ edit_ifile(ifile)
}
}
}
free(qopen_filename);
/*
* Get the new ifile.
@@ -376,11 +394,24 @@ edit_ifile(ifile)
#if LOGFILE
if (namelogfile != NULL && is_tty)
use_logfile(namelogfile);
#endif
#if HAVE_STAT_INO
/* Remember the i-number and device of the opened file. */
{
struct stat statbuf;
int r = stat(qopen_filename, &statbuf);
if (r == 0)
{
curr_ino = statbuf.st_ino;
curr_dev = statbuf.st_dev;
}
}
#endif
if (every_first_cmd != NULL)
ungetsc(every_first_cmd);
}
free(qopen_filename);
no_display = !any_display;
flush();
any_display = TRUE;
@@ -498,7 +529,7 @@ edit_last()
/*
* Edit the next or previous file in the command line (ifile) list.
* Edit the n-th next or previous file in the command line (ifile) list.
*/
static int
edit_istep(h, n, dir)
@@ -547,14 +578,14 @@ edit_inext(h, n)
IFILE h;
int n;
{
return (edit_istep(h, n, 1));
return (edit_istep(h, n, +1));
}
public int
edit_next(n)
int n;
{
return edit_istep(curr_ifile, n, 1);
return edit_istep(curr_ifile, n, +1);
}
static int
@@ -649,6 +680,14 @@ reedit_ifile(save_ifile)
quit(QUIT_ERROR);
}
public void
reopen_curr_ifile()
{
IFILE save_ifile = save_curr_ifile();
close_file();
reedit_ifile(save_ifile);
}
/*
* Edit standard input.
*/
@@ -739,7 +778,7 @@ loop:
* Append: open the file and seek to the end.
*/
logfile = open(filename, OPEN_APPEND);
if (lseek(logfile, (off_t)0, 2) == BAD_LSEEK)
if (lseek(logfile, (off_t)0, SEEK_END) == BAD_LSEEK)
{
close(logfile);
logfile = -1;
+53 -29
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -51,6 +51,8 @@
extern int force_open;
extern int secure;
extern int use_lessopen;
extern int ctldisp;
extern int utf_mode;
extern IFILE curr_ifile;
extern IFILE old_ifile;
#if SPACES_IN_FILENAMES
@@ -195,7 +197,7 @@ shell_quote(s)
newstr = p = (char *) ecalloc(len, sizeof(char));
if (use_quotes)
{
sprintf(newstr, "%c%s%c", openquote, s, closequote);
SNPRINTF3(newstr, len, "%c%s%c", openquote, s, closequote);
} else
{
while (*s != '\0')
@@ -226,6 +228,7 @@ dirfile(dirname, filename)
{
char *pathname;
char *qpathname;
int len;
int f;
if (dirname == NULL || *dirname == '\0')
@@ -233,11 +236,11 @@ dirfile(dirname, filename)
/*
* Construct the full pathname.
*/
pathname = (char *) calloc(strlen(dirname) + strlen(filename) + 2,
sizeof(char));
len= strlen(dirname) + strlen(filename) + 2;
pathname = (char *) calloc(len, sizeof(char));
if (pathname == NULL)
return (NULL);
sprintf(pathname, "%s%s%s", dirname, PATHNAME_SEP, filename);
SNPRINTF3(pathname, len, "%s%s%s", dirname, PATHNAME_SEP, filename);
/*
* Make sure the file exists.
*/
@@ -425,18 +428,23 @@ fcomplete(s)
*/
{
char *slash;
int len;
for (slash = s+strlen(s)-1; slash > s; slash--)
if (*slash == *PATHNAME_SEP || *slash == '/')
break;
fpat = (char *) ecalloc(strlen(s)+4, sizeof(char));
len = strlen(s) + 4;
fpat = (char *) ecalloc(len, sizeof(char));
if (strchr(slash, '.') == NULL)
sprintf(fpat, "%s*.*", s);
SNPRINTF1(fpat, len, "%s*.*", s);
else
sprintf(fpat, "%s*", s);
SNPRINTF1(fpat, len, "%s*", s);
}
#else
fpat = (char *) ecalloc(strlen(s)+2, sizeof(char));
sprintf(fpat, "%s*", s);
{
int len = strlen(s) + 2;
fpat = (char *) ecalloc(len, sizeof(char));
SNPRINTF1(fpat, len, "%s*", s);
}
#endif
qs = lglob(fpat);
s = shell_unquote(qs);
@@ -464,17 +472,29 @@ bin_file(f)
{
int i;
int n;
unsigned char data[64];
int bin_count = 0;
unsigned char data[256];
if (!seekable(f))
return (0);
if (lseek(f, (off_t)0, 0) == BAD_LSEEK)
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 (binary_char(data[i]))
return (1);
return (0);
{
char c = data[i];
if (ctldisp == OPT_ONPLUS && IS_CSI_START(c))
{
while (++i < n && is_ansi_middle(data[i]))
continue;
} else if (binary_char(c))
bin_count++;
}
/*
* Call it a binary file if there are more than 5 binary characters
* in the first 256 bytes of the file.
*/
return (bin_count > 5);
}
/*
@@ -486,7 +506,7 @@ seek_filesize(f)
{
off_t spos;
spos = lseek(f, (off_t)0, 2);
spos = lseek(f, (off_t)0, SEEK_END);
if (spos == BAD_LSEEK)
return (NULL_POSITION);
return ((POSITION) spos);
@@ -570,9 +590,9 @@ shellcmd(cmd)
fd = popen(cmd, "r");
} else
{
scmd = (char *) ecalloc(strlen(shell) + strlen(esccmd) + 5,
sizeof(char));
sprintf(scmd, "%s %s %s", shell, shell_coption(), esccmd);
int len = strlen(shell) + strlen(esccmd) + 5;
scmd = (char *) ecalloc(len, sizeof(char));
SNPRINTF3(scmd, len, "%s %s %s", shell, shell_coption(), esccmd);
free(esccmd);
fd = popen(scmd, "r");
free(scmd);
@@ -680,7 +700,7 @@ lglob(filename)
do {
n = strlen(drive) + strlen(dir) + strlen(fnd.GLOB_NAME) + 1;
pathname = (char *) ecalloc(n, sizeof(char));
sprintf(pathname, "%s%s%s", drive, dir, fnd.GLOB_NAME);
SNPRINTF3(pathname, n, "%s%s%s", drive, dir, fnd.GLOB_NAME);
qpathname = shell_quote(pathname);
free(pathname);
if (qpathname != NULL)
@@ -725,6 +745,7 @@ lglob(filename)
char *lessecho;
char *cmd;
char *esc;
int len;
esc = get_meta_escape();
if (strlen(esc) == 0)
@@ -741,8 +762,9 @@ lglob(filename)
/*
* Invoke lessecho, and read its output (a globbed list of filenames).
*/
cmd = (char *) ecalloc(strlen(lessecho) + strlen(ofilename) + (7*strlen(metachars())) + 24, sizeof(char));
sprintf(cmd, "%s -p0x%x -d0x%x -e%s ", lessecho, openquote, closequote, esc);
len = 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);
for (s = metachars(); *s != '\0'; s++)
sprintf(cmd + strlen(cmd), "-n0x%x ", *s);
@@ -795,6 +817,7 @@ open_altfile(filename, pf, pfd)
#else
char *lessopen;
char *cmd;
int len;
FILE *fd;
#if HAVE_FILENO
int returnfd = 0;
@@ -822,9 +845,9 @@ open_altfile(filename, pf, pfd)
#endif
}
cmd = (char *) ecalloc(strlen(lessopen) + strlen(filename) + 2,
sizeof(char));
sprintf(cmd, lessopen, filename);
len = strlen(lessopen) + strlen(filename) + 2;
cmd = (char *) ecalloc(len, sizeof(char));
SNPRINTF1(cmd, len, lessopen, filename);
fd = shellcmd(cmd);
free(cmd);
if (fd == NULL)
@@ -884,6 +907,7 @@ close_altfile(altfilename, filename, pipefd)
char *lessclose;
FILE *fd;
char *cmd;
int len;
if (secure)
return;
@@ -900,9 +924,9 @@ close_altfile(altfilename, filename, pipefd)
}
if ((lessclose = lgetenv("LESSCLOSE")) == NULL)
return;
cmd = (char *) ecalloc(strlen(lessclose) + strlen(filename) +
strlen(altfilename) + 2, sizeof(char));
sprintf(cmd, lessclose, filename, altfilename);
len = strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2;
cmd = (char *) ecalloc(len, sizeof(char));
SNPRINTF2(cmd, len, lessclose, filename, altfilename);
fd = shellcmd(cmd);
free(cmd);
if (fd != NULL)
@@ -956,7 +980,7 @@ bad_file(filename)
register char *m = NULL;
filename = shell_unquote(filename);
if (is_dir(filename))
if (!force_open && is_dir(filename))
{
static char is_a_dir[] = " is a directory";
+21 -21
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -21,18 +21,19 @@ 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;
extern int sigs;
extern int top_scroll;
extern int quiet;
extern int sc_width, sc_height;
extern int quit_at_eof;
extern int plusoption;
extern int forw_scroll;
extern int back_scroll;
extern int ignore_eoi;
extern int clear_bg;
extern int final_attr;
extern int oldbot;
#if TAGS
extern char *tagoption;
#endif
@@ -77,7 +78,7 @@ eof_check()
* of the screen; this can happen when we display a short file
* for the first time.
*/
static void
public void
squish_check()
{
if (!squished)
@@ -124,13 +125,6 @@ forw(n, pos, force, only_last, nblank)
if (!do_repaint)
{
/*
* Forget any current line shift we might have
* (from the last line of the previous screenful).
*/
extern int cshift;
cshift = 0;
if (top_scroll && n >= sc_height - 1 && pos != ch_length())
{
/*
@@ -142,12 +136,8 @@ forw(n, pos, force, only_last, nblank)
pos_clear();
add_forw_pos(pos);
force = 1;
if (top_scroll == OPT_ONPLUS || first_time)
clear();
clear();
home();
} else
{
clear_bot();
}
if (pos != position(BOTTOM_PLUS_ONE) || empty_screen())
@@ -162,8 +152,7 @@ forw(n, pos, force, only_last, nblank)
force = 1;
if (top_scroll)
{
if (top_scroll == OPT_ONPLUS)
clear();
clear();
home();
} else if (!first_time)
{
@@ -237,10 +226,17 @@ forw(n, pos, force, only_last, nblank)
squished = 1;
continue;
}
if (top_scroll == OPT_ON)
clear_eol();
put_line();
if (clear_bg && final_attr != AT_NORMAL)
#if 0
/* {{
* Can't call clear_eol here. The cursor might be at end of line
* on an ignaw terminal, so clear_eol would clear the last char
* of the current line instead of all of the next line.
* If we really need to do this on clear_bg terminals, we need
* to find a better way.
* }}
*/
if (clear_bg && apply_at_specials(final_attr) != AT_NORMAL)
{
/*
* Writing the last character on the last line
@@ -251,6 +247,8 @@ forw(n, pos, force, only_last, nblank)
*/
clear_eol();
}
#endif
forw_prompt = 1;
}
if (ignore_eoi)
@@ -316,6 +314,8 @@ back(n, pos, force, only_last)
eof_bell();
else if (do_repaint)
repaint();
else if (!oldbot)
lower_left();
(void) currline(BOTTOM);
}
@@ -331,7 +331,7 @@ forward(n, force, only_last)
{
POSITION pos;
if (quit_at_eof && hit_eof && !(ch_getflags() & CH_HELPFILE))
if (get_quit_at_eof() && hit_eof && !(ch_getflags() & CH_HELPFILE))
{
/*
* If the -e flag is set and we're trying to go
+31 -8
View File
@@ -14,6 +14,7 @@
public void remove_top ();
public void win32_scroll_up ();
public void lower_left ();
public void line_left ();
public void check_winch ();
public void goto_line ();
public void vbell ();
@@ -21,17 +22,16 @@
public void clear ();
public void clear_eol ();
public void clear_bot ();
public void so_enter ();
public void so_exit ();
public void ul_enter ();
public void ul_exit ();
public void bo_enter ();
public void bo_exit ();
public void bl_enter ();
public void bl_exit ();
public void at_enter ();
public void at_exit ();
public void at_switch ();
public int is_at_equiv ();
public int apply_at_specials ();
public void backspace ();
public void putbs ();
public char WIN32getch ();
public void WIN32setcolors ();
public void WIN32textout ();
public void match_brac ();
public void ch_ungetchar ();
public void end_logfile ();
@@ -54,6 +54,16 @@
public int binary_char ();
public int control_char ();
public char * prchar ();
public char * prutfchar ();
public int utf_len ();
public int is_utf8_well_formed ();
public LWCHAR get_wchar ();
public void put_wchar ();
public LWCHAR step_char ();
public int is_composing_char ();
public int is_ubin_char ();
public int is_wide_char ();
public int is_combining_char ();
public void cmd_reset ();
public void clear_cmd ();
public void cmd_putstr ();
@@ -64,6 +74,9 @@
public int cmd_char ();
public LINENUM cmd_int ();
public char * get_cmdbuf ();
public char * cmd_lastpattern ();
public void init_cmdhist ();
public void save_cmdhist ();
public int in_mca ();
public void dispversion ();
public int getcc ();
@@ -93,6 +106,7 @@
public IFILE save_curr_ifile ();
public void unsave_ifile ();
public void reedit_ifile ();
public void reopen_curr_ifile ();
public int edit_stdin ();
public void cat_file ();
public void use_logfile ();
@@ -110,6 +124,7 @@
public char * bad_file ();
public POSITION filesize ();
public char * shell_coption ();
public void squish_check ();
public void forw ();
public void back ();
public void forward ();
@@ -142,10 +157,14 @@
public void jump_line_loc ();
public void jump_loc ();
public void init_line ();
public int is_ascii_char ();
public void prewind ();
public void plinenum ();
public void pshift_all ();
public int is_ansi_end ();
public int is_ansi_middle ();
public int pappend ();
public int pflushmbc ();
public void pdone ();
public int gline ();
public void null_line ();
@@ -169,6 +188,8 @@
public void opt_o ();
public void opt__O ();
public void opt_l ();
public void opt_j ();
public void calc_jump_sline ();
public void opt_k ();
public void opt_t ();
public void opt__T ();
@@ -189,6 +210,8 @@
public int isoptpending ();
public void nopendopt ();
public int getnum ();
public long getfraction ();
public int get_quit_at_eof ();
public void init_option ();
public struct loption * findopt ();
public struct loption * findopt_name ();
+4 -3
View File
@@ -118,8 +118,8 @@ constant char helpdata[] = {
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','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',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','a','u','t','o','m','a','t','i','c','a','l','l','y',' ','a','l','l','o','c','a','t','e',' ','b','u','f','f','e','r','s',' ','f','o','r',' ','p','i','p','e','s','.','\n',
' ',' ','-','c',' ',' ','-','C',' ',' ','.','.','.','.',' ',' ','-','-','c','l','e','a','r','-','s','c','r','e','e','n',' ',' ','-','-','C','L','E','A','R','-','S','C','R','E','E','N','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','b','y',' ','s','c','r','o','l','l','i','n','g','/','c','l','e','a','r','i','n','g','.','\n',
' ',' ','-','c',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','c','l','e','a','r','-','s','c','r','e','e','n','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','b','y',' ','c','l','e','a','r','i','n','g',' ','r','a','t','h','e','r',' ','t','h','a','n',' ','s','c','r','o','l','l','i','n','g','.','\n',
' ',' ','-','d',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','d','u','m','b','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','u','m','b',' ','t','e','r','m','i','n','a','l','.','\n',
' ',' ','-','D',' ','[','_','\b','x','_','\b','n','_','\b','.','_','\b','n',']',' ',' ','.',' ',' ','-','-','c','o','l','o','r','=','_','\b','x','_','\b','n','_','\b','.','_','\b','n','\n',
@@ -151,7 +151,7 @@ constant char helpdata[] = {
' ',' ','-','m',' ',' ','-','M',' ',' ','.','.','.','.',' ',' ','-','-','l','o','n','g','-','p','r','o','m','p','t',' ',' ','-','-','L','O','N','G','-','P','R','O','M','P','T','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','p','r','o','m','p','t',' ','s','t','y','l','e','.','\n',
' ',' ','-','n',' ',' ','-','N',' ',' ','.','.','.','.',' ',' ','-','-','l','i','n','e','-','n','u','m','b','e','r','s',' ',' ','-','-','L','I','N','E','-','N','U','M','B','E','R','S','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','l','i','n','e',' ','n','u','m','b','e','r','s','.','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','l','i','n','e',' ','n','u','m','b','e','r','s','.','\n',
' ',' ','-','o',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','o','g','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','p','y',' ','t','o',' ','l','o','g',' ','f','i','l','e',' ','(','s','t','a','n','d','a','r','d',' ','i','n','p','u','t',' ','o','n','l','y',')','.','\n',
' ',' ','-','O',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','L','O','G','-','F','I','L','E','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
@@ -220,6 +220,7 @@ constant char helpdata[] = {
' ','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',
'\n',
'\n',
0 };
constant int size_helpdata = sizeof(helpdata) - 1;
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+78 -15
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -27,6 +27,7 @@ extern int hshift;
extern int quit_if_one_screen;
extern int sigs;
extern int ignore_eoi;
extern int status_col;
extern POSITION start_attnpos;
extern POSITION end_attnpos;
#if HILITE_SEARCH
@@ -45,10 +46,12 @@ extern int size_linebuf;
forw_line(curr_pos)
POSITION curr_pos;
{
POSITION base_pos;
POSITION new_pos;
register int c;
int blankline;
int endline;
int backchars;
if (curr_pos == NULL_POSITION)
{
@@ -56,7 +59,7 @@ forw_line(curr_pos)
return (NULL_POSITION);
}
#if HILITE_SEARCH
if (hilite_search == OPT_ONPLUS)
if (hilite_search == OPT_ONPLUS || status_col)
/*
* If we are ignoring EOI (command F), only prepare
* one line ahead, to avoid getting stuck waiting for
@@ -73,9 +76,48 @@ forw_line(curr_pos)
return (NULL_POSITION);
}
prewind();
plinenum(curr_pos);
(void) ch_seek(curr_pos);
base_pos = curr_pos;
for (;;)
{
if (ABORT_SIGS())
{
null_line();
return (NULL_POSITION);
}
c = ch_back_get();
if (c == EOI)
break;
if (c == '\n')
{
(void) ch_forw_get();
break;
}
--base_pos;
}
prewind();
plinenum(base_pos);
(void) ch_seek(base_pos);
while (base_pos < curr_pos)
{
if (ABORT_SIGS())
{
null_line();
return (NULL_POSITION);
}
c = ch_forw_get();
backchars = pappend(c, base_pos);
base_pos++;
if (backchars > 0)
{
pshift_all();
base_pos -= backchars;
while (--backchars >= 0)
(void) ch_back_get();
}
}
(void) pflushmbc();
pshift_all();
c = ch_forw_get();
if (c == EOI)
@@ -97,15 +139,24 @@ forw_line(curr_pos)
/*
* End of the line.
*/
backchars = pflushmbc();
new_pos = ch_tell();
endline = TRUE;
if (backchars > 0 && !chopline && hshift == 0)
{
new_pos -= backchars + 1;
endline = FALSE;
} else
endline = TRUE;
break;
}
if (c != '\r')
blankline = 0;
/*
* Append the char to the line and get the next char.
*/
if (pappend(c, ch_tell()-1))
backchars = pappend(c, ch_tell()-1);
if (backchars > 0)
{
/*
* The char won't fit in the line; the line
@@ -123,7 +174,7 @@ forw_line(curr_pos)
quit_if_one_screen = FALSE;
} else
{
new_pos = ch_tell() - 1;
new_pos = ch_tell() - backchars;
endline = FALSE;
}
break;
@@ -167,6 +218,7 @@ back_line(curr_pos)
POSITION new_pos, begin_new_pos;
int c;
int endline;
int backchars;
if (curr_pos == NULL_POSITION || curr_pos <= ch_zero())
{
@@ -174,7 +226,7 @@ back_line(curr_pos)
return (NULL_POSITION);
}
#if HILITE_SEARCH
if (hilite_search == OPT_ONPLUS)
if (hilite_search == OPT_ONPLUS || status_col)
prep_hilite((curr_pos < 3*size_linebuf) ?
0 : curr_pos - 3*size_linebuf, curr_pos, -1);
#endif
@@ -263,10 +315,10 @@ back_line(curr_pos)
return (NULL_POSITION);
}
endline = FALSE;
loop:
begin_new_pos = new_pos;
prewind();
plinenum(new_pos);
loop:
begin_new_pos = new_pos;
(void) ch_seek(new_pos);
do
@@ -280,10 +332,17 @@ back_line(curr_pos)
new_pos++;
if (c == '\n')
{
backchars = pflushmbc();
if (backchars > 0 && !chopline && hshift == 0)
{
backchars++;
goto shift;
}
endline = TRUE;
break;
}
if (pappend(c, ch_tell()-1))
backchars = pappend(c, ch_tell()-1);
if (backchars > 0)
{
/*
* Got a full printable line, but we haven't
@@ -296,9 +355,13 @@ back_line(curr_pos)
quit_if_one_screen = FALSE;
break;
}
pdone(0);
(void) ch_back_get();
new_pos--;
shift:
pshift_all();
while (backchars-- > 0)
{
(void) ch_back_get();
new_pos--;
}
goto loop;
}
} while (new_pos < curr_pos);
+1 -1
View File
@@ -97,7 +97,7 @@ fi
# Make a temp file name in the proper directory.
dstdir=`dirname $dst`
dsttmp=$dstdir/#inst.$$#
dsttmp=$dstdir/_inst.$$_
# Move or copy the file name to the temp name
+17 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -22,6 +22,7 @@ extern int squished;
extern int screen_trashed;
extern int sc_width, sc_height;
extern int show_attn;
extern int top_scroll;
/*
* Jump to the end of the file.
@@ -30,6 +31,7 @@ extern int show_attn;
jump_forw()
{
POSITION pos;
POSITION end_pos;
if (ch_end_seek())
{
@@ -41,11 +43,17 @@ jump_forw()
* Go back one line from the end of the file
* to get to the beginning of the last line.
*/
pos = back_line(ch_tell());
pos_clear();
end_pos = ch_tell();
pos = back_line(end_pos);
if (pos == NULL_POSITION)
jump_loc((POSITION)0, sc_height-1);
else
{
jump_loc(pos, sc_height-1);
if (position(sc_height-1) != end_pos)
repaint();
}
}
/*
@@ -101,8 +109,9 @@ repaint()
* Jump to a specified percentage into the file.
*/
public void
jump_percent(percent)
jump_percent(percent, fraction)
int percent;
long fraction;
{
POSITION pos, len;
@@ -120,7 +129,7 @@ jump_percent(percent)
error("Don't know length of file", NULL_PARG);
return;
}
pos = percent_pos(len, percent);
pos = percent_pos(len, percent, fraction);
if (pos >= len)
pos = len-1;
@@ -279,7 +288,10 @@ jump_loc(pos, sline)
}
}
lastmark();
clear();
if (!top_scroll)
clear();
else
home();
screen_trashed = 0;
add_back_pos(pos);
back(sc_height-1, pos, 1, 0);
+101 -24
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -8,6 +8,7 @@
* contact the author, see the README file.
*/
#define NEWBOT 1
/*
* Standard include file for "less".
@@ -70,6 +71,9 @@
#if HAVE_CTYPE_H
#include <ctype.h>
#endif
#if HAVE_WCTYPE_H
#include <wctype.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
@@ -79,13 +83,21 @@
#if HAVE_STRING_H
#include <string.h>
#endif
/* OS-specific includes */
#ifdef _OSK
#include <modes.h>
#include <strings.h>
#endif
#ifdef __TANDEM
#include <floss.h>
#endif
#if MSDOS_COMPILER==WIN32C || OS2
#include <io.h>
#endif
#if MSDOS_COMPILER==DJGPPC
#include <io.h>
#include <sys/exceptn.h>
@@ -104,17 +116,50 @@ void free();
* Simple lowercase test which can be used during option processing
* (before options are parsed which might tell us what charset to use).
*/
#define SIMPLE_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define SIMPLE_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
#define SIMPLE_TO_UPPER(c) ((c) - 'a' + 'A')
#define SIMPLE_TO_LOWER(c) ((c) - 'A' + 'a')
#define ASCII_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define ASCII_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
#define ASCII_TO_UPPER(c) ((c) - 'a' + 'A')
#define ASCII_TO_LOWER(c) ((c) - 'A' + 'a')
#if !HAVE_UPPER_LOWER
#define isupper(c) SIMPLE_IS_UPPER(c)
#define islower(c) SIMPLE_IS_LOWER(c)
#define toupper(c) SIMPLE_TO_UPPER(c)
#define tolower(c) SIMPLE_TO_LOWER(c)
#undef IS_UPPER
#undef IS_LOWER
#undef TO_UPPER
#undef TO_LOWER
#undef IS_SPACE
#undef IS_DIGIT
#if HAVE_WCTYPE
#define IS_UPPER(c) iswupper(c)
#define IS_LOWER(c) iswlower(c)
#define TO_UPPER(c) towupper(c)
#define TO_LOWER(c) towlower(c)
#else
#if HAVE_UPPER_LOWER
#define IS_UPPER(c) isupper((unsigned char) (c))
#define IS_LOWER(c) islower((unsigned char) (c))
#define TO_UPPER(c) toupper((unsigned char) (c))
#define TO_LOWER(c) tolower((unsigned char) (c))
#else
#define IS_UPPER(c) ASCII_IS_UPPER(c)
#define IS_LOWER(c) ASCII_IS_LOWER(c)
#define TO_UPPER(c) ASCII_TO_UPPER(c)
#define TO_LOWER(c) ASCII_TO_LOWER(c)
#endif
#endif
#ifdef isspace
#define IS_SPACE(c) isspace((unsigned char)(c))
#else
#define IS_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f')
#endif
#ifdef isdigit
#define IS_DIGIT(c) isdigit((unsigned char)(c))
#else
#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
#endif
#define IS_CSI_START(c) ((c) == ESC || (!utf_mode && ((unsigned char)(c)) == CSI))
#ifndef NULL
#define NULL 0
@@ -137,8 +182,28 @@ void free();
#endif
#endif
#if HAVE_SNPRINTF
#define SNPRINTF1(str, size, fmt, v1) snprintf((str), (size), (fmt), (v1))
#define SNPRINTF2(str, size, fmt, v1, v2) snprintf((str), (size), (fmt), (v1), (v2))
#define SNPRINTF3(str, size, fmt, v1, v2, v3) snprintf((str), (size), (fmt), (v1), (v2), (v3))
#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) snprintf((str), (size), (fmt), (v1), (v2), (v3), (v4))
#else
/* Use unsafe sprintf if we don't have snprintf. */
#define SNPRINTF1(str, size, fmt, v1) sprintf((str), (fmt), (v1))
#define SNPRINTF2(str, size, fmt, v1, v2) sprintf((str), (fmt), (v1), (v2))
#define SNPRINTF3(str, size, fmt, v1, v2, v3) sprintf((str), (fmt), (v1), (v2), (v3))
#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) sprintf((str), (fmt), (v1), (v2), (v3), (v4))
#endif
#define BAD_LSEEK ((off_t)-1)
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
@@ -153,9 +218,11 @@ void free();
/*
* Special types and constants.
*/
typedef unsigned long LWCHAR;
typedef off_t POSITION;
typedef off_t LINENUM;
#define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */
#define MAX_UTF_CHAR_LEN 6 /* Max bytes in one UTF-8 char */
#define NULL_POSITION ((POSITION)(-1))
@@ -248,6 +315,10 @@ struct textlist
#define READ_INTR (-2)
/* A fraction is represented by an int n; the fraction is n/NUM_FRAC_DENOM */
#define NUM_FRAC_DENOM 1000000
#define NUM_LOG_FRAC_DENOM 6
/* How quiet should we be? */
#define NOT_QUIET 0 /* Ring bell at eof and for errors */
#define LITTLE_QUIET 1 /* Ring bell only for errors */
@@ -264,14 +335,14 @@ struct textlist
#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
/* How should we search? */
#define SRCH_FORW 000001 /* Search forward from current position */
#define SRCH_BACK 000002 /* Search backward from current position */
#define SRCH_NO_MOVE 000004 /* Highlight, but don't move */
#define SRCH_FIND_ALL 000010 /* Find and highlight all matches */
#define SRCH_NO_MATCH 000100 /* Search for non-matching lines */
#define SRCH_PAST_EOF 000200 /* Search past end-of-file, into next file */
#define SRCH_FIRST_FILE 000400 /* Search starting at the first file */
#define SRCH_NO_REGEX 001000 /* 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_REVERSE(t) (((t) & SRCH_FORW) ? \
(((t) & ~SRCH_FORW) | SRCH_BACK) : \
@@ -289,13 +360,15 @@ struct textlist
#define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */
/* Special chars used to tell put_line() to do something special */
/* Special char bit-flags used to tell put_line() to do something special */
#define AT_NORMAL (0)
#define AT_UNDERLINE (1)
#define AT_BOLD (2)
#define AT_BLINK (3)
#define AT_INVIS (4)
#define AT_STANDOUT (5)
#define AT_UNDERLINE (1 << 0)
#define AT_BOLD (1 << 1)
#define AT_BLINK (1 << 2)
#define AT_STANDOUT (1 << 3)
#define AT_ANSI (1 << 4) /* Content-supplied "ANSI" escape sequence */
#define AT_BINARY (1 << 5) /* LESS*BINFMT representation */
#define AT_HILITE (1 << 6) /* Internal highlights (e.g., for search) */
#if '0' == 240
#define IS_EBCDIC_HOST 1
@@ -370,6 +443,7 @@ struct textlist
#endif /* IS_EBCDIC_HOST */
#define ESC CONTROL('[')
#define CSI ((unsigned char)'\233')
#if _OSK_MWC32
#define LSIGNAL(sig,func) os9_signal(sig,func)
@@ -400,6 +474,9 @@ struct textlist
#define QUIT_ERROR 1
#define QUIT_SAVED_STATUS (-1)
#define FOLLOW_DESC 0
#define FOLLOW_NAME 1
/* filestate flags */
#define CH_CANSEEK 001
#define CH_KEEPOPEN 002
+4 -3
View File
@@ -115,8 +115,8 @@
Number of buffers.
-B ........ --auto-buffers
Don't automatically allocate buffers for pipes.
-c -C .... --clear-screen --CLEAR-SCREEN
Repaint by scrolling/clearing.
-c ........ --clear-screen
Repaint by clearing rather than scrolling.
-d ........ --dumb
Dumb terminal.
-D [_x_n_._n] . --color=_x_n_._n
@@ -148,7 +148,7 @@
-m -M .... --long-prompt --LONG-PROMPT
Set prompt style.
-n -N .... --line-numbers --LINE-NUMBERS
Use line numbers.
Don't use line numbers.
-o [_f_i_l_e] . --log-file=[_f_i_l_e]
Copy to log file (standard input only).
-O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e]
@@ -218,3 +218,4 @@
SHIFT-TAB ESC-TAB Complete filename & reverse cycle.
CNTL-L Complete filename, list all.
+1002 -1518
View File
File diff suppressed because it is too large Load Diff
+285 -204
View File
@@ -1,24 +1,24 @@
.TH LESS 1 "Version 382: 03 Feb 2004"
.TH LESS 1 "Version 418: 02 Jan 2008"
.SH NAME
less \- opposite of more
.SH SYNOPSIS
.B "less -?"
.B "less \-?"
.br
.B "less --help"
.B "less \-\-help"
.br
.B "less -V"
.B "less \-V"
.br
.B "less --version"
.B "less \-\-version"
.br
.B "less [-[+]aBcCdeEfFgGiIJLmMnNqQrRsSuUVwWX~]"
.B "less [\-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]"
.br
.B " [-b \fIspace\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]"
.B " [\-b \fIspace\fP] [\-h \fIlines\fP] [\-j \fIline\fP] [\-k \fIkeyfile\fP]"
.br
.B " [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP] [-t \fItag\fP]"
.B " [\-{oO} \fIlogfile\fP] [\-p \fIpattern\fP] [\-P \fIprompt\fP] [\-t \fItag\fP]"
.br
.B " [-T \fItagsfile\fP] [-x \fItab\fP,...] [-y \fIlines\fP] [-[z] \fIlines\fP]"
.B " [\-T \fItagsfile\fP] [\-x \fItab\fP,...] [\-y \fIlines\fP] [\-[z] \fIlines\fP]"
.br
.B " [-# \fIshift\fP] [+[+]\fIcmd\fP] [--] [\fIfilename\fP]..."
.B " [\-# \fIshift\fP] [+[+]\fIcmd\fP] [\-\-] [\fIfilename\fP]..."
.br
(See the OPTIONS section for alternate option syntax with long option names.)
@@ -57,7 +57,7 @@ two character sequence "ESCAPE", then "v".
Help: display a summary of these commands.
If you forget all the other commands, remember this one.
.IP "SPACE or ^V or f or ^F"
Scroll forward N lines, default one window (see option -z below).
Scroll forward N lines, default one window (see option \-z below).
If N is more than the screen size, only the final screenful is displayed.
Warning: some systems use ^V as a special literalization character.
.IP "z"
@@ -73,7 +73,7 @@ Scroll forward N lines, default one half of the screen size.
If N is specified, it becomes the new default for
subsequent d and u commands.
.IP "b or ^B or ESC-v"
Scroll backward N lines, default one window (see option -z below).
Scroll backward N lines, default one window (see option \-z below).
If N is more than the screen size, only the final screenful is displayed.
.IP "w"
Like ESC-v, but if N is specified, it becomes the new window size.
@@ -87,14 +87,14 @@ If N is specified, it becomes the new default for
subsequent d and u commands.
.IP "ESC-) or RIGHTARROW"
Scroll horizontally right N characters, default half the screen width
(see the -# option).
(see the \-# option).
If a number N is specified, it becomes the default for future RIGHTARROW
and LEFTARROW commands.
While the text is scrolled, it acts as though the -S option
While the text is scrolled, it acts as though the \-S option
(chop lines) were in effect.
.IP "ESC-( or LEFTARROW"
Scroll horizontally left N characters, default half the screen width
(see the -# option).
(see the \-# option).
If a number N is specified, it becomes the default for future RIGHTARROW
and LEFTARROW commands.
.IP "r or ^R or ^L"
@@ -108,7 +108,7 @@ end of file is reached.
Normally this command would be used when already at the end of the file.
It is a way to monitor the tail of a file which is growing
while it is being viewed.
(The behavior is similar to the "tail -f" command.)
(The behavior is similar to the "tail \-f" command.)
.IP "g or < or ESC-<"
Go to line N in the file, default 1 (beginning of file).
(Warning: this may be slow if N is large.)
@@ -119,7 +119,9 @@ or if N is not specified and
standard input, rather than a file, is being read.)
.IP "p or %"
Go to a position N percent into the file.
N should be between 0 and 100.
N should be between 0 and 100, and may contain a decimal point.
.IP "P"
Go to the line containing byte offset N in the file.
.IP "{"
If a left curly bracket appears in the top line displayed
on the screen,
@@ -175,9 +177,9 @@ Same as single quote.
Search forward in the file for the N-th line containing the pattern.
N defaults to 1.
The pattern is a regular expression, as recognized by
.I ed.
the regular expression library supplied by your system.
The search starts at the second line displayed
(but see the -a and -j options, which change this).
(but see the \-a and \-j options, which change this).
.sp
Certain characters are special
if entered at the beginning of the pattern;
@@ -194,7 +196,7 @@ the search continues in the next file in the command line list.
Begin the search at the first line of the FIRST file
in the command line list,
regardless of what is currently displayed on the screen
or the settings of the -a or -j options.
or the settings of the \-a or \-j options.
.IP "^K"
Highlight any text which matches the pattern on the current screen,
but don't move to the first match (KEEP current position).
@@ -219,7 +221,7 @@ the search continues in the previous file in the command line list.
Begin the search at the last line of the last file
in the command line list,
regardless of what is currently displayed on the screen
or the settings of the -a or -j options.
or the settings of the \-a or \-j options.
.IP "^K"
As in forward searches.
.IP "^R"
@@ -252,7 +254,7 @@ Turn off highlighting of strings matching the current search pattern.
If highlighting is already off because of a previous ESC-u command,
turn highlighting back on.
Any search command will also turn highlighting back on.
(Highlighting can also be disabled by toggling the -G option;
(Highlighting can also be disabled by toggling the \-G option;
in that case search commands do not turn highlighting back on.)
.IP ":e [filename]"
Examine a new file.
@@ -272,7 +274,7 @@ If the filename consists of several files, they are all inserted into
the list of files and the first one is examined.
If the filename contains one or more spaces,
the entire filename should be enclosed in double quotes
(also see the -" option).
(also see the \-" option).
.IP "^X^V or E"
Same as :e.
Warning: some systems use ^V as a special literalization character.
@@ -306,8 +308,8 @@ this will change the setting of that option
and print a message describing the new setting.
If a ^P (CONTROL-P) is entered immediately after the dash,
the setting of the option is changed but no message is printed.
If the option letter has a numeric value (such as -b or -h),
or a string value (such as -P or -t),
If the option letter has a numeric value (such as \-b or \-h),
or a string value (such as \-P or \-t),
a new value may be entered after the option letter.
If no new value is entered, a message describing
the current setting is printed and nothing is changed.
@@ -401,17 +403,17 @@ either a dash followed by a single letter,
or two dashes followed by a long option name.
A long option name may be abbreviated as long as
the abbreviation is unambiguous.
For example, --quit-at-eof may be abbreviated --quit, but not
--qui, since both --quit-at-eof and --quiet begin with --qui.
Some long option names are in uppercase, such as --QUIT-AT-EOF, as
distinct from --quit-at-eof.
For example, \-\-quit-at-eof may be abbreviated \-\-quit, but not
--qui, since both \-\-quit-at-eof and \-\-quiet begin with \-\-qui.
Some long option names are in uppercase, such as \-\-QUIT-AT-EOF, as
distinct from \-\-quit-at-eof.
Such option names need only have their first letter capitalized;
the remainder of the name may be in either case.
For example, --Quit-at-eof is equivalent to --QUIT-AT-EOF.
For example, \-\-Quit-at-eof is equivalent to \-\-QUIT-AT-EOF.
.PP
Options are also taken from the environment variable "LESS".
For example,
to avoid typing "less -options ..." each time
to avoid typing "less \-options ..." each time
.I less
is invoked, you might tell
.I csh:
@@ -432,62 +434,63 @@ If an option appears in the LESS variable, it can be reset
to its default value on the command line by beginning the command
line option with "\-+".
.sp
For options like -P or -D which take a following string,
For options like \-P or \-D which take a following string,
a dollar sign ($) must be used to signal the end of the string.
For example, to set two -D options on MS-DOS, you must have
For example, to set two \-D options on MS-DOS, you must have
a dollar sign between them, like this:
.sp
LESS="-Dn9.1$-Ds4.1"
.sp
.IP "-? or --help"
.IP "\-? or \-\-help"
This option displays a summary of the commands accepted by
.I less
(the same as the h command).
(Depending on how your shell interprets the question mark,
it may be necessary to quote the question mark, thus: "-\e?".)
.IP "-a or --search-skip-screen"
it may be necessary to quote the question mark, thus: "\-\e?".)
.IP "\-a or \-\-search-skip-screen"
Causes searches to start after the last line
displayed on the screen,
thus skipping all lines displayed on the screen.
By default, searches start at the second line on the screen
(or after the last found line; see the -j option).
.IP "-b\fIn\fP or --buffers=\fIn\fP"
(or after the last found line; see the \-j option).
.IP "\-b\fIn\fP or \-\-buffers=\fIn\fP"
Specifies the amount of buffer space
.I less
will use for each file, in units of kilobytes (1024 bytes).
By default 64K of buffer space is used for each file
(unless the file is a pipe; see the -B option).
The -b option specifies instead that \fIn\fP kilobytes of
(unless the file is a pipe; see the \-B option).
The \-b option specifies instead that \fIn\fP kilobytes of
buffer space should be used for each file.
If \fIn\fP is -1, buffer space is unlimited; that is,
the entire file is read into memory.
.IP "-B or --auto-buffers"
If \fIn\fP is \-1, buffer space is unlimited; that is,
the entire file can be read into memory.
.IP "\-B or \-\-auto-buffers"
By default, when data is read from a pipe,
buffers are allocated automatically as needed.
If a large amount of data is read from the pipe, this can cause
a large amount of memory to be allocated.
The -B option disables this automatic allocation of buffers for pipes,
The \-B option disables this automatic allocation of buffers for pipes,
so that only 64K
(or the amount of space specified by the -b option)
(or the amount of space specified by the \-b option)
is used for the pipe.
Warning: use of -B can result in erroneous display, since only the
most recently viewed part of the file is kept in memory;
Warning: use of \-B can result in erroneous display, since only the
most recently viewed part of the piped data is kept in memory;
any earlier data is lost.
.IP "-c or --clear-screen"
.IP "\-c or \-\-clear-screen"
Causes full screen repaints to be painted from the top line down.
By default,
full screen repaints are done by scrolling from the bottom of the screen.
.IP "-C or --CLEAR-SCREEN"
The -C option is like -c, but the screen is cleared before it is repainted.
.IP "-d or --dumb"
The -d option suppresses the error message
.IP "\-C or \-\-CLEAR-SCREEN"
Same as \-c, for compatibility with older versions of
.I less.
.IP "\-d or \-\-dumb"
The \-d option suppresses the error message
normally displayed if the terminal is dumb;
that is, lacks some important capability,
such as the ability to clear the screen or scroll backward.
The -d option does not otherwise change the behavior of
The \-d option does not otherwise change the behavior of
.I less
on a dumb terminal.
.IP "-D\fBx\fP\fIcolor\fP or --color=\fBx\fP\fIcolor\fP"
.IP "\-D\fBx\fP\fIcolor\fP or \-\-color=\fBx\fP\fIcolor\fP"
[MS-DOS only]
Sets the color of the text displayed.
\fBx\fP is a single character which selects the type of text whose color is
@@ -496,7 +499,7 @@ being set: n=normal, s=standout, d=bold, u=underlined, k=blink.
The first number selects the foreground color and the second selects
the background color of the text.
A single number \fIN\fP is the same as \fIN.0\fP.
.IP "-e or --quit-at-eof"
.IP "\-e or \-\-quit-at-eof"
Causes
.I less
to automatically exit
@@ -504,88 +507,106 @@ the second time it reaches end-of-file.
By default, the only way to exit
.I less
is via the "q" command.
.IP "-E or --QUIT-AT-EOF"
.IP "\-E or \-\-QUIT-AT-EOF"
Causes
.I less
to automatically exit the first time it reaches end-of-file.
.IP "-f or --force"
.IP "\-f or \-\-force"
Forces non-regular files to be opened.
(A non-regular file is a directory or a device special file.)
Also suppresses the warning message when a binary file is opened.
By default,
.I less
will refuse to open non-regular files.
.IP "-F or --quit-if-one-screen"
Note that some operating systems will not allow directories
to be read, even if \-f is set.
.IP "\-F or \-\-quit-if-one-screen"
Causes
.I less
to automatically exit
if the entire file can be displayed on the first screen.
.IP "-g or --hilite-search"
.IP "\-g or \-\-hilite-search"
Normally,
.I less
will highlight ALL strings which match the last search command.
The -g option changes this behavior to highlight only the particular string
The \-g option changes this behavior to highlight only the particular string
which was found by the last search command.
This can cause
.I less
to run somewhat faster than the default.
.IP "-G or --HILITE-SEARCH"
The -G option suppresses all highlighting of strings found by search commands.
.IP "-h\fIn\fP or ---max-back-scroll=\fIn\fP"
.IP "\-G or \-\-HILITE-SEARCH"
The \-G option suppresses all highlighting of strings found by search commands.
.IP "\-h\fIn\fP or \-\-max-back-scroll=\fIn\fP"
Specifies a maximum number of lines to scroll backward.
If it is necessary to scroll backward more than \fIn\fP lines,
the screen is repainted in a forward direction instead.
(If the terminal does not have the ability to scroll
backward, -h0 is implied.)
.IP "-i or --ignore-case"
backward, \-h0 is implied.)
.IP "\-i or \-\-ignore-case"
Causes searches to ignore case; that is,
uppercase and lowercase are considered identical.
This option is ignored if any uppercase letters
appear in the search pattern;
in other words,
if a pattern contains uppercase letters, then that search does not ignore case.
.IP "-I or --IGNORE-CASE"
Like -i, but searches ignore case even if
.IP "\-I or \-\-IGNORE-CASE"
Like \-i, but searches ignore case even if
the pattern contains uppercase letters.
.IP "-j\fIn\fP or --jump-target=\fIn\fP"
.IP "\-j\fIn\fP or \-\-jump-target=\fIn\fP"
Specifies a line on the screen where the "target" line
is to be positioned.
A target line is the object of a text search,
tag search, jump to a line number,
jump to a file percentage, or jump to a marked position.
The screen line is specified by a number: the top line on the screen
The target line is the line specified by any command to
search for a pattern, jump to a line number,
jump to a file percentage or jump to a tag.
The screen line may be specified by a number: the top line on the screen
is 1, the next is 2, and so on.
The number may be negative to specify a line relative to the bottom
of the screen: the bottom line on the screen is -1, the second
to the bottom is -2, and so on.
If the -j option is used, searches begin at the line immediately
after the target line.
For example, if "-j4" is used, the target line is the
fourth line on the screen, so searches begin at the fifth line
of the screen: the bottom line on the screen is \-1, the second
to the bottom is \-2, and so on.
Alternately, the screen line may be specified as a fraction of the height
of the screen, starting with a decimal point: .5 is in the middle of the
screen, .3 is three tenths down from the first line, and so on.
If the line is specified as a fraction, the actual line number
is recalculated if the terminal window is resized, so that the
target line remains at the specified fraction of the screen height.
If any form of the \-j option is used,
forward searches begin at the line immediately after the target line,
and backward searches begin at the target line.
For example, if "\-j4" is used, the target line is the
fourth line on the screen, so forward searches begin at the fifth line
on the screen.
.IP "-J or --status-column"
.IP "\-J or \-\-status-column"
Displays a status column at the left edge of the screen.
The status column shows the lines that matched the current search.
The status column is also used if the -w or -W option is in effect.
.IP "-k\fIfilename\fP or --lesskey-file=\fIfilename\fP"
The status column is also used if the \-w or \-W option is in effect.
.IP "\-k\fIfilename\fP or \-\-lesskey-file=\fIfilename\fP"
Causes
.I less
to open and interpret the named file as a
.I lesskey
(1) file.
Multiple -k options may be specified.
Multiple \-k options may be specified.
If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or
if a lesskey file is found in a standard place (see KEY BINDINGS),
it is also used as a
.I lesskey
file.
.IP "-L or --no-lessopen"
.IP "\-K or \-\-quit-on-intr"
Causes
.I less
to exit immediately when an interrupt character (usually ^C) is typed.
Normally, an interrupt character causes
.I less
to stop whatever it is doing and return to its command prompt.
Note that use of this option makes it impossible to return to the
command prompt from the "F" command.
.IP "\-L or \-\-no-lessopen"
Ignore the LESSOPEN environment variable
(see the INPUT PREPROCESSOR section below).
This option can be set from within \fIless\fP,
but it will apply only to files opened subsequently, not to the
file which is currently open.
.IP "-m or --long-prompt"
.IP "\-m or \-\-long-prompt"
Causes
.I less
to prompt verbosely (like \fImore\fP),
@@ -593,25 +614,25 @@ with the percent into the file.
By default,
.I less
prompts with a colon.
.IP "-M or --LONG-PROMPT"
.IP "\-M or \-\-LONG-PROMPT"
Causes
.I less
to prompt even more verbosely than
.I more.
.IP "-n or --line-numbers"
.IP "\-n or \-\-line-numbers"
Suppresses line numbers.
The default (to use line numbers) may cause
.I less
to run more slowly in some cases, especially with a very large input file.
Suppressing line numbers with the -n option will avoid this problem.
Suppressing line numbers with the \-n option will avoid this problem.
Using line numbers means: the line number will be displayed in the verbose
prompt and in the = command,
and the v command will pass the current line number to the editor
(see also the discussion of LESSEDIT in PROMPTS below).
.IP "-N or --LINE-NUMBERS"
.IP "\-N or \-\-LINE-NUMBERS"
Causes a line number to be displayed at the beginning of
each line in the display.
.IP "-o\fIfilename\fP or --log-file=\fIfilename\fP"
.IP "\-o\fIfilename\fP or \-\-log-file=\fIfilename\fP"
Causes
.I less
to copy its input to the named file as it is being viewed.
@@ -620,24 +641,24 @@ not an ordinary file.
If the file already exists,
.I less
will ask for confirmation before overwriting it.
.IP "-O\fIfilename\fP or --LOG-FILE=\fIfilename\fP"
The -O option is like -o, but it will overwrite an existing
.IP "\-O\fIfilename\fP or \-\-LOG-FILE=\fIfilename\fP"
The \-O option is like \-o, but it will overwrite an existing
file without asking for confirmation.
.sp
If no log file has been specified,
the -o and -O options can be used from within
the \-o and \-O options can be used from within
.I less
to specify a log file.
Without a file name, they will simply report the name of the log file.
The "s" command is equivalent to specifying -o from within
The "s" command is equivalent to specifying \-o from within
.I less.
.IP "-p\fIpattern\fP or --pattern=\fIpattern\fP"
The -p option on the command line is equivalent to
.IP "\-p\fIpattern\fP or \-\-pattern=\fIpattern\fP"
The \-p option on the command line is equivalent to
specifying +/\fIpattern\fP;
that is, it tells
.I less
to start at the first occurrence of \fIpattern\fP in the file.
.IP "-P\fIprompt\fP or --prompt=\fIprompt\fP"
.IP "\-P\fIprompt\fP or \-\-prompt=\fIprompt\fP"
Provides a way to tailor the three prompt
styles to your own preference.
This option would normally be put in the LESS environment
@@ -648,15 +669,15 @@ Such an option must either be the last option in the LESS variable,
or be terminated by a dollar sign.
-Ps followed by a string changes the default (short) prompt
to that string.
-Pm changes the medium (-m) prompt.
-PM changes the long (-M) prompt.
-Pm changes the medium (\-m) prompt.
-PM changes the long (\-M) prompt.
-Ph changes the prompt for the help screen.
-P= changes the message printed by the = command.
-Pw changes the message printed while waiting for data (in the F command).
All prompt strings consist of a sequence of
letters and special escape sequences.
See the section on PROMPTS for more details.
.IP "-q or --quiet or --silent"
.IP "\-q or \-\-quiet or \-\-silent"
Causes moderately "quiet" operation:
the terminal bell is not rung
if an attempt is made to scroll past the end of the file
@@ -665,50 +686,54 @@ If the terminal has a "visual bell", it is used instead.
The bell will be rung on certain other errors,
such as typing an invalid character.
The default is to ring the terminal bell in all such cases.
.IP "-Q or --QUIET or --SILENT"
.IP "\-Q or \-\-QUIET or \-\-SILENT"
Causes totally "quiet" operation:
the terminal bell is never rung.
.IP "-r or --raw-control-chars"
.IP "\-r or \-\-raw-control-chars"
Causes "raw" control characters to be displayed.
The default is to display control characters using the caret notation;
for example, a control-A (octal 001) is displayed as "^A".
Warning: when the -r option is used,
Warning: when the \-r option is used,
.I less
cannot keep track of the actual appearance of the screen
(since this depends on how the screen responds to
each type of control character).
Thus, various display problems may result,
such as long lines being split in the wrong place.
.IP "-R or --RAW-CONTROL-CHARS"
Like -r, but tries to keep track of the screen appearance where possible.
This works only if the input consists of normal text and possibly some
ANSI "color" escape sequences, which are sequences of the form:
.IP "\-R or \-\-RAW-CONTROL-CHARS"
Like \-r, but only ANSI "color" escape sequences are output in "raw" form.
Unlike \-r, the screen appearance is maintained correctly in most cases.
ANSI "color" escape sequences are sequences of the form:
.sp
ESC [ ... m
.sp
where the "..." is zero or more characters other than "m".
where the "..." is zero or more color specification characters
For the purpose of keeping track of screen appearance,
all control characters and all ANSI color escape sequences are
assumed to not move the cursor.
ANSI color escape sequences are assumed to not move the cursor.
You can make
.I less
think that characters other than "m" can end ANSI color escape sequences
by setting the environment variable LESSANSIENDCHARS to the list of
characters which can end a color escape sequence.
.IP "-s or --squeeze-blank-lines"
And you can make
.I less
think that characters other than the standard ones may appear between
the ESC and the m by setting the environment variable LESSANSIMIDCHARS
to the list of characters which can appear.
.IP "\-s or \-\-squeeze-blank-lines"
Causes consecutive blank lines to be squeezed into a single blank line.
This is useful when viewing
.I nroff
output.
.IP "-S or --chop-long-lines"
.IP "\-S or \-\-chop-long-lines"
Causes lines longer than the screen width to be
chopped rather than folded.
That is, the portion of a long line that does not fit in
the screen width is not shown.
The default is to fold long lines; that is, display the remainder
on the next line.
.IP "-t\fItag\fP or --tag=\fItag\fP"
The -t option, followed immediately by a TAG,
.IP "\-t\fItag\fP or \-\-tag=\fItag\fP"
The \-t option, followed immediately by a TAG,
will edit the file containing that tag.
For this to work, tag information must be available;
for example, there may be a file in the current directory called "tags",
@@ -720,22 +745,22 @@ the name of a command compatible with
.I global
(1), and that command is executed to find the tag.
(See http://www.gnu.org/software/global/global.html).
The -t option may also be specified from within
The \-t option may also be specified from within
.I less
(using the \- command) as a way of examining a new file.
The command ":t" is equivalent to specifying -t from within
The command ":t" is equivalent to specifying \-t from within
.I less.
.IP "-T\fItagsfile\fP or --tag-file=\fItagsfile\fP"
.IP "\-T\fItagsfile\fP or \-\-tag-file=\fItagsfile\fP"
Specifies a tags file to be used instead of "tags".
.IP "-u or --underline-special"
.IP "\-u or \-\-underline-special"
Causes backspaces and carriage returns to be treated as printable characters;
that is, they are sent to the terminal when they appear in the input.
.IP "-U or --UNDERLINE-SPECIAL"
.IP "\-U or \-\-UNDERLINE-SPECIAL"
Causes backspaces, tabs and carriage returns to be
treated as control characters;
that is, they are handled as specified by the -r option.
that is, they are handled as specified by the \-r option.
.sp
By default, if neither -u nor -U is given,
By default, if neither \-u nor \-U is given,
backspaces which appear adjacent to an underscore character
are treated specially:
the underlined text is displayed
@@ -746,25 +771,25 @@ the overstruck text is printed
using the terminal's hardware boldface capability.
Other backspaces are deleted, along with the preceding character.
Carriage returns immediately followed by a newline are deleted.
other carriage returns are handled as specified by the -r option.
other carriage returns are handled as specified by the \-r option.
Text which is overstruck or underlined can be searched for
if neither -u nor -U is in effect.
.IP "-V or --version"
if neither \-u nor \-U is in effect.
.IP "\-V or \-\-version"
Displays the version number of
.I less.
.IP "-w or --hilite-unread"
.IP "\-w or \-\-hilite-unread"
Temporarily highlights the first "new" line after a forward movement
of a full page.
The first "new" line is the line immediately following the line previously
at the bottom of the screen.
Also highlights the target line after a g or p command.
The highlight is removed at the next command which causes movement.
The entire line is highlighted, unless the -J option is in effect,
The entire line is highlighted, unless the \-J option is in effect,
in which case only the status column is highlighted.
.IP "-W or --HILITE-UNREAD"
Like -w, but temporarily highlights the first new line after any
.IP "\-W or \-\-HILITE-UNREAD"
Like \-w, but temporarily highlights the first new line after any
forward movement command larger than one line.
.IP "-x\fIn\fP,... or --tabs=\fIn\fP,..."
.IP "\-x\fIn\fP,... or \-\-tabs=\fIn\fP,..."
Sets tab stops.
If only one \fIn\fP is specified, tab stops are set at multiples of \fIn\fP.
If multiple values separated by commas are specified, tab stops
@@ -772,38 +797,33 @@ are set at those positions, and then continue with the same spacing as the
last two.
For example, \fI-x9,17\fP will set tabs at positions 9, 17, 25, 33, etc.
The default for \fIn\fP is 8.
.IP "-X or --no-init"
.IP "\-X or \-\-no-init"
Disables sending the termcap initialization and deinitialization strings
to the terminal.
This is sometimes desirable if the deinitialization string does
something unnecessary, like clearing the screen.
.IP "--no-keypad"
Disables sending the keypad initialization and deinitialization strings
to the terminal.
This is sometimes useful if the keypad strings make the numeric
keypad behave in an undesirable manner.
.IP "-y\fIn\fP or --max-forw-scroll=\fIn\fP"
.IP "\-y\fIn\fP or \-\-max-forw-scroll=\fIn\fP"
Specifies a maximum number of lines to scroll forward.
If it is necessary to scroll forward more than \fIn\fP lines,
the screen is repainted instead.
The -c or -C option may be used to repaint from the top of
The \-c or \-C option may be used to repaint from the top of
the screen if desired.
By default, any forward movement causes scrolling.
.IP "-[z]\fIn\fP or --window=\fIn\fP"
.IP "\-[z]\fIn\fP or \-\-window=\fIn\fP"
Changes the default scrolling window size to \fIn\fP lines.
The default is one screenful.
The z and w commands can also be used to change the window size.
The "z" may be omitted for compatibility with
The "z" may be omitted for compatibility with some versions of
.I more.
If the number
.I n
is negative, it indicates
.I n
lines less than the current screen size.
For example, if the screen is 24 lines, \fI-z-4\fP sets the
For example, if the screen is 24 lines, \fI\-z-4\fP sets the
scrolling window to 20 lines. If the screen is resized to 40 lines,
the scrolling window automatically changes to 36 lines.
.IP "-\fI\(dqcc\fP\ or\ --quotes=\fIcc\fP"
.IP "\-\fI\(dqcc\fP\ or\ \-\-quotes=\fIcc\fP"
Changes the filename quoting character.
This may be necessary if you are trying to name a file
which contains both spaces and quote characters.
@@ -816,19 +836,37 @@ and the close quote to the second character.
Filenames containing a space should then be preceded by the open quote
character and followed by the close quote character.
Note that even after the quote characters are changed, this option
remains -" (a dash followed by a double quote).
.IP "-~ or --tilde"
remains \-" (a dash followed by a double quote).
.IP "\-~ or \-\-tilde"
Normally lines after end of file are displayed as a single tilde (~).
This option causes lines after end of file to be displayed as blank lines.
.IP "-# or --shift"
.IP "\-# or \-\-shift"
Specifies the default number of positions to scroll horizontally
in the RIGHTARROW and LEFTARROW commands.
If the number specified is zero, it sets the default number of
positions to one half of the screen width.
.IP --
A command line argument of "--" marks the end of option arguments.
.IP "\-\-no-keypad"
Disables sending the keypad initialization and deinitialization strings
to the terminal.
This is sometimes useful if the keypad strings make the numeric
keypad behave in an undesirable manner.
.IP "\-\-follow-name"
Normally, if the input file is renamed while an F command is executing,
.I less
will continue to display the contents of the original file despite
its name change.
If \-\-follow-name is specified, during an F command
.I less
will periodically attempt to reopen the file by name.
If the reopen succeeds and the file is a different file from the original
(which means that a new file has been created
with the same name as the original (now renamed) file),
.I less
will display the contents of that new file.
.IP \-\-
A command line argument of "\-\-" marks the end of option arguments.
Any arguments following this are interpreted as filenames.
This can be useful when viewing a file whose name begins with a "-" or "+".
This can be useful when viewing a file whose name begins with a "\-" or "+".
.IP +
If a command line option begins with \fB+\fP,
the remainder of that option is taken to be an initial command to
@@ -852,7 +890,8 @@ or the pattern for a search command),
certain keys can be used to manipulate the command line.
Most commands have an alternate form in [ brackets ] which can be used if
a key does not exist on a particular keyboard.
(The bracketed forms do not work in the MS-DOS version.)
(Note that the forms beginning with ESC do not work
in some MS-DOS and Windows systems because ESC is the line erase character.)
Any of these special keys may be entered literally by preceding
it with the "literal" character, either ^V or ^A.
A backslash itself may also be entered literally by entering two backslashes.
@@ -1019,15 +1058,15 @@ lessopen.sh:
.br
case "$1" in
.br
*.Z) uncompress -c $1 >/tmp/less.$$ 2>/dev/null
*.Z) uncompress -\c $1 >/tmp/less.$$ 2>/dev/null
.br
if [ -s /tmp/less.$$ ]; then
if [ \-s /tmp/less.$$ ]; then
.br
echo /tmp/less.$$
.br
else
.br
rm -f /tmp/less.$$
rm \-f /tmp/less.$$
.br
fi
.br
@@ -1074,7 +1113,7 @@ lesspipe.sh:
.br
case "$1" in
.br
*.Z) uncompress -c $1 2>/dev/null
*.Z) uncompress \-c $1 2>/dev/null
.br
;;
.br
@@ -1087,7 +1126,7 @@ When an input pipe is used, a LESSCLOSE postprocessor can be used,
but it is usually not necessary since there is no replacement file
to clean up.
In this case, the replacement file name passed to the LESSCLOSE
postprocessor is "-".
postprocessor is "\-".
.SH "NATIONAL CHARACTER SETS"
There are three types of characters in the input file:
@@ -1131,8 +1170,12 @@ Selects a Russian character set.
Selects a character set appropriate for NeXT computers.
.IP utf-8
Selects the UTF-8 encoding of the ISO 10646 character set.
UTF-8 is special in that it supports multi-byte characters in the input file.
It is the only character set that supports multi-byte characters.
.IP windows
Selects a character set appropriate for Microsoft Windows (cp 1251).
.PP
In special cases, it may be desired to tailor
In rare cases, it may be desired to tailor
.I less
to use a character set other than the ones definable by LESSCHARSET.
In this case, the environment variable LESSCHARDEF can be used
@@ -1173,7 +1216,8 @@ to each of the possible values for LESSCHARSET:
next\ \ 8bcccbcc18b95.bb125.bb
.PP
If neither LESSCHARSET nor LESSCHARDEF is set,
but the string "UTF-8" is found in the LC_ALL, LC_TYPE or LANG
but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8"
is found in the LC_ALL, LC_TYPE or LANG
environment variables, then the default character set is utf-8.
.PP
If that string is not found, but your system supports the
@@ -1205,10 +1249,28 @@ printf-style escape sequence (a % followed by x, X, o, d, etc.).
For example, if LESSBINFMT is "*u[%x]", binary characters
are displayed in underlined hexadecimal surrounded by brackets.
The default if no LESSBINFMT is specified is "*s<%X>".
The default if no LESSBINFMT is specified is "*s<%02X>".
Warning: the result of expanding the character via LESSBINFMT must
be less than 31 characters.
.PP
When the character set is utf-8, the LESSUTFBINFMT environment variable
acts similarly to LESSBINFMT but it applies to Unicode code points
that were successfully decoded but are unsuitable for display (e.g.,
unassigned code points).
Its default value is "<U+%04lX>".
Note that LESSUTFBINFMT and LESSBINFMT share their display attribute
setting ("*x") so specifying one will affect both;
LESSUTFBINFMT is read after LESSBINFMT so its setting, if any,
will have priority.
Problematic octets in a UTF-8 file (octets of a truncated sequence,
octets of a complete but non-shortest form sequence, illegal octets,
and stray trailing octets)
are displayed individually using LESSBINFMT so as to facilitate diagnostic
of how the UTF-8 file is ill-formed.
.SH "PROMPTS"
The -P option allows you to tailor the prompt to your preference.
The string given to the -P option replaces the specified prompt string.
The \-P option allows you to tailor the prompt to your preference.
The string given to the \-P option replaces the specified prompt string.
Certain characters in the string are interpreted specially.
The prompt mechanism is rather complicated to provide flexibility,
but the ordinary user need not understand the details of constructing
@@ -1225,7 +1287,7 @@ display is used,
an "m" means use the middle line,
a "b" means use the bottom line,
a "B" means use the line just after the bottom line,
and a "j" means use the "target" line, as specified by the -j option.
and a "j" means use the "target" line, as specified by the \-j option.
.IP "%B"
Replaced by the size of the current input file.
.IP "%c"
@@ -1350,7 +1412,7 @@ followed by the name of the next file, if there is one.
Finally, any trailing spaces are truncated.
This is the default prompt.
For reference, here are the defaults for
the other two prompts (-m and -M respectively).
the other two prompts (\-m and \-M respectively).
Each is broken into two lines here for readability only.
.nf
.sp
@@ -1398,11 +1460,11 @@ the pipe command
the examine command.
.IP "v"
the editing command
.IP "s -o"
.IP "s \-o"
log files
.IP "-k"
.IP "\-k"
use of lesskey files
.IP "-t"
.IP "\-t"
use of tags files
.IP " "
metacharacters in filenames, such as *
@@ -1412,6 +1474,36 @@ filename completion (TAB, ^L)
.PP
Less can also be compiled to be permanently in "secure" mode.
.SH "COMPATIBILITY WITH MORE"
If the environment variable LESS_IS_MORE is set to 1,
or if the program is invoked via a file link named "more",
.I less
behaves (mostly) in conformance with the POSIX "more" command specification.
In this mode, less behaves differently in these ways:
.PP
The \-e option works differently.
If the \-e option is not set,
.I less
behaves as if the \-E option were set.
If the \-e option is set,
.I less
behaves as if the \-e and \-F options were set.
.PP
The \-m option works differently.
If the \-m option is not set, the medium prompt is used,
and it is prefixed with the string "--More--".
If the \-m option is set, the short prompt is used.
.PP
The \-n option acts like the \-z option.
The normal behavior of the \-n option is unavailable in this mode.
.PP
The parameter to the \-p option is taken to be a
.I less
command rather than a search pattern.
.PP
The LESS environment variable is ignored,
and the MORE environment variable is used in its place.
.SH "ENVIRONMENT VARIABLES"
Environment variables may be specified either in the system environment
as usual, or in a
@@ -1447,8 +1539,12 @@ Options which are passed to
.I less
automatically.
.IP LESSANSIENDCHARS
Characters which are assumed to end an ANSI color escape sequence
Characters which may end an ANSI color escape sequence
(default "m").
.IP LESSANSIMIDCHARS
Characters which may appear between the ESC character and the
end character in an ANSI color escape sequence
(default "0123456789;[?!"'#%()*+\ ".
.IP LESSBINFMT
Format for displaying non-printable, non-control characters.
.IP LESSCHARDEF
@@ -1465,10 +1561,21 @@ in filenames on Unix systems.
Editor prototype string (used for the v command).
See discussion under PROMPTS.
.IP LESSGLOBALTAGS
Name of the command used by the -t option to find global tags.
Name of the command used by the \-t option to find global tags.
Normally should be set to "global" if your system has the
.I global
(1) command. If not set, global tags are not used.
.IP LESSHISTFILE
Name of the history file used to remember search commands and
shell commands between invocations of
.I less.
If set to "\-" or "/dev/null", a history file is not used.
The default is "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on
DOS and Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini"
on OS/2 systems.
.IP LESSHISTSIZE
The maximum number of commands to save in the history file.
The default is 100.
.IP LESSKEY
Name of the default lesskey(1) file.
.IP LESSKEY_SYSTEM
@@ -1487,6 +1594,12 @@ Runs less in "secure" mode.
See discussion under SECURITY.
.IP LESSSEPARATOR
String to be appended to a directory name in filename completion.
.IP LESSUTFBINFMT
Format for displaying non-printable Unicode code points.
.IP LESS_IS_MORE
Emulate the
.I more
(1) command.
.IP LINES
Sets the number of lines on the screen.
Takes precedence over the number of lines specified by the TERM variable.
@@ -1508,46 +1621,8 @@ The name of the editor (used for the v command).
.SH "SEE ALSO"
lesskey(1)
.SH WARNINGS
The = command and prompts (unless changed by -P)
report the line numbers of the lines at the top and bottom of the screen,
but the byte and percent of the line after the one at the bottom of the screen.
.PP
If the :e command is used to name more than one file,
and one of the named files has been viewed previously,
the new files may be entered into the list in an unexpected order.
.PP
On certain older terminals (the so-called "magic cookie" terminals),
search highlighting will cause an erroneous display.
On such terminals, search highlighting is disabled by default
to avoid possible problems.
.PP
In certain cases, when search highlighting is enabled and
a search pattern begins with a ^,
more text than the matching string may be highlighted.
(This problem does not occur when less is compiled to use the POSIX
regular expression package.)
.PP
When viewing text containing ANSI color escape sequences using the -R option,
searching will not find text containing an embedded escape sequence.
Also, search highlighting may change the color of some of the text
which follows the highlighted text.
.PP
On some systems,
.I setlocale
claims that ASCII characters 0 thru 31 are control characters
rather than binary characters.
This causes
.I less
to treat some binary files as ordinary, non-binary files.
To workaround this problem, set the environment variable
LESSCHARSET to "ascii" (or whatever character set is appropriate).
.PP
See http://www.greenwoodsoftware.com/less for the latest list of known bugs in this
version of less.
.SH COPYRIGHT
Copyright (C) 2002 Mark Nudelman
Copyright (C) 1984-2007 Mark Nudelman
.PP
less is part of the GNU project and is free software.
You can redistribute it and/or modify it
@@ -1572,6 +1647,12 @@ See the GNU General Public License for more details.
.PP
Mark Nudelman <[email protected]>
.br
Send bug reports or comments to the above address or to [email protected].
See http://www.greenwoodsoftware.com/less/bugs.html for the latest list of known bugs in less.
.br
For more information, see the less homepage at http://www.greenwoodsoftware.com/less.
Send bug reports or comments to the above address or to
.br
[email protected].
.br
For more information, see the less homepage at
.br
http://www.greenwoodsoftware.com/less.
+5 -5
View File
@@ -1,11 +1,11 @@
resource app_version
{
major = 3,
middle = 8,
minor = 2,
major = 4,
middle = 1,
minor = 8,
variety = 5,
internal = 0,
short_info = "382",
long_info = "382 ©2004 The Free Software Foundation"
short_info = "418",
long_info = "418 ©2008 The Free Software Foundation"
};
+2 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -28,7 +28,7 @@
#include "less.h"
static char *version = "$Revision: 1.2 $";
static char *version = "$Revision: 1.11 $";
static int quote_all = 0;
static char openquote = '"';
+49
View File
@@ -0,0 +1,49 @@
LESSECHO(1) LESSECHO(1)
NAME
lessecho - expand metacharacters
SYNOPSIS
lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-a] file ...
DESCRIPTION
lessecho is a program that simply echos its arguments on standard out-
put. But any argument containing spaces is enclosed in quotes.
OPTIONS
A summary of options is included below.
-ox Specifies "x" to be the open quote character.
-cx Specifies "x" to be the close quote character.
-pn Specifies "n" to be the open quote character, as an integer.
-dn Specifies "n" to be the close quote character, as an integer.
-mx Specifies "x" to be a metachar.
-nn Specifies "n" to be a metachar, as an integer.
-ex Specifies "x" to be the escape char for metachars.
-fn Specifies "n" to be the escape char for metachars, as an inte-
ger.
-a Specifies that all arguments are to be quoted. The default is
that only arguments containing spaces are quoted.
SEE ALSO
less(1)
AUTHOR
This manual page was written by Thomas Schoepf <[email protected]>,
for the Debian GNU/Linux system (but may be used by others).
Send bug reports or comments to [email protected].
Version 418: 02 Jan 2008 LESSECHO(1)
+47
View File
@@ -0,0 +1,47 @@
.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 <[email protected]>,
for the Debian GNU/Linux system (but may be used by others).
.PP
Send bug reports or comments to [email protected].
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+117 -219
View File
@@ -1,46 +1,40 @@
LESSKEY(1) LESSKEY(1)
LESSKEY(1) LESSKEY(1)
NNAAMMEE
NAME
lesskey - specify key bindings for less
SSYYNNOOPPSSIISS
lleesssskkeeyy [[--oo oouuttppuutt]] [[----]] [[iinnppuutt]]
lleesssskkeeyy [[----oouuttppuutt==oouuttppuutt]] [[----]] [[iinnppuutt]]
lleesssskkeeyy --VV
lleesssskkeeyy ----vveerrssiioonn
SYNOPSIS
lesskey [-o output] [--] [input]
lesskey [--output=output] [--] [input]
lesskey -V
lesskey --version
DDEESSCCRRIIPPTTIIOONN
_L_e_s_s_k_e_y is used to specify a set of key bindings to be
used by _l_e_s_s_. The input file is a text file which
describes the key bindings, If the input file is "-",
standard input is read. If no input file is specified, a
standard filename is used as the name of the input file,
which depends on the system being used: On Unix systems,
$HOME/.lesskey is used; on MS-DOS systems, $HOME/_lesskey
is used; and on OS/2 systems $HOME/lesskey.ini is used, or
$INIT/lesskey.ini if $HOME is undefined. The output file
is a binary file which is used by _l_e_s_s_. If no output file
is specified, and the environment variable LESSKEY is set,
the value of LESSKEY is used as the name of the output
file. Otherwise, a standard filename is used as the name
of the output file, which depends on the system being
used: On Unix and OS-9 systems, $HOME/.less is used; on
MS-DOS systems, $HOME/_less is used; and on OS/2 systems,
$HOME/less.ini is used, or $INIT/less.ini if $HOME is
undefined. If the output file already exists, _l_e_s_s_k_e_y
will overwrite it.
DESCRIPTION
Lesskey is used to specify a set of key bindings to be used by less.
The input file is a text file which describes the key bindings, If the
input file is "-", standard input is read. If no input file is speci-
fied, a standard filename is used as the name of the input file, which
depends on the system being used: On Unix systems, $HOME/.lesskey is
used; on MS-DOS systems, $HOME/_lesskey is used; and on OS/2 systems
$HOME/lesskey.ini is used, or $INIT/lesskey.ini if $HOME is undefined.
The output file is a binary file which is used by less. If no output
file is specified, and the environment variable LESSKEY is set, the
value of LESSKEY is used as the name of the output file. Otherwise, a
standard filename is used as the name of the output file, which depends
on the system being used: On Unix and OS-9 systems, $HOME/.less is
used; on MS-DOS systems, $HOME/_less is used; and on OS/2 systems,
$HOME/less.ini is used, or $INIT/less.ini if $HOME is undefined. If
the output file already exists, lesskey will overwrite it.
The -V or --version option causes _l_e_s_s_k_e_y to print its
version number and immediately exit. If -V or --version
is present, other options and arguments are ignored.
The -V or --version option causes lesskey to print its version number
and immediately exit. If -V or --version is present, other options and
arguments are ignored.
The input file consists of one or more _s_e_c_t_i_o_n_s_. Each
section starts with a line that identifies the type of
section. Possible sections are:
The input file consists of one or more sections. Each section starts
with a line that identifies the type of section. Possible sections
are:
#command
Defines new command keys.
@@ -50,42 +44,28 @@ DDEESSCCRRIIPPTTIIOONN
#env Defines environment variables.
Blank lines and lines which start with a pound sign (#)
are ignored, except for the special section header lines.
Blank lines and lines which start with a pound sign (#) are ignored,
except for the special section header lines.
CCOOMMMMAANNDD SSEECCTTIIOONN
COMMAND SECTION
The command section begins with the line
#command
If the command section is the first section in the file, this line may
be omitted. The command section consists of lines of the form:
string <whitespace> action [extra-string] <newline>
Version 382: 03 Feb 2004 1
LESSKEY(1) LESSKEY(1)
If the command section is the first section in the file,
this line may be omitted. The command section consists of
lines of the form:
_s_t_r_i_n_g <whitespace> _a_c_t_i_o_n [extra-string] <newline>
Whitespace is any sequence of one or more spaces and/or
tabs. The _s_t_r_i_n_g is the command key(s) which invoke the
action. The _s_t_r_i_n_g may be a single command key, or a
sequence of up to 15 keys. The _a_c_t_i_o_n is the name of the
less action, from the list below. The characters in the
_s_t_r_i_n_g may appear literally, or be prefixed by a caret to
indicate a control key. A backslash followed by one to
three octal digits may be used to specify a character by
its octal value. A backslash followed by certain charac­
ters specifies input characters as follows:
Whitespace is any sequence of one or more spaces and/or tabs. The
string is the command key(s) which invoke the action. The string may
be a single command key, or a sequence of up to 15 keys. The action is
the name of the less action, from the list below. The characters in
the string may appear literally, or be prefixed by a caret to indicate
a control key. A backslash followed by one to three octal digits may
be used to specify a character by its octal value. A backslash fol-
lowed by certain characters specifies input characters as follows:
\b BACKSPACE
@@ -115,37 +95,22 @@ LESSKEY(1) LESSKEY(1)
\kx DELETE
A backslash followed by any other character indicates that
character is to be taken literally. Characters which must
be preceded by backslash include caret, space, tab and the
backslash itself.
A backslash followed by any other character indicates that character is
to be taken literally. Characters which must be preceded by backslash
include caret, space, tab and the backslash itself.
An action may be followed by an "extra" string. When such
a command is entered while running _l_e_s_s_, the action is
performed, and then the extra string is parsed, just as if
it were typed in to _l_e_s_s_. This feature can be used in
An action may be followed by an "extra" string. When such a command is
entered while running less, the action is performed, and then the extra
string is parsed, just as if it were typed in to less. This feature
can be used in certain cases to extend the functionality of a command.
For example, see the "{" and ":t" commands in the example below. The
extra string has a special meaning for the "quit" action: when less
quits, first character of the extra string is used as its exit status.
Version 382: 03 Feb 2004 2
LESSKEY(1) LESSKEY(1)
certain cases to extend the functionality of a command.
For example, see the "{" and ":t" commands in the example
below. The extra string has a special meaning for the
"quit" action: when _l_e_s_s quits, first character of the
extra string is used as its exit status.
EEXXAAMMPPLLEE
The following input file describes the set of default com­
mand keys used by less:
EXAMPLE
The following input file describes the set of default command keys used
by less:
#command
\r forw-line
@@ -190,18 +155,6 @@ EEXXAAMMPPLLEE
< goto-line
\e< goto-line
p percent
Version 382: 03 Feb 2004 3
LESSKEY(1) LESSKEY(1)
% percent
\e[ left-scroll
\e] right-scroll
@@ -256,18 +209,6 @@ LESSKEY(1) LESSKEY(1)
0 digit
1 digit
2 digit
Version 382: 03 Feb 2004 4
LESSKEY(1) LESSKEY(1)
3 digit
4 digit
5 digit
@@ -282,57 +223,40 @@ LESSKEY(1) LESSKEY(1)
ZZ quit
PPRREECCEEDDEENNCCEE
Commands specified by _l_e_s_s_k_e_y take precedence over the
default commands. A default command key may be disabled
by including it in the input file with the action
"invalid". Alternatively, a key may be defined to do
nothing by using the action "noaction". "noaction" is
similar to "invalid", but _l_e_s_s will give an error beep for
an "invalid" command, but not for a "noaction" command.
In addition, ALL default commands may be disabled by
adding this control line to the input file:
PRECEDENCE
Commands specified by lesskey take precedence over the default com-
mands. A default command key may be disabled by including it in the
input file with the action "invalid". Alternatively, a key may be
defined to do nothing by using the action "noaction". "noaction" is
similar to "invalid", but less will give an error beep for an "invalid"
command, but not for a "noaction" command. In addition, ALL default
commands may be disabled by adding this control line to the input file:
#stop
This will cause all default commands to be ignored. The
#stop line should be the last line in that section of the
file.
This will cause all default commands to be ignored. The #stop line
should be the last line in that section of the file.
Be aware that #stop can be dangerous. Since all default
commands are disabled, you must provide sufficient com­
mands before the #stop line to enable all necessary
actions. For example, failure to provide a "quit" command
can lead to frustration.
Be aware that #stop can be dangerous. Since all default commands are
disabled, you must provide sufficient commands before the #stop line to
enable all necessary actions. For example, failure to provide a "quit"
command can lead to frustration.
LLIINNEE EEDDIITTIINNGG SSEECCTTIIOONN
LINE EDITING SECTION
The line-editing section begins with the line:
#line-edit
This section specifies new key bindings for the line edit­
ing commands, in a manner similar to the way key bindings
for ordinary commands are specified in the #command sec­
tion. The line-editing section consists of a list of keys
and actions, one per line as in the example below.
This section specifies new key bindings for the line editing commands,
in a manner similar to the way key bindings for ordinary commands are
specified in the #command section. The line-editing section consists
of a list of keys and actions, one per line as in the example below.
EEXXAAMMPPLLEE
The following input file describes the set of default
line-editing keys used by less:
Version 382: 03 Feb 2004 5
LESSKEY(1) LESSKEY(1)
EXAMPLE
The following input file describes the set of default line-editing keys
used by less:
#line-edit
\t forw-complete
@@ -365,40 +289,26 @@ LESSKEY(1) LESSKEY(1)
LLEESSSS EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
LESS ENVIRONMENT VARIABLES
The environment variable section begins with the line
#env
Following this line is a list of environment variable
assignments. Each line consists of an environment vari­
able name, an equals sign (=) and the value to be assigned
to the environment variable. White space before and after
the equals sign is ignored. Variables assigned in this
way are visible only to _l_e_s_s_. If a variable is specified
in the system environment and also in a lesskey file, the
value in the lesskey file takes precedence. Although the
lesskey file can be used to override variables set in the
environment, the main purpose of assigning variables in
the lesskey file is simply to have all _l_e_s_s configuration
Following this line is a list of environment variable assignments.
Each line consists of an environment variable name, an equals sign (=)
and the value to be assigned to the environment variable. White space
before and after the equals sign is ignored. Variables assigned in
this way are visible only to less. If a variable is specified in the
system environment and also in a lesskey file, the value in the lesskey
file takes precedence. Although the lesskey file can be used to over-
ride variables set in the environment, the main purpose of assigning
variables in the lesskey file is simply to have all less configuration
information stored in one file.
EEXXAAMMPPLLEE
The following input file sets the -i option whenever _l_e_s_s
is run, and specifies the character set to be "latin1":
Version 382: 03 Feb 2004 6
LESSKEY(1) LESSKEY(1)
EXAMPLE
The following input file sets the -i option whenever less is run, and
specifies the character set to be "latin1":
#env
LESS = -i
@@ -406,57 +316,45 @@ LESSKEY(1) LESSKEY(1)
SSEEEE AALLSSOO
SEE ALSO
less(1)
WWAARRNNIINNGGSS
It is not possible to specify special keys, such as upar­
row, in a keyboard-independent manner. The only way to
specify such keys is to specify the escape sequence which
a particular keyboard sends when such a key is pressed.
WARNINGS
It is not possible to specify special keys, such as uparrow, in a key-
board-independent manner. The only way to specify such keys is to
specify the escape sequence which a particular keyboard sends when such
a key is pressed.
On MS-DOS and OS/2 systems, certain keys send a sequence
of characters which start with a NUL character (0). This
NUL character should be represented as \340 in a lesskey
file.
On MS-DOS and OS/2 systems, certain keys send a sequence of characters
which start with a NUL character (0). This NUL character should be
represented as \340 in a lesskey file.
CCOOPPYYRRIIGGHHTT
Copyright (C) 2000 Mark Nudelman
COPYRIGHT
Copyright (C) 2000-2007 Mark Nudelman
lesskey is part of the GNU project and is free software;
you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option)
any later version.
lesskey is part of the GNU project and is free software; you can redis-
tribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either version 2,
or (at your option) any later version.
lesskey is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied war­
ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR­
POSE. See the GNU General Public License for more
details.
lesskey is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public
License along with lesskey; see the file COPYING. If not,
write to the Free Software Foundation, 59 Temple Place,
Suite 330, Boston, MA 02111-1307, USA.
You should have received a copy of the GNU General Public License along
with lesskey; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
AAUUTTHHOORR
AUTHOR
Mark Nudelman <[email protected]>
Send bug reports or comments to the above address or to
bug-[email protected].
Send bug reports or comments to the above address or to bug-
[email protected].
Version 382: 03 Feb 2004 7
Version 418: 02 Jan 2008 LESSKEY(1)
+2 -2
View File
@@ -1,4 +1,4 @@
.TH LESSKEY 1 "Version 382: 03 Feb 2004"
.TH LESSKEY 1 "Version 418: 02 Jan 2008"
.SH NAME
lesskey \- specify key bindings for less
.SH SYNOPSIS
@@ -358,7 +358,7 @@ which start with a NUL character (0).
This NUL character should be represented as \e340 in a lesskey file.
.SH COPYRIGHT
Copyright (C) 2000 Mark Nudelman
Copyright (C) 2000-2007 Mark Nudelman
.PP
lesskey is part of the GNU project and is free software;
you can redistribute it and/or modify it
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+627 -305
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -314,7 +314,7 @@ find_linenum(pos)
/*
* Allow a signal to abort this loop.
*/
cpos = forw_raw_line(cpos, (char **)NULL);
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
return (0);
longish();
@@ -343,7 +343,7 @@ find_linenum(pos)
/*
* Allow a signal to abort this loop.
*/
cpos = back_raw_line(cpos, (char **)NULL);
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
return (0);
longish();
@@ -398,7 +398,7 @@ find_pos(linenum)
/*
* Allow a signal to abort this loop.
*/
cpos = forw_raw_line(cpos, (char **)NULL);
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
return (NULL_POSITION);
}
@@ -414,7 +414,7 @@ find_pos(linenum)
/*
* Allow a signal to abort this loop.
*/
cpos = back_raw_line(cpos, (char **)NULL);
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
return (NULL_POSITION);
}
+4 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -133,9 +133,9 @@ lsystem(cmd, donemsg)
char *esccmd = shell_quote(cmd);
if (esccmd != NULL)
{
p = (char *) ecalloc(strlen(shell) +
strlen(esccmd) + 5, sizeof(char));
sprintf(p, "%s %s %s", shell, shell_coption(), esccmd);
int len = strlen(shell) + strlen(esccmd) + 5;
p = (char *) ecalloc(len, sizeof(char));
SNPRINTF3(p, len, "%s %s %s", shell, shell_coption(), esccmd);
free(esccmd);
}
}
+30 -8
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -32,6 +32,7 @@ public char * progname;
public int quitting;
public int secure;
public int dohelp;
public int less_is_more;
#if LOGFILE
public int logfile = -1;
@@ -56,6 +57,8 @@ static char consoleTitle[256];
extern int missing_cap;
extern int know_dumb;
extern int quit_if_one_screen;
extern int pr_type;
/*
@@ -111,11 +114,26 @@ main(argc, argv)
is_tty = isatty(1);
get_term();
init_cmds();
init_prompt();
init_charset();
init_line();
init_cmdhist();
init_option();
s = lgetenv("LESS");
/*
* If the name of the executable program is "more",
* act like LESS_IS_MORE is set.
*/
for (s = progname + strlen(progname); s > progname; s--)
{
if (s[-1] == PATHNAME_SEP[0])
break;
}
if (strcmp(s, "more") == 0)
less_is_more = 1;
init_prompt();
s = lgetenv(less_is_more ? "MORE" : "LESS");
if (s != NULL)
scan_option(save(s));
@@ -140,6 +158,9 @@ 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')
@@ -335,14 +356,14 @@ sprefix(ps, s, uppercase)
c = *ps;
if (uppercase)
{
if (len == 0 && SIMPLE_IS_LOWER(c))
if (len == 0 && ASCII_IS_LOWER(c))
return (-1);
if (SIMPLE_IS_UPPER(c))
c = SIMPLE_TO_LOWER(c);
if (ASCII_IS_UPPER(c))
c = ASCII_TO_LOWER(c);
}
sc = *s;
if (len > 0 && SIMPLE_IS_UPPER(sc))
sc = SIMPLE_TO_LOWER(sc);
if (len > 0 && ASCII_IS_UPPER(sc))
sc = ASCII_TO_LOWER(sc);
if (c != sc)
break;
len++;
@@ -369,6 +390,7 @@ quit(status)
save_status = status;
quitting = 1;
edit((char*)NULL);
save_cmdhist();
if (any_display && is_tty)
clear_bot();
deinit();
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+84 -9
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -45,6 +45,9 @@ extern char *hproto;
extern char *wproto;
extern IFILE curr_ifile;
extern char version[];
extern int jump_sline;
extern int jump_sline_fraction;
extern int less_is_more;
#if LOGFILE
extern char *namelogfile;
extern int force_logfile;
@@ -53,7 +56,6 @@ extern int logfile;
#if TAGS
public char *tagoption = NULL;
extern char *tags;
extern int jump_sline;
#endif
#if MSDOS_COMPILER
extern int nm_fg_color, nm_bg_color;
@@ -154,6 +156,71 @@ opt_l(type, s)
}
}
/*
* Handlers for -j option.
*/
public void
opt_j(type, s)
int type;
char *s;
{
PARG parg;
char buf[16];
int len;
int err;
switch (type)
{
case INIT:
case TOGGLE:
if (*s == '.')
{
s++;
jump_sline_fraction = getfraction(&s, "j", &err);
if (err)
error("Invalid line fraction", NULL_PARG);
else
calc_jump_sline();
} else
{
int sline = getnum(&s, "j", &err);
if (err)
error("Invalid line number", NULL_PARG);
else
{
jump_sline = sline;
jump_sline_fraction = -1;
}
}
break;
case QUERY:
if (jump_sline_fraction < 0)
{
parg.p_int = jump_sline;
error("Position target at screen line %d", &parg);
} else
{
sprintf(buf, ".%06d", jump_sline_fraction);
len = strlen(buf);
while (len > 2 && buf[len-1] == '0')
len--;
buf[len] = '\0';
parg.p_string = buf;
error("Position target at screen position %s", &parg);
}
break;
}
}
public void
calc_jump_sline()
{
if (jump_sline_fraction < 0)
return;
jump_sline = sc_height * jump_sline_fraction / NUM_FRAC_DENOM;
}
#if USERFILE
public void
opt_k(type, s)
@@ -201,10 +268,13 @@ opt_t(type, s)
}
findtag(skipsp(s));
save_ifile = save_curr_ifile();
if (edit_tagfile())
break;
if ((pos = tagsearch()) == NULL_POSITION)
/*
* Try to open the file containing the tag
* and search for the tag in that file.
*/
if (edit_tagfile() || (pos = tagsearch()) == NULL_POSITION)
{
/* Failed: reopen the old file. */
reedit_ifile(save_ifile);
break;
}
@@ -259,7 +329,12 @@ opt_p(type, s)
*/
plusoption = TRUE;
ungetsc(s);
ungetsc("/");
/*
* In "more" mode, the -p argument is a command,
* not a search string, so we don't need a slash.
*/
if (!less_is_more)
ungetsc("/");
break;
}
}
@@ -367,7 +442,7 @@ opt__V(type, s)
any_display = 1;
putstr("less ");
putstr(version);
putstr("\nCopyright (C) 2002 Mark Nudelman\n\n");
putstr("\nCopyright (C) 1984-2007 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");
@@ -450,8 +525,8 @@ opt_D(type, s)
}
if (type == TOGGLE)
{
so_enter();
so_exit();
at_enter(AT_STANDOUT);
at_exit();
}
break;
case QUERY:
+86 -19
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -29,6 +29,8 @@ static char *optstring();
static int flip_triple();
extern int screen_trashed;
extern int less_is_more;
extern int quit_at_eof;
extern char *every_first_cmd;
/*
@@ -132,6 +134,10 @@ scan_option(s)
s--;
optc = 'z';
break;
case 'n':
if (less_is_more)
optc = 'z';
break;
}
/*
@@ -142,12 +148,12 @@ scan_option(s)
if (optname == NULL)
{
printopt = propt(optc);
lc = SIMPLE_IS_LOWER(optc);
lc = ASCII_IS_LOWER(optc);
o = findopt(optc);
} else
{
printopt = optname;
lc = SIMPLE_IS_LOWER(optname[0]);
lc = ASCII_IS_LOWER(optname[0]);
o = findopt_name(&optname, NULL, &err);
s = optname;
optname = NULL;
@@ -350,14 +356,14 @@ toggle_option(c, s, how_toggle)
{
case OPT_TOGGLE:
*(o->ovar) = flip_triple(*(o->ovar),
islower(c));
ASCII_IS_LOWER(c));
break;
case OPT_UNSET:
*(o->ovar) = o->odefault;
break;
case OPT_SET:
*(o->ovar) = flip_triple(o->odefault,
islower(c));
ASCII_IS_LOWER(c));
break;
}
break;
@@ -583,6 +589,30 @@ optstring(s, p_str, printopt, validchars)
return (p);
}
/*
*/
static int
num_error(printopt, errp)
char *printopt;
int *errp;
{
PARG parg;
if (errp != NULL)
{
*errp = TRUE;
return (-1);
}
if (printopt != NULL)
{
parg.p_string = printopt;
error("Number is required after %s", &parg);
}
quit(QUIT_ERROR);
/* NOTREACHED */
return (-1);
}
/*
* Translate a string into a number.
* Like atoi(), but takes a pointer to a char *, and updates
@@ -597,7 +627,6 @@ getnum(sp, printopt, errp)
register char *s;
register int n;
register int neg;
PARG parg;
s = skipsp(*sp);
neg = FALSE;
@@ -607,19 +636,7 @@ getnum(sp, printopt, errp)
s++;
}
if (*s < '0' || *s > '9')
{
if (errp != NULL)
{
*errp = TRUE;
return (-1);
}
if (printopt != NULL)
{
parg.p_string = printopt;
error("Number is required after %s", &parg);
}
quit(QUIT_ERROR);
}
return (num_error(printopt, errp));
n = 0;
while (*s >= '0' && *s <= '9')
@@ -631,3 +648,53 @@ getnum(sp, printopt, errp)
n = -n;
return (n);
}
/*
* Translate a string into a fraction, represented by the part of a
* number which would follow a decimal point.
* The value of the fraction is returned as parts per NUM_FRAC_DENOM.
* That is, if "n" is returned, the fraction intended is n/NUM_FRAC_DENOM.
*/
public long
getfraction(sp, printopt, errp)
char **sp;
char *printopt;
int *errp;
{
register char *s;
long frac = 0;
int fraclen = 0;
s = skipsp(*sp);
if (*s < '0' || *s > '9')
return (num_error(printopt, errp));
for ( ; *s >= '0' && *s <= '9'; s++)
{
frac = (frac * 10) + (*s - '0');
fraclen++;
}
if (fraclen > NUM_LOG_FRAC_DENOM)
while (fraclen-- > NUM_LOG_FRAC_DENOM)
frac /= 10;
else
while (fraclen++ < NUM_LOG_FRAC_DENOM)
frac *= 10;
*sp = s;
if (errp != NULL)
*errp = FALSE;
return (frac);
}
/*
* Get the value of the -e flag.
*/
public int
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;
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+45 -8
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -40,6 +40,7 @@ public int ctldisp; /* Send control chars to screen untranslated */
public int force_open; /* Open the file even if not regular file */
public int swindow; /* Size of scrolling window */
public int jump_sline; /* Screen line of "jump target" */
public long jump_sline_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 */
@@ -48,10 +49,15 @@ public int show_attn; /* Hilite first unread line */
public int shift_count; /* Number of positions to shift horizontally */
public int status_col; /* Display a status column */
public int use_lessopen; /* Use the LESSOPEN filter */
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}} */
#if HILITE_SEARCH
public int hilite_search; /* Highlight matched search patterns? */
#endif
public int less_is_more = 0; /* Make compatible with POSIX more */
/*
* Long option names.
*/
@@ -76,6 +82,7 @@ static struct optname J__optname = { "status-column", NULL };
#if USERFILE
static struct optname k_optname = { "lesskey-file", NULL };
#endif
static struct optname K__optname = { "quit-on-intr", NULL };
static struct optname L__optname = { "no-lessopen", NULL };
static struct optname m_optname = { "long-prompt", NULL };
static struct optname n_optname = { "line-numbers", NULL };
@@ -106,6 +113,8 @@ static struct optname tilde_optname = { "tilde", NULL };
static struct optname query_optname = { "help", NULL };
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 };
/*
@@ -151,7 +160,7 @@ static struct loption option[] =
TRIPLE, OPT_OFF, &top_scroll, NULL,
{
"Repaint by scrolling from bottom of screen",
"Repaint by clearing each line",
"Repaint by painting from top of screen",
"Repaint by painting from top of screen"
}
},
@@ -224,10 +233,10 @@ static struct loption option[] =
}
},
{ 'j', &j_optname,
NUMBER, 1, &jump_sline, NULL,
STRING, 0, NULL, opt_j,
{
"Target line: ",
"Position target at screen line %d",
"0123456789.",
NULL
}
},
@@ -245,6 +254,14 @@ static struct loption option[] =
{ NULL, NULL, NULL }
},
#endif
{ 'K', &K__optname,
BOOL, OPT_OFF, &quit_on_intr, NULL,
{
"Interrupt (ctrl-C) returns to prompt",
"Interrupt (ctrl-C) exits less",
NULL
}
},
{ 'l', NULL,
STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_l,
{ NULL, NULL, NULL }
@@ -417,6 +434,22 @@ static struct loption option[] =
NULL
}
},
{ '.', &oldbot_optname,
BOOL, OPT_OFF, &oldbot, NULL,
{
"Use new bottom of screen behavior",
"Use old bottom of screen behavior",
NULL
}
},
{ '.', &follow_optname,
BOOL, FOLLOW_DESC, &follow_mode, NULL,
{
"F command Follows file descriptor",
"F command Follows file name",
NULL
}
},
{ '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } }
};
@@ -428,6 +461,11 @@ static struct loption option[] =
init_option()
{
register struct loption *o;
char *p;
p = lgetenv("LESS_IS_MORE");
if (p != NULL && *p != '\0')
less_is_more = 1;
for (o = option; o->oletter != '\0'; o++)
{
@@ -454,7 +492,7 @@ findopt(c)
{
if (o->oletter == c)
return (o);
if ((o->otype & TRIPLE) && toupper(o->oletter) == c)
if ((o->otype & TRIPLE) && ASCII_TO_UPPER(o->oletter) == c)
return (o);
}
return (NULL);
@@ -467,9 +505,9 @@ findopt(c)
is_optchar(c)
char c;
{
if (SIMPLE_IS_UPPER(c))
if (ASCII_IS_UPPER(c))
return 1;
if (SIMPLE_IS_LOWER(c))
if (ASCII_IS_LOWER(c))
return 1;
if (c == '-')
return 1;
@@ -498,7 +536,6 @@ findopt_name(p_optname, p_oname, p_err)
int maxlen = 0;
int ambig = 0;
int exact = 0;
char *eq;
/*
* Check all options.
+37 -9
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -74,6 +74,7 @@ iread(fd, buf, len)
{
register int n;
start:
#if MSDOS_COMPILER==WIN32C
if (ABORT_SIGS())
return (READ_INTR);
@@ -156,7 +157,25 @@ iread(fd, buf, len)
#endif
reading = 0;
if (n < 0)
{
#if HAVE_ERRNO
/*
* Certain values of errno indicate we should just retry the read.
*/
#if MUST_DEFINE_ERRNO
extern int errno;
#endif
#ifdef EINTR
if (errno == EINTR)
goto start;
#endif
#ifdef EAGAIN
if (errno == EAGAIN)
goto start;
#endif
#endif
return (-1);
}
return (n);
}
@@ -216,6 +235,7 @@ errno_message(filename)
{
register char *p;
register char *m;
int len;
#if HAVE_ERRNO
#if MUST_DEFINE_ERRNO
extern int errno;
@@ -224,8 +244,9 @@ errno_message(filename)
#else
p = "cannot open";
#endif
m = (char *) ecalloc(strlen(filename) + strlen(p) + 3, sizeof(char));
sprintf(m, "%s: %s", filename, p);
len = strlen(filename) + strlen(p) + 3;
m = (char *) ecalloc(len, sizeof(char));
SNPRINTF2(m, len, "%s: %s", filename, p);
return (m);
}
@@ -249,18 +270,25 @@ percentage(num, den)
* Return the specified percentage of a POSITION.
*/
public POSITION
percent_pos(pos, percent)
percent_pos(pos, percent, fraction)
POSITION pos;
int percent;
long fraction;
{
POSITION result100;
/* Change percent (parts per 100) to perden (parts per NUM_FRAC_DENOM). */
long perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
POSITION temp;
if (percent == 0)
if (perden == 0)
return (0);
else if ((result100 = pos * percent) / percent == pos)
return (result100 / 100);
temp = pos * perden; /* This might overflow. */
if (temp / perden == pos)
/* No overflow */
return (temp / NUM_FRAC_DENOM);
else
return (percent * (pos / 100));
/* Above calculation overflows;
* use a method that is less precise but won't overflow. */
return (perden * (pos / NUM_FRAC_DENOM));
}
#if !HAVE_STRCHR
+107 -148
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -21,6 +21,7 @@
public int errmsgs; /* Count of messages displayed by error() */
public int need_clr;
public int final_attr;
public int at_prompt;
extern int sigs;
extern int sc_width;
@@ -28,8 +29,9 @@ extern int so_s_width, so_e_width;
extern int screen_trashed;
extern int any_display;
extern int is_tty;
extern int oldbot;
#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
extern int ctldisp;
extern int nm_fg_color, nm_bg_color;
extern int bo_fg_color, bo_bg_color;
@@ -47,7 +49,6 @@ put_line()
register int c;
register int i;
int a;
int curr_attr;
if (ABORT_SIGS())
{
@@ -58,49 +59,19 @@ put_line()
return;
}
curr_attr = AT_NORMAL;
final_attr = AT_NORMAL;
for (i = 0; (c = gline(i, &a)) != '\0'; i++)
{
if (a != curr_attr)
{
/*
* Changing attributes.
* Display the exit sequence for the old attribute
* and the enter sequence for the new one.
*/
switch (curr_attr)
{
case AT_UNDERLINE: ul_exit(); break;
case AT_BOLD: bo_exit(); break;
case AT_BLINK: bl_exit(); break;
case AT_STANDOUT: so_exit(); break;
}
switch (a)
{
case AT_UNDERLINE: ul_enter(); break;
case AT_BOLD: bo_enter(); break;
case AT_BLINK: bl_enter(); break;
case AT_STANDOUT: so_enter(); break;
}
curr_attr = a;
}
if (curr_attr == AT_INVIS)
continue;
at_switch(a);
final_attr = a;
if (c == '\b')
putbs();
else
putchr(c);
}
switch (curr_attr)
{
case AT_UNDERLINE: ul_exit(); break;
case AT_BOLD: bo_exit(); break;
case AT_BLINK: bl_exit(); break;
case AT_STANDOUT: so_exit(); break;
}
final_attr = curr_attr;
at_exit();
}
static char obuf[OUTBUF_SIZE];
@@ -131,53 +102,7 @@ flush()
n = ob - obuf;
if (n == 0)
return;
#if MSDOS_COMPILER==WIN32C
if (is_tty && any_display)
{
char *op;
DWORD nwritten = 0;
CONSOLE_SCREEN_BUFFER_INFO scr;
int row;
int col;
int olen;
extern HANDLE con_out;
olen = ob - obuf;
/*
* There is a bug in Win32 WriteConsole() if we're
* writing in the last cell with a different color.
* To avoid color problems in the bottom line,
* we scroll the screen manually, before writing.
*/
GetConsoleScreenBufferInfo(con_out, &scr);
col = scr.dwCursorPosition.X;
row = scr.dwCursorPosition.Y;
for (op = obuf; op < obuf + olen; op++)
{
if (*op == '\n')
{
col = 0;
row++;
} else if (*op == '\r')
{
col = 0;
} else
{
col++;
if (col >= sc_width)
{
col = 0;
row++;
}
}
}
if (row > scr.srWindow.Bottom)
win32_scroll_up(row - scr.srWindow.Bottom);
WriteConsole(con_out, obuf, olen, &nwritten, NULL);
ob = obuf;
return;
}
#else
#if MSDOS_COMPILER==MSOFTC
if (is_tty && any_display)
{
@@ -187,12 +112,12 @@ flush()
return;
}
#else
#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
if (is_tty && any_display)
{
*ob = '\0';
if (ctldisp != OPT_ONPLUS)
cputs(obuf);
WIN32textout(obuf, ob - obuf);
else
{
/*
@@ -202,64 +127,69 @@ flush()
* the -D command-line option.
*/
char *anchor, *p, *p_next;
int buflen = ob - obuf;
unsigned char fg, bg, norm_attr;
/*
* Only dark colors mentioned here, so that
* bold has visible effect.
*/
unsigned char fg, bg;
#if MSDOS_COMPILER==WIN32C
/* Screen colors used by 3x and 4x SGR commands. */
static unsigned char screen_color[] = {
0, /* BLACK */
FOREGROUND_RED,
FOREGROUND_GREEN,
FOREGROUND_RED|FOREGROUND_GREEN,
FOREGROUND_BLUE,
FOREGROUND_BLUE|FOREGROUND_RED,
FOREGROUND_BLUE|FOREGROUND_GREEN,
FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
};
#else
static enum COLORS screen_color[] = {
BLACK, RED, GREEN, BROWN,
BLUE, MAGENTA, CYAN, LIGHTGRAY
};
#endif
/* Normal text colors are used as baseline. */
bg = nm_bg_color & 0xf;
fg = nm_fg_color & 0xf;
norm_attr = (bg << 4) | fg;
for (anchor = p_next = obuf;
(p_next = memchr (p_next, ESC,
buflen - (p_next - obuf)))
!= NULL; )
(p_next = memchr(p_next, ESC, ob - p_next)) != NULL; )
{
p = p_next;
/*
* Handle the null escape sequence
* (ESC-[m), which is used to restore
* the original color.
*/
if (p[1] == '[' && is_ansi_end(p[2]))
if (p[1] == '[') /* "ESC-[" sequence */
{
textattr(norm_attr);
p += 3;
anchor = p_next = p;
continue;
}
if (p[1] == '[') /* "Esc-[" sequence */
{
/*
* If some chars seen since
* the last escape sequence,
* write it out to the screen
* using current text attributes.
*/
if (p > anchor)
{
*p = '\0';
cputs (anchor);
*p = ESC;
/*
* If some chars seen since
* the last escape sequence,
* write them out to the screen.
*/
WIN32textout(anchor, p-anchor);
anchor = p;
}
p += 2;
p += 2; /* Skip the "ESC-[" */
if (is_ansi_end(*p))
{
/*
* Handle null escape sequence
* "ESC[m", which restores
* the normal color.
*/
p++;
anchor = p_next = p;
WIN32setcolors(nm_fg_color, nm_bg_color);
continue;
}
p_next = p;
/*
* Select foreground/background colors
* based on the escape sequence.
*/
fg = nm_fg_color;
bg = nm_bg_color;
while (!is_ansi_end(*p))
{
char *q;
long code = strtol(p, &q, 10);
if (!*q)
if (*q == '\0')
{
/*
* Incomplete sequence.
@@ -267,15 +197,15 @@ flush()
* in the buffer.
*/
int slop = q - anchor;
/* {{ strcpy args overlap! }} */
strcpy(obuf, anchor);
ob = &obuf[slop];
return;
}
if (q == p
|| code > 49 || code < 0
|| (!is_ansi_end(*q)
&& *q != ';'))
if (q == p ||
code > 49 || code < 0 ||
(!is_ansi_end(*q) && *q != ';'))
{
p_next = q;
break;
@@ -285,11 +215,21 @@ flush()
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;
break;
case 1: /* bold on */
fg = bo_fg_color;
bg = bo_bg_color;
break;
case 3: /* italic on */
case 7: /* inverse on */
fg = so_fg_color;
bg = so_bg_color;
break;
@@ -297,16 +237,14 @@ flush()
fg = ul_fg_color;
bg = ul_bg_color;
break;
case 5: /* slow blink on */
case 6: /* fast blink on */
fg = bl_fg_color;
bg = bl_bg_color;
break;
case 8: /* concealed on */
fg = (bg & 7) | 8;
break;
case 0: /* all attrs off */
case 22:/* bold off */
case 23:/* italic off */
case 24:/* underline off */
fg = nm_fg_color;
bg = nm_bg_color;
break;
case 30: case 31: case 32:
case 33: case 34: case 35:
case 36: case 37:
@@ -326,26 +264,23 @@ flush()
}
p = q;
}
if (is_ansi_end(*p) && p > p_next)
{
bg &= 15;
fg &= 15;
textattr ((bg << 4)| fg);
p_next = anchor = p + 1;
} else
if (!is_ansi_end(*p) || p == p_next)
break;
fg &= 0xf;
bg &= 0xf;
WIN32setcolors(fg, bg);
p_next = anchor = p + 1;
} else
p_next++;
}
/* Output what's left in the buffer. */
cputs (anchor);
WIN32textout(anchor, ob - anchor);
}
ob = obuf;
return;
}
#endif
#endif
#endif
fd = (any_display) ? 1 : 2;
if (write(fd, obuf, n) != n)
@@ -360,6 +295,25 @@ flush()
putchr(c)
int c;
{
#if 0 /* fake UTF-8 output for testing */
extern int utf_mode;
if (utf_mode)
{
static char ubuf[MAX_UTF_CHAR_LEN];
static int ubuf_len = 0;
static int ubuf_index = 0;
if (ubuf_len == 0)
{
ubuf_len = utf_len(c);
ubuf_index = 0;
}
ubuf[ubuf_index++] = c;
if (ubuf_index < ubuf_len)
return c;
c = get_wchar(ubuf) & 0xFF;
ubuf_len = 0;
}
#endif
if (need_clr)
{
need_clr = 0;
@@ -384,6 +338,7 @@ putchr(c)
if (ob >= &obuf[sizeof(obuf)-1])
flush();
*ob++ = c;
at_prompt = 0;
return (c);
}
@@ -534,8 +489,11 @@ error(fmt, parg)
if (any_display && is_tty)
{
if (!oldbot)
squish_check();
at_exit();
clear_bot();
so_enter();
at_enter(AT_STANDOUT);
col += so_s_width;
}
@@ -548,7 +506,7 @@ error(fmt, parg)
}
putstr(return_to_continue);
so_exit();
at_exit();
col += sizeof(return_to_continue) + so_e_width;
get_return();
@@ -578,11 +536,12 @@ ierror(fmt, parg)
char *fmt;
PARG *parg;
{
at_exit();
clear_bot();
so_enter();
at_enter(AT_STANDOUT);
(void) less_printf(fmt, parg);
putstr(intr_to_abort);
so_exit();
at_exit();
flush();
need_clr = 1;
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+28 -11
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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,6 +30,7 @@ extern int linenums;
extern int hshift;
extern int sc_height;
extern int jump_sline;
extern int less_is_more;
extern IFILE curr_ifile;
#if EDITOR
extern char *editor;
@@ -52,6 +53,8 @@ static constant char h_proto[] =
"HELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done";
static constant char w_proto[] =
"Waiting for data";
static constant char more_proto[] =
"--More--(?eEND ?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t)";
public char *prproto[3];
public char constant *eqproto = e_proto;
@@ -68,7 +71,7 @@ static char *mp;
init_prompt()
{
prproto[0] = save(s_proto);
prproto[1] = save(m_proto);
prproto[1] = save(less_is_more ? more_proto : m_proto);
prproto[2] = save(M_proto);
eqproto = save(e_proto);
hproto = save(h_proto);
@@ -164,7 +167,7 @@ curr_byte(where)
POSITION pos;
pos = position(where);
while (pos == NULL_POSITION && where >= 0 && where < sc_height)
while (pos == NULL_POSITION && where >= 0 && where < sc_height-1)
pos = position(++where);
if (pos == NULL_POSITION)
pos = ch_length();
@@ -200,7 +203,7 @@ cond(c, where)
case 'd': /* Same as l */
return (linenums);
case 'L': /* Final line number known? */
case 'D': /* Same as L */
case 'D': /* Final page number known? */
return (linenums && ch_length() != NULL_POSITION);
case 'm': /* More than one file? */
#if TAGS
@@ -254,6 +257,9 @@ protochar(c, where, iseditproto)
LINENUM last_linenum;
IFILE h;
#undef PAGE_NUM
#define PAGE_NUM(linenum) ((((linenum) - 1) / (sc_height - 1)) + 1)
switch (c)
{
case 'b': /* Current byte offset */
@@ -269,17 +275,26 @@ protochar(c, where, iseditproto)
case 'd': /* Current page number */
linenum = currline(where);
if (linenum > 0 && sc_height > 1)
ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);
ap_linenum(PAGE_NUM(linenum));
else
ap_quest();
break;
case 'D': /* Last page number */
case 'D': /* Final page number */
/* Find the page number of the last byte in the file (len-1). */
len = ch_length();
if (len == NULL_POSITION || len == ch_zero() ||
(linenum = find_linenum(len)) <= 0)
if (len == NULL_POSITION)
ap_quest();
else if (len == 0)
/* An empty file has no pages. */
ap_linenum(0);
else
ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);
{
linenum = find_linenum(len - 1);
if (linenum <= 0)
ap_quest();
else
ap_linenum(PAGE_NUM(linenum));
}
break;
#if EDITOR
case 'E': /* Editor name */
@@ -518,7 +533,7 @@ pr_expand(proto, maxwidth)
}
if (mp == message)
return (NULL);
return ("");
if (maxwidth > 0 && mp >= message + maxwidth)
{
/*
@@ -549,9 +564,11 @@ eq_message()
pr_string()
{
char *prompt;
int type;
type = (!less_is_more) ? pr_type : pr_type ? 0 : 1;
prompt = pr_expand((ch_getflags() & CH_HELPFILE) ?
hproto : prproto[pr_type],
hproto : prproto[type],
sc_width-so_s_width-so_e_width-2);
new_file = 0;
return (prompt);
+202 -131
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -38,11 +38,12 @@ extern int fd0;
#else
#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
#include <termios.h>
#if HAVE_SYS_IOCTL_H && !defined(TIOCGWINSZ)
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
#include <termios.h>
#else
#if HAVE_TERMIO_H
#include <termio.h>
@@ -50,10 +51,7 @@ extern int fd0;
#if HAVE_SGSTAT_H
#include <sgstat.h>
#else
//#include <sgtty.h>
#endif
#if HAVE_SYS_IOCTL_H && (defined(TIOCGWINSZ) || defined(TCGETA) || defined(TIOCGETP) || defined(WIOCGETD))
#include <sys/ioctl.h>
#include <sgtty.h>
#endif
#endif
#endif
@@ -165,6 +163,7 @@ static char
*sc_home, /* Cursor home */
*sc_addline, /* Add line, scroll down following lines */
*sc_lower_left, /* Cursor to last line, first column */
*sc_return, /* Cursor to beginning of current line */
*sc_move, /* General cursor positioning */
*sc_clear, /* Clear screen */
*sc_eol_clear, /* Clear to end of line */
@@ -189,7 +188,9 @@ static int init_done = 0;
public int auto_wrap; /* Terminal does \r\n when write past margin */
public int ignaw; /* Terminal ignores \n immediately after wrap */
public int erase_char, kill_char; /* The user's erase and line-kill chars */
public int erase_char; /* The user's erase char */
public int erase2_char; /* The user's other erase char */
public int kill_char; /* The user's line-kill char */
public int werase_char; /* The user's word-erase char */
public int sc_width, sc_height; /* Height & width of screen */
public int bo_s_width, bo_e_width; /* Printing width of boldface seq */
@@ -202,6 +203,7 @@ public int clear_bg; /* Clear fills with background color */
public int missing_cap = 0; /* Some capability is missing */
static int attrmode = AT_NORMAL;
extern int binattr;
#if !MSDOS_COMPILER
static char *cheaper();
@@ -230,6 +232,8 @@ extern int sigs;
extern int wscroll;
extern int screen_trashed;
extern int tty;
extern int top_scroll;
extern int oldbot;
#if HILITE_SEARCH
extern int hilite_search;
#endif
@@ -257,6 +261,7 @@ raw_mode(on)
if (on == curr_on)
return;
erase2_char = '\b'; /* in case OS doesn't know about erase2 */
#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
{
struct termios s;
@@ -339,6 +344,9 @@ raw_mode(on)
}
#endif
erase_char = s.c_cc[VERASE];
#ifdef VERASE2
erase2_char = s.c_cc[VERASE2];
#endif
kill_char = s.c_cc[VKILL];
#ifdef VWERASE
werase_char = s.c_cc[VWERASE];
@@ -615,7 +623,25 @@ ltget_env(capname)
char *capname;
{
char name[16];
char *s;
s = lgetenv("LESS_TERMCAP_DEBUG");
if (s != NULL && *s != '\0')
{
struct env { struct env *next; char *name; char *value; };
static struct env *envs = NULL;
struct env *p;
for (p = envs; p != NULL; p = p->next)
if (strcmp(p->name, capname) == 0)
return p->value;
p = (struct env *) ecalloc(1, sizeof(struct env));
p->name = save(capname);
p->value = (char *) ecalloc(strlen(capname)+3, sizeof(char));
sprintf(p->value, "<%s>", capname);
p->next = envs;
envs = p;
return p->value;
}
strcpy(name, "LESS_TERMCAP_");
strcat(name, capname);
return (lgetenv(name));
@@ -1121,7 +1147,7 @@ get_term()
if ((term = lgetenv("TERM")) == NULL)
term = DEFAULT_TERM;
hardcopy = 0;
if (tgetent(termbuf, term) <= 0)
if (tgetent(termbuf, term) != TGETENT_OK)
hardcopy = 1;
if (ltgetflag("hc"))
hardcopy = 1;
@@ -1201,7 +1227,7 @@ get_term()
if (below_mem && (sc_eos_clear == NULL || *sc_eos_clear == '\0'))
{
missing_cap = 1;
sc_eol_clear = "";
sc_eos_clear = "";
}
sc_clear = ltgetstr("cl", &sp);
@@ -1276,6 +1302,13 @@ get_term()
}
sc_lower_left = cheaper(t1, t2, "\r");
/*
* Get carriage return string.
*/
sc_return = ltgetstr("cr", &sp);
if (sc_return == NULL)
sc_return = "\r";
/*
* Choose between using "al" or "sr" ("add line" or "scroll reverse")
* to add a line at the top of the screen.
@@ -1505,6 +1538,19 @@ init()
tputs(sc_init, sc_height, putchr);
if (!no_keypad)
tputs(sc_s_keypad, sc_height, putchr);
if (top_scroll)
{
int i;
/*
* This is nice to terminals with no alternate screen,
* but with saved scrolled-off-the-top lines. This way,
* no previous line is lost, but we start with a whole
* screen to ourself.
*/
for (i = 1; i < sc_height; i++)
putchr('\n');
}
#else
#if MSDOS_COMPILER==WIN32C
if (!no_init)
@@ -1781,6 +1827,37 @@ lower_left()
#endif
}
/*
* Move cursor to left position of current line.
*/
public void
line_left()
{
#if !MSDOS_COMPILER
tputs(sc_return, 1, putchr);
#else
int row;
flush();
#if MSDOS_COMPILER==WIN32C
{
CONSOLE_SCREEN_BUFFER_INFO scr;
GetConsoleScreenBufferInfo(con_out, &scr);
row = scr.dwCursorPosition.Y - scr.srWindow.Top + 1;
}
#else
#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
row = wherey();
#else
{
struct rccoord tpos = _gettextposition();
row = tpos.row;
}
#endif
#endif
_settextposition(row, 1);
#endif
}
/*
* Check if the console size has changed and reset internals
* (in lieu of SIGWINCH for WIN32).
@@ -1846,12 +1923,12 @@ create_flash()
videopages = w.numvideopages;
if (videopages < 2)
{
so_enter();
so_exit();
at_enter(AT_STANDOUT);
at_exit();
} else
{
_setactivepage(1);
so_enter();
at_enter(AT_STANDOUT);
blanks = (char *) ecalloc(w.numtextcols, sizeof(char));
for (col = 0; col < w.numtextcols; col++)
blanks[col] = ' ';
@@ -1860,7 +1937,7 @@ create_flash()
_setactivepage(0);
_setvisualpage(0);
free(blanks);
so_exit();
at_exit();
}
#else
#if MSDOS_COMPILER==BORLANDC
@@ -2089,154 +2166,119 @@ clear_bot()
* the mode while we do the clear. Some terminals fill the
* cleared area with the current attribute.
*/
lower_left();
switch (attrmode)
if (oldbot)
lower_left();
else
line_left();
if (attrmode == AT_NORMAL)
clear_eol_bot();
else
{
case AT_STANDOUT:
so_exit();
int saved_attrmode = attrmode;
at_exit();
clear_eol_bot();
so_enter();
break;
case AT_UNDERLINE:
ul_exit();
clear_eol_bot();
ul_enter();
break;
case AT_BOLD:
bo_exit();
clear_eol_bot();
bo_enter();
break;
case AT_BLINK:
bl_exit();
clear_eol_bot();
bl_enter();
break;
default:
clear_eol_bot();
break;
at_enter(saved_attrmode);
}
}
/*
* Begin "standout" (bold, underline, or whatever).
*/
public void
so_enter()
at_enter(attr)
int attr;
{
attr = apply_at_specials(attr);
#if !MSDOS_COMPILER
tputs(sc_s_in, 1, putchr);
/* The one with the most priority is last. */
if (attr & AT_UNDERLINE)
tputs(sc_u_in, 1, putchr);
if (attr & AT_BOLD)
tputs(sc_b_in, 1, putchr);
if (attr & AT_BLINK)
tputs(sc_bl_in, 1, putchr);
if (attr & AT_STANDOUT)
tputs(sc_s_in, 1, putchr);
#else
flush();
SETCOLORS(so_fg_color, so_bg_color);
/* The one with the most priority is first. */
if (attr & AT_STANDOUT)
{
SETCOLORS(so_fg_color, so_bg_color);
} else if (attr & AT_BLINK)
{
SETCOLORS(bl_fg_color, bl_bg_color);
}
else if (attr & AT_BOLD)
{
SETCOLORS(bo_fg_color, bo_bg_color);
}
else if (attr & AT_UNDERLINE)
{
SETCOLORS(ul_fg_color, ul_bg_color);
}
#endif
attrmode = AT_STANDOUT;
attrmode = attr;
}
/*
* End "standout".
*/
public void
so_exit()
at_exit()
{
#if !MSDOS_COMPILER
tputs(sc_s_out, 1, putchr);
/* Undo things in the reverse order we did them. */
if (attrmode & AT_STANDOUT)
tputs(sc_s_out, 1, putchr);
if (attrmode & AT_BLINK)
tputs(sc_bl_out, 1, putchr);
if (attrmode & AT_BOLD)
tputs(sc_b_out, 1, putchr);
if (attrmode & AT_UNDERLINE)
tputs(sc_u_out, 1, putchr);
#else
flush();
SETCOLORS(nm_fg_color, nm_bg_color);
#endif
attrmode = AT_NORMAL;
}
/*
* Begin "underline" (hopefully real underlining,
* otherwise whatever the terminal provides).
*/
public void
ul_enter()
at_switch(attr)
int attr;
{
#if !MSDOS_COMPILER
tputs(sc_u_in, 1, putchr);
#else
flush();
SETCOLORS(ul_fg_color, ul_bg_color);
#endif
attrmode = AT_UNDERLINE;
int new_attrmode = apply_at_specials(attr);
int ignore_modes = AT_ANSI;
if ((new_attrmode & ~ignore_modes) != (attrmode & ~ignore_modes))
{
at_exit();
at_enter(attr);
}
}
/*
* End "underline".
*/
public void
ul_exit()
public int
is_at_equiv(attr1, attr2)
int attr1;
int attr2;
{
#if !MSDOS_COMPILER
tputs(sc_u_out, 1, putchr);
#else
flush();
SETCOLORS(nm_fg_color, nm_bg_color);
#endif
attrmode = AT_NORMAL;
attr1 = apply_at_specials(attr1);
attr2 = apply_at_specials(attr2);
return (attr1 == attr2);
}
/*
* Begin "bold"
*/
public void
bo_enter()
public int
apply_at_specials(attr)
int attr;
{
#if !MSDOS_COMPILER
tputs(sc_b_in, 1, putchr);
#else
flush();
SETCOLORS(bo_fg_color, bo_bg_color);
#endif
attrmode = AT_BOLD;
}
if (attr & AT_BINARY)
attr |= binattr;
if (attr & AT_HILITE)
attr |= AT_STANDOUT;
attr &= ~(AT_BINARY|AT_HILITE);
/*
* End "bold".
*/
public void
bo_exit()
{
#if !MSDOS_COMPILER
tputs(sc_b_out, 1, putchr);
#else
flush();
SETCOLORS(nm_fg_color, nm_bg_color);
#endif
attrmode = AT_NORMAL;
}
/*
* Begin "blink"
*/
public void
bl_enter()
{
#if !MSDOS_COMPILER
tputs(sc_bl_in, 1, putchr);
#else
flush();
SETCOLORS(bl_fg_color, bl_bg_color);
#endif
attrmode = AT_BLINK;
}
/*
* End "blink".
*/
public void
bl_exit()
{
#if !MSDOS_COMPILER
tputs(sc_bl_out, 1, putchr);
#else
flush();
SETCOLORS(nm_fg_color, nm_bg_color);
#endif
attrmode = AT_NORMAL;
return attr;
}
#if 0 /* No longer used */
@@ -2427,3 +2469,32 @@ WIN32getch(tty)
return ((char)ascii);
}
#endif
#if MSDOS_COMPILER
/*
*/
public void
WIN32setcolors(fg, bg)
int fg;
int bg;
{
SETCOLORS(fg, bg);
}
/*
*/
public void
WIN32textout(text, len)
char *text;
int len;
{
#if MSDOS_COMPILER==WIN32C
WriteConsole(con_out, text, len, NULL, NULL);
#else
char c = text[len];
text[len] = '\0';
cputs(text);
text[len] = c;
#endif
}
#endif
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
+268 -99
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -15,6 +15,7 @@
#include "less.h"
#include "position.h"
#include "charset.h"
#define MINPOS(a,b) (((a) < (b)) ? (a) : (b))
#define MAXPOS(a,b) (((a) > (b)) ? (a) : (b))
@@ -54,6 +55,7 @@ extern int jump_sline;
extern int bs_mode;
extern int ctldisp;
extern int status_col;
extern void * constant ml_search;
extern POSITION start_attnpos;
extern POSITION end_attnpos;
#if HILITE_SEARCH
@@ -62,7 +64,9 @@ extern int screen_trashed;
extern int size_linebuf;
extern int squished;
extern int can_goto_line;
extern int utf_mode;
static int hide_hilite;
static int oldbot;
static POSITION prep_startpos;
static POSITION prep_endpos;
@@ -101,44 +105,81 @@ static int is_ucase_pattern;
static int last_search_type;
static char *last_pattern = NULL;
/*
* Convert text. Perform one or more of these transformations:
*/
#define CVT_TO_LC 01 /* Convert upper-case to lower-case */
#define CVT_BS 02 /* Do backspace processing */
#define CVT_CRLF 04 /* Remove CR after LF */
#define CVT_ANSI 010 /* Remove ANSI escape sequences */
static void
cvt_text(odst, osrc, ops)
char *odst;
char *osrc;
/*
* Get the length of a buffer needed to convert a string.
*/
static int
cvt_length(len, ops)
int len;
int ops;
{
register char *dst;
register char *src;
if (utf_mode)
/*
* Just copying a string in UTF-8 mode can cause it to grow
* in length.
* Six output bytes for one input byte is the worst case
* (and unfortunately is far more than is needed in any
* non-pathological situation, so this is very wasteful).
*/
len *= 6;
return len + 1;
}
for (src = osrc, dst = odst; *src != '\0'; src++)
/*
* Convert text. Perform one or more of these transformations:
*/
static void
cvt_text(odst, osrc, lenp, ops)
char *odst;
char *osrc;
int *lenp;
int ops;
{
char *dst;
char *src;
register char *src_end;
LWCHAR ch;
if (lenp != NULL)
src_end = osrc + *lenp;
else
src_end = osrc + strlen(osrc);
for (src = osrc, dst = odst; src < src_end; )
{
if ((ops & CVT_TO_LC) && isupper((unsigned char) *src))
ch = step_char(&src, +1, src_end);
if ((ops & CVT_TO_LC) && IS_UPPER(ch))
{
/* Convert uppercase to lowercase. */
*dst++ = tolower((unsigned char) *src);
else if ((ops & CVT_BS) && *src == '\b' && dst > odst)
/* Delete BS and preceding char. */
dst--;
else if ((ops & CVT_ANSI) && *src == ESC)
put_wchar(&dst, TO_LOWER(ch));
} else 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. */
while (src[1] != '\0')
if (is_ansi_end(*++src))
src++; /* skip the CSI start char */
while (src < src_end)
if (!is_ansi_middle(*src++))
break;
} else
/* Just copy. */
*dst++ = *src;
put_wchar(&dst, ch);
}
if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r')
dst--;
*dst = '\0';
if (lenp != NULL)
*lenp = dst - odst;
}
/*
@@ -169,14 +210,18 @@ get_cvt_ops()
* Are there any uppercase letters in this string?
*/
static int
is_ucase(s)
char *s;
is_ucase(str)
char *str;
{
register char *p;
char *str_end = str + strlen(str);
LWCHAR ch;
for (p = s; *p != '\0'; p++)
if (isupper((unsigned char) *p))
while (str < str_end)
{
ch = step_char(&str, +1, str_end);
if (IS_UPPER(ch))
return (1);
}
return (0);
}
@@ -247,17 +292,26 @@ repaint_hilite(on)
if (pos == NULL_POSITION)
continue;
epos = position(slinenum+1);
#if 0
/*
* If any character in the line is highlighted,
* repaint the line.
*
* {{ This doesn't work -- if line is drawn with highlights
* which should be erased (e.g. toggle -i with status column),
* we must redraw the line even if it has no highlights.
* For now, just repaint every line. }}
*/
if (is_hilited(pos, epos, 1))
if (is_hilited(pos, epos, 1, NULL))
#endif
{
(void) forw_line(pos);
goto_line(slinenum);
put_line();
}
}
if (!oldbot)
lower_left();
hide_hilite = save_hide_hilite;
}
@@ -272,6 +326,7 @@ clear_attn()
POSITION old_end_attnpos;
POSITION pos;
POSITION epos;
int moved = 0;
if (start_attnpos == NULL_POSITION)
return;
@@ -299,8 +354,11 @@ clear_attn()
(void) forw_line(pos);
goto_line(slinenum);
put_line();
moved = 1;
}
}
if (moved)
lower_left();
}
#endif
@@ -325,7 +383,7 @@ undo_search()
* Compile a search pattern, for future use by match_pattern.
*/
static int
compile_pattern(pattern, search_type)
compile_pattern2(pattern, search_type)
char *pattern;
int search_type;
{
@@ -404,6 +462,30 @@ compile_pattern(pattern, search_type)
return (0);
}
/*
* Like compile_pattern, but convert the pattern to lowercase if necessary.
*/
static int
compile_pattern(pattern, search_type)
char *pattern;
int search_type;
{
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, CVT_TO_LC);
}
result = compile_pattern2(cvt_pattern, search_type);
if (cvt_pattern != pattern)
free(cvt_pattern);
return (result);
}
/*
* Forget that we have a compiled pattern.
*/
@@ -441,8 +523,9 @@ uncompile_pattern()
* Set sp and ep to the start and end of the matched string.
*/
static int
match_pattern(line, sp, ep, notbol)
match_pattern(line, line_len, sp, ep, notbol)
char *line;
int line_len;
char **sp;
char **ep;
int notbol;
@@ -450,7 +533,7 @@ match_pattern(line, sp, ep, notbol)
int matched;
if (last_search_type & SRCH_NO_REGEX)
return (match(last_pattern, line, sp, ep));
return (match(last_pattern, strlen(last_pattern), line, line_len, sp, ep));
#if HAVE_POSIX_REGCOMP
{
@@ -472,7 +555,7 @@ match_pattern(line, sp, ep, notbol)
{
int flags = (notbol) ? PCRE_NOTBOL : 0;
int ovector[3];
matched = pcre_exec(regpattern, NULL, line, strlen(line),
matched = pcre_exec(regpattern, NULL, line, line_len,
0, flags, ovector, 3) >= 0;
if (!matched)
return (0);
@@ -506,7 +589,7 @@ match_pattern(line, sp, ep, notbol)
*ep = regpattern->endp[0];
#endif
#if NO_REGEX
matched = match(last_pattern, line, sp, ep);
matched = match(last_pattern, strlen(last_pattern), line, line_len, sp, ep);
#endif
return (matched);
}
@@ -530,17 +613,43 @@ clr_hilite()
prep_startpos = prep_endpos = NULL_POSITION;
}
/*
* Should any characters in a specified range be highlighted?
*/
static int
is_hilited_range(pos, epos)
POSITION pos;
POSITION epos;
{
struct hilite *hl;
/*
* Look at each highlight and see if any part of it falls in the range.
*/
for (hl = hilite_anchor.hl_first; hl != NULL; hl = hl->hl_next)
{
if (hl->hl_endpos > pos &&
(epos == NULL_POSITION || epos > hl->hl_startpos))
return (1);
}
return (0);
}
/*
* Should any characters in a specified range be highlighted?
* If nohide is nonzero, don't consider hide_hilite.
*/
public int
is_hilited(pos, epos, nohide)
is_hilited(pos, epos, nohide, p_matches)
POSITION pos;
POSITION epos;
int nohide;
int *p_matches;
{
struct hilite *hl;
int match;
if (p_matches != NULL)
*p_matches = 0;
if (!status_col &&
start_attnpos != NULL_POSITION &&
@@ -551,6 +660,16 @@ is_hilited(pos, epos, nohide)
*/
return (1);
match = is_hilited_range(pos, epos);
if (!match)
return (0);
if (p_matches != NULL)
/*
* Report matches, even if we're hiding highlights.
*/
*p_matches = 1;
if (hilite_search == 0)
/*
* Not doing highlighting.
@@ -563,16 +682,7 @@ is_hilited(pos, epos, nohide)
*/
return (0);
/*
* Look at each highlight and see if any part of it falls in the range.
*/
for (hl = hilite_anchor.hl_first; hl != NULL; hl = hl->hl_next)
{
if (hl->hl_endpos > pos &&
(epos == NULL_POSITION || epos > hl->hl_startpos))
return (1);
}
return (0);
return (1);
}
/*
@@ -616,7 +726,7 @@ add_hilite(anchor, hl)
}
/*
* Adjust hl_startpos & hl_endpos to account for backspace processing.
* Adjust hl_startpos & hl_endpos to account for processing by cvt_text.
*/
static void
adj_hilite(anchor, linepos, cvt_ops)
@@ -625,19 +735,25 @@ adj_hilite(anchor, linepos, cvt_ops)
int cvt_ops;
{
char *line;
char *oline;
int line_len;
char *line_end;
struct hilite *hl;
int checkstart;
POSITION opos;
POSITION npos;
LWCHAR ch;
int ncwidth;
/*
* The line was already scanned and hilites were added (in hilite_line).
* But it was assumed that each char position in the line
* correponds to one char position in the file.
* This may not be true if there are backspaces in the line.
* This may not be true if cvt_text modified the line.
* Get the raw line again. Look at each character.
*/
(void) forw_raw_line(linepos, &line);
(void) forw_raw_line(linepos, &line, &line_len);
line_end = line + line_len;
opos = npos = linepos;
hl = anchor->hl_first;
checkstart = TRUE;
@@ -662,41 +778,47 @@ adj_hilite(anchor, linepos, cvt_ops)
hl = hl->hl_next;
continue; /* {{ necessary }} */
}
if (*line == '\0')
if (line == line_end)
break;
if (cvt_ops & CVT_ANSI)
/* Get the next char from the line. */
oline = line;
ch = step_char(&line, +1, line_end);
ncwidth = line - oline;
npos += ncwidth;
/* Figure out how this char was processed by cvt_text. */
if ((cvt_ops & CVT_BS) && ch == '\b')
{
while (line[0] == ESC)
/* Skip the backspace and the following char. */
oline = line;
ch = step_char(&line, +1, line_end);
ncwidth = line - oline;
npos += ncwidth;
} else if ((cvt_ops & CVT_TO_LC) && IS_UPPER(ch))
{
/* Converted uppercase to lower.
* Note that this may have changed the number of bytes
* that the character occupies. */
char dbuf[6];
char *dst = dbuf;
put_wchar(&dst, TO_LOWER(ch));
opos += dst - dbuf;
} else if ((cvt_ops & CVT_ANSI) && IS_CSI_START(ch))
{
/* Skip to end of ANSI escape sequence. */
line++; /* skip the CSI start char */
npos++;
while (line < line_end)
{
/*
* Found an ESC. The file position moves
* forward past the entire ANSI escape sequence.
*/
line++;
npos++;
while (*line != '\0')
{
npos++;
if (is_ansi_end(*line++))
break;
}
if (!is_ansi_middle(*line++))
break;
}
}
opos++;
npos++;
line++;
if (cvt_ops & CVT_BS)
} else
{
while (line[0] == '\b' && line[1] != '\0')
{
/*
* Found a backspace. The file position moves
* forward by 2 relative to the processed line
* which was searched in hilite_line.
*/
npos += 2;
line += 2;
}
/* Ordinary unprocessed character. */
opos += ncwidth;
}
}
}
@@ -707,14 +829,16 @@ adj_hilite(anchor, linepos, cvt_ops)
* sp,ep delimit the first match already found.
*/
static void
hilite_line(linepos, line, sp, ep, cvt_ops)
hilite_line(linepos, line, line_len, sp, ep, cvt_ops)
POSITION linepos;
char *line;
int line_len;
char *sp;
char *ep;
int cvt_ops;
{
char *searchp;
char *line_end = line + line_len;
struct hilite *hl;
struct hilite hilites;
@@ -728,7 +852,7 @@ hilite_line(linepos, line, sp, ep, cvt_ops)
* substrings of the line, may mark more than is correct
* if the pattern starts with "^". This bug is fixed
* for those regex functions that accept a notbol parameter
* (currently POSIX and V8-with-regexec2). }}
* (currently POSIX, PCRE and V8-with-regexec2). }}
*/
searchp = line;
/*
@@ -755,11 +879,11 @@ hilite_line(linepos, line, sp, ep, cvt_ops)
*/
if (ep > searchp)
searchp = ep;
else if (*searchp != '\0')
else if (searchp != line_end)
searchp++;
else /* end of line */
break;
} while (match_pattern(searchp, &sp, &ep, 1));
} while (match_pattern(searchp, line_end - searchp, &sp, &ep, 1));
/*
* If there were backspaces in the original line, they
@@ -890,7 +1014,7 @@ search_pos(search_type)
pos = position(linenum);
if (search_type & SRCH_FORW)
{
pos = forw_raw_line(pos, (char **)NULL);
pos = forw_raw_line(pos, (char **)NULL, (int *)NULL);
while (pos == NULL_POSITION)
{
if (++linenum >= sc_height)
@@ -924,6 +1048,8 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
POSITION *pendpos;
{
char *line;
char *cline;
int line_len;
LINENUM linenum;
char *sp, *ep;
int line_match;
@@ -966,7 +1092,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* starting position of that line in linepos.
*/
linepos = pos;
pos = forw_raw_line(pos, &line);
pos = forw_raw_line(pos, &line, &line_len);
if (linenum != 0)
linenum++;
} else
@@ -975,7 +1101,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* Read the previous line and save the
* starting position of that line in linepos.
*/
pos = back_raw_line(pos, &line);
pos = back_raw_line(pos, &line, &line_len);
linepos = pos;
if (linenum != 0)
linenum--;
@@ -1008,18 +1134,22 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* If we're doing backspace processing, delete backspaces.
*/
cvt_ops = get_cvt_ops();
cvt_text(line, line, cvt_ops);
cline = calloc(1, cvt_length(line_len, cvt_ops));
cvt_text(cline, line, &line_len, cvt_ops);
/*
* Test the next line to see if we have a match.
* We are successful if we either want a match and got one,
* or if we want a non-match and got one.
*/
line_match = match_pattern(line, &sp, &ep, 0);
line_match = match_pattern(cline, line_len, &sp, &ep, 0);
line_match = (!(search_type & SRCH_NO_MATCH) && line_match) ||
((search_type & SRCH_NO_MATCH) && !line_match);
if (!line_match)
{
free(cline);
continue;
}
/*
* Got a match.
*/
@@ -1032,8 +1162,9 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* hilite list and keep searching.
*/
if (line_match)
hilite_line(linepos, line, sp, ep, cvt_ops);
hilite_line(linepos, cline, line_len, sp, ep, cvt_ops);
#endif
free(cline);
} else if (--matches <= 0)
{
/*
@@ -1041,7 +1172,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* Return it.
*/
#if HILITE_SEARCH
if (hilite_search == 1)
if (hilite_search == OPT_ON)
{
/*
* Clear the hilite list and add only
@@ -1049,9 +1180,10 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
*/
clr_hilite();
if (line_match)
hilite_line(linepos, line, sp, ep, cvt_ops);
hilite_line(linepos, cline, line_len, sp, ep, cvt_ops);
}
#endif
free(cline);
if (plinepos != NULL)
*plinepos = linepos;
return (0);
@@ -1059,6 +1191,41 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
}
}
/*
* search for a pattern in history. If found, compile that pattern.
*/
static int
hist_pattern(search_type)
int search_type;
{
#if CMD_HISTORY
char *pattern;
set_mlist(ml_search, 0);
pattern = cmd_lastpattern();
if (pattern == NULL)
return (0);
if (compile_pattern(pattern, search_type) < 0)
return (0);
is_ucase_pattern = is_ucase(pattern);
if (is_ucase_pattern && caseless != OPT_ONPLUS)
is_caseless = 0;
else
is_caseless = caseless;
#if HILITE_SEARCH
if (hilite_search == OPT_ONPLUS && !hide_hilite)
hilite_screen();
#endif
return (1);
#else /* CMD_HISTORY */
return (0);
#endif /* CMD_HISTORY */
}
/*
* Search for the n-th occurrence of a specified pattern,
* either forward or backward.
@@ -1075,14 +1242,14 @@ search(search_type, pattern, n)
int n;
{
POSITION pos;
int ucase;
int result;
if (pattern == NULL || *pattern == '\0')
{
/*
* A null pattern means use the previously compiled pattern.
*/
if (!prev_pattern())
if (!prev_pattern() && !hist_pattern(search_type))
{
error("No previous regular expression", NULL_PARG);
return (-1);
@@ -1118,16 +1285,13 @@ search(search_type, pattern, n)
/*
* Compile the pattern.
*/
ucase = is_ucase(pattern);
if (caseless == OPT_ONPLUS)
cvt_text(pattern, pattern, CVT_TO_LC);
if (compile_pattern(pattern, search_type) < 0)
return (-1);
/*
* Ignore case if -I is set OR
* -i is set AND the pattern is all lowercase.
*/
is_ucase_pattern = ucase;
is_ucase_pattern = is_ucase(pattern);
if (is_ucase_pattern && caseless != OPT_ONPLUS)
is_caseless = 0;
else
@@ -1248,7 +1412,7 @@ prep_hilite(spos, epos, maxlines)
{
max_epos = spos;
for (i = 0; i < maxlines; i++)
max_epos = forw_raw_line(max_epos, (char **)NULL);
max_epos = forw_raw_line(max_epos, (char **)NULL, (int *)NULL);
}
/*
@@ -1344,18 +1508,23 @@ prep_hilite(spos, epos, maxlines)
* It supports no metacharacters like *, etc.
*/
static int
match(pattern, buf, pfound, pend)
char *pattern, *buf;
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 != '\0'; buf++)
for ( ; buf < buf_end; buf++)
{
for (pp = pattern, lp = buf; *pp == *lp; pp++, lp++)
if (*pp == '\0' || *lp == '\0')
if (pp == pattern_end || lp == buf_end)
break;
if (*pp == '\0')
if (pp == pattern_end)
{
if (pfound != NULL)
*pfound = buf;
+7 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -33,6 +33,8 @@ extern int lnloop;
extern int linenums;
extern int wscroll;
extern int reading;
extern int quit_on_intr;
extern long jump_sline_fraction;
/*
* Interrupt signal handler.
@@ -152,13 +154,12 @@ init_signals(on)
#endif
#ifdef SIGWINCH
(void) LSIGNAL(SIGWINCH, winch);
#else
#endif
#ifdef SIGWIND
(void) LSIGNAL(SIGWIND, winch);
#endif
#ifdef SIGQUIT
(void) LSIGNAL(SIGQUIT, SIG_IGN);
#endif
#endif
} else
{
@@ -241,12 +242,15 @@ psignals()
if (sc_width != old_width || sc_height != old_height)
{
wscroll = (sc_height + 1) / 2;
calc_jump_sline();
screen_trashed = 1;
}
}
#endif
if (tsignals & S_INTERRUPT)
{
if (quit_on_intr)
quit(QUIT_OK);
bell();
/*
* {{ You may wish to replace the bell() with
+25 -28
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -56,7 +56,7 @@ static int getentry();
*
* Use either pattern or line number.
* findgtag() always uses line number, so pattern is always NULL.
* findctag() usually either pattern (in which case line number is 0),
* findctag() uses either pattern (in which case line number is 0),
* or line number (in which case pattern is NULL).
*/
struct taglist {
@@ -75,10 +75,10 @@ struct tag {
static struct tag *curtag;
#define TAG_INS(tp) \
(tp)->next = taglist.tl_first; \
(tp)->prev = TAG_END; \
taglist.tl_first->prev = (tp); \
taglist.tl_first = (tp);
(tp)->next = TAG_END; \
(tp)->prev = taglist.tl_last; \
taglist.tl_last->next = (tp); \
taglist.tl_last = (tp);
#define TAG_RM(tp) \
(tp)->next->prev = (tp)->prev; \
@@ -418,7 +418,7 @@ ctagsearch()
* starting position of that line in linepos.
*/
linepos = pos;
pos = forw_raw_line(pos, &line);
pos = forw_raw_line(pos, &line, (int *)NULL);
if (linenum != 0)
linenum++;
@@ -498,7 +498,7 @@ findgtag(tag, type)
#if !HAVE_POPEN
return TAG_NOFILE;
#else
char command[512];
char *command;
char *flag;
char *qtag;
char *cmd = lgetenv("LESSGLOBALTAGS");
@@ -528,10 +528,13 @@ findgtag(tag, type)
qtag = shell_quote(tag);
if (qtag == NULL)
qtag = tag;
command = (char *) ecalloc(strlen(cmd) + strlen(flag) +
strlen(qtag) + 5, sizeof(char));
sprintf(command, "%s -x%s %s", cmd, flag, qtag);
if (qtag != tag)
free(qtag);
fp = popen(command, "r");
free(command);
#endif
}
if (fp != NULL)
@@ -539,6 +542,7 @@ findgtag(tag, type)
while (fgets(buf, sizeof(buf), fp))
{
char *name, *file, *line;
int len;
if (sigs)
{
@@ -548,8 +552,9 @@ findgtag(tag, type)
#endif
return TAG_INTR;
}
if (buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = 0;
len = strlen(buf);
if (len > 0 && buf[len-1] == '\n')
buf[len-1] = '\0';
else
{
int c;
@@ -657,7 +662,7 @@ prevgtag()
/*
* Position the current file at at what is hopefully the tag that was chosen
* using either findtag() or one of nextgtag() and prevgtag(). Returns -1
* if it was unable to position at the tag, 0 if succesful.
* if it was unable to position at the tag, 0 if successful.
*/
static POSITION
gtagsearch()
@@ -695,14 +700,6 @@ gtagsearch()
* The tag, file, and line will each be NUL-terminated pointers
* into buf.
*/
#ifndef isspace
#define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f')
#endif
#ifndef isdigit
#define isdigit(c) ((c) >= '0' && (c <= '9'))
#endif
static int
getentry(buf, tag, file, line)
char *buf; /* standard or extended ctags -x format data */
@@ -712,12 +709,12 @@ getentry(buf, tag, file, line)
{
char *p = buf;
for (*tag = p; *p && !isspace(*p); p++) /* tag name */
for (*tag = p; *p && !IS_SPACE(*p); p++) /* tag name */
;
if (*p == 0)
return (-1);
*p++ = 0;
for ( ; *p && isspace(*p); p++) /* (skip blanks) */
for ( ; *p && IS_SPACE(*p); p++) /* (skip blanks) */
;
if (*p == 0)
return (-1);
@@ -725,27 +722,27 @@ getentry(buf, tag, file, line)
* If the second part begin with other than digit,
* it is assumed tag type. Skip it.
*/
if (!isdigit(*p))
if (!IS_DIGIT(*p))
{
for ( ; *p && !isspace(*p); p++) /* (skip tag type) */
for ( ; *p && !IS_SPACE(*p); p++) /* (skip tag type) */
;
for (; *p && isspace(*p); p++) /* (skip blanks) */
for (; *p && IS_SPACE(*p); p++) /* (skip blanks) */
;
}
if (!isdigit(*p))
if (!IS_DIGIT(*p))
return (-1);
*line = p; /* line number */
for (*line = p; *p && !isspace(*p); p++)
for (*line = p; *p && !IS_SPACE(*p); p++)
;
if (*p == 0)
return (-1);
*p++ = 0;
for ( ; *p && isspace(*p); p++) /* (skip blanks) */
for ( ; *p && IS_SPACE(*p); p++) /* (skip blanks) */
;
if (*p == 0)
return (-1);
*file = p; /* file name */
for (*file = p; *p && !isspace(*p); p++)
for (*file = p; *p && !IS_SPACE(*p); p++)
;
if (*p == 0)
return (-1);
+35 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -26,6 +26,7 @@ static DWORD console_mode;
public int tty;
extern int sigs;
extern int utf_mode;
/*
* Open keyboard for input.
@@ -131,6 +132,38 @@ getchr()
*/
quit(QUIT_ERROR);
}
#endif
#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;
if (c == CONTROL('A'))
{
hex_in = 2;
result = 0;
continue;
}
if (hex_in > 0)
{
int v;
if (c >= '0' && c <= '9')
v = c - '0';
else if (c >= 'a' && c <= 'f')
v = c - 'a' + 10;
else if (c >= 'A' && c <= 'F')
v = c - 'A' + 10;
else
hex_in = 0;
hex_value = (hex_value << 4) | v;
if (--hex_in > 0)
{
result = 0;
continue;
}
c = hex_value;
}
}
#endif
/*
* Various parts of the program cannot handle
@@ -141,5 +174,5 @@ getchr()
c = '\340';
} while (result != 1);
return (c & 0377);
return (c & 0xFF);
}
+63 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1984-2002 Mark Nudelman
* Copyright (C) 1984-2007 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.
@@ -646,6 +646,67 @@ v380 11/24/02 Make LINENUM same as POSITION.
v381 11/28/02 Make -N use 7 columns for line number if possible.
-----------------------------------------------------------------
v382 2/3/04 Remove copyrighted code.
-----------------------------------------------------------------
v383 2/16/04 Add history file; add -K option; improve UTF-8 handling;
fix some signed char bugs (thanks to Christian Biere);
fix some upper/lower case bugs (thanks to Bjoern Jacke);
add erase2 char (thanks to David Lawrence);
add windows charset (thanks to Dimitar Zhekov).
v384 2/20/04 Improvements in UTF-8 handling.
v385 2/23/04 Fix UTF-8 output bug.
-----------------------------------------------------------------
v386 9/13/05 Improvements to UTF-8 shift & color (thanks to Charles Levert);
protect against invalid LESSOPEN and LESSCLOSE values.
v387 9/14/05 Update Charles Levert's UTF-8 patch.
v388 9/14/05 Change history behavior; change most sprintf calls to snprintf.
v389 9/14/05 Fix copy & paste with long lines; improve performance of
expand_linebuf; fix crash in init_mlist;
v390 9/15/05 Show search matches in status column even if -G is set.
-----------------------------------------------------------------
v391 9/17/05 Fix bugs.
v392 10/14/05 Fix line wrapping bug.
v393 10/19/05 Allow multiple attributes per char; fix bold+underline bug
(thanks again to Charles Levert).
v394 11/8/05 Fix prompt bug; fix compile problem in Windows build.
-----------------------------------------------------------------
v395 1/12/07 Update Unicode tables (thanks to Charles Levert);
don't chmod if LESSHISTFILE = /dev/null;
make -f work for directories; support DESTDIR in Makefile;
fix sigset_t detection in configure;
make "t" cmd traverse tags in correct order
v396 1/13/07 Add compatibility with POSIX more.
v397 3/21/07 Allow decimal point in number for % command;
Allow decimal point in number for -j option;
Allow n command to fetch last search pattern from history
(thanks to arno).
v398 3/22/07 Don't rewrite history file if not necessary;
fix bug when filenames contain "$".
v399 3/22/07 Don't move to bottom of screen at startup;
don't output extraneous newlines.
v400 3/23/07 Allow search to find pattern after null byte (PCRE and no-regex)
(thanks to Michael Constant).
-----------------------------------------------------------------
v401 3/24/07 Minor documentation fixes.
v402 3/30/07 Fix autoconf bug when memcpy etc are inline;
fix bug in terminating number following -j option.
v403 5/25/07 Fix Windows build.
v404 6/5/07 Fix display bug with F command and long lines.
v405 6/17/07 Fix display bug when using -w option.
v406 6/17/07 Fix secure build.
v407 8/16/07 Fix bugs; support CSI chars.
v408 10/1/07 Fix bug in -i with non-ASCII chars.
v409 10/12/07 Fix crash when viewing text with invalid UTF-8 sequences.
v411 11/6/07 Fix case-insensitive searching with non-ASCII text.
v412 11/6/07 Use symbolic SEEK constants.
v413 11/6/07 Fix search highlight bug with non-ASCII text.
v414 11/6/07 Fix display bug with no-wrap terminals.
v415 11/14/07 Add --follow-name option.
v416 11/22/07 Fix crash when searching text with invalid UTF-8 sequences.
v417 12/31/07 Don't support single-char CSI in UTF-8 mode;
fix bug with -R and invalid CSI sequences;
fix bug searching text with SGR sequences with -r;
emulate SGR sequences in WIN32 build.
v418 12/31/07 Clean up.
*/
char version[] = "382";
char version[] = "418";