mirror of
https://github.com/vbatts/bvi.git
synced 2024-11-21 16:15:43 +00:00
bvi-1.3.0.src.tar.gz
This commit is contained in:
commit
0220b756fa
80 changed files with 17347 additions and 0 deletions
58
CHANGES
Normal file
58
CHANGES
Normal file
|
@ -0,0 +1,58 @@
|
|||
New in release 1.3.0
|
||||
====================
|
||||
|
||||
* a "bmore" program has been added
|
||||
* --with-ncurses option to configure to specify an alternate
|
||||
search path for Ncurses outside the normal include/lib search path.
|
||||
* make uninstall option
|
||||
* Reading of Block Special Files
|
||||
* New Command line options:
|
||||
+cmd
|
||||
-b begin \
|
||||
-e end > for partial file read
|
||||
-s size /
|
||||
* :e# bug fixed
|
||||
* Debian bug #68436 (Buffer overflow in io.c) fixed
|
||||
|
||||
|
||||
New in release 1.2.0
|
||||
====================
|
||||
|
||||
* configuration with GNU autoconfig
|
||||
* CR moves cursor to 1st column
|
||||
* alphabet. order for :set all
|
||||
* new settings:
|
||||
set columns=n
|
||||
set (no)memmove
|
||||
* insert and delete (a, d, i, I, x, X)
|
||||
* vi-syntax for y (yank), overwriting put o
|
||||
* new colon (ex) commands:
|
||||
:undo :delete :global
|
||||
:yank :put :overwrite
|
||||
:insert :change :append
|
||||
* new option:
|
||||
-f script
|
||||
|
||||
|
||||
New in release 1.1.1
|
||||
=====================
|
||||
|
||||
* .bvirc not read in some cases, fixed
|
||||
* ":f newname" does not work, fixed
|
||||
* distribution tar file with no directory, fixed
|
||||
* freebsd and openbsd added to Makefile
|
||||
* undo of D command fixed
|
||||
|
||||
|
||||
New in release 1.1.0
|
||||
=====================
|
||||
|
||||
* A lot of bugfixes
|
||||
* New option ":set offset=n" for counting the addresses beginning
|
||||
with n instead of 0
|
||||
* New bit-wise commands :xor :and :or :not :neg :lshift :rshift
|
||||
:rrotate :lrotate
|
||||
* Byte addressing for colon commands, e.g. ":5,100w foo" writes
|
||||
byte 5 through 100 to file foo
|
||||
* Backwards hex search character % changed to #
|
||||
* Filename substitution with %, e.g. ":w %.new"
|
339
COPYING
Normal file
339
COPYING
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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".
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
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,
|
||||
|
||||
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,
|
||||
|
||||
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 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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: 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
|
||||
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
|
||||
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) 19yy <name of author>
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
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:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision 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.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
18
CREDITS
Normal file
18
CREDITS
Normal file
|
@ -0,0 +1,18 @@
|
|||
Patches:
|
||||
Guido <guido@bearix.oche.de> sys_errlist
|
||||
Christian "naddy" Weisgerber <naddy@mips.rhein-neckar.de> {Free,Open}BSD
|
||||
Gunnar Larisch <la@softing.com> ^ZZ bug
|
||||
Peter J. Holzer <hjp@wsr.ac.at> setlocale
|
||||
Albert Chin-A-Young <china@thewrittenword.com> Makefile.in
|
||||
Ralf <rks@ffm.tc.iot.dtag.de> AIX fixes
|
||||
Claudio Nieder <claudio@chili.symmetrix.ch> Makefile
|
||||
|
||||
Packages:
|
||||
Christian "naddy" Weisgerber <naddy@mips.rhein-neckar.de> Source RPM
|
||||
Christian Kurz <shorty@jupiter.rhein-neckar.de> Debian package
|
||||
Stijn de Bekker <stijn@debekker.org> Debian package
|
||||
Troy Engel <tengel@sonic.net> i386 RPM package
|
||||
|
||||
Doc:
|
||||
Sven Guckes <guckes@math.fu-berlin.de>
|
||||
Ben <info@leedsnet.com>
|
91
Makefile.in
Normal file
91
Makefile.in
Normal file
|
@ -0,0 +1,91 @@
|
|||
# bvi - Binary Visual Editor Makefile
|
||||
#
|
||||
# This is the Makefile for bvi - binary visual editor. If it has the name
|
||||
# "Makefile.in" then it is a template for a Makefile; to generate the actual
|
||||
# Makefile, run "./configure", which is a configuration script generated by the
|
||||
# "autoconf" program (constructs like "@foo@" will get replaced in the
|
||||
# actual Makefile.
|
||||
#
|
||||
# Copyright (c) 1996-2000 by Gerhard Buergmann
|
||||
# Gerhard.Buergmann@altavista.net
|
||||
#
|
||||
# 1996-01-18 V 1.0.0
|
||||
# 1999-01-15 V 1.1.0
|
||||
# 1999-03-03 V 1.1.1
|
||||
# 1999-10-22 V 1.2.0
|
||||
# 2000-05-31 V 1.3.0 beta
|
||||
# 2000-10-01 V 1.3.0 final
|
||||
#
|
||||
###############################################
|
||||
|
||||
srcdir = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = $(DESTDIR)@bindir@
|
||||
mandir = $(DESTDIR)@mandir@
|
||||
datadir = $(DESTDIR)@datadir@
|
||||
|
||||
man1dir = $(mandir)/man1
|
||||
|
||||
OBJS = bvi.o comm.o set.o re.o io.o edit.o recomp.o
|
||||
HEADER = bvi.h set.h
|
||||
BMOBJ = bmore.o bm_unix.o recomp.o
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ @CPPFLAGS@
|
||||
DEFS = @DEFS@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
SHELL = /bin/sh
|
||||
|
||||
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
|
||||
all: bvi bmore
|
||||
|
||||
bvi: $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o bvi $(OBJS) $(LIBS)
|
||||
|
||||
bmore: $(BMOBJ)
|
||||
$(CC) $(LDFLAGS) -o bmore $(BMOBJ) $(LIBS)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(DEFS) -c $<
|
||||
|
||||
bmore.o: bmore.c
|
||||
$(CC) $(CFLAGS) $(DEFS) -DHELPFILE=\"$(datadir)/bmore.help\" -c $<
|
||||
|
||||
|
||||
install: all installdirs
|
||||
@echo "Installing bvi"
|
||||
@$(INSTALL_DATA) bvi.1 bmore.1 $(man1dir)
|
||||
@$(INSTALL_PROGRAM) -s bvi $(bindir)
|
||||
@$(INSTALL_PROGRAM) -s bmore $(bindir)
|
||||
@$(INSTALL_DATA) bmore.help $(datadir)
|
||||
@if [ -f $(bindir)/bview ]; then rm $(bindir)/bview; fi
|
||||
@if [ -f $(bindir)/bvedit ]; then rm $(bindir)/bvedit; fi
|
||||
@ln $(bindir)/bvi $(bindir)/bview
|
||||
@ln $(bindir)/bvi $(bindir)/bvedit
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${srcdir}/mkinstalldirs $(bindir) $(datadir) $(man1dir)
|
||||
|
||||
uninstall:
|
||||
@echo "Uninstalling bvi"
|
||||
@if [ -f $(bindir)/bview ]; then rm $(bindir)/bview; fi
|
||||
@if [ -f $(bindir)/bvedit ]; then rm $(bindir)/bvedit; fi
|
||||
@if [ -f $(bindir)/bvi ]; then rm $(bindir)/bvi; fi
|
||||
@if [ -f $(bindir)/bmore ]; then rm $(bindir)/bmore; fi
|
||||
@if [ -f $(datadir)/bmore.help ]; then rm $(datadir)/bmore.help; fi
|
||||
@if [ -f $(man1dir)/bvi.1 ]; then rm $(man1dir)/bvi.1; fi
|
||||
@if [ -f $(man1dir)/bmore.1 ]; then rm $(man1dir)/bmore.1; fi
|
||||
|
||||
clean:
|
||||
rm -f core *.o bvi bmore a.out
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile config.cache config.h config.log config.status
|
35
README
Normal file
35
README
Normal file
|
@ -0,0 +1,35 @@
|
|||
BVI - Binary visual editor
|
||||
==========================
|
||||
http://bvi.linuxave.net/
|
||||
|
||||
This editor for binary files was written by Gerhard Buergmann
|
||||
and is distributed under the GPL (GNU Public License).
|
||||
|
||||
|
||||
How to compile
|
||||
==============
|
||||
|
||||
gunzip -c bvi-1.3.0.tar.gz | tar xvf -
|
||||
cd bvi-1.3.0
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
HTML documentation in subdirectory html/
|
||||
|
||||
Subscribe to the bvi mailing for support, updates and other news:
|
||||
|
||||
Send a blank email to bvi-subscribe@eGroups.com. You will receive a
|
||||
subscription confirmation message. Simply reply this message and your
|
||||
subscription will be complete.
|
||||
|
||||
|
||||
------------------------------------------------------------------------
|
||||
PLEASE send any bug reports (and fixes), code for new features,
|
||||
comments, questions, etc. (even flames) to:
|
||||
|
||||
Gerhard Buergmann
|
||||
Vienna, Austria
|
||||
E-mail: Gerhard.Buergmann@altavista.net
|
||||
|
||||
|
7
acconfig.h
Normal file
7
acconfig.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
/***** begin user configuration section *****/
|
||||
|
||||
#undef HAVE_NCURSES_H
|
||||
|
||||
#undef HAVE_CURSES_H
|
||||
|
||||
#undef NO_SYSERRL
|
BIN
bc/bmore/BMORE.PRJ
Normal file
BIN
bc/bmore/BMORE.PRJ
Normal file
Binary file not shown.
BIN
bc/bmore/BMORE.TCP
Normal file
BIN
bc/bmore/BMORE.TCP
Normal file
Binary file not shown.
BIN
bc/bmore/TCCONFIG.TC
Normal file
BIN
bc/bmore/TCCONFIG.TC
Normal file
Binary file not shown.
BIN
bc/bmore/TCDEF.DSK
Normal file
BIN
bc/bmore/TCDEF.DSK
Normal file
Binary file not shown.
BIN
bc/bvi/BVI.DSK
Normal file
BIN
bc/bvi/BVI.DSK
Normal file
Binary file not shown.
BIN
bc/bvi/BVI.PRJ
Normal file
BIN
bc/bvi/BVI.PRJ
Normal file
Binary file not shown.
BIN
bc/bvi/TCCONFIG.TC
Normal file
BIN
bc/bvi/TCCONFIG.TC
Normal file
Binary file not shown.
BIN
bc/bvi/TCPICK.TCP
Normal file
BIN
bc/bvi/TCPICK.TCP
Normal file
Binary file not shown.
126
bm_dos.c
Executable file
126
bm_dos.c
Executable file
|
@ -0,0 +1,126 @@
|
|||
/* BM_DOS.C - DOS specific subroutines for BMORE
|
||||
*
|
||||
* 2000-05-10 V 1.3.0 alpha
|
||||
* 2000-07-07 V 1.3.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
/*
|
||||
#define DEBUG 1
|
||||
*/
|
||||
|
||||
#include "bmore.h"
|
||||
|
||||
#define TBUFSIZ 1024
|
||||
|
||||
|
||||
extern off_t bytepos, screen_home;
|
||||
extern FILE *curr_file;
|
||||
/*
|
||||
extern int screenlines;
|
||||
*/
|
||||
|
||||
int got_int;
|
||||
int no_intty, no_tty;
|
||||
|
||||
#ifdef DEBUG
|
||||
FILE *dbug;
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
initterm()
|
||||
{
|
||||
maxx = 80;
|
||||
maxy = 25;
|
||||
}
|
||||
|
||||
void
|
||||
set_tty ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
reset_tty ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sig()
|
||||
{
|
||||
signal(SIGINT, sig);
|
||||
|
||||
got_int = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doshell() - run a command or an interactive shell
|
||||
*/
|
||||
void
|
||||
doshell(cmd)
|
||||
char *cmd;
|
||||
{
|
||||
system(cmd);
|
||||
printf("\r");
|
||||
clrscr();
|
||||
fseek(curr_file, screen_home, SEEK_SET);
|
||||
bytepos = screen_home;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
home()
|
||||
{
|
||||
/*
|
||||
tputs(Home, 1, putch);
|
||||
|
||||
screenlines = 0;
|
||||
*/
|
||||
gotoxy(1, 1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
vgetc()
|
||||
{
|
||||
return ((char)bioskey(0));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* force clear to end of line
|
||||
*/
|
||||
cleareol()
|
||||
{
|
||||
/*
|
||||
tputs(erase_ln, 1, putch);
|
||||
*/
|
||||
clreol();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
beep(void)
|
||||
{
|
||||
putchar(7);
|
||||
}
|
||||
|
||||
|
234
bm_unix.c
Normal file
234
bm_unix.c
Normal file
|
@ -0,0 +1,234 @@
|
|||
/* BM_UNIX.C - Unix specific subroutines for BMORE
|
||||
*
|
||||
* 2000-05-31 V 1.3.0 beta
|
||||
* 2000-10-12 V 1.3.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
|
||||
#include "bmore.h"
|
||||
#include <termios.h>
|
||||
|
||||
#define TBUFSIZ 1024
|
||||
|
||||
#define stty(fd,argp) tcsetattr(fd,TCSAFLUSH,argp)
|
||||
|
||||
struct termios ostate, nstate;
|
||||
|
||||
|
||||
char *rev_start, *rev_end;/* enter and exit standout mode */
|
||||
char *Home; /* go to home */
|
||||
char *clear_sc; /* clear screen */
|
||||
char *erase_ln; /* erase line */
|
||||
|
||||
extern off_t bytepos, screen_home;
|
||||
extern FILE *curr_file;
|
||||
|
||||
int got_int;
|
||||
int fnum, no_intty, no_tty, slow_tty;
|
||||
int dum_opt, dlines;
|
||||
|
||||
|
||||
/*
|
||||
* A real function, for the tputs routine
|
||||
*/
|
||||
#ifdef NEED_PUTC_CHAR
|
||||
|
||||
int
|
||||
putchr(char ch)
|
||||
{return putchar((int)ch);}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
putchr(ch)
|
||||
int ch;
|
||||
{return putchar(ch);}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
initterm()
|
||||
{
|
||||
char buf[TBUFSIZ];
|
||||
static char clearbuf[TBUFSIZ];
|
||||
char *term;
|
||||
char *clearptr;
|
||||
|
||||
struct termios nstate;
|
||||
|
||||
no_tty = tcgetattr(fileno(stdout), &ostate);
|
||||
nstate = ostate;
|
||||
nstate.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL);
|
||||
nstate.c_cc[VMIN] = 1;
|
||||
nstate.c_cc[VTIME] = 0;
|
||||
tcsetattr(fileno(stdin), TCSADRAIN, &nstate);
|
||||
|
||||
if ((term = getenv("TERM")) == 0 || tgetent(buf, term) <= 0) {
|
||||
printf("Dumb terminal\n");
|
||||
maxx = 80;
|
||||
maxy = 24;
|
||||
} else {
|
||||
maxy = tgetnum("li");
|
||||
maxx = tgetnum("co");
|
||||
}
|
||||
clearptr = clearbuf;
|
||||
erase_ln = tgetstr("ce", &clearptr);
|
||||
clear_sc = tgetstr("cl", &clearptr);
|
||||
rev_start = tgetstr("so", &clearptr);
|
||||
rev_end = tgetstr("se", &clearptr);
|
||||
|
||||
no_intty = tcgetattr(fileno(stdin), &ostate);
|
||||
tcgetattr(fileno(stderr), &ostate);
|
||||
|
||||
nstate = ostate;
|
||||
if (!no_tty)
|
||||
ostate.c_lflag &= ~(ICANON|ECHO);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
set_tty()
|
||||
{
|
||||
ostate.c_lflag &= ~(ICANON|ECHO);
|
||||
stty(fileno(stderr), &ostate);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
reset_tty()
|
||||
{
|
||||
if (no_tty) return;
|
||||
ostate.c_lflag |= ICANON|ECHO;
|
||||
stty(fileno(stderr), &ostate);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sig()
|
||||
{
|
||||
signal(SIGINT, sig);
|
||||
signal(SIGQUIT, sig);
|
||||
|
||||
got_int = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* doshell() - run a command or an interactive shell
|
||||
*/
|
||||
void
|
||||
doshell(cmd)
|
||||
char *cmd;
|
||||
{
|
||||
char *getenv();
|
||||
char cline[128];
|
||||
|
||||
/*
|
||||
outstr("\r\n");
|
||||
flushbuf();
|
||||
*/
|
||||
|
||||
if (cmd == NULL) {
|
||||
if ((cmd = getenv("SHELL")) == NULL)
|
||||
cmd = "/bin/sh";
|
||||
sprintf(cline, "%s -i", cmd);
|
||||
cmd = cline;
|
||||
}
|
||||
|
||||
printf(cmd);
|
||||
reset_tty();
|
||||
|
||||
system(cmd);
|
||||
set_tty();
|
||||
printf("\r");
|
||||
home();
|
||||
fseek(curr_file, screen_home, SEEK_SET);
|
||||
bytepos = screen_home;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
highvideo()
|
||||
{
|
||||
if (rev_start && rev_end)
|
||||
tputs(rev_start, 1, putchr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
normvideo()
|
||||
{
|
||||
if (rev_start && rev_end)
|
||||
tputs(rev_end, 1, putchr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
clrscr()
|
||||
{
|
||||
tputs(clear_sc, 1, putchr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
home()
|
||||
{
|
||||
tputs(Home, 1, putchr);
|
||||
}
|
||||
|
||||
|
||||
/* force clear to end of line */
|
||||
void
|
||||
clreol()
|
||||
{
|
||||
tputs(erase_ln, 1, putchr);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
vgetc()
|
||||
{
|
||||
char cha;
|
||||
extern int errno;
|
||||
|
||||
errno = 0;
|
||||
if (read(2, &cha, 1) <= 0) {
|
||||
if (errno != EINTR)
|
||||
exit(2);
|
||||
}
|
||||
return (cha);
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
/*
|
||||
* Copy contents of memory (with possible overlapping).
|
||||
*/
|
||||
char *
|
||||
memmove(s1, s2, n)
|
||||
char *s1;
|
||||
char *s2;
|
||||
size_t n;
|
||||
{
|
||||
bcopy(s2, s1, n);
|
||||
return(s1);
|
||||
}
|
||||
#endif
|
299
bmore.1
Normal file
299
bmore.1
Normal file
|
@ -0,0 +1,299 @@
|
|||
.TH BMORE 1 "13 June 2000"
|
||||
.SH NAME
|
||||
bmore \- browse through a binary file
|
||||
.SH SYNOPSIS
|
||||
.B bmore
|
||||
[
|
||||
.B \-adi
|
||||
] [
|
||||
.B +\fIlinenumber\fP
|
||||
] [
|
||||
.B +/\fIASCII-pattern\fP
|
||||
] [
|
||||
.B +\\\\\fIHex-pattern\fP
|
||||
] [
|
||||
.I filename
|
||||
\&.\|.\|. ]
|
||||
.LP
|
||||
.if n .ti +05i
|
||||
.SH DESCRIPTION
|
||||
.IX "bmore command" "" "\fLbmore\fP \(em browse binary file"
|
||||
.IX "binary file, browse through" \fLbmore\fP
|
||||
.IX file "browse bmore" "" "browse through binary\(em \fLbmore\fP"
|
||||
.IX display "file by screenfuls \(em \fLbmore\fP"
|
||||
.LP
|
||||
.B more
|
||||
is a filter that displays the contents of a binary
|
||||
file
|
||||
on the terminal, one screenful at a time. It normally pauses after
|
||||
each screenful, and prints
|
||||
.B --More--
|
||||
at the bottom of the screen.
|
||||
.B bmore
|
||||
provides a two-line overlap between screens for continuity.
|
||||
If
|
||||
.B bmore
|
||||
is reading from a file rather than a pipe, the percentage of
|
||||
characters displayed so far is also shown.
|
||||
.LP
|
||||
.B bmore
|
||||
scrolls up to display one more screen line in response to a
|
||||
.SM RETURN
|
||||
character; it displays another screenful in response to a
|
||||
.SM SPACE
|
||||
character. Other commands are listed below.
|
||||
.LP
|
||||
The screen is divided in three sections or panes:
|
||||
The byte offset (extreme left), the hex pane (middle),
|
||||
and an ascii pane (right) which shows as printable characters
|
||||
those bytes in the hex pane.
|
||||
On an 80 column terminal there will be sixteen hex values
|
||||
and their ASCII values on each screen line.
|
||||
Note that (as one would expect) the first byte has the offset \*(L'0\*(R' (zero).
|
||||
.LP
|
||||
.B bmore
|
||||
sets the terminal
|
||||
to
|
||||
.I noecho
|
||||
mode, so that the output can be continuous.
|
||||
Commands that you type do not normally show up on your terminal,
|
||||
except for the
|
||||
.B /
|
||||
,
|
||||
.B \\\\
|
||||
and
|
||||
.B !
|
||||
commands.
|
||||
.LP
|
||||
If the standard output is not a terminal,
|
||||
.B more
|
||||
acts just like
|
||||
.BR cat (1V),
|
||||
except that a header is printed before each file in a series.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-a
|
||||
ASCII mode: no hex representation of the contents. Non printable
|
||||
characters are displayed as a dot (.)
|
||||
.TP
|
||||
.B \-d
|
||||
Display error messages rather than ringing the terminal bell if
|
||||
an unrecognized command is used.
|
||||
This is helpful for inexperienced users.
|
||||
.TP
|
||||
.B \-i
|
||||
Ignore case for searching.
|
||||
.TP
|
||||
.BI + linenumber\fP
|
||||
Start up at
|
||||
.IR linenumber .
|
||||
.TP
|
||||
.BI +/ ASCII-pattern\fP
|
||||
Start up at the line containing the regular expression
|
||||
.IR pattern .
|
||||
Note: unlike
|
||||
editors, this construct should
|
||||
.I not
|
||||
end with a
|
||||
.RB ` / '.
|
||||
If it does, then the trailing slash is taken as a character in the
|
||||
search pattern.
|
||||
.TP
|
||||
.br
|
||||
.ne 8
|
||||
.SH USAGE
|
||||
.SS Commands
|
||||
.LP
|
||||
The commands take effect immediately; it is not necessary to
|
||||
type a carriage return.
|
||||
Up to the time when the command character itself is given,
|
||||
the user may type the line kill character to cancel the numerical
|
||||
argument being formed.
|
||||
In addition, the user may type the erase character to redisplay the
|
||||
.RB ` "--More--(\fIxx\fP%)" '
|
||||
message.
|
||||
.LP
|
||||
In the following commands,
|
||||
.I i
|
||||
is a numerical argument
|
||||
.RB ( 1
|
||||
by default).
|
||||
.TP 10
|
||||
.IR i \s-1SPACE\s0
|
||||
Display another screenful, or
|
||||
.I i
|
||||
more lines if
|
||||
.I i
|
||||
is specified.
|
||||
.TP
|
||||
.IR i \s-1RETURN\s0
|
||||
Display another line, or
|
||||
.I i
|
||||
more lines, if specified.
|
||||
.TP
|
||||
.IB i ^D
|
||||
(\s-1CTRL\s0\-D)
|
||||
Display (scroll down) 11 more lines.
|
||||
.I i
|
||||
is given, the scroll size is set to
|
||||
.IR i\| .
|
||||
.TP
|
||||
.IR i d
|
||||
Same as
|
||||
.BR ^D .
|
||||
.TP
|
||||
.IB i z
|
||||
Same as
|
||||
.SM SPACE,
|
||||
except that
|
||||
.IR i\| ,
|
||||
if present, becomes the new default number
|
||||
of lines per screenful.
|
||||
.TP
|
||||
.IB i s
|
||||
Skip
|
||||
.I i\|
|
||||
lines and then print a screenful.
|
||||
.TP
|
||||
.IB i f
|
||||
Skip
|
||||
.I i
|
||||
screenfuls and then print a screenful.
|
||||
.TP
|
||||
.IB i ^B
|
||||
(\s-1CTRL-B\s0)
|
||||
Skip back
|
||||
.I i
|
||||
screenfuls and then print a screenful.
|
||||
.TP
|
||||
.I b
|
||||
Same as
|
||||
.B ^B
|
||||
(\s-1CTRL-D\s0).
|
||||
.TP
|
||||
.B q
|
||||
.PD 0
|
||||
.TP
|
||||
.B Q
|
||||
.PD
|
||||
Exit from
|
||||
.BR more .
|
||||
.TP
|
||||
.B =
|
||||
Display the current line number.
|
||||
.TP
|
||||
.B v
|
||||
Drop into the
|
||||
.BR bvi (1)
|
||||
editor at the current offset of the current
|
||||
file.
|
||||
.TP
|
||||
.B w
|
||||
Drop into the
|
||||
.BR bvi (1)
|
||||
editor at the current offset of the current
|
||||
file. Only the portion of the file displayed on the screen will be loaded.
|
||||
.TP
|
||||
.B h
|
||||
Help. Give a description of all the
|
||||
.B more
|
||||
commands.
|
||||
.TP
|
||||
.IB i / pattern
|
||||
Search for the
|
||||
.IR i\| th
|
||||
occurrence of the regular expression
|
||||
.IR pattern .
|
||||
Display the screenful starting at the file position
|
||||
that contains the
|
||||
.IR i\| th
|
||||
match for the regular expression
|
||||
.IR ASCII-pattern ,
|
||||
or the end of a pipe, whichever comes first. If
|
||||
.B bmore
|
||||
is displaying a file and there is no such match, its position
|
||||
in the file remains unchanged. Regular expressions can be
|
||||
edited using erase and kill characters.
|
||||
Erasing back past the first column cancels the search command.
|
||||
.TP
|
||||
.B \'
|
||||
Single quote. Go to the point from which the last search started.
|
||||
If no search has been performed in the current file,
|
||||
go to the beginning of the file.
|
||||
.TP
|
||||
.BI ! command
|
||||
Invoke a shell to execute
|
||||
.IR command\| .
|
||||
The characters
|
||||
.B %
|
||||
and
|
||||
.BR ! ,
|
||||
when used within
|
||||
.I command
|
||||
are replaced with the current filename
|
||||
and the previous shell command,
|
||||
respectively.
|
||||
If there is no current filename,
|
||||
.B %
|
||||
is not expanded. Prepend a backslash to these characters to
|
||||
escape expansion.
|
||||
.TP
|
||||
.IB i :n
|
||||
Skip to the
|
||||
.IR i\| th
|
||||
next filename given in the command line,
|
||||
or to the last filename in the list if
|
||||
.I i
|
||||
is out of range.
|
||||
.TP
|
||||
.IB i :p
|
||||
Skip to the
|
||||
.IR i\| th
|
||||
previous filename given in the command line,
|
||||
or to the first filename if
|
||||
.I i
|
||||
is out of range.
|
||||
If given while
|
||||
.B more
|
||||
is positioned within a file, go to the
|
||||
beginning of the file.
|
||||
If
|
||||
.B more
|
||||
is reading from a pipe,
|
||||
.B more
|
||||
simply rings the terminal bell.
|
||||
.br
|
||||
.ne 2
|
||||
.TP
|
||||
.B :f
|
||||
Display the current filename and offset number.
|
||||
.br
|
||||
.ne 5
|
||||
.TP
|
||||
.B :q
|
||||
.PD 0
|
||||
.TP
|
||||
.B :Q
|
||||
.PD
|
||||
Exit from
|
||||
.B bmore
|
||||
(same as
|
||||
.B q
|
||||
or
|
||||
.B Q ).
|
||||
.TP
|
||||
.B \&.
|
||||
Dot. Repeat the previous command.
|
||||
.TP
|
||||
.SH FILES
|
||||
.PD 0
|
||||
.TP 20
|
||||
.B /etc/termcap
|
||||
terminal data base
|
||||
.TP
|
||||
.B /usr/local/share/bmore.help
|
||||
help file
|
||||
.PD
|
||||
.SH "SEE ALSO"
|
||||
.BR bvi (1),
|
||||
.BR termcap (5)
|
827
bmore.c
Normal file
827
bmore.c
Normal file
|
@ -0,0 +1,827 @@
|
|||
/* BMORE - binary more
|
||||
*
|
||||
* 1990-01-31 V 1.0.0
|
||||
* 1990-09-04 V 1.1.0
|
||||
* 2000-05-31 V 1.3.0 beta
|
||||
* 2000-10-18 V 1.3.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1990-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#ifdef __MSDOS__
|
||||
# define PRINTF cprintf
|
||||
#else
|
||||
# define PRINTF printf
|
||||
#ifndef HELPFILE
|
||||
# define HELPFILE "/usr/local/lib/bmore.help"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "bmore.h"
|
||||
|
||||
char *copyright = "Copyright (C) 1990-2000 by Gerhard Buergmann";
|
||||
|
||||
int maxx, maxy;
|
||||
char *name = NULL;
|
||||
char sstring[MAXCMD] = "";
|
||||
char string[MAXCMD];
|
||||
FILE *curr_file = NULL, *help_file;
|
||||
int AnzAdd;
|
||||
long precount = -1; /* number preceding command */
|
||||
|
||||
char **files; /* list of input files */
|
||||
int numfiles; /* number of input files */
|
||||
int file_nr = 0; /* number of current input file */
|
||||
|
||||
int arrnum = 0;
|
||||
char numarr[64]; /* string for collecting number */
|
||||
char addr_form[15];
|
||||
|
||||
int ascii_flag = 0;
|
||||
int d_flag = 0;
|
||||
int init_search = 0;
|
||||
char buffer1[MAXCMD], buffer2[MAXCMD];
|
||||
int out_len;
|
||||
int corr = 0, to_print;
|
||||
off_t init_byte = 0;
|
||||
off_t last_search = 0;
|
||||
off_t screen_home, filesize;
|
||||
off_t bytepos, oldpos;
|
||||
int prompt = 1;
|
||||
char helppath[MAXCMD];
|
||||
|
||||
static char *progname;
|
||||
static char cmdbuf[MAXCMD];
|
||||
static int cnt = 0;
|
||||
static int icnt = 0;
|
||||
static int smode;
|
||||
|
||||
char search_pat[BUFFER]; /* / or ? command */
|
||||
char *emptyclass = "Empty byte class '[]' or '[^]'";
|
||||
|
||||
|
||||
/* -a ASCII mode
|
||||
* -d beginners mode
|
||||
* -i ignore case
|
||||
*/
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-adi] [+linenum | +/pattern] name1 name2 ...\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int ch, ch1;
|
||||
int colon = 0, last_ch = 0;
|
||||
long last_pre = 0;
|
||||
int lflag, repeat;
|
||||
long count;
|
||||
int i, n = 1;
|
||||
int d_line, r_line, z_line;
|
||||
|
||||
|
||||
#ifdef __MSDOS__
|
||||
char *poi;
|
||||
|
||||
strcpy(helppath, argv[0]);
|
||||
poi = strrchr(helppath, '\\');
|
||||
*poi = '\0';
|
||||
strcat(helppath, "\\MORE.HLP");
|
||||
#else
|
||||
strncpy(helppath, HELPFILE, MAXCMD - 1);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
while (n < argc) {
|
||||
switch (argv[n][0]) {
|
||||
case '-':
|
||||
i = 1;
|
||||
while (argv[n][i] != '\0') {
|
||||
switch (argv[n][i]) {
|
||||
case 'a': ascii_flag++;
|
||||
break;
|
||||
case 'd': d_flag++;
|
||||
break;
|
||||
case 'i': ignore_case++;
|
||||
break;
|
||||
default: usage();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
n++;
|
||||
break;
|
||||
case '+': /* +cmd */
|
||||
if (argv[n][1] == '/' || argv[n][1] == '\\') {
|
||||
init_search = argv[n][1];
|
||||
strcpy(sstring, &argv[n][2]);
|
||||
} else {
|
||||
if (argv[n][1] == '0') {
|
||||
init_byte = (off_t)strtol(argv[n] + 1, NULL, 16);
|
||||
} else {
|
||||
init_byte = (off_t)strtol(argv[n] + 1, NULL, 10);
|
||||
}
|
||||
}
|
||||
n++;
|
||||
break;
|
||||
default: /* must be a file name */
|
||||
name = strdup(argv[n]);
|
||||
files = &(argv[n]);
|
||||
numfiles = argc - n;
|
||||
n = argc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (numfiles == 0) {
|
||||
curr_file = stdin;
|
||||
if (isatty(fileno(stdin)) != 0) usage();
|
||||
} else {
|
||||
open_file(name);
|
||||
file_nr = 1;
|
||||
fseek(curr_file, init_byte, SEEK_SET);
|
||||
bytepos += init_byte;
|
||||
}
|
||||
screen_home = bytepos;
|
||||
|
||||
initterm();
|
||||
set_tty();
|
||||
maxy -= 2;
|
||||
z_line = maxy;
|
||||
d_line = maxy / 2;
|
||||
r_line = 1;
|
||||
|
||||
AnzAdd = 10;
|
||||
strcpy(addr_form, "%08lX ");
|
||||
|
||||
if (ascii_flag)
|
||||
out_len = ((maxx - AnzAdd - 1) / 4) * 4;
|
||||
else
|
||||
out_len = ((maxx - AnzAdd - 1) / 16) * 4;
|
||||
|
||||
if (init_search)
|
||||
bmsearch(init_search);
|
||||
|
||||
if (no_tty) {
|
||||
while(!printout(1));
|
||||
reset_tty();
|
||||
exit(0);
|
||||
}
|
||||
if (printout(maxy)) {
|
||||
do_next(1);
|
||||
}
|
||||
/* main loop */
|
||||
do {
|
||||
to_print = 0;
|
||||
if (prompt) {
|
||||
highvideo();
|
||||
PRINTF("--More--");
|
||||
if (prompt == 2) {
|
||||
PRINTF("(Next file: %s)", name);
|
||||
} else if (!no_intty && filesize) {
|
||||
PRINTF("(%d%%)", (int)((bytepos * 100) / filesize));
|
||||
}
|
||||
|
||||
if (d_flag) PRINTF("[Press space to continue, 'q' to quit]");
|
||||
normvideo();
|
||||
fflush(stdout);
|
||||
}
|
||||
ch = vgetc();
|
||||
if (prompt == 2) {
|
||||
open_file(name);
|
||||
}
|
||||
prompt = 1;
|
||||
PRINTF("\r");
|
||||
while (ch >= '0' && ch <= '9') {
|
||||
numarr[arrnum++] = ch;
|
||||
ch = vgetc();
|
||||
}
|
||||
numarr[arrnum] = '\0';
|
||||
if (arrnum != 0) precount = strtol(numarr, (char **)NULL, 10);
|
||||
else precount = -1;
|
||||
lflag = arrnum = 0;
|
||||
|
||||
if (ch == '.') {
|
||||
precount = last_pre;
|
||||
ch = last_ch;
|
||||
repeat = 1;
|
||||
} else {
|
||||
last_pre = precount;
|
||||
last_ch = ch;
|
||||
if (ch == ':') colon = vgetc();
|
||||
repeat = 0;
|
||||
}
|
||||
|
||||
switch (ch) {
|
||||
case ' ': /* Display next k lines of text [current screen size] */
|
||||
if (precount > 0) to_print = precount;
|
||||
else to_print = maxy;
|
||||
break;
|
||||
case 'z': /* Display next k lines of bytes [current screen size]* */
|
||||
if (precount > 0) z_line = precount;
|
||||
to_print = z_line;
|
||||
break;
|
||||
case '\r':
|
||||
case '\n': /* Display next k lines of text [current screen size]* */
|
||||
if (precount > 0) r_line = precount;
|
||||
to_print = r_line;
|
||||
break;
|
||||
case 'q':
|
||||
case 'Q':
|
||||
clreol();
|
||||
reset_tty();
|
||||
exit(0);
|
||||
case ':' :
|
||||
switch (colon) {
|
||||
case 'f':
|
||||
prompt = 0;
|
||||
if (!no_intty)
|
||||
PRINTF("\"%s\" line %lu", name,
|
||||
(unsigned long)(bytepos - out_len));
|
||||
else
|
||||
PRINTF("[Not a file] line %lu",
|
||||
(unsigned long)(bytepos - out_len));
|
||||
fflush(stdout);
|
||||
break;
|
||||
case 'n':
|
||||
if (precount < 1) precount = 1;
|
||||
do_next(precount);
|
||||
PRINTF("\r");
|
||||
clreol();
|
||||
PRINTF("\n...Skipping to file %s\r\n\r\n", name);
|
||||
prompt = 2;
|
||||
break;
|
||||
case 'p':
|
||||
if (precount < 1) precount = 1;
|
||||
do_next(-precount);
|
||||
PRINTF("\r");
|
||||
clreol();
|
||||
PRINTF("\n...Skipping back to file %s\r\n\r\n", name);
|
||||
prompt = 2;
|
||||
break;
|
||||
case 'q':
|
||||
clreol();
|
||||
reset_tty();
|
||||
exit(0);
|
||||
break;
|
||||
case '!':
|
||||
if (!no_intty) {
|
||||
clreol();
|
||||
if (rdline(ch)) break;
|
||||
doshell(sstring);
|
||||
PRINTF("------------------------\r\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
beep();
|
||||
}
|
||||
break;
|
||||
case 'd': /* Scroll k lines [current scroll size, initially 11]* */
|
||||
case CTRL('D'):
|
||||
if (precount > 0) d_line = precount;
|
||||
to_print = d_line;
|
||||
break;
|
||||
case CTRL('L'): /*** REDRAW SCREEN ***/
|
||||
if (no_intty) {
|
||||
beep();
|
||||
} else {
|
||||
clrscr();
|
||||
to_print = maxy + 1;
|
||||
fseek(curr_file, screen_home, SEEK_SET);
|
||||
bytepos = screen_home;
|
||||
}
|
||||
break;
|
||||
case 'b': /* Skip backwards k screenfuls of text [1] */
|
||||
case CTRL('B'):
|
||||
if (no_intty) {
|
||||
beep();
|
||||
} else {
|
||||
if (precount < 1) precount = 1;
|
||||
PRINTF("...back %ld page", precount);
|
||||
if (precount > 1) {
|
||||
PRINTF("s\r\n");
|
||||
} else {
|
||||
PRINTF("\r\n");
|
||||
}
|
||||
screen_home -= (maxy + 1) * out_len;
|
||||
if (screen_home < 0) screen_home = 0;
|
||||
fseek(curr_file, screen_home, SEEK_SET);
|
||||
bytepos = screen_home;
|
||||
to_print = maxy + 1;
|
||||
}
|
||||
break;
|
||||
case 'f': /* Skip forward k screenfuls of bytes [1] */
|
||||
case 's': /* Skip forward k lines of bytes [1] */
|
||||
if (precount < 1) precount = 1;
|
||||
if (ch == 'f') {
|
||||
count = maxy * precount;
|
||||
} else {
|
||||
count = precount;
|
||||
}
|
||||
putchar('\r');
|
||||
clreol();
|
||||
PRINTF("\n...skipping %ld line", count);
|
||||
if (count > 1) {
|
||||
PRINTF("s\r\n\r\n");
|
||||
} else {
|
||||
PRINTF("\r\n\r\n");
|
||||
}
|
||||
screen_home += (count + maxy) * out_len;
|
||||
fseek(curr_file, screen_home, SEEK_SET);
|
||||
bytepos = screen_home;
|
||||
to_print = maxy;
|
||||
break;
|
||||
case '\\':
|
||||
if (ascii_flag) {
|
||||
beep();
|
||||
break;
|
||||
}
|
||||
case '/': /**** Search String ****/
|
||||
if (!repeat) {
|
||||
if (rdline(ch)) break;
|
||||
}
|
||||
case 'n': /**** Search Next ****/
|
||||
case 'N':
|
||||
bmsearch(ch);
|
||||
/*
|
||||
to_print--;
|
||||
*/
|
||||
break;
|
||||
case '\'':
|
||||
if (no_intty) {
|
||||
beep();
|
||||
} else {
|
||||
bytepos = last_search;
|
||||
fseek(curr_file, bytepos, SEEK_SET);
|
||||
screen_home = bytepos;
|
||||
to_print = maxy;
|
||||
PRINTF("\r");
|
||||
clreol();
|
||||
PRINTF("\n\r\n***Back***\r\n\r\n");
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
prompt = 0;
|
||||
clreol();
|
||||
PRINTF("%lX hex %lu dec", (unsigned long)bytepos,
|
||||
(unsigned long)bytepos);
|
||||
fflush(stdout);
|
||||
break;
|
||||
case '?':
|
||||
case 'h':
|
||||
if ((help_file = fopen(helppath, "r")) == NULL) {
|
||||
emsg("Can't open help file");
|
||||
break;
|
||||
}
|
||||
while ((ch1 = getc(help_file)) != EOF)
|
||||
putchar(ch1);
|
||||
fclose(help_file);
|
||||
to_print = 0;
|
||||
break;
|
||||
case 'w':
|
||||
case 'v':
|
||||
if (!no_intty) {
|
||||
clreol();
|
||||
if (ch == 'v') {
|
||||
sprintf(string, "bvi +%lu %s",
|
||||
(unsigned long)(screen_home +
|
||||
(maxy + 1) / 2 * out_len), name);
|
||||
} else {
|
||||
if (precount < 1) precount = bytepos - screen_home;
|
||||
sprintf(string, "bvi -b %lu -s %lu %s",
|
||||
(unsigned long)screen_home,
|
||||
(unsigned long)precount, name);
|
||||
}
|
||||
doshell(string);
|
||||
to_print = maxy + 1;
|
||||
break;
|
||||
}
|
||||
default :
|
||||
if (d_flag) {
|
||||
emsg("[Press 'h' for instructions.]");
|
||||
} else {
|
||||
beep();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (to_print) {
|
||||
if (printout(to_print)) {
|
||||
do_next(1);
|
||||
}
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rdline(ch)
|
||||
int ch;
|
||||
{
|
||||
int i = 0;
|
||||
int ch1 = 0;
|
||||
|
||||
clreol();
|
||||
putchar(ch);
|
||||
fflush(stdout);
|
||||
|
||||
while (i < MAXCMD) {
|
||||
ch1 = vgetc();
|
||||
if (ch1 == '\n' || ch1 == '\r' || ch1 == ESC) {
|
||||
break;
|
||||
} else if (ch1 == 8) {
|
||||
if (i) {
|
||||
sstring[--i] = '\0';
|
||||
PRINTF("\r%c%s", ch, sstring);
|
||||
clreol();
|
||||
} else {
|
||||
ch1 = ESC;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
putchar(ch1);
|
||||
sstring[i++] = ch1;
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
if (ch1 == ESC) {
|
||||
putchar('\r');
|
||||
clreol();
|
||||
return 1;
|
||||
}
|
||||
if (i) sstring[i] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_next(n)
|
||||
int n;
|
||||
{
|
||||
if (numfiles) {
|
||||
if (n == 1 && file_nr == numfiles) {
|
||||
reset_tty();
|
||||
exit(0);
|
||||
}
|
||||
if ((file_nr + n) > numfiles)
|
||||
file_nr = numfiles;
|
||||
else if ((file_nr + n) < 1)
|
||||
file_nr = 1;
|
||||
else
|
||||
file_nr += n;
|
||||
prompt = 2;
|
||||
free(name);
|
||||
name = strdup(*(files + file_nr - 1));
|
||||
} else {
|
||||
reset_tty();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
open_file(name)
|
||||
char *name;
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if (stat(name, &buf) > -1) {
|
||||
filesize = buf.st_size;
|
||||
}
|
||||
if (numfiles > 1) {
|
||||
PRINTF("\r");
|
||||
clreol();
|
||||
PRINTF("\n::::::::::::::\r\n%s\r\n::::::::::::::\r\n", name);
|
||||
corr = 2;
|
||||
}
|
||||
if (curr_file != NULL) fclose(curr_file);
|
||||
if ((curr_file = fopen(name, "rb")) == NULL) {
|
||||
reset_tty();
|
||||
perror(name);
|
||||
exit(1);
|
||||
}
|
||||
bytepos = screen_home = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
putline(buf, num)
|
||||
char *buf;
|
||||
int num;
|
||||
{
|
||||
int print_pos;
|
||||
unsigned char ch;
|
||||
|
||||
PRINTF(addr_form, bytepos);
|
||||
for (print_pos = 0; print_pos < num; print_pos++) {
|
||||
ch = buf[print_pos];
|
||||
if (!ascii_flag) {
|
||||
PRINTF("%02X ", ch);
|
||||
}
|
||||
++bytepos;
|
||||
if ((ch > 31) && (ch < 127))
|
||||
*(string + print_pos) = ch;
|
||||
else
|
||||
*(string + print_pos) = '.';
|
||||
}
|
||||
*(string + num) = '\0';
|
||||
PRINTF("%s\r\n", string);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
printout(lns)
|
||||
int lns;
|
||||
{
|
||||
int c, num;
|
||||
int doub = 0;
|
||||
static int flag;
|
||||
|
||||
if (corr && (lns > maxy - 2)) lns -= corr;
|
||||
corr = 0;
|
||||
do {
|
||||
for (num = 0; num < out_len; num++) {
|
||||
if ((c = nextchar()) == -1) break;
|
||||
buffer1[num] = c;
|
||||
}
|
||||
if (!num) return 1;
|
||||
if (memcmp(buffer1, buffer2, num) || !bytepos ) {
|
||||
memcpy(buffer2, buffer1, num);
|
||||
putline(buffer2, num);
|
||||
if (!no_tty) flag = TRUE;
|
||||
lns--;
|
||||
} else {
|
||||
if (flag) {
|
||||
clreol();
|
||||
PRINTF("*\r\n");
|
||||
lns--;
|
||||
} else {
|
||||
doub++;
|
||||
}
|
||||
flag = FALSE;
|
||||
bytepos += num;
|
||||
}
|
||||
if (lns == 0) {
|
||||
screen_home = bytepos - ((maxy + 1 + doub) * out_len);
|
||||
if (screen_home < 0) screen_home = 0;
|
||||
return 0;
|
||||
}
|
||||
} while(num);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
nextchar()
|
||||
{
|
||||
if (cnt == 0) return fgetc(curr_file);
|
||||
cnt--;
|
||||
return cmdbuf[icnt++] & 0xff;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pushback(n, where)
|
||||
int n;
|
||||
char *where;
|
||||
{
|
||||
if (cnt) memmove(cmdbuf + n, cmdbuf, n);
|
||||
memcpy(cmdbuf, where, n);
|
||||
icnt = 0;
|
||||
cnt += n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Return:
|
||||
* -1 EOF
|
||||
* 0 not found at current position
|
||||
* 1 found
|
||||
*/
|
||||
int
|
||||
bmregexec(scan)
|
||||
char *scan;
|
||||
{
|
||||
char *act;
|
||||
int count, test;
|
||||
int l;
|
||||
char act_pat[MAXCMD]; /* found pattern */
|
||||
|
||||
act = act_pat;
|
||||
l = 0;
|
||||
while (*scan != 0) {
|
||||
if ((test = nextchar()) == -1) return -1;
|
||||
*act++ = test;
|
||||
if (++l == MAXCMD) {
|
||||
pushback(l, act_pat);
|
||||
return 0;
|
||||
}
|
||||
if (ignore_case && smode == ASCII) test = toupper(test);
|
||||
switch (*scan++) {
|
||||
case ONE: /* exactly one character */
|
||||
count = *scan++;
|
||||
if (count == 1) {
|
||||
if (test != *scan) {
|
||||
bytepos++;
|
||||
if (l > 1) pushback(--l, act_pat + 1);
|
||||
return 0;
|
||||
}
|
||||
scan++;
|
||||
} else if (count > 1) {
|
||||
if (sbracket(test, scan, count)) {
|
||||
bytepos++;
|
||||
if (l > 1) pushback(--l, act_pat + 1);
|
||||
return 0;
|
||||
}
|
||||
scan += count;
|
||||
}
|
||||
break;
|
||||
case STAR: /* zero or more characters */
|
||||
count = *scan++;
|
||||
if (count == 1) { /* only one character, 0 - n times */
|
||||
while (test == *scan) {
|
||||
if ((test = nextchar()) == -1) return -2;
|
||||
*act++ = test;
|
||||
if (++l == MAXCMD) {
|
||||
pushback(l, act_pat);
|
||||
return 0;
|
||||
}
|
||||
if (ignore_case && smode == ASCII)
|
||||
test = toupper(test);
|
||||
}
|
||||
pushback(1, --act);
|
||||
l--;
|
||||
scan++;
|
||||
} else if (count > 1) { /* characters in bracket */
|
||||
if (*scan == '^') {
|
||||
do {
|
||||
/* If we found something matching the next part of the expression, we
|
||||
* abandon the search for not-matching characters. */
|
||||
if (bmregexec(scan + count)) {
|
||||
*act++ = test; /* May be wrong case !! */
|
||||
l++;
|
||||
scan += count;
|
||||
bytepos--;
|
||||
break;
|
||||
}
|
||||
if (sbracket(test, scan, count)) {
|
||||
bytepos++;
|
||||
if (l > 1) pushback(--l, act_pat + 1);
|
||||
return 0;
|
||||
} else {
|
||||
if ((test = nextchar()) == -1) return -3;
|
||||
*act++ = test;
|
||||
if (++l == MAXCMD) {
|
||||
pushback(l, act_pat);
|
||||
return 0;
|
||||
}
|
||||
if (ignore_case && smode == ASCII)
|
||||
test = toupper(test);
|
||||
}
|
||||
} while(1);
|
||||
} else {
|
||||
while(!sbracket(test, scan, count)) {
|
||||
if ((test = nextchar()) == -1) return -4;
|
||||
*act++ = test;
|
||||
if (++l == MAXCMD) {
|
||||
pushback(l, act_pat);
|
||||
return 0;
|
||||
}
|
||||
if (ignore_case && smode == ASCII)
|
||||
test = toupper(test);
|
||||
}
|
||||
scan += count;
|
||||
pushback(1, --act);
|
||||
l--;
|
||||
}
|
||||
} else { /* ".*" */
|
||||
do {
|
||||
if ((test = nextchar()) == -1) return -5;
|
||||
*act++ = test;
|
||||
if (++l == MAXCMD) {
|
||||
pushback(l, act_pat);
|
||||
return 0;
|
||||
}
|
||||
pushback(1, act - 1);
|
||||
bytepos--;
|
||||
} while (bmregexec(scan) == 0);
|
||||
bytepos++;
|
||||
act--;
|
||||
l--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
pushback(l, act_pat);
|
||||
return 1; /* found */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sbracket(start, scan, count)
|
||||
int start;
|
||||
char *scan;
|
||||
int count;
|
||||
{
|
||||
if (*scan++ == '^') {
|
||||
if (!memchr(scan, start, --count)) return 0;
|
||||
} else {
|
||||
if (memchr(scan, start, --count)) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bmsearch(ch)
|
||||
int ch;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (sstring[0] == '\0') {
|
||||
emsg("No previous regular expression");
|
||||
return;
|
||||
}
|
||||
if (ch == '/') {
|
||||
if (ascii_comp(search_pat, sstring)) return;
|
||||
}
|
||||
if (ch == '\\') {
|
||||
if (hex_comp(search_pat, sstring)) return;
|
||||
}
|
||||
oldpos = bytepos;
|
||||
last_search = screen_home;
|
||||
if (precount < 1) precount = 1;
|
||||
while (precount--) {
|
||||
while ((i = bmregexec(search_pat)) == 0);
|
||||
if (i == 1) {
|
||||
screen_home = bytepos;
|
||||
to_print = maxy;
|
||||
} else { /* i == -1 -> EOF */
|
||||
if (no_intty) {
|
||||
PRINTF("\r\nPattern not found\r\n");
|
||||
do_next(1);
|
||||
} else {
|
||||
sprintf(string, "Pattern not found %d - %ul", i, (unsigned long)bytepos);
|
||||
emsg(string);
|
||||
/*
|
||||
emsg("Pattern not found");
|
||||
*/
|
||||
bytepos = oldpos;
|
||||
fseek(curr_file, bytepos, SEEK_SET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (precount) {
|
||||
nextchar();
|
||||
bytepos++;
|
||||
}
|
||||
}
|
||||
if (prompt) {
|
||||
PRINTF("\r\n...skipping\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
emsg(s)
|
||||
char *s;
|
||||
{
|
||||
putchar('\r');
|
||||
clreol();
|
||||
highvideo();
|
||||
PRINTF(s);
|
||||
normvideo();
|
||||
fflush(stdout);
|
||||
prompt = 0;
|
||||
}
|
156
bmore.h
Normal file
156
bmore.h
Normal file
|
@ -0,0 +1,156 @@
|
|||
/* BMORE.H
|
||||
*
|
||||
* 1996-02-28 V 1.0.0
|
||||
* 1999-01-21 V 1.1.0
|
||||
* 1999-03-17 V 1.1.1
|
||||
* 1999-07-01 V 1.2.0 beta
|
||||
* 1999-08-21 V 1.2.0 final
|
||||
* 2000-05-31 V 1.3.0 beta
|
||||
* 2000-10-04 V 1.3.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifdef __MSDOS__
|
||||
# include "patchlev.h"
|
||||
# include "dosconf.h"
|
||||
# include <alloc.h>
|
||||
# include <conio.h>
|
||||
# include <bios.h>
|
||||
#else
|
||||
# include "patchlevel.h"
|
||||
# include "config.h"
|
||||
# include <unistd.h>
|
||||
#if HAVE_NCURSES_H
|
||||
# include <ncurses.h>
|
||||
#else
|
||||
# include <curses.h>
|
||||
#endif
|
||||
#include <term.h>
|
||||
#endif
|
||||
|
||||
/* defines for filemode */
|
||||
#define ERROR -1
|
||||
#define REGULAR 0
|
||||
#define NEW 1
|
||||
#define DIRECTORY 2
|
||||
#define CHARACTER_SPECIAL 3
|
||||
#define BLOCK_SPECIAL 4
|
||||
#define PARTIAL 5
|
||||
|
||||
/* regular expressions */
|
||||
#define END 0
|
||||
#define ONE 1
|
||||
#define STAR 2
|
||||
|
||||
#define ASCII 1
|
||||
#define FORWARD 0
|
||||
#define BACKWARD 1
|
||||
#define CR '\r'
|
||||
#define NL '\n'
|
||||
#define BS 8
|
||||
#define ESC 27
|
||||
#define SEARCH 0
|
||||
#define REPLACE 1
|
||||
#ifndef CTRL
|
||||
# define CTRL(n) (n&0x1f)
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifdef __MSDOS__
|
||||
# define ANSI
|
||||
# define PTR char huge *
|
||||
# define off_t long
|
||||
# define DELIM '\\'
|
||||
# define strncasecmp strnicmp
|
||||
# define strcasecmp stricmp
|
||||
#else
|
||||
# define PTR char *
|
||||
# define DELIM '/'
|
||||
#endif
|
||||
|
||||
#define MAXCMD 255
|
||||
#define BUFFER 1024
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
extern FILE *debug_fp;
|
||||
#endif
|
||||
|
||||
extern char *version;
|
||||
|
||||
#ifdef NO_SYSERRL
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
|
||||
|
||||
extern int maxx, maxy;
|
||||
extern int ignore_case, magic;
|
||||
extern int no_tty, no_intty;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef ANSI
|
||||
void initterm(void), set_tty(void), reset_tty(void);
|
||||
void clreol(void), clrscr(void), highvideo(void), normvideo(void);
|
||||
void /* beep(void), */ home(void);
|
||||
void doshell(char *), emsg(char *);
|
||||
void do_next(int);
|
||||
void open_file(char *);
|
||||
void bmsearch(int);
|
||||
void pushback(int, char *);
|
||||
int printout(int), rdline(int);
|
||||
int nextchar(void), vgetc(void);
|
||||
int sbracket(int, char *, int);
|
||||
int bmregexec(char *);
|
||||
int ascii_comp(char *, char *), hex_comp(char *, char *);
|
||||
void putline(char *, int);
|
||||
#else
|
||||
void initterm(), set_tty(), reset_tty();
|
||||
void clreol(), clrscr(), highvideo(), normvideo();
|
||||
void /* beep(), */ home();
|
||||
void doshell(), emsg();
|
||||
void do_next();
|
||||
void open_file();
|
||||
void bmsearch();
|
||||
void pushback();
|
||||
int printout(), rdline();
|
||||
int nextchar(), vgetc();
|
||||
int sbracket();
|
||||
int bmregexec();
|
||||
int ascii_comp(), hex_comp();
|
||||
void putline();
|
||||
#endif
|
26
bmore.help
Normal file
26
bmore.help
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
Most commands optionally preceded by integer argument k. Defaults in brackets.
|
||||
Star (*) indicates argument becomes new default.
|
||||
-------------------------------------------------------------------------------
|
||||
<space> Display next k lines of bytes [current screen size]
|
||||
z Display next k lines of bytes [current screen size]*
|
||||
<return> Display next k lines of bytes [1]*
|
||||
d or ctrl-D Scroll k lines [current scroll size, initially 11]*
|
||||
q or Q or <interrupt> Exit from bmore
|
||||
s Skip forward k lines of bytes [1]
|
||||
f Skip forward k screenfuls of bytes [1]
|
||||
b or ctrl-B Skip backwards k screenfuls of bytes [1]
|
||||
' Go to place where previous search started
|
||||
= Display current byte number
|
||||
/<regular expression> Search for kth occurrence of ascii regular expr [1]
|
||||
\<regular expression> Search for kth occurrence of binary regular expr [1]
|
||||
n Search for kth occurrence of last r.e [1]
|
||||
!<cmd> or :!<cmd> Execute <cmd> in a subshell
|
||||
v Start up bvi at current position
|
||||
w Start up bvi reading only a screenful of bytes [screen]
|
||||
ctrl-L Redraw screen
|
||||
:n Go to kth next file [1]
|
||||
:p Go to kth previous file [1]
|
||||
:f Display current file name and byte position
|
||||
. Repeat previous command
|
||||
-------------------------------------------------------------------------------
|
26
bmore.hlp
Normal file
26
bmore.hlp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
Most commands optionally preceded by integer argument k. Defaults in brackets.
|
||||
Star (*) indicates argument becomes new default.
|
||||
-------------------------------------------------------------------------------
|
||||
<space> Display next k lines of bytes [current screen size]
|
||||
z Display next k lines of bytes [current screen size]*
|
||||
<return> Display next k lines of bytes [1]*
|
||||
d or ctrl-D Scroll k lines [current scroll size, initially 11]*
|
||||
q or Q or <interrupt> Exit from bmore
|
||||
s Skip forward k lines of bytes [1]
|
||||
f Skip forward k screenfuls of bytes [1]
|
||||
b or ctrl-B Skip backwards k screenfuls of bytes [1]
|
||||
' Go to place where previous search started
|
||||
= Display current byte number
|
||||
/<regular expression> Search for kth occurrence of ascii regular expr [1]
|
||||
\<regular expression> Search for kth occurrence of binary regular expr [1]
|
||||
n Search for kth occurrence of last r.e [1]
|
||||
!<cmd> or :!<cmd> Execute <cmd> in a subshell
|
||||
v Start up bvi at current position
|
||||
w Start up bvi reading only a screenful of bytes [screen]
|
||||
ctrl-L Redraw screen
|
||||
:n Go to kth next file [1]
|
||||
:p Go to kth previous file [1]
|
||||
:f Display current file name and byte position
|
||||
. Repeat previous command
|
||||
-------------------------------------------------------------------------------
|
198
bmore.man
Normal file
198
bmore.man
Normal file
|
@ -0,0 +1,198 @@
|
|||
|
||||
|
||||
|
||||
BMORE(1) BMORE(1)
|
||||
|
||||
|
||||
NNAAMMEE
|
||||
bmore - browse through a binary file
|
||||
|
||||
SSYYNNOOPPSSIISS
|
||||
bbmmoorree [ --aaddii ] [ ++_l_i_n_e_n_u_m_b_e_r ] [ ++//_A_S_C_I_I_-_p_a_t_t_e_r_n ] [
|
||||
++\\_H_e_x_-_p_a_t_t_e_r_n ] [ _f_i_l_e_n_a_m_e ... ]
|
||||
|
||||
|
||||
DDEESSCCRRIIPPTTIIOONN
|
||||
mmoorree is a filter that displays the contents of a binary
|
||||
file on the terminal, one screenful at a time. It nor
|
||||
mally pauses after each screenful, and prints ----MMoorree---- at
|
||||
the bottom of the screen. bbmmoorree provides a two-line over
|
||||
lap between screens for continuity. If bbmmoorree is reading
|
||||
from a file rather than a pipe, the percentage of charac
|
||||
ters displayed so far is also shown.
|
||||
|
||||
bbmmoorree scrolls up to display one more screen line in
|
||||
response to a RETURN character; it displays another
|
||||
screenful in response to a SPACE character. Other com
|
||||
mands are listed below.
|
||||
|
||||
The screen is divided in three sections or panes: The byte
|
||||
offset (extreme left), the hex pane (middle), and an ascii
|
||||
pane (right) which shows as printable characters those
|
||||
bytes in the hex pane. On an 80 column terminal there
|
||||
will be sixteen hex values and their ASCII values on each
|
||||
screen line. Note that (as one would expect) the first
|
||||
byte has the offset 0 (zero).
|
||||
|
||||
bbmmoorree sets the terminal to _n_o_e_c_h_o mode, so that the output
|
||||
can be continuous. Commands that you type do not normally
|
||||
show up on your terminal, except for the // , \\ and !! com
|
||||
mands.
|
||||
|
||||
If the standard output is not a terminal, mmoorree acts just
|
||||
like ccaatt(1V), except that a header is printed before each
|
||||
file in a series.
|
||||
|
||||
OOPPTTIIOONNSS
|
||||
--aa ASCII mode: no hex representation of the contents.
|
||||
Non printable characters are displayed as a dot (.)
|
||||
|
||||
--dd Display error messages rather than ringing the ter
|
||||
minal bell if an unrecognized command is used.
|
||||
This is helpful for inexperienced users.
|
||||
|
||||
--ii Ignore case for searching.
|
||||
|
||||
++_l_i_n_e_n_u_m_b_e_r
|
||||
Start up at _l_i_n_e_n_u_m_b_e_r.
|
||||
|
||||
++//_A_S_C_I_I_-_p_a_t_t_e_r_n
|
||||
Start up at the line containing the regular
|
||||
|
||||
|
||||
|
||||
13 June 2000 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BMORE(1) BMORE(1)
|
||||
|
||||
|
||||
expression _p_a_t_t_e_r_n. Note: unlike editors, this
|
||||
construct should _n_o_t end with a `//'. If it does,
|
||||
then the trailing slash is taken as a character in
|
||||
the search pattern.
|
||||
|
||||
|
||||
UUSSAAGGEE
|
||||
|
||||
CCoommmmaannddss
|
||||
The commands take effect immediately; it is not necessary
|
||||
to type a carriage return. Up to the time when the com
|
||||
mand character itself is given, the user may type the line
|
||||
kill character to cancel the numerical argument being
|
||||
formed. In addition, the user may type the erase charac
|
||||
ter to redisplay the `----MMoorree----((_x_x%%))' message.
|
||||
|
||||
In the following commands, _i is a numerical argument (11 by
|
||||
default).
|
||||
|
||||
_iSPACE Display another screenful, or _i more lines if _i
|
||||
is specified.
|
||||
|
||||
_iRETURN Display another line, or _i more lines, if speci
|
||||
fied.
|
||||
|
||||
_i^^DD (CTRL-D) Display (scroll down) 11 more lines. _i
|
||||
is given, the scroll size is set to _i.
|
||||
|
||||
_id Same as ^^DD.
|
||||
|
||||
_izz Same as SPACE, except that _i, if present,
|
||||
becomes the new default number of lines per
|
||||
screenful.
|
||||
|
||||
_iss Skip _i lines and then print a screenful.
|
||||
|
||||
_iff Skip _i screenfuls and then print a screenful.
|
||||
|
||||
_i^^BB (CTRL-B) Skip back _i screenfuls and then print a
|
||||
screenful.
|
||||
|
||||
_b Same as ^^BB (CTRL-D).
|
||||
|
||||
qq
|
||||
QQ Exit from mmoorree.
|
||||
|
||||
== Display the current line number.
|
||||
|
||||
vv Drop into the bbvvii(1) editor at the current off
|
||||
set of the current file.
|
||||
|
||||
ww Drop into the bbvvii(1) editor at the current off
|
||||
set of the current file. Only the portion of the
|
||||
file displayed on the screen will be loaded.
|
||||
|
||||
|
||||
|
||||
13 June 2000 2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BMORE(1) BMORE(1)
|
||||
|
||||
|
||||
hh Help. Give a description of all the mmoorree com
|
||||
mands.
|
||||
|
||||
_i//_p_a_t_t_e_r_n Search for the _ith occurrence of the regular
|
||||
expression _p_a_t_t_e_r_n. Display the screenful
|
||||
starting at the file position that contains the
|
||||
_ith match for the regular expression _A_S_C_I_I_-_p_a_t_
|
||||
_t_e_r_n, or the end of a pipe, whichever comes
|
||||
first. If bbmmoorree is displaying a file and there
|
||||
is no such match, its position in the file
|
||||
remains unchanged. Regular expressions can be
|
||||
edited using erase and kill characters. Erasing
|
||||
back past the first column cancels the search
|
||||
command.
|
||||
|
||||
´´ Single quote. Go to the point from which the
|
||||
last search started. If no search has been per
|
||||
formed in the current file, go to the beginning
|
||||
of the file.
|
||||
|
||||
!!_c_o_m_m_a_n_d Invoke a shell to execute _c_o_m_m_a_n_d. The charac
|
||||
ters %% and !!, when used within _c_o_m_m_a_n_d are
|
||||
replaced with the current filename and the pre
|
||||
vious shell command, respectively. If there is
|
||||
no current filename, %% is not expanded. Prepend
|
||||
a backslash to these characters to escape expan
|
||||
sion.
|
||||
|
||||
_i::nn Skip to the _ith next filename given in the com
|
||||
mand line, or to the last filename in the list
|
||||
if _i is out of range.
|
||||
|
||||
_i::pp Skip to the _ith previous filename given in the
|
||||
command line, or to the first filename if _i is
|
||||
out of range. If given while mmoorree is positioned
|
||||
within a file, go to the beginning of the file.
|
||||
If mmoorree is reading from a pipe, mmoorree simply
|
||||
rings the terminal bell.
|
||||
|
||||
::ff Display the current filename and offset number.
|
||||
|
||||
::qq
|
||||
::QQ Exit from bbmmoorree (same as qq or QQ ))..
|
||||
|
||||
.. Dot. Repeat the previous command.
|
||||
|
||||
|
||||
FFIILLEESS
|
||||
//eettcc//tteerrmmccaapp terminal data base
|
||||
//uussrr//llooccaall//sshhaarree//bbmmoorree..hheellpp
|
||||
help file
|
||||
|
||||
SSEEEE AALLSSOO
|
||||
bbvvii(1), tteerrmmccaapp(5)
|
||||
|
||||
|
||||
|
||||
13 June 2000 3
|
||||
|
||||
|
614
bvi.1
Normal file
614
bvi.1
Normal file
|
@ -0,0 +1,614 @@
|
|||
.rn '' }`
|
||||
''' $RCSfile$$Revision$$Date$
|
||||
'''
|
||||
''' $Log$
|
||||
'''
|
||||
.de Sh
|
||||
.br
|
||||
.if t .Sp
|
||||
.ne 5
|
||||
.PP
|
||||
\fB\\$1\fR
|
||||
.PP
|
||||
..
|
||||
.de Sp
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Ip
|
||||
.br
|
||||
.ie \\n(.$>=3 .ne \\$3
|
||||
.el .ne 3
|
||||
.IP "\\$1" \\$2
|
||||
..
|
||||
.de Vb
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve
|
||||
.ft R
|
||||
|
||||
.fi
|
||||
..
|
||||
'''
|
||||
'''
|
||||
''' Set up \*(-- to give an unbreakable dash;
|
||||
''' string Tr holds user defined translation string.
|
||||
''' Bell System Logo is used as a dummy character.
|
||||
'''
|
||||
.tr \(*W-|\(bv\*(Tr
|
||||
.ie n \{\
|
||||
.ds -- \(*W-
|
||||
.ds PI pi
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
.ds L" ""
|
||||
.ds R" ""
|
||||
''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of
|
||||
''' \*(L" and \*(R", except that they are used on ".xx" lines,
|
||||
''' such as .IP and .SH, which do another additional levels of
|
||||
''' double-quote interpretation
|
||||
.ds M" """
|
||||
.ds S" """
|
||||
.ds N" """""
|
||||
.ds T" """""
|
||||
.ds L' '
|
||||
.ds R' '
|
||||
.ds M' '
|
||||
.ds S' '
|
||||
.ds N' '
|
||||
.ds T' '
|
||||
'br\}
|
||||
.el\{\
|
||||
.ds -- \(em\|
|
||||
.tr \*(Tr
|
||||
.ds L" ``
|
||||
.ds R" ''
|
||||
.ds M" ``
|
||||
.ds S" ''
|
||||
.ds N" ``
|
||||
.ds T" ''
|
||||
.ds L' `
|
||||
.ds R' '
|
||||
.ds M' `
|
||||
.ds S' '
|
||||
.ds N' `
|
||||
.ds T' '
|
||||
.ds PI \(*p
|
||||
'br\}
|
||||
.\" If the F register is turned on, we'll generate
|
||||
.\" index entries out stderr for the following things:
|
||||
.\" TH Title
|
||||
.\" SH Header
|
||||
.\" Sh Subsection
|
||||
.\" Ip Item
|
||||
.\" X<> Xref (embedded
|
||||
.\" Of course, you have to process the output yourself
|
||||
.\" in some meaninful fashion.
|
||||
.if \nF \{
|
||||
.de IX
|
||||
.tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
.nr % 0
|
||||
.rr F
|
||||
.\}
|
||||
.TH BVI 1 "BVI Version 1.3.0" "18/Oct/2000" "User Commands"
|
||||
.IX Title "BVI 1"
|
||||
.UC
|
||||
.IX Name "bvi, bview - visual display editor for binary files"
|
||||
.if n .hy 0
|
||||
.if n .na
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.de CQ \" put $1 in typewriter font
|
||||
.ft CW
|
||||
'if n "\c
|
||||
'if t \\&\\$1\c
|
||||
'if n \\&\\$1\c
|
||||
'if n \&"
|
||||
\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
|
||||
'.ft R
|
||||
..
|
||||
.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
|
||||
. \" AM - accent mark definitions
|
||||
.bd B 3
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds ? ?
|
||||
. ds ! !
|
||||
. ds /
|
||||
. ds q
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
|
||||
. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
|
||||
.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
|
||||
.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
|
||||
.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
.ds oe o\h'-(\w'o'u*4/10)'e
|
||||
.ds Oe O\h'-(\w'O'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds v \h'-1'\o'\(aa\(ga'
|
||||
. ds _ \h'-1'^
|
||||
. ds . \h'-1'.
|
||||
. ds 3 3
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
. ds oe oe
|
||||
. ds Oe OE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.SH "NAME"
|
||||
.IX Header "NAME"
|
||||
bvi, bview \- visual editor for binary files
|
||||
.SH "VERSION"
|
||||
.IX Header "VERSION"
|
||||
bvi-1.3.0
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
\fBbvi\fR\ \ \ [\fB\-R\fR]\ [\fB\-c\fR\ \fIcmd\fR]\ [\fB\-f\fR\ \fIscript\fR]\ [\fB\-b\fR\ \fIbegin\fR]\ [\fB\-e\fR\ \fIend\fR]\ [\fB\-s\fR\ \fIsize\fR]\ \fIfile\fR...
|
||||
\fBbview\fR\ [\fB\-R\fR]\ [\fB\-c\fR\ \fIcmd\fR]\ [\fB\-f\fR\ \fIscript\fR]\ [\fB\-b\fR\ \fIbegin\fR]\ [\fB\-e\fR\ \fIend\fR]\ [\fB\-s\fR\ \fIsize\fR]\ \fIfile\fR...
|
||||
.SH "OPTIONS"
|
||||
.IX Header "OPTIONS"
|
||||
.Ip "\fIfile\fR..." 4
|
||||
.IX Item "\fIfile\fR..."
|
||||
A list of filenames. The first one will be the current file and
|
||||
will be read
|
||||
into the buffer. The cursor will be positioned on the first line of
|
||||
the buffer. You can get to the other files with the ":next" command.
|
||||
.Ip "\fB\-R\fR" 4
|
||||
.IX Item "\fB\-R\fR"
|
||||
\*(L"Readonly": The readonly flag is set for all the files,
|
||||
preventing accidental overwriting with a write command.
|
||||
|
||||
.Ip "\fB\-b\fR \fIbegin\fR" 4
|
||||
.IX Item "\fB\-b\fR \fIbegin\fR"
|
||||
causes bvi to load a file not from the start but from
|
||||
offset \fIbegin\fR.
|
||||
|
||||
.Ip "\fB\-e\fR \fIend\fR" 4
|
||||
.IX Item "\fB\-e\fR \fIend\fR"
|
||||
causes bvi to load a file not till end but till address \fIend\fR.
|
||||
|
||||
.Ip "\fB\-s\fR \fIsize\fR" 4
|
||||
.IX Item "\fB\-s\fR \fIsize\fR"
|
||||
causes bvi not to load the complete file but only \fIsize\fR bytes.
|
||||
|
||||
.Ip "\fB\-c\fR \fIcmd\fR" 4
|
||||
.IX Item "\fB\-c\fR \fIcmd\fR"
|
||||
\fIcmd\fR will be executed after the first
|
||||
file has been read. If the \fIcmd\fR contains
|
||||
spaces it must be enclosed in double quotes
|
||||
(this depends on the shell that is used).
|
||||
.Ip "\fB\-f\fR \fIscript\fR" 4
|
||||
.IX Item "\fB\-f\fR \fIscript\fR"
|
||||
This command provides a means for collecting a series of \*(L"ex\*(R"
|
||||
(colon) commands into a script file, then using this file to edit
|
||||
other files. Since there is no binary stream editor \*(L"bsed\*(R", you
|
||||
can use this option to make several global changes in a binary file.
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
Bvi stands for \*(L"Binary VIsual editor\*(R".
|
||||
Bvi is a screen oriented editor for binary files;
|
||||
its command set is based on that of the \fIvi\fR\|(1) text editor.
|
||||
As a binary editor does not have the concept of \*(L"lines\*(R"
|
||||
there are differences from Vi commands wherever the latter are
|
||||
line orientate.
|
||||
.SH "COMPARISON"
|
||||
.IX Header "COMPARISON"
|
||||
The main differences between Vi and Bvi are:
|
||||
.PP
|
||||
The screen is divided in three sections or panes:
|
||||
The byte offset (extreme left), the hex pane (middle),
|
||||
and an ascii pane (right) which shows as printable characters
|
||||
those bytes in the hex pane.
|
||||
On an 80 column terminal there will be sixteen hex values
|
||||
and their ASCII values on each screen line.
|
||||
Note that (as one would expect) the first byte has the offset \*(L'0\*(R' (zero).
|
||||
.PP
|
||||
You can toggle between the hex and ascii windows with the tab key (TAB).
|
||||
Toggling between these two windows does not change the current
|
||||
position (offset) within the file.
|
||||
.PP
|
||||
No \*(L"lines\*(R" concept:
|
||||
Files are treated as one long stream of bytes. The characters
|
||||
\*(L"newline\*(R" and \*(L"carriage return\*(R" are not special, id est they
|
||||
never mark the end of lines. Therefore the lines on the screen do not
|
||||
represent lines in the usual way. Data is broken across screen lines
|
||||
arbitarily.
|
||||
As a consequence there are no commands in bvi from ex or vi
|
||||
that are based on line numbers, eg \*(L"dd\*(R", \*(L"yy\*(R", \*(L'C\*(R', \*(L'S\*(R', \*(L'o\*(R', \*(L'O\*(R'.
|
||||
This also changes the meaning of \*(L"range\*(R" before the \*(L":write\*(R" command
|
||||
to a byte offset, ie the command \*(L":100,200w foo\*(R" writes all *bytes*
|
||||
(not lines) from offset 100 to offset 200 to the file \*(L"foo\*(R".
|
||||
.PP
|
||||
No \*(L"text objects":
|
||||
There are also no text-specific arrangements like words,
|
||||
paragraphs, sentences, sections and so on.
|
||||
.PP
|
||||
Extended \*(L"ruler":
|
||||
The bottom line of the screen shows the current address (byte offset)
|
||||
and the current character in these notations:
|
||||
.PP
|
||||
.Vb 1
|
||||
\& octal, hexadecimal, decimal and ascii.
|
||||
.Ve
|
||||
Search patterns:
|
||||
All search commands understand these special characters:
|
||||
.PP
|
||||
.Vb 3
|
||||
\& . any character
|
||||
\& [] set of characters
|
||||
\& * zero or more occurrences of previous char or set
|
||||
.Ve
|
||||
But as there is no concept of lines you cannot use the standard symbols
|
||||
("anchors") for \*(L"begin-of-line\*(R" ('^') and \*(L"end-of-line\*(R" ('$').
|
||||
Searching for the start/end of lines must be done explicitly
|
||||
by adding these special characters to your search pattern
|
||||
using these meta sequences:
|
||||
.PP
|
||||
.Vb 4
|
||||
\& \en newline
|
||||
\& \er return
|
||||
\& \et tab
|
||||
\& \e0 binary zero
|
||||
.Ve
|
||||
Additional search commands:
|
||||
Similar to the text search commands there are additional hex-search
|
||||
functions \*(L'\e\*(R' and \*(L'#\*(R' which allow to search for any byte value.
|
||||
Example: \*(L"\e62 76 69\*(R" will search for the string \*(L"bvi\*(R".
|
||||
Spaces between hex value are optional, so searching
|
||||
for \*(L"6775636B6573\*(R" will find \*(L"guckes\*(R".
|
||||
.PP
|
||||
Changing the length of data (insertion, deletion) moves the data to other addresses;
|
||||
this is bad for many cases (eg. databases, program files) and is
|
||||
thus disabled by default. You can enable this commands by typing
|
||||
.PP
|
||||
\f(CW :set memmove\fR
|
||||
.PP
|
||||
\fBBVI Modes:\fR
|
||||
.PP
|
||||
Command Mode (Normal Mode):
|
||||
.PP
|
||||
Input is treated as command. Note that command mode is the default
|
||||
mode after startup and after escaping from input mode.
|
||||
Use ESC (escape) to cancel a partial (uncompleted) command.
|
||||
.PP
|
||||
Input Mode:
|
||||
.PP
|
||||
Input is treated as replacement of current characters or
|
||||
(after the end of the file) is appended
|
||||
to the current file. This mode is entered from command mode by
|
||||
typing one of \*(L'i\*(R', \*(L'I\*(R', \*(L'A\*(R', \*(L'r\*(R', or \*(L'R\*(R'.
|
||||
You can enter the characters from the keyboard (in the ASCII window) or
|
||||
hexadecimal values (in the HEX window).
|
||||
Type TAB to switch between these two windows.
|
||||
Type ESC to finish the current input and return to command mode.
|
||||
Type CTRL\-C to cancel current command abnormally.
|
||||
.PP
|
||||
Command line mode (Last Line Mode or : mode):
|
||||
.PP
|
||||
Similar to vi, this mode is entered by typing one of the
|
||||
characters
|
||||
: / ? \e # !
|
||||
The command is terminated and executed by typing a carriage
|
||||
return; to cancel a partially typed command, type
|
||||
ESC to cancel the current command and return to command mode.
|
||||
.SH "ENVIRONMENT"
|
||||
.IX Header "ENVIRONMENT"
|
||||
The editor recognizes the environment variable BVIINIT as a
|
||||
command (or list of commands) to run when it starts up. If
|
||||
this variable is undefined, the editor checks for startup
|
||||
commands in the file \fI~/.bvirc\fR file, which you must own.
|
||||
However, if there is a \fI.bvirc\fR owned by you in the current
|
||||
directory, the editor takes its startup commands from this
|
||||
file \- overriding both the file in your home directory and
|
||||
the environment variable.
|
||||
.SH "TERMINOLOGY"
|
||||
.IX Header "TERMINOLOGY"
|
||||
Characters names are abbreviated as follows:
|
||||
Abbr. ASCII name aka
|
||||
CR 010 carriage return
|
||||
^A 001 control-a
|
||||
^H 008 control-h
|
||||
^I 009 control-i aka TAB
|
||||
^U 021 control-u
|
||||
^Z 026 control-z
|
||||
ESC 027 escape aka ESC
|
||||
DEL 127 delete
|
||||
LEFT --- left arrow
|
||||
RIGHT --- right arrow
|
||||
DOWN --- down arrow
|
||||
UP --- up arrow
|
||||
.SH "COMMAND SUMMARY"
|
||||
.IX Header "COMMAND SUMMARY"
|
||||
See the TERMINOLOGY for a summary on key name abbreviations
|
||||
used within the following description of commands.
|
||||
.PP
|
||||
\fBAbstract:\fR
|
||||
Arrow keys move the cursor on the screen within the current window.
|
||||
.PP
|
||||
\fBSample commands:\fR
|
||||
:version show version info
|
||||
<\- v ^ \-> arrow keys move the cursor
|
||||
h j k l same as arrow keys
|
||||
u undo previous change
|
||||
ZZ exit bvi, saving changes
|
||||
:q! quit, discarding changes
|
||||
/\fItext\fR search for \fItext\fR
|
||||
^U ^D scroll up or down
|
||||
.PP
|
||||
\fBCounts before bvi commands:\fR
|
||||
Numbers may be typed as a prefix to some commands.
|
||||
They are interpreted in one of these ways.
|
||||
.PP
|
||||
.Vb 4
|
||||
\& screen column |
|
||||
\& byte of file G
|
||||
\& scroll amount ^D ^U
|
||||
\& repeat effect most of the rest
|
||||
.Ve
|
||||
\fBInterrupting, canceling\fR
|
||||
ESC end insert or incomplete command
|
||||
DEL (delete or rubout) interrupts
|
||||
.PP
|
||||
\fBFile manipulation:\fR
|
||||
ZZ if file modified, write and exit;
|
||||
otherwise, exit
|
||||
:w write changed buffer to file
|
||||
:w! write changed buffer to file, overriding
|
||||
read-only ("forced\*(R" write)
|
||||
:q quit when no changes have been made
|
||||
:q! quit and discard all changes
|
||||
:e \fIfile\fR edit \fIfile\fR
|
||||
:e! re-read current file, discard all changes
|
||||
:e # edit the alternate file
|
||||
:e! # edit the alternate file, discard changes
|
||||
:w \fIfile\fR write current buffer to \fIfile\fR
|
||||
:w! \fIfile\fR write current buffer to \fIfile\fR overriding
|
||||
read-only (this \*(L"overwrites\*(R" the file)
|
||||
:sh run the command as set with option \*(L"shell\*(R",
|
||||
then return
|
||||
:!\fIcmd\fR run the command \fIcmd\fR from \*(L"shell\*(R", then
|
||||
return
|
||||
:n edit next file in the argument list
|
||||
:f show current filename, modified flag,
|
||||
current byte offset, and percentage of
|
||||
current position within buffer
|
||||
^G same as :f
|
||||
.PP
|
||||
\fBAdditional edit commands\fR
|
||||
You can insert/append/change bytes in ASCII/binary/decimal/
|
||||
hexadecimal or octal representation. You can enter several
|
||||
(screen) lines of input. A line with only a period (.) in it
|
||||
will terminate the command. You must not type in values greater
|
||||
than a byte value. This causes an abandonment of the command.
|
||||
Pressing the CR key does not insert a newline \- character into
|
||||
the file. If you use ASCII mode you can use the special characters
|
||||
\en, \er, \et and \e0.
|
||||
.PP
|
||||
.Vb 3
|
||||
\& :i aCR insert bytes (ASCII) at cursor position
|
||||
\& :a bCR append bytes (Binary) at end of file
|
||||
\& :c hCR change bytes (hexadecimal) at cursor position
|
||||
.Ve
|
||||
\fBBit-level operations\fR
|
||||
:and \fIn\fR bitwise \*(L'and\*(R' operation with value \fIn\fR
|
||||
:or \fIn\fR bitwise \*(L'or\*(R' operation with value \fIn\fR
|
||||
:xor \fIn\fR bitwise \*(L'xor\*(R' operation with value \fIn\fR
|
||||
:neg two's complement
|
||||
:not logical negation
|
||||
:sl \fIi\fR shift each byte \fIi\fR bits to the left
|
||||
:sr \fIi\fR shift each byte \fIi\fR bits to the right
|
||||
:rl \fIi\fR rotate each byte \fIi\fR bits to the left
|
||||
:rr \fIi\fR rotate each byte \fIi\fR bits to the right
|
||||
.PP
|
||||
\fBCommand mode addresses\fR
|
||||
:w foo write current buffer to a file
|
||||
named \*(L"foo\*(R"
|
||||
:5,10w foo copy byte 5 through 100 into as
|
||||
file named foo
|
||||
:.,.+20w foo copy the current byte and the next
|
||||
20 bytes to foo
|
||||
:^,'aw foo write all bytes from the beginning
|
||||
through marker \*(L'a\*(R'
|
||||
:/\fIpat\fR/,$ foo search pattern \fIpat\fR and and copy
|
||||
through end of file
|
||||
.PP
|
||||
\fBPositioning within file:\fR
|
||||
^B backward screen
|
||||
^F forward screen
|
||||
^D scroll down half screen
|
||||
^U scroll up half screen
|
||||
\fIn\fRG go to the specified character
|
||||
(end default), where \fIn\fR is a decimal address
|
||||
/\fIpat\fR next line matching \fIpat\fR
|
||||
?\fIpat\fR previous line matching \fIpat\fR
|
||||
\e\fIhex\fR jump to next occurrence of hex string \fIhex\fR
|
||||
#\fIhex\fR jump to previous occurrence of hex string \fIhex\fR
|
||||
n repeat last search command
|
||||
N repeat last search command, but in opposite
|
||||
direction
|
||||
.PP
|
||||
\fBAdjusting the screen:\fR
|
||||
^L clear and redraw screen
|
||||
zCR redraw screen with current line at top of screen
|
||||
z- redraw screen with current line at bottom of
|
||||
screen
|
||||
z. redraw screen with current line at center of
|
||||
screen
|
||||
/\fIpat\fR/z- search for pattern \fIpat\fR and then move currents
|
||||
line to bottom
|
||||
^E scroll screen down 1 line
|
||||
^Y scroll screen up 1 line
|
||||
.PP
|
||||
\fBMarking and returning:\fR
|
||||
m\fIx\fR mark current position with lower-case letter \fIx\fR
|
||||
Note: this command works for all lower-case letters
|
||||
\*(L'\fIx\fR move cursor to mark \fIx\fR in ASCII section
|
||||
`\fIx\fR move cursor to mark \fIx\fR in HEX section
|
||||
\*(L'\*(R' move cursor to previous context in ASCII section
|
||||
`` move cursor to previous context in HEX section
|
||||
|
||||
\fBLine positioning:\fR
|
||||
H jump to first line on screen ("top")
|
||||
L jump to last line on screen ("low")
|
||||
M jump to middle line on screen ("middle")
|
||||
\- jump onto previous line on screen
|
||||
+ jump onto next line on screen
|
||||
CR same as +
|
||||
DOWN or j next line, same column
|
||||
UP or k previous line, same column
|
||||
.PP
|
||||
\fBCharacter positioning:\fR
|
||||
^ first byte in HEX window
|
||||
$ end of screen line
|
||||
l or RIGHT jump onto next byte (within current
|
||||
screen line)
|
||||
h or LEFT jump onto previous byte (within current
|
||||
screen line)
|
||||
^H same as LEFT
|
||||
space same as RIGHT
|
||||
f\fIx\fR find next occurrence of character \fIx\fR
|
||||
F\fIx\fR find previous occurrence of character \fIx\fR
|
||||
\fIn\fR| jump onto \fIn\fRth byte/character within current
|
||||
line
|
||||
.PP
|
||||
\fBStrings:\fR
|
||||
(works similar to the \fIstrings\fR\|(1) command)
|
||||
Note: \*(L"Words\*(R" are defined as strings of \*(L"nonprinting
|
||||
characters\*(R".
|
||||
e jump to next end of word
|
||||
w jump to next begin of word
|
||||
b jump to previous begin of word
|
||||
W forward to next string delimited with a
|
||||
\e0 or \en
|
||||
B back to previous string delimited with a
|
||||
nonprinting char
|
||||
.PP
|
||||
\fBCorrections during insert:\fR
|
||||
^H erase last character (backspace)
|
||||
erase your erase character, same as ^H (backspace)
|
||||
ESC ends insertion, back to command mode
|
||||
.PP
|
||||
\fBAppend and replace:\fR
|
||||
A append at end of file
|
||||
rx replace current bte with char \*(L'x\*(R'
|
||||
R enter replace mode; for all subsequent input,
|
||||
the current byte is overwritten with the next
|
||||
input character; leave replace mode with ESC.
|
||||
.PP
|
||||
\fBMiscellaneous Operations:\fR
|
||||
TAB toggle between ASCII and HEX section
|
||||
.PP
|
||||
\fBYank and Put:\fR
|
||||
3ySPACE yank 3 characters
|
||||
p insert contents of yank buffer
|
||||
o replace text with content of yank buffer
|
||||
P put back at end of file
|
||||
.PP
|
||||
\fBUndo, Redo:\fR
|
||||
u undo last change
|
||||
Note: Only the last change can be undone.
|
||||
Therefore this commands toggles between the
|
||||
last and second-t-last state of the buffer.
|
||||
.PP
|
||||
\fBSetting Options:\fR
|
||||
With the :set command you can set options in bvi
|
||||
.PP
|
||||
.Vb 1
|
||||
\& Option Default Description
|
||||
.Ve
|
||||
.Vb 19
|
||||
\& autowrite noaw Save current file, if modified, if you
|
||||
\& give a :n, :r or ! command
|
||||
\& columns cm=16 on an 80 character wide terminal
|
||||
\& ignorecase noic Ignores letter case in searching
|
||||
\& magic nomagic Makes . [ * special in patterns
|
||||
\& memmove nomm enables insert and delete commands
|
||||
\& offset of=0 adds an offset to the diplayed addresses
|
||||
\& readonly noro If set, write fails unless you use ! after command
|
||||
\& scroll sc=1/2 window
|
||||
\& Number of lines scrolled by ^U and ^D
|
||||
\& showmode mo Displays statusline on bottom of the screen
|
||||
\& terse noterse Let you obtain shorter error messages
|
||||
\& window window=screensize
|
||||
\& Lines in window, can be reduced at slow terminals
|
||||
\& wordlength wl=4 Length of an ASCII-string found by w, W, b or B
|
||||
\& wrapscan ws Searches wrap around past the end of the file
|
||||
\& unixstyle nous The representation of ascii characters below
|
||||
\& 32 is displayed in the statusline as shown
|
||||
\& in ascii(7) if unset rather in DOS-style (^A)
|
||||
.Ve
|
||||
.SH "AUTHOR"
|
||||
.IX Header "AUTHOR"
|
||||
bvi was developed by Gerhard Buergmann, Vienna, Austria
|
||||
\fIGerhard.Buergmann@altavista.net\fR
|
||||
.SH "WWW"
|
||||
.IX Header "WWW"
|
||||
Bvi\ Homepage:\ \ http://bvi.linuxave.net/
|
||||
Vi\ Pages:\ \ \ \ \ \ http://www.math.fu-berlin.de/~guckes/vi/
|
||||
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (all\ about\ Vi\ and\ its\ clones)
|
||||
.SH "FILES"
|
||||
.IX Header "FILES"
|
||||
\fI\ $HOME/.bvirc\fR\ \ \ \ \ \ \ \ \ \ editor\ startup\ file
|
||||
\fI\ ./.bvirc\fR\ \ \ \ \ \ \ \ \ \ \ \ \ \ editor\ startup\ file
|
||||
.SH "BUGS"
|
||||
.IX Header "BUGS"
|
||||
Bvi does not update the screen when the terminal changes its size.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
\fIvi\fR\|(1), \fIstrings\fR\|(1), \fIascii\fR\|(5)
|
||||
|
||||
.rn }` ''
|
984
bvi.c
Normal file
984
bvi.c
Normal file
|
@ -0,0 +1,984 @@
|
|||
/* BVI - Binary Visual Editor
|
||||
*
|
||||
* 1996-02-28 V 1.0.0
|
||||
* 1999-01-27 V 1.1.0
|
||||
* 1999-04-22 V 1.1.1
|
||||
* 1999-07-01 V 1.2.0 beta
|
||||
* 1999-10-22 V 1.2.0 final
|
||||
* 2000-05-10 V 1.3.0 alpha
|
||||
* 2000-10-24 V 1.3.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "bvi.h"
|
||||
#include "set.h"
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
|
||||
char *copyright = "Copyright (C) 1996-2000 by Gerhard Buergmann";
|
||||
|
||||
jmp_buf env; /* context for `longjmp' function */
|
||||
|
||||
int loc;
|
||||
int maxx, maxy, x, xx, y;
|
||||
int screen, status;
|
||||
off_t size;
|
||||
PTR mem = NULL;
|
||||
PTR curpos;
|
||||
PTR maxpos;
|
||||
PTR pagepos;
|
||||
PTR spos;
|
||||
char *name = NULL;
|
||||
char *shell;
|
||||
char string[MAXCMD];
|
||||
char cmdstr[MAXCMD + 1] = "";
|
||||
FILE *Ausgabe_Datei;
|
||||
int edits = 0;
|
||||
int AnzAdd, Anzahl, Anzahl3;
|
||||
off_t filesize, memsize, undosize;
|
||||
long precount = -1; /* number preceding command */
|
||||
|
||||
int block_flag = 0;
|
||||
off_t block_begin, block_end, block_size;
|
||||
|
||||
|
||||
char **files; /* list of input files */
|
||||
int numfiles; /* number of input files */
|
||||
int curfile; /* number of the current file */
|
||||
|
||||
int arrnum = 0;
|
||||
char numarr[64]; /* string for collecting number */
|
||||
char rep_buf[BUFFER];
|
||||
|
||||
PTR current;
|
||||
PTR last_motion;
|
||||
PTR current_start;
|
||||
PTR undo_start;
|
||||
off_t undo_count;
|
||||
off_t yanked = 0L;
|
||||
char *yank_buf = NULL;
|
||||
char *undo_buf = NULL;
|
||||
PTR markbuf[26];
|
||||
|
||||
char addr_form[15];
|
||||
|
||||
char *nobytes = "No bytes@in the buffer";
|
||||
|
||||
static char progname[8];
|
||||
static char line[MAXCMD];
|
||||
static int mark;
|
||||
static int scrolly;
|
||||
static int wrstat = 1;
|
||||
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-R] [-c cmd | +cmd] [-f script]\n\
|
||||
[-b begin] [-e end] [-s size] file ...\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int ch;
|
||||
int lflag;
|
||||
long count;
|
||||
int n = 1;
|
||||
int script = -1;
|
||||
off_t inaddr;
|
||||
char *poi;
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
poi = strrchr(argv[0], DELIM);
|
||||
|
||||
if (poi) strncpy(progname, ++poi, 7);
|
||||
else strncpy(progname, argv[0], 7);
|
||||
strtok(progname, ".");
|
||||
|
||||
if (!strcasecmp(progname, "bview")) {
|
||||
params[P_RO].flags |= P_CHANGED;
|
||||
P(P_RO) = TRUE;
|
||||
} else if (!strcasecmp(progname, "bvedit")) {
|
||||
/* This should be the beginners version */
|
||||
}
|
||||
|
||||
while (n < argc) {
|
||||
switch (argv[n][0]) {
|
||||
case '-':
|
||||
if (argv[n][1] == 'R') {
|
||||
params[P_RO].flags |= P_CHANGED;
|
||||
P(P_RO) = TRUE;
|
||||
} else if (argv[n][1] == 'c') {
|
||||
if (argv[n + 1] == NULL) {
|
||||
usage();
|
||||
} else {
|
||||
strcpy(cmdstr, argv[++n]);
|
||||
}
|
||||
} else if (argv[n][1] == 'f') {
|
||||
if (argv[n + 1] == NULL || argv[n + 1][0] == '-') {
|
||||
usage();
|
||||
} else {
|
||||
script = ++n;
|
||||
}
|
||||
} else if (argv[n][1] == 'b') {
|
||||
if (argv[n + 1] == NULL || argv[n + 1][0] == '-') {
|
||||
usage();
|
||||
} else {
|
||||
block_begin = calc_size(argv[++n]);
|
||||
block_flag |= 1;
|
||||
}
|
||||
} else if (argv[n][1] == 'e') {
|
||||
if (argv[n + 1] == NULL || argv[n + 1][0] == '-') {
|
||||
usage();
|
||||
} else {
|
||||
block_end = calc_size(argv[++n]);
|
||||
block_flag |= 2;
|
||||
}
|
||||
} else if (argv[n][1] == 's') {
|
||||
if (argv[n + 1] == NULL || argv[n + 1][0] == '-') {
|
||||
usage();
|
||||
} else {
|
||||
block_size = calc_size(argv[++n]);
|
||||
block_flag |= 4;
|
||||
}
|
||||
} else if (argv[n][1] == 'w') {
|
||||
if (argv[n][2] == '\0') {
|
||||
usage();
|
||||
} else {
|
||||
params[P_LI].flags |= P_CHANGED;
|
||||
P(P_LI) = atoi(argv[n] + 2);
|
||||
}
|
||||
} else usage();
|
||||
n++;
|
||||
break;
|
||||
case '+': /* +cmd */
|
||||
if (argv[n][1] == '\0') {
|
||||
strcpy(cmdstr, "$");
|
||||
} else {
|
||||
strcpy(cmdstr, &argv[n][1]);
|
||||
}
|
||||
n++;
|
||||
break;
|
||||
default: /* must be a file name */
|
||||
name = strdup(argv[n]);
|
||||
files = &(argv[n]);
|
||||
numfiles = argc - n;
|
||||
n = argc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (block_flag) {
|
||||
case 2:
|
||||
block_begin = 0;
|
||||
case 1|2:
|
||||
block_size = block_end - block_begin + 1;
|
||||
break;
|
||||
case 4:
|
||||
block_begin = 0;
|
||||
case 1|4:
|
||||
block_end = block_begin + block_size - 1;
|
||||
break;
|
||||
case 2|4:
|
||||
block_begin = block_end + 1 - block_size;
|
||||
break;
|
||||
case 1|2|4:
|
||||
if (block_end - block_begin != block_size + 1) {
|
||||
fprintf(stderr, "Ambigous block data\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (block_flag && !numfiles) {
|
||||
fprintf(stderr, "Cannot read a range of a nonexisting file\n");
|
||||
exit(1);
|
||||
}
|
||||
if (numfiles > 1) fprintf(stderr, "%d files to edit\n", numfiles);
|
||||
curfile = 0;
|
||||
|
||||
/****** Initialisation of curses ******/
|
||||
initscr();
|
||||
attrset(A_NORMAL);
|
||||
|
||||
maxy = LINES;
|
||||
if (params[P_LI].flags & P_CHANGED) maxy = P(P_LI);
|
||||
scrolly = maxy / 2;
|
||||
P(P_SS) = scrolly;
|
||||
P(P_LI) = maxy;
|
||||
maxy--;
|
||||
keypad(stdscr, TRUE);
|
||||
scrollok(stdscr, TRUE);
|
||||
nonl();
|
||||
cbreak();
|
||||
noecho();
|
||||
|
||||
/*
|
||||
AnzAdd = 8;
|
||||
strcpy(addr_form, "%06lX ");
|
||||
*/
|
||||
AnzAdd = 10;
|
||||
strcpy(addr_form, "%08lX ");
|
||||
|
||||
Anzahl = ((COLS - AnzAdd - 1) / 16) * 4;
|
||||
P(P_CM) = Anzahl;
|
||||
maxx = Anzahl * 4 + AnzAdd + 1;
|
||||
Anzahl3 = Anzahl * 3;
|
||||
status = Anzahl3 + Anzahl - 17;
|
||||
screen = Anzahl * (maxy - 1);
|
||||
|
||||
signal(SIGINT, SIG_IGN);
|
||||
filesize = load(name);
|
||||
|
||||
bvi_init(argv[0]);
|
||||
params[P_TT].svalue = terminal;
|
||||
if (block_flag && (P(P_MM) == TRUE)) {
|
||||
P(P_MM) = FALSE;
|
||||
params[P_TT].flags |= P_CHANGED;
|
||||
}
|
||||
if (script > -1)
|
||||
read_rc(argv[script]);
|
||||
if (*cmdstr != '\0')
|
||||
docmdline(cmdstr);
|
||||
|
||||
/* main loop */
|
||||
do {
|
||||
setjmp(env);
|
||||
current = (PTR)(pagepos + y * Anzahl + xpos());
|
||||
if (wrstat) statpos();
|
||||
wrstat = 1;
|
||||
setcur();
|
||||
ch = vgetc();
|
||||
while (ch >= '0' && ch <= '9') {
|
||||
numarr[arrnum++] = ch;
|
||||
ch = vgetc();
|
||||
}
|
||||
numarr[arrnum] = '\0';
|
||||
if (arrnum != 0) precount = strtol(numarr, (char **)NULL, 10);
|
||||
else precount = -1;
|
||||
lflag = arrnum = 0;
|
||||
|
||||
switch (ch) {
|
||||
case '^': x = AnzAdd;
|
||||
loc = HEX;
|
||||
break;
|
||||
/*
|
||||
case '0': x = AnzAdd + Anzahl3;
|
||||
loc = ASCII;
|
||||
break;
|
||||
*/
|
||||
case '$': x = AnzAdd - 1 + Anzahl3 + Anzahl;
|
||||
loc = ASCII;
|
||||
break;
|
||||
case '\t': toggle();
|
||||
break;
|
||||
case '~': if (precount < 1) precount = 1;
|
||||
sprintf(rep_buf, "%ld~", precount);
|
||||
do_tilde(precount);
|
||||
lflag++;
|
||||
break;
|
||||
case KEY_HOME:
|
||||
case 'H': if (precount > 0) {
|
||||
y = --precount;
|
||||
if (y > maxy - 1) {
|
||||
scrolldown(y - maxy + 1);
|
||||
y = maxy - 1; }
|
||||
} else y = 0;
|
||||
if (loc == HEX) x = AnzAdd;
|
||||
else x = AnzAdd + Anzahl3;
|
||||
break;
|
||||
case 'M': y = maxy / 2;
|
||||
if ((PTR)(pagepos + screen) > maxpos)
|
||||
y = (int)(maxpos - pagepos) / Anzahl / 2;
|
||||
if (loc == HEX) x = AnzAdd;
|
||||
else x = AnzAdd + Anzahl3;
|
||||
break;
|
||||
case KEY_LL:
|
||||
case 'L': if (precount < 1) precount = 1;
|
||||
n = maxy - 1;
|
||||
if ((PTR)((pagepos + screen)) > maxpos)
|
||||
n = (int)(maxpos - pagepos) / Anzahl;
|
||||
if (precount < n) y = n + 1 - precount;
|
||||
if (loc == HEX) x = AnzAdd;
|
||||
else x = AnzAdd + Anzahl3;
|
||||
break;
|
||||
case CTRL('H'):
|
||||
case KEY_BACKSPACE:
|
||||
case KEY_LEFT:
|
||||
case 'h': do {
|
||||
if (x > (AnzAdd + 2) && x < (Anzahl3 + AnzAdd + 1))
|
||||
x -= 3;
|
||||
else
|
||||
if (x > (Anzahl3 + AnzAdd - 2)) x--;
|
||||
} while (--precount > 0);
|
||||
if (x < AnzAdd + Anzahl3) loc = HEX;
|
||||
else loc = ASCII;
|
||||
break;
|
||||
case ' ':
|
||||
case KEY_RIGHT:
|
||||
case 'l': do {
|
||||
if (x < (Anzahl3 + 6)) x += 3;
|
||||
else if (x > (Anzahl3 + 3)
|
||||
&& x < (Anzahl3 + AnzAdd - 1 + Anzahl))
|
||||
x++;
|
||||
} while (--precount > 0);
|
||||
if (x < AnzAdd + Anzahl3) loc = HEX;
|
||||
else loc = ASCII;
|
||||
break;
|
||||
case '-':
|
||||
case KEY_UP :
|
||||
case 'k': do {
|
||||
if (y > 0) y--;
|
||||
else scrollup(1);
|
||||
} while(--precount > 0);
|
||||
break;
|
||||
case '+':
|
||||
case CR: if (loc == HEX) x = AnzAdd;
|
||||
else x = AnzAdd + Anzahl3;
|
||||
case 'j':
|
||||
case CTRL('J'):
|
||||
case CTRL('N'):
|
||||
case KEY_DOWN:
|
||||
do {
|
||||
if ((PTR)((pagepos + (y + 1) * Anzahl)) > maxpos) break;
|
||||
if (y < (maxy - 1)) y++;
|
||||
else scrolldown(1);
|
||||
} while(--precount > 0);
|
||||
break;
|
||||
case '|': if (precount < 1) break;
|
||||
if (loc == ASCII) x = AnzAdd - 1 + Anzahl3 + precount;
|
||||
else x = 5 + 3 * precount;
|
||||
if (x > AnzAdd - 1 + Anzahl3 + Anzahl) {
|
||||
x = AnzAdd - 1 + Anzahl3 + Anzahl;
|
||||
loc = ASCII; }
|
||||
break;
|
||||
case ':' : clearstr();
|
||||
addch(ch);
|
||||
refresh();
|
||||
getcmdstr(cmdstr, 1);
|
||||
if (strlen(cmdstr))
|
||||
docmdline(cmdstr);
|
||||
break;
|
||||
case CTRL('B'):
|
||||
case KEY_PPAGE: /**** Previous Page ****/
|
||||
if (mem <= (PTR)(pagepos - screen)) pagepos -= screen;
|
||||
else pagepos = mem;
|
||||
repaint();
|
||||
break;
|
||||
case CTRL('D'):
|
||||
if (precount > 1) scrolly = precount;
|
||||
scrolldown(scrolly);
|
||||
break;
|
||||
case CTRL('U'):
|
||||
if (precount > 1) scrolly = precount;
|
||||
scrollup(scrolly);
|
||||
break;
|
||||
case CTRL('E'):
|
||||
if (y > 0) y--;
|
||||
scrolldown(1);
|
||||
break;
|
||||
case CTRL('F'):
|
||||
case KEY_NPAGE: /**** Next Page *****/
|
||||
if (maxpos >= (PTR)(pagepos + screen)) {
|
||||
pagepos += screen;
|
||||
current += screen;
|
||||
if (current - mem >= filesize) {
|
||||
current = mem + filesize;
|
||||
setpage((PTR)(mem + filesize - 1L));
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
break;
|
||||
case CTRL('G'):
|
||||
fileinfo(name);
|
||||
wrstat = 0;
|
||||
break;
|
||||
case CTRL('L'): /*** REDRAW SCREEN ***/
|
||||
new_screen();
|
||||
break;
|
||||
case CTRL('Y'):
|
||||
if (y < maxy) y++;
|
||||
scrollup(1);
|
||||
break;
|
||||
case 'A': smsg("APPEND MODE");
|
||||
current = (PTR)(mem + filesize - 1L);
|
||||
setpage(current++);
|
||||
cur_forw(0);
|
||||
setcur();
|
||||
undosize = filesize;
|
||||
undo_count = edit(ch);
|
||||
break;
|
||||
case 'B':
|
||||
case 'b': setpage(backsearch(current, ch));
|
||||
break;
|
||||
case 'e': setpage(end_word(current));
|
||||
break;
|
||||
case ',': do_ft(-1, 0);
|
||||
break;
|
||||
case ';': do_ft(0, 0);
|
||||
break;
|
||||
case 'F':
|
||||
case 'f':
|
||||
case 't':
|
||||
case 'T': do_ft(ch, 0);
|
||||
break;
|
||||
case 'G': last_motion = current;
|
||||
if (precount > -1) {
|
||||
if ((precount < P(P_OF)) ||
|
||||
(precount - P(P_OF)) > (filesize - 1L)) {
|
||||
beep();
|
||||
} else {
|
||||
setpage((PTR)(mem + precount - P(P_OF)));
|
||||
}
|
||||
} else {
|
||||
setpage((PTR)(mem + filesize - 1L));
|
||||
}
|
||||
break;
|
||||
case 'g': last_motion = current;
|
||||
msg("Goto Hex Address: ");
|
||||
refresh();
|
||||
getcmdstr(cmdstr, 19);
|
||||
if (cmdstr[0] == '^') {
|
||||
inaddr = P(P_OF);
|
||||
} else if (cmdstr[0] == '$') {
|
||||
inaddr = filesize + P(P_OF) - 1L;
|
||||
} else {
|
||||
long ltmp;
|
||||
sscanf(cmdstr, "%lx", <mp);
|
||||
inaddr = (off_t)ltmp;
|
||||
}
|
||||
if (inaddr < P(P_OF)) break;
|
||||
inaddr -= P(P_OF);
|
||||
if (inaddr < filesize) {
|
||||
setpage(mem + inaddr);
|
||||
} else {
|
||||
if (filesize == 0L) break;
|
||||
sprintf(string, "Max. address of current file : %06lX",
|
||||
(long)(filesize - 1L + P(P_OF)));
|
||||
emsg(string);
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
case '/': /**** Search String ****/
|
||||
case '#':
|
||||
case '\\': clearstr();
|
||||
addch(ch);
|
||||
refresh();
|
||||
if (getcmdstr(line, 1)) break;
|
||||
last_motion = current;
|
||||
searching(ch, line, current, maxpos - 1, P(P_WS));
|
||||
break;
|
||||
case 'n': /**** Search Next ****/
|
||||
case 'N': last_motion = current;
|
||||
searching(ch, "", current, maxpos - 1, P(P_WS));
|
||||
break;
|
||||
case 'm': do_mark(vgetc(), current);
|
||||
break;
|
||||
case '\'':
|
||||
case '`': if ((ch == '`' && loc == ASCII) ||
|
||||
(ch == '\'' && loc == HEX))
|
||||
toggle();
|
||||
mark = vgetc();
|
||||
if (mark == '`' || mark == '\'') {
|
||||
setpage(last_motion);
|
||||
last_motion = current;
|
||||
} else {
|
||||
if (mark < 'a' || mark > 'z') {
|
||||
beep(); break;
|
||||
} else if (markbuf[mark - 'a'] == NULL) {
|
||||
beep(); break;
|
||||
}
|
||||
setpage(markbuf[mark - 'a']);
|
||||
}
|
||||
break;
|
||||
case 'D': if (precount < 1) precount = 1;
|
||||
sprintf(rep_buf, "%ldD", precount);
|
||||
trunc_cur();
|
||||
break;
|
||||
case 'o': /* overwrite: this is an overwriting put */
|
||||
if (precount < 1) precount = 1;
|
||||
sprintf(rep_buf, "%ldo", precount);
|
||||
do_over(current, yanked, yank_buf);
|
||||
break;
|
||||
case 'P':
|
||||
if (precount < 1) precount = 1;
|
||||
if ((undo_count = alloc_buf(yanked, &undo_buf)) == 0L)
|
||||
break;
|
||||
sprintf(rep_buf, "%ldP", precount);
|
||||
if (do_append(yanked, yank_buf)) break;
|
||||
/* we save it not for undo but for the dot command
|
||||
memcpy(undo_buf, yank_buf, yanked);
|
||||
*/
|
||||
repaint();
|
||||
break;
|
||||
case 'r':
|
||||
case 'R': if (filesize == 0L) break;
|
||||
sprintf(rep_buf, "%ld%c", precount, ch);
|
||||
undo_count = edit(ch);
|
||||
lflag++;
|
||||
break;
|
||||
case 'u': do_undo();
|
||||
break;
|
||||
case 'W':
|
||||
case 'w': loc = ASCII;
|
||||
setpage(wordsearch(current, ch));
|
||||
break;
|
||||
case 'y': count = range(ch);
|
||||
if (count > 0) {
|
||||
if ((yanked = alloc_buf(count, &yank_buf)) == 0L) {
|
||||
break;
|
||||
}
|
||||
memcpy(yank_buf, current, yanked);
|
||||
} else if (count < 0) {
|
||||
if ((yanked = alloc_buf(-count, &yank_buf)) == 0L) {
|
||||
break;
|
||||
}
|
||||
memcpy(yank_buf, current + count, yanked);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
/*
|
||||
sprintf(string, "%ld bytes yanked", labs(count));
|
||||
msg(string);
|
||||
*/
|
||||
break;
|
||||
case 'z': do_z(vgetc());
|
||||
break;
|
||||
case 'Z': if (vgetc() == 'Z') do_exit();
|
||||
else beep();
|
||||
break;
|
||||
case '.':
|
||||
if (!strlen(rep_buf)) {
|
||||
beep();
|
||||
} else {
|
||||
stuffin(rep_buf);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
if P(P_MM) {
|
||||
if (precount < 1) precount = 1;
|
||||
switch (ch) {
|
||||
case 'I':
|
||||
sprintf(rep_buf, "%ldI", precount);
|
||||
current = mem;
|
||||
setpage(mem);
|
||||
repaint();
|
||||
undo_count = edit('i');
|
||||
lflag++;
|
||||
break;
|
||||
/* undo does not work correctly !!! */
|
||||
case 's':
|
||||
sprintf(rep_buf, "%lds", precount);
|
||||
if (do_delete((off_t)precount, current)) break;
|
||||
precount = 1;
|
||||
undo_count = edit('i');
|
||||
lflag++;
|
||||
break;
|
||||
case 'a':
|
||||
if (cur_forw(1)) break;
|
||||
current++;
|
||||
case 'i':
|
||||
sprintf(rep_buf, "%ld%c", precount, ch);
|
||||
undo_count = edit(ch);
|
||||
lflag++;
|
||||
break;
|
||||
case 'p':
|
||||
sprintf(rep_buf, "%ldp", precount);
|
||||
do_put(current, yanked, yank_buf);
|
||||
break;
|
||||
case 'c':
|
||||
case 'd':
|
||||
count = range(ch);
|
||||
if (count > 0)
|
||||
do_delete((off_t)count, current);
|
||||
else if (count < 0)
|
||||
do_back(-count, current);
|
||||
if (ch == 'c') {
|
||||
precount = 1;
|
||||
undo_count = edit('i');
|
||||
lflag++;
|
||||
/*
|
||||
} else if (count) {
|
||||
sprintf(string, "%ld bytes deleted", labs(count));
|
||||
msg(string);
|
||||
*/
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
sprintf(rep_buf, "%ldx", precount);
|
||||
do_delete((off_t)precount, current);
|
||||
break;
|
||||
case 'X':
|
||||
sprintf(rep_buf, "%ldX", precount);
|
||||
do_back(precount, current);
|
||||
break;
|
||||
default:
|
||||
flushinp();
|
||||
beep();
|
||||
}
|
||||
} else {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'I':
|
||||
case 'p':
|
||||
case 'x':
|
||||
case 'X':
|
||||
movebyte();
|
||||
default:
|
||||
flushinp();
|
||||
beep();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lflag) lineout();
|
||||
} while (1);
|
||||
}
|
||||
|
||||
|
||||
off_t
|
||||
calc_size(arg)
|
||||
char *arg;
|
||||
{
|
||||
long val;
|
||||
char *poi;
|
||||
|
||||
if (*arg == '0') {
|
||||
val = strtol(arg, &poi, 16);
|
||||
} else {
|
||||
val = strtol(arg, &poi, 10);
|
||||
}
|
||||
switch (*poi) {
|
||||
case 'k':
|
||||
case 'K': val *= 1024;
|
||||
break;
|
||||
case 'm':
|
||||
case 'M': val *= 1048576;
|
||||
break;
|
||||
case '\0': break;
|
||||
default: usage();
|
||||
}
|
||||
return (off_t)val;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
trunc_cur()
|
||||
{
|
||||
undosize = filesize;
|
||||
undo_count = (off_t)(maxpos - current);
|
||||
undo_start = current;
|
||||
filesize = pagepos - mem + y * Anzahl + xpos();
|
||||
maxpos = (PTR)(mem + filesize);
|
||||
if (filesize == 0L) {
|
||||
emsg(nobytes);
|
||||
} else cur_back();
|
||||
edits = U_TRUNC;
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
do_append(count, buf)
|
||||
int count;
|
||||
char *buf;
|
||||
{
|
||||
if (filesize + count > memsize) {
|
||||
if (enlarge(count + 100L)) return 1;
|
||||
}
|
||||
memcpy(mem + filesize, buf, count);
|
||||
undo_start = mem + filesize - 1L;
|
||||
setpage(undo_start + count);
|
||||
edits = U_APPEND;
|
||||
undosize = filesize;
|
||||
filesize += count;
|
||||
maxpos += count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_tilde(count)
|
||||
off_t count;
|
||||
{
|
||||
if (filesize == 0L) return;
|
||||
undo_start = current;
|
||||
if (current + count > maxpos) {
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
if ((undo_count = alloc_buf(count, &undo_buf)) == 0L)
|
||||
return;
|
||||
memcpy(undo_buf, current, undo_count);
|
||||
while (count--) {
|
||||
if (isupper((int)(*current))) *current = tolower((int)(*current));
|
||||
else if (islower((int)(*current)))
|
||||
*current = toupper((int)(*current));
|
||||
current++;
|
||||
cur_forw(0);
|
||||
}
|
||||
edits = U_TILDE;
|
||||
setcur();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_undo()
|
||||
{
|
||||
off_t n, tempsize;
|
||||
char temp;
|
||||
PTR set_cursor;
|
||||
PTR s;
|
||||
PTR d;
|
||||
|
||||
if (undo_count == 0L) {
|
||||
emsg("Nothing to undo");
|
||||
return;
|
||||
}
|
||||
set_cursor = undo_start;
|
||||
switch (edits) {
|
||||
case U_EDIT:
|
||||
case U_TILDE:
|
||||
n = undo_count;
|
||||
s = undo_buf;
|
||||
d = undo_start;
|
||||
while (n--) {
|
||||
temp = *d;
|
||||
*d = *s;
|
||||
*s = temp;
|
||||
s++; d++;
|
||||
}
|
||||
break;
|
||||
case U_APPEND:
|
||||
case U_TRUNC:
|
||||
tempsize = filesize;
|
||||
filesize = undosize;
|
||||
undosize = tempsize;
|
||||
maxpos = (PTR)(mem + filesize);
|
||||
if (filesize)
|
||||
set_cursor = maxpos - 1L;
|
||||
else
|
||||
set_cursor = maxpos;
|
||||
break;
|
||||
case U_INSERT:
|
||||
filesize -= undo_count;
|
||||
maxpos -= undo_count;
|
||||
memcpy(undo_buf, undo_start, undo_count);
|
||||
memmove(undo_start, undo_start + undo_count,
|
||||
maxpos - undo_start);
|
||||
edits = U_DELETE;
|
||||
break;
|
||||
case U_BACK:
|
||||
case U_DELETE:
|
||||
filesize += undo_count;
|
||||
maxpos += undo_count;
|
||||
memmove(undo_start + undo_count, undo_start,
|
||||
maxpos - undo_start);
|
||||
memcpy(undo_start, undo_buf, undo_count);
|
||||
edits = U_INSERT;
|
||||
break;
|
||||
}
|
||||
setpage(set_cursor);
|
||||
if (edits == U_TRUNC && undosize > filesize) cur_back();
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_over(loc, n, buf)
|
||||
PTR loc;
|
||||
off_t n;
|
||||
PTR buf;
|
||||
{
|
||||
if (n < 1L) {
|
||||
emsg(nobytes);
|
||||
return;
|
||||
}
|
||||
if (loc + n > maxpos) {
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
if ((undo_count = alloc_buf(n, &undo_buf)) == 0L)
|
||||
return;
|
||||
undo_start = loc;
|
||||
memcpy(undo_buf, loc, n);
|
||||
memcpy(loc, buf, n);
|
||||
edits = U_EDIT;
|
||||
setpage(loc + n - 1);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_put(loc, n, buf)
|
||||
PTR loc;
|
||||
off_t n;
|
||||
PTR buf;
|
||||
{
|
||||
if (n < 1L) {
|
||||
emsg(nobytes);
|
||||
return;
|
||||
}
|
||||
if (loc > maxpos) {
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
if (filesize + n > memsize) {
|
||||
if (enlarge(n + 1024)) return;
|
||||
}
|
||||
if ((undo_count = alloc_buf(n, &undo_buf)) == 0L)
|
||||
return;
|
||||
undo_start = loc + 1;
|
||||
edits = U_INSERT;
|
||||
filesize += n;
|
||||
maxpos += n;
|
||||
memmove(undo_start + n, undo_start, maxpos - loc);
|
||||
memcpy(undo_start, buf, n);
|
||||
setpage(loc + n);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
/* argument sig not used, because only SIGINT will be catched */
|
||||
void
|
||||
jmpproc(sig)
|
||||
int sig;
|
||||
{
|
||||
if (P(P_EB)) beep();
|
||||
repaint();
|
||||
clearstr();
|
||||
signal(SIGINT, SIG_IGN);
|
||||
longjmp(env, 0);
|
||||
}
|
||||
|
||||
|
||||
off_t
|
||||
range(ch)
|
||||
int ch;
|
||||
{
|
||||
int ch1;
|
||||
long count;
|
||||
|
||||
ch1 = vgetc();
|
||||
while (ch1 >= '0' && ch1 <= '9') {
|
||||
numarr[arrnum++] = ch1;
|
||||
ch1 = vgetc();
|
||||
}
|
||||
numarr[arrnum] = '\0';
|
||||
if (arrnum != 0) count = strtol(numarr, (char **)NULL, 10);
|
||||
else count = 1;
|
||||
arrnum = 0;
|
||||
sprintf(rep_buf, "%ld%c%s%c", precount, ch, numarr, ch1);
|
||||
switch (ch1) {
|
||||
case '/': /**** Search String ****/
|
||||
case '\\':
|
||||
strcat(rep_buf, "\n");
|
||||
clearstr();
|
||||
addch(ch1);
|
||||
refresh();
|
||||
if (getcmdstr(line, 1)) break;
|
||||
end_addr = searching(ch1, line, current, maxpos - 1, FALSE);
|
||||
if (!end_addr) {
|
||||
beep();
|
||||
return 0;
|
||||
}
|
||||
return(end_addr - current);
|
||||
case '?':
|
||||
case '#':
|
||||
strcat(rep_buf, "\n");
|
||||
clearstr();
|
||||
addch(ch1);
|
||||
refresh();
|
||||
if (getcmdstr(line, 1)) break;
|
||||
start_addr = searching(ch1, line, current, maxpos - 1, FALSE);
|
||||
if (!start_addr) {
|
||||
beep();
|
||||
return 0;
|
||||
}
|
||||
return(start_addr - current);
|
||||
case 'f':
|
||||
case 't':
|
||||
precount = count;
|
||||
end_addr = do_ft(ch1, 1);
|
||||
if (!end_addr) {
|
||||
beep();
|
||||
return 0;
|
||||
}
|
||||
return (end_addr + 1 - current);
|
||||
case 'F':
|
||||
case 'T':
|
||||
precount = count;
|
||||
start_addr = do_ft(ch1, 1);
|
||||
if (!start_addr) {
|
||||
beep();
|
||||
return 0;
|
||||
}
|
||||
return (start_addr - current);
|
||||
case '$':
|
||||
trunc_cur();
|
||||
return 0;
|
||||
case 'G':
|
||||
if (count == -1) {
|
||||
trunc_cur();
|
||||
return 0;
|
||||
} else if ((count < P(P_OF)) || (count
|
||||
- (off_t)P(P_OF)) > (filesize - 1L)) {
|
||||
beep();
|
||||
return 0;
|
||||
} else {
|
||||
if (mem + count < current) {
|
||||
return(mem + count - current);
|
||||
} else {
|
||||
return(count - (current - mem));
|
||||
}
|
||||
}
|
||||
case ' ':
|
||||
return precount;
|
||||
case '`':
|
||||
case '\'':
|
||||
mark = vgetc();
|
||||
if (mark < 'a' || mark > 'z') {
|
||||
beep();
|
||||
return 0;
|
||||
}
|
||||
end_addr = markbuf[mark - 'a'];
|
||||
if (end_addr == NULL) {
|
||||
beep();
|
||||
return 0;
|
||||
}
|
||||
if (end_addr < current) {
|
||||
return(end_addr - current);
|
||||
} else {
|
||||
return(end_addr - current + 1);
|
||||
}
|
||||
}
|
||||
beep();
|
||||
return 0;
|
||||
}
|
281
bvi.h
Normal file
281
bvi.h
Normal file
|
@ -0,0 +1,281 @@
|
|||
/* BVI.H
|
||||
*
|
||||
* 1996-02-28 V 1.0.0
|
||||
* 1999-01-21 V 1.1.0
|
||||
* 1999-03-17 V 1.1.1
|
||||
* 1999-07-01 V 1.2.0 beta
|
||||
* 1999-08-21 V 1.2.0 final
|
||||
* 2000-05-10 V 1.3.0 alpha
|
||||
* 2000-10-24 V 1.3.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifdef __MSDOS__
|
||||
# include "patchlev.h"
|
||||
# include "dosconf.h"
|
||||
# include "doscur.h"
|
||||
# include <alloc.h>
|
||||
#else
|
||||
# include "patchlevel.h"
|
||||
# include "config.h"
|
||||
#if HAVE_NCURSES_H
|
||||
# include <ncurses.h>
|
||||
#else
|
||||
# include <curses.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* defines for filemode */
|
||||
#define ERROR -1
|
||||
#define REGULAR 0
|
||||
#define NEW 1
|
||||
#define DIRECTORY 2
|
||||
#define CHARACTER_SPECIAL 3
|
||||
#define BLOCK_SPECIAL 4
|
||||
#define PARTIAL 5
|
||||
|
||||
/* regular expressions */
|
||||
#define END 0
|
||||
#define ONE 1
|
||||
#define STAR 2
|
||||
|
||||
/* undo modes */
|
||||
#define U_EDIT 1 /* undo o r R */
|
||||
#define U_TRUNC 2 /* undo D */
|
||||
#define U_INSERT 4 /* undo i */
|
||||
#define U_DELETE 8 /* undo x */
|
||||
#define U_BACK 16 /* undo X */
|
||||
#define U_APPEND 32 /* undo P A */
|
||||
#define U_TILDE 64 /* ~ */
|
||||
|
||||
#define S_GLOBAL 0x100
|
||||
|
||||
/* logic modes */
|
||||
#define LSHIFT 1
|
||||
#define RSHIFT 2
|
||||
#define LROTATE 3
|
||||
#define RROTATE 4
|
||||
#define AND 5
|
||||
#define OR 6
|
||||
#define XOR 7
|
||||
#define NEG 8
|
||||
#define NOT 9
|
||||
|
||||
#define HEX 0
|
||||
#define ASCII 1
|
||||
#define FORWARD 0
|
||||
#define BACKWARD 1
|
||||
#define CR '\r'
|
||||
#define NL '\n'
|
||||
#define BS 8
|
||||
#define ESC 27
|
||||
#define SEARCH 0
|
||||
#define REPLACE 1
|
||||
#ifndef CTRL
|
||||
# define CTRL(n) (n&0x1f)
|
||||
#endif
|
||||
|
||||
#define CMDLNG(a,b) (len <= a && len >= b)
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifdef __MSDOS__
|
||||
# define ANSI
|
||||
# define PTR char huge *
|
||||
# define off_t long
|
||||
# define DELIM '\\'
|
||||
# define strncasecmp strnicmp
|
||||
# define strcasecmp stricmp
|
||||
# define memcpy d_memcpy
|
||||
# define memmove d_memmove
|
||||
#else
|
||||
# define PTR char *
|
||||
# define DELIM '/'
|
||||
#endif
|
||||
|
||||
#define MAXCMD 255
|
||||
#define BUFFER 1024
|
||||
|
||||
#define SKIP_WHITE while(*cmd!='\0'&&isspace(*cmd))cmd++;
|
||||
|
||||
#ifdef DEBUG
|
||||
extern FILE *debug_fp;
|
||||
#endif
|
||||
|
||||
extern char *version;
|
||||
|
||||
#ifdef NO_SYSERRL
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
|
||||
extern char addr_form[];
|
||||
extern char pattern[];
|
||||
extern char rep_buf[];
|
||||
extern int maxx, maxy, x, y;
|
||||
extern int filemode, loc;
|
||||
extern int edits, new;
|
||||
extern int AnzAdd;
|
||||
extern int Anzahl, Anzahl3;
|
||||
extern int addr_flag;
|
||||
extern int ignore_case, magic;
|
||||
extern int screen, status;
|
||||
extern PTR mem;
|
||||
extern PTR maxpos;
|
||||
extern PTR pagepos;
|
||||
extern PTR undo_start;
|
||||
extern PTR current_start;
|
||||
extern PTR curpos;
|
||||
extern PTR current;
|
||||
extern PTR start_addr;
|
||||
extern PTR end_addr;
|
||||
extern char *name, cmdstr[];
|
||||
extern off_t filesize, memsize;
|
||||
extern PTR markbuf[];
|
||||
extern PTR last_motion;
|
||||
extern off_t undo_count;
|
||||
extern off_t yanked;
|
||||
extern off_t undosize;
|
||||
extern char *copyright, *notfound;
|
||||
extern char *terminal;
|
||||
extern char *undo_buf;
|
||||
extern char *yank_buf;
|
||||
extern int repl_count;
|
||||
extern char string[];
|
||||
extern char *shell;
|
||||
extern char *poi;
|
||||
extern int smode;
|
||||
extern int again;
|
||||
extern int block_flag;
|
||||
extern off_t block_begin, block_end, block_size;
|
||||
|
||||
#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */
|
||||
#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */
|
||||
#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */
|
||||
#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */
|
||||
#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */
|
||||
#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */
|
||||
#endif
|
||||
|
||||
#ifdef __MSDOS__
|
||||
void d_memcpy(PTR, PTR, off_t);
|
||||
void d_memmove(PTR, PTR, off_t);
|
||||
#endif
|
||||
|
||||
#ifdef ANSI
|
||||
off_t alloc_buf(off_t, char **), yd_addr(void);
|
||||
off_t range(int);
|
||||
void do_dot(void), do_exit(void), do_shell(void), do_undo(void);
|
||||
void do_tilde(off_t), trunc_cur(void);
|
||||
void do_back(off_t, PTR), do_ins_chg(PTR, char *, int);
|
||||
void do_mark(int, PTR), badcmd(char *), movebyte(void);
|
||||
void docmdline(char *), do_over(PTR, off_t, PTR), do_put(PTR, off_t, PTR);
|
||||
void jmpproc(int), printline(PTR, int);
|
||||
int addfile(char *);
|
||||
int bregexec(PTR, char *);
|
||||
int chk_comm(int);
|
||||
int doecmd(char *, int);
|
||||
int do_append(int, char *), do_logic(int, char *);
|
||||
int do_delete(off_t, PTR);
|
||||
int doset(char *);
|
||||
int do_substitution(int, char *, PTR, PTR);
|
||||
int hexchar(void);
|
||||
int outmsg(char *);
|
||||
PTR searching(int, char *, PTR, PTR, int);
|
||||
PTR wordsearch(PTR, char);
|
||||
PTR backsearch(PTR, char);
|
||||
PTR fsearch(PTR, PTR, char *);
|
||||
PTR rsearch(PTR, PTR, char *);
|
||||
PTR end_word(PTR);
|
||||
PTR calc_addr(char **, PTR);
|
||||
PTR do_ft(int, int);
|
||||
char *patcpy(char *, char *, char);
|
||||
void setpage(PTR), msg(char *), emsg(char *), smsg(char *);
|
||||
void usage(void), bvi_init(char *), statpos(void), setcur(void);
|
||||
void showparms(int), toggle(void), scrolldown(int), scrollup(int);
|
||||
void fileinfo(char *);
|
||||
void clearstr(void), clear_marks(void), repaint(void), new_screen(void);
|
||||
void quit(void), sysemsg(char *), do_z(int), stuffin(char *);
|
||||
off_t edit(int), load(char *);
|
||||
off_t calc_size(char *);
|
||||
int ascii_comp(char *, char *), hex_comp(char *, char *);
|
||||
int cur_forw(int), cur_back(void);
|
||||
int lineout(void), save(char *, PTR, PTR, int);
|
||||
int at_least(char *, char *, int);
|
||||
int vgetc(void), xpos(void), enlarge(off_t);
|
||||
int getcmdstr(char *, int), read_rc(char *);
|
||||
int wait_return(int);
|
||||
#else
|
||||
int addfile();
|
||||
off_t alloc_buf(), yd_addr();
|
||||
off_t range();
|
||||
off_t calc_size();
|
||||
void do_mark(), badcmd(), movebyte();
|
||||
void do_back(), do_ins_chg();
|
||||
void jmpproc(), printline();
|
||||
int chk_comm();
|
||||
void docmdline(), do_over(), do_put();
|
||||
int doecmd();
|
||||
void do_dot(), do_exit(), do_shell(), do_undo();
|
||||
void do_tilde(), trunc_cur();
|
||||
int do_append(), do_logic();
|
||||
int do_delete();
|
||||
int doset();
|
||||
int do_substitution();
|
||||
int hexchar();
|
||||
int outmsg();
|
||||
PTR searching();
|
||||
PTR wordsearch();
|
||||
PTR backsearch();
|
||||
int bregexec();
|
||||
PTR fsearch();
|
||||
PTR rsearch();
|
||||
PTR end_word();
|
||||
PTR calc_addr();
|
||||
PTR do_ft();
|
||||
char *patcpy();
|
||||
void setpage(), msg(), emsg(), smsg();
|
||||
void usage(), bvi_init(), statpos(), setcur();
|
||||
void showparms(), toggle(), scrolldown(), scrollup();
|
||||
void fileinfo();
|
||||
void clearstr(), clear_marks(), new_screen(), repaint();
|
||||
void quit(), sysemsg(), do_z(), stuffin();
|
||||
off_t edit(), load();
|
||||
int ascii_comp(), hex_comp();
|
||||
int cur_forw(), cur_back();
|
||||
int lineout(), save(), at_least(), read_rc();
|
||||
int getcmdstr(), enlarge();
|
||||
int vgetc(), xpos();
|
||||
int wait_return();
|
||||
#endif
|
404
bvi.man
Normal file
404
bvi.man
Normal file
|
@ -0,0 +1,404 @@
|
|||
BVI(1) User Commands BVI(1)
|
||||
|
||||
|
||||
NAME
|
||||
bvi, bview - visual display editor for binary files
|
||||
|
||||
VERSION
|
||||
bvi-1.2.0
|
||||
|
||||
SYNOPSIS
|
||||
bvi [-R] [-c cmd] [-f script] file...
|
||||
bview [-R] [-c cmd] [-f script] file...
|
||||
|
||||
OPTIONS
|
||||
file...
|
||||
One or more files. The file argument indicates one or
|
||||
more files to be edited.
|
||||
|
||||
-R "Readonly": The readonly flag is set for all the
|
||||
files, preventing accidental overwriting with a write
|
||||
command.
|
||||
|
||||
-c cmd
|
||||
Execute command cmd. Begin editing by executing the
|
||||
specified editor command (usually a search or
|
||||
positioning command).
|
||||
|
||||
-f script
|
||||
This command provides a means for collecting a series
|
||||
of "ex" (colon) commands into a script file, then
|
||||
using this file to edit other files. Since there is no
|
||||
binary stream editor "bsed", you can use this option
|
||||
to make several global changes in a binary file.
|
||||
|
||||
DESCRIPTION
|
||||
Bvi stands for "Binary VIsual editor". Bvi is a display
|
||||
oriented editor for binary files; its command set is based
|
||||
on those of the vi(1) texteditor. As a binary editor
|
||||
cannot have the concept of "lines" there are several
|
||||
differences to Vi commands (see COMPARISON).
|
||||
|
||||
COMPARISON
|
||||
The main differences between Vi and Bvi are:
|
||||
|
||||
The screen is divided in three sections/windows: The byte
|
||||
offset (at the left side), the hex window (in the middle),
|
||||
and the ascii window (to the right) which shows the ascii
|
||||
values of those bytes in the hex window. On an 80 column
|
||||
terminal you will therefore see sixteen hex values and
|
||||
their ASCII values on each screen line. Note that the
|
||||
first byte has the offset '0' (zero).
|
||||
|
||||
You can toggle between the hex and ascii windows with the
|
||||
tabulator key (TAB). Toggling between these two windows
|
||||
does not change the current position within the file.
|
||||
|
||||
No "lines" concept: Files are treated as one long series
|
||||
of bytes only. These characters "newline" and "carriage
|
||||
return" thus are not special, ie they do not mark the end
|
||||
of lines. Therefore the lines on the screen do not
|
||||
represent lines in the usual way. Data is broken across
|
||||
screen lines as they happen to fit in. As a consequence
|
||||
there are no commands in bvi from ex or vi that are based
|
||||
on line numbers, eg "dd", "yy", 'C', 'S', 'o', 'O'. This
|
||||
also changes the meaning of "range" before the ":write"
|
||||
command to a byte offset, ie the command ":100,200w foo"
|
||||
writes all *bytes* (not lines) from offset 100 to offset
|
||||
200 to the file "foo".
|
||||
|
||||
No "text objects": There are also no text-specific
|
||||
arrangements like words, paragraphs, sentences, sections
|
||||
and so on.
|
||||
|
||||
Extended "ruler": The bottom line of the screen shows the
|
||||
current address (byte offset) and the current character in
|
||||
these notations:
|
||||
|
||||
octal, hexadecimal, decimal and ascii.
|
||||
|
||||
Search patterns: All search commands understand these
|
||||
special characters:
|
||||
|
||||
. any character
|
||||
[] set of characters
|
||||
* zero or more occurrences of previous char or set
|
||||
|
||||
But as there is no concept of lines you cannot use the
|
||||
standard symbols ("anchors") for "begin-of-line" ('^') and
|
||||
"end-of-line" ('$'). Searching for the start/end of lines
|
||||
must be done explicitly by adding these special characters
|
||||
to your search pattern using these meta sequences:
|
||||
|
||||
\n newline
|
||||
\r return
|
||||
\t tab
|
||||
\0 binary zero
|
||||
|
||||
Additional search commands: Similar to the text search
|
||||
commands there are additional hex-search functions '\' and
|
||||
'#' which allow to search for any byte value. Example:
|
||||
"\62 76 69" will search for the string "bvi". Spaces
|
||||
between hex value are optional, so searching for
|
||||
"6775636B6573" will find "guckes".
|
||||
|
||||
Changing data (insertion, deletion) moves the data to
|
||||
other addresses; this is bad for many cases (eg.
|
||||
databases, program files) and is thus disabled by default.
|
||||
You can enable this commands by typing
|
||||
|
||||
:set memmove
|
||||
|
||||
BVI Modes:
|
||||
|
||||
Command Mode aka Normal Mode:
|
||||
|
||||
Input is treated as commands. Note that command mode is
|
||||
the default mode after startup and when you escape/quit
|
||||
from either command line mode or input mode. Use ESC
|
||||
(escape) to cancel a partial (uncompleted) command.
|
||||
|
||||
Input Mode:
|
||||
|
||||
Input is treated as replacement of current character or is
|
||||
appended to the current file. This mode is entered from
|
||||
command mode by typing either of 'i', 'I', 'A', 'r', or
|
||||
'R'. You can enter the character itself (in the ASCII
|
||||
window) or its hexadecimal value (in the HEX window).
|
||||
Type TAB to switch between these two windows. Type ESC to
|
||||
cancel current command and return to command mode. Type
|
||||
CTRL-C to cancel current command abnormally.
|
||||
|
||||
Command line mode (aka Last Line Mode):
|
||||
|
||||
Reading input for : / ? \ # or !; terminate by typing a
|
||||
carriage return; an interrupt cancels termination. Type
|
||||
ESC to cancel current command and return to command mode.
|
||||
|
||||
ENVIRONMENT
|
||||
The editor recognizes the environment variable BVIINIT as
|
||||
a command (or list of commands) to run when it starts
|
||||
up. If this variable is undefined, the editor checks for
|
||||
startup commands in the file ~/.bvirc file, which you
|
||||
must own. However, if there is a .bvirc owned by you in
|
||||
the current directory, the editor takes its startup
|
||||
commands from this file - overriding both the file in your
|
||||
home directory and the environment variable.
|
||||
|
||||
TERMINOLOGY
|
||||
Characters names are abbreviated as follows:
|
||||
Abbr. ASCII name aka
|
||||
CR 010 carriage return
|
||||
^A 001 control-a
|
||||
^H 008 control-h
|
||||
^I 009 control-i aka TAB
|
||||
^U 021 control-u
|
||||
^Z 026 control-z
|
||||
ESC 027 escape aka ESC
|
||||
DEL 127 delete
|
||||
LEFT --- left arrow
|
||||
RIGHT --- right arrow
|
||||
DOWN --- down arrow
|
||||
UP --- up arrow
|
||||
|
||||
COMMAND SUMMARY
|
||||
See the TERMINOLOGY for a summary on key name
|
||||
abbreviations used within the following description of
|
||||
commands.
|
||||
|
||||
Abstract:
|
||||
Arrow keys move the cursor on the screen within the
|
||||
current window.
|
||||
|
||||
Sample commands:
|
||||
:version show version info
|
||||
<- v ^ -> arrow keys move the cursor
|
||||
h j k l same as arrow keys
|
||||
u undo previous change
|
||||
ZZ exit bvi, saving changes
|
||||
:q! quit, discarding changes
|
||||
/text search for text
|
||||
^U ^D scroll up or down
|
||||
|
||||
Counts before bvi commands:
|
||||
Numbers may be typed as a prefix to some commands.
|
||||
They are interpreted in one of these ways.
|
||||
|
||||
screen column |
|
||||
byte of file G
|
||||
scroll amount ^D ^U
|
||||
repeat effect most of the rest
|
||||
|
||||
Interrupting, canceling
|
||||
ESC end insert or incomplete command
|
||||
DEL (delete or rubout) interrupts
|
||||
|
||||
File manipulation:
|
||||
ZZ if file modified, write and exit;
|
||||
otherwise, exit
|
||||
:w write changed buffer to file
|
||||
:w! write changed buffer to file, overriding
|
||||
read-only ("forced" write)
|
||||
:q quit when no changes have been made
|
||||
:q! quit and discard all changes
|
||||
:e file edit file
|
||||
:e! reedit current file, discard all changes
|
||||
:e # edit the alternate file
|
||||
:e! # edit the alternate file, discard changes
|
||||
:w file write current buffer to file
|
||||
:w! file write current buffer to file overriding
|
||||
read-only (this "overwrites" the file)
|
||||
:sh run the command as set with option "shell",
|
||||
then return
|
||||
:!cmd run the command cmd from "shell", then
|
||||
return
|
||||
:n edit next file in the argument list
|
||||
:f show current filename, modified flag,
|
||||
current byte offset, and percentage of
|
||||
current position within buffer
|
||||
^G same as :f
|
||||
|
||||
Additional edit commands
|
||||
You can insert/append/change bytes in
|
||||
ASCII/binary/decimal/ hexadecimal or octal representation.
|
||||
You can enter several (screen) lines of input. A line with
|
||||
only a period (.) in it will terminate the command. You
|
||||
must not type in values greater than a byte value. This
|
||||
causes an abandom of the command. Pressing the CR key
|
||||
does not insert a newline - character into the file. If
|
||||
you use ASCII mode you can use the special characters \n,
|
||||
\r, \t and \0.
|
||||
|
||||
:i aCR insert bytes (ASCII) at cursor position
|
||||
:a bCR append bytes (Binary) at end of file
|
||||
:c hCR change bytes (hexadecimal) at cursor position
|
||||
|
||||
Bit-level operations
|
||||
:and n bitwise 'and' operation with value n
|
||||
:or n bitwise 'or' operation with value n
|
||||
:xor n bitwise 'xor' operation with value n
|
||||
:neg two's complement
|
||||
:not logical negation
|
||||
:sl i shift each byte i bits to the left
|
||||
:sr i shift each byte i bits to the right
|
||||
:rl i rotate each byte i bits to the left
|
||||
:rr i rotate each byte i bits to the right
|
||||
|
||||
Command mode addresses
|
||||
:w foo write current buffer to a file
|
||||
named "foo"
|
||||
:5,10w foo copy byte 5 through 100 into as
|
||||
file named foo
|
||||
:.,.+20w foo copy the current byte and the next
|
||||
20 bytes to foo
|
||||
:^,'aw foo write all bytes from the beginning
|
||||
through marker 'a'
|
||||
:/pat/,$ foo search pattern pat and and copy
|
||||
through end of file
|
||||
|
||||
Positioning within file:
|
||||
^B backward screen
|
||||
^F forward screen
|
||||
^D scroll down half screen
|
||||
^U scroll up half screen
|
||||
nG go to the specified character
|
||||
(end default), where n is a decimal address
|
||||
/pat next line matching pat
|
||||
?pat previous line matching pat
|
||||
\hex jump to next occurrence of hex string hex
|
||||
#hex jump to previous occurrence of hex string hex
|
||||
n repeat last search command
|
||||
N repeat last search command, but in opposite
|
||||
direction
|
||||
|
||||
Adjusting the screen:
|
||||
^L clear and redraw screen
|
||||
zCR redraw screen with current line at top of screen
|
||||
z- redraw screen with current line at bottom of
|
||||
screen
|
||||
z. redraw screen with current line at center of
|
||||
screen
|
||||
/pat/z- search for pattern pat and then move currents
|
||||
line to bottom
|
||||
^E scroll screen down 1 line
|
||||
^Y scroll screen up 1 line
|
||||
|
||||
Marking and returning:
|
||||
mx mark current position with lower-case letter x
|
||||
Note: this command works for all lower-case
|
||||
letters
|
||||
'x move cursor to mark x in ASCII section
|
||||
`x move cursor to mark x in HEX section
|
||||
'' move cursor to previous context in ASCII section
|
||||
`` move cursor to previous context in HEX section
|
||||
|
||||
Line positioning:
|
||||
H jump to first line on screen ("top")
|
||||
L jump to last line on screen ("low")
|
||||
M jump to middle line on screen ("middle")
|
||||
- jump onto previous line on screen
|
||||
+ jump onto next line on screen
|
||||
CR same as +
|
||||
DOWN or j next line, same column
|
||||
UP or k previous line, same column
|
||||
|
||||
Character positioning:
|
||||
^ first byte in HEX window
|
||||
$ end of screen line
|
||||
l or RIGHT jump onto next byte (within current
|
||||
screen line)
|
||||
h or LEFT jump onto previous byte (within current
|
||||
screen line)
|
||||
^H same as LEFT
|
||||
space same as RIGHT
|
||||
fx find next occurrence of character x
|
||||
Fx find previous occurrence of character x
|
||||
n| jump onto nth byte/character within current
|
||||
line
|
||||
|
||||
Strings:
|
||||
(works similar to the strings(1) command)
|
||||
Note: "Words" are defined as strings of "nonprinting
|
||||
characters".
|
||||
e jump to next end of word
|
||||
w jump to next begin of word
|
||||
b jump to previous begin of word
|
||||
W forward to next string delimited with a
|
||||
\0 or \n
|
||||
B back to previous string delimited with a
|
||||
nonprinting char
|
||||
|
||||
Corrections during insert:
|
||||
^H erase last character (backspace)
|
||||
erase your erase character, same as ^H (backspace)
|
||||
ESC ends insertion, back to command mode
|
||||
|
||||
Append and replace:
|
||||
A append at end of file
|
||||
rx replace current bte with char 'x'
|
||||
R enter replace mode; for all subsequent input,
|
||||
the current byte is overwritten with the next
|
||||
input character; leave replace mode with ESC.
|
||||
|
||||
Miscellaneous Operations:
|
||||
TAB toggle between ASCII and HEX section
|
||||
|
||||
Yank and Put:
|
||||
3ySPACE yank 3 characters
|
||||
p insert contents of yank buffer
|
||||
o replace text with content of yank buffer
|
||||
P put back at end of file
|
||||
|
||||
Undo, Redo:
|
||||
u undo last change
|
||||
Note: Only the last change can be undone.
|
||||
Therefore this commands toggles between the
|
||||
last and second-t-last state of the buffer.
|
||||
|
||||
Setting Options:
|
||||
With the :set command you can set options in bvi
|
||||
|
||||
Option Default Description
|
||||
|
||||
autowrite noaw Save current file, if modified, if you
|
||||
give a :n, :r or ! command
|
||||
columns cm=16 on an 80 character wide terminal
|
||||
ignorecase noic Ignores letter case in searching
|
||||
magic nomagic Makes . [ * special in patterns
|
||||
memmove nomm enables insert and delete commands
|
||||
offset of=0 adds an offset to the diplayed addresses
|
||||
readonly noro If set, write fails unless you use ! after command
|
||||
scroll sc=1/2 window
|
||||
Number of lines scrolled by ^U and ^D
|
||||
showmode mo Displays statusline on bottom of the screen
|
||||
terse noterse Let you obtain shorter error messages
|
||||
window window=screensize
|
||||
Lines in window, can be reduced at slow terminals
|
||||
wordlength wl=4 Length of an ASCII-string found by w, W, b or B
|
||||
wrapscan ws Searches wrap around past the end of the file
|
||||
unixstyle nous The representation of ascii characters below
|
||||
32 is displayed in the statusline as shown
|
||||
in ascii(7) if unset rather in DOS-style (^A)
|
||||
|
||||
AUTHOR
|
||||
bvi was developed by Gerhard Buergmann, Vienna, Austria
|
||||
Gerhard.Buergmann@altavista.net
|
||||
|
||||
WWW
|
||||
Bvi Homepage: http://bvi.linuxave.net/
|
||||
Vi Pages: http://www.math.fu-berlin.de/~guckes/vi/
|
||||
(all about Vi and its clones)
|
||||
|
||||
FILES
|
||||
$HOME/.bvirc editor startup file
|
||||
./.bvirc editor startup file
|
||||
|
||||
BUGS
|
||||
Bvi does not update the screen when the terminal changes
|
||||
its size.
|
||||
|
||||
SEE ALSO
|
||||
vi(1), strings(1), ascii(5)
|
||||
|
||||
|
||||
31/Oct/99 BVI Version 1.2.0 8
|
828
comm.c
Normal file
828
comm.c
Normal file
|
@ -0,0 +1,828 @@
|
|||
/* COMM.C - Routines to parse and execute "command line" commands, such as
|
||||
* search or colon commands.
|
||||
*
|
||||
* 1996-01-16 created;
|
||||
* 1998-03-14 V 1.0.1
|
||||
* 1999-02-03 V 1.1.0
|
||||
* 1999-06-22 V 1.2.0 beta
|
||||
* 1999-09-10 V 1.2.0 final
|
||||
* 2000-03-03 V 1.3.0 beta
|
||||
* 2000-07-15 V 1.3.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include "bvi.h"
|
||||
#include "set.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __MSDOS__
|
||||
# include <io.h>
|
||||
# include <dir.h>
|
||||
# define WRITE (O_WRONLY|O_CREAT|O_TRUNC|O_BINARY)
|
||||
# define APPEND (O_WRONLY|O_APPEND|O_BINARY)
|
||||
#else
|
||||
# define WRITE (O_WRONLY|O_CREAT|O_TRUNC)
|
||||
# define APPEND (O_WRONLY|O_APPEND)
|
||||
#endif
|
||||
|
||||
#define CMDSZ 256 /* size of the command buffer */
|
||||
#define MAXNAME 10 /* size of a : command name */
|
||||
|
||||
#define NO_ADDR 1
|
||||
#define NO_ARG 8
|
||||
#define ONE_ARG 16
|
||||
#define MAX_ONE_ARG 32
|
||||
#define ONE_FILE 64
|
||||
#define MAX_ONE_FILE 128
|
||||
|
||||
static char *altfile = NULL; /* alternate file */
|
||||
static struct stat buf;
|
||||
static int c_argc = 0;
|
||||
static char *c_argv[9];
|
||||
|
||||
char *nowrtmsg = "No write@since last change (:%s! overrides)";
|
||||
char *morefiles = "more files@to edit";
|
||||
char *ambigous = "Ambigous|Too many file names";
|
||||
char *ambvalue = "Ambigous|Too many values";
|
||||
char *extra = "Extra chars|Extra characters at end of command";
|
||||
char *noaddr = "No address allowed@on this command";
|
||||
char *noval = "No value@for binary operation";
|
||||
int repl_count = -1;
|
||||
int addr_flag;
|
||||
|
||||
PTR start_addr;
|
||||
PTR end_addr;
|
||||
|
||||
extern char *name; /* actual filename */
|
||||
extern char **files; /* used for "next" and "rewind" */
|
||||
extern int numfiles, curfile;
|
||||
extern int errno;
|
||||
|
||||
static char oldbuf[CMDSZ]; /** for :!! command **/
|
||||
|
||||
|
||||
/*
|
||||
* docmdline() - handle a colon command
|
||||
*
|
||||
* Handles a colon command received interactively by getcmdln() or from
|
||||
* the environment variable "BVIINIT" (or eventually .bvirc).
|
||||
*/
|
||||
void
|
||||
docmdline(cmdline)
|
||||
char *cmdline;
|
||||
{
|
||||
char buff[CMDSZ];
|
||||
char cmdbuf[CMDSZ];
|
||||
char cmdname[MAXNAME];
|
||||
char *cmd;
|
||||
char *p;
|
||||
size_t len;
|
||||
int n, ok;
|
||||
int force = 0;
|
||||
int saveflag;
|
||||
|
||||
if (cmdline == NULL) return;
|
||||
if (*cmdline == '"') return; /** comment **/
|
||||
if (strlen(cmdline) > CMDSZ - 2) {
|
||||
emsg("Command too long");
|
||||
return;
|
||||
}
|
||||
strcpy(buff, cmdline);
|
||||
cmd = buff;
|
||||
|
||||
/* With no address given, we start at the beginning of the file and
|
||||
* go to the end of the file (not line like in vi).
|
||||
*/
|
||||
addr_flag = 0;
|
||||
start_addr = mem;
|
||||
end_addr = maxpos - 1;
|
||||
SKIP_WHITE
|
||||
if (*cmd == '%') {
|
||||
cmd++;
|
||||
addr_flag = 2;
|
||||
} else {
|
||||
if ((start_addr = calc_addr(&cmd, mem)) == NULL) {
|
||||
return;
|
||||
}
|
||||
if (*cmd == ',') {
|
||||
cmd++;
|
||||
addr_flag = 1;
|
||||
SKIP_WHITE
|
||||
if ((end_addr = calc_addr(&cmd, maxpos - 1)) == NULL) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (addr_flag) {
|
||||
/* if we have only one address */
|
||||
end_addr = start_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
SKIP_WHITE
|
||||
|
||||
if (start_addr > (end_addr + 1)) {
|
||||
emsg("Addr1 > addr2|First address exceeds second");
|
||||
return;
|
||||
}
|
||||
if ((end_addr + 1) > maxpos) {
|
||||
emsg("Not that many bytes@in buffer");
|
||||
return;
|
||||
}
|
||||
if (start_addr < mem) {
|
||||
sprintf(string, "Negative address@- first byte is %ld", P(P_OF));
|
||||
emsg(string);
|
||||
return;
|
||||
}
|
||||
|
||||
SKIP_WHITE
|
||||
|
||||
/**** End of address range calculation ****/
|
||||
|
||||
if (*cmd == '\0') {
|
||||
setpage(end_addr);
|
||||
return;
|
||||
}
|
||||
strcpy(cmdbuf, cmd); /* save the unmodified command */
|
||||
|
||||
if (*cmd == '!') {
|
||||
if (*(cmdbuf + 1) == '\0') {
|
||||
emsg("Incomplete shell escape command@- use 'shell' to get a shell");
|
||||
return;
|
||||
}
|
||||
if (*(cmdbuf + 1) == '!') {
|
||||
if (oldbuf[0] != '\0') {
|
||||
strcpy(cmdbuf + 1, oldbuf);
|
||||
msg(oldbuf);
|
||||
} else {
|
||||
emsg("No previous command@to substitute for !");
|
||||
return;
|
||||
}
|
||||
} else sprintf(oldbuf, "\n%s\n", cmdbuf + 1);
|
||||
|
||||
if (P(P_AW)) {
|
||||
save(name, mem, maxpos, WRITE);
|
||||
edits = 0;
|
||||
}
|
||||
if (edits) msg("[No write]|[No write since last change]");
|
||||
savetty();
|
||||
endwin();
|
||||
system(cmdbuf + 1);
|
||||
fprintf(stderr, "[Hit return to continue]");
|
||||
getchar();
|
||||
doupdate();
|
||||
repaint();
|
||||
clearstr();
|
||||
return;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
while (*cmd >= 'a' && *cmd <= 'z') {
|
||||
cmdname[n++] = *cmd++;
|
||||
if (n == MAXNAME) {
|
||||
sprintf(string, "What?|%s: Not an editor command", cmdbuf);
|
||||
emsg(string);
|
||||
return;
|
||||
}
|
||||
}
|
||||
cmdname[n] = '\0';
|
||||
if (*cmd == '!') {
|
||||
force = 1;
|
||||
cmd++;
|
||||
}
|
||||
len = strlen(cmdname);
|
||||
SKIP_WHITE
|
||||
|
||||
if (!strncmp("substitute", cmdname, len) && CMDLNG(10,1)) {
|
||||
repl_count = do_substitution(*cmd, cmd + 1, start_addr, end_addr);
|
||||
if (repl_count == -1) {
|
||||
emsg("No previous substitute re|No previous substitute regular expression");
|
||||
return; /* No prev subst */
|
||||
}
|
||||
repaint();
|
||||
if (!repl_count) {
|
||||
emsg("Fail|Substitute pattern matching failed");
|
||||
} else if (repl_count > 1) {
|
||||
sprintf(string, "%d subs|%d substitutions", repl_count, repl_count);
|
||||
msg(string);
|
||||
}
|
||||
return;
|
||||
} else if (!strncmp("global", cmdname, len) && CMDLNG(6,1)) {
|
||||
current = start_addr - 1;
|
||||
repl_count = 0;
|
||||
addch('\n');
|
||||
while ((current = searching(*cmd, cmd + 1, current,
|
||||
end_addr, FALSE|S_GLOBAL)) != 0L) {
|
||||
addch('\n');
|
||||
printline(current, maxy - 1);
|
||||
repl_count++;
|
||||
if (repl_count == LINES - 2) {
|
||||
if (wait_return(FALSE)) return;
|
||||
repl_count = 0;
|
||||
}
|
||||
}
|
||||
if (repl_count) {
|
||||
wait_return(TRUE);
|
||||
} else {
|
||||
repaint();
|
||||
emsg(notfound);
|
||||
}
|
||||
return;
|
||||
} else if (cmdname[0] == 't') {
|
||||
if (!addr_flag) start_addr = current;
|
||||
cmd = cmdname + 1L;
|
||||
SKIP_WHITE
|
||||
do_mark(*cmd, start_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!strncmp("write", cmdname, len) && CMDLNG(5,1)) || !strcmp("wq", cmdname)) {
|
||||
if (*cmd == '>') {
|
||||
if (*(++cmd) == '>') {
|
||||
cmd++;
|
||||
saveflag = APPEND;
|
||||
} else {
|
||||
emsg("Write forms are 'w' and 'w>>'");
|
||||
return;
|
||||
}
|
||||
} else if (*cmd == '!') {
|
||||
emsg("Not yet implemented");
|
||||
return;
|
||||
} else {
|
||||
saveflag = WRITE;
|
||||
}
|
||||
SKIP_WHITE
|
||||
|
||||
c_argc = 0;
|
||||
if ((c_argv[c_argc] = strtok(cmd, " \t")) != NULL) c_argc++;
|
||||
while ((c_argv[c_argc] = strtok(NULL, " \t")) != NULL) c_argc++;
|
||||
|
||||
if (c_argc > 1) {
|
||||
emsg(ambigous);
|
||||
return; }
|
||||
if (c_argc == 1) {
|
||||
/* change '%' to Filename */
|
||||
while ((p = strchr(c_argv[0], '%')) != NULL && *(p-1) != '\\') {
|
||||
if (name == NULL) {
|
||||
emsg("No filename@to substitute for %");
|
||||
return;
|
||||
}
|
||||
*p = '\0';
|
||||
strcpy (oldbuf, c_argv[0]);
|
||||
strcat (oldbuf, name);
|
||||
strcat (oldbuf, p + 1);
|
||||
c_argv[0] = oldbuf;
|
||||
}
|
||||
}
|
||||
if (name == NULL && c_argc != 0) name = strdup(c_argv[0]);
|
||||
if (force) {
|
||||
if (c_argc == 0) ok = save(name, start_addr, end_addr, saveflag);
|
||||
else ok = save(c_argv[0], start_addr, end_addr, saveflag);
|
||||
} else {
|
||||
if (c_argc == 0) {
|
||||
if (P(P_RO)) {
|
||||
sprintf(string, "\"%s\" File is read only", name);
|
||||
emsg(string);
|
||||
return;
|
||||
} else ok = save(name, start_addr, end_addr, saveflag);
|
||||
} else {
|
||||
if (!stat(c_argv[0], &buf)) {
|
||||
if (saveflag == WRITE) {
|
||||
sprintf(string, "File exists@- use \"%s! %s\" to overwrite", cmdname, c_argv[0]);
|
||||
emsg(string);
|
||||
return;
|
||||
} else { /* APPEND */
|
||||
/* We can only append to a regular file! */
|
||||
if (S_ISREG(buf.st_mode)) {
|
||||
if (filemode == PARTIAL) filemode = REGULAR;
|
||||
} else if (S_ISBLK(buf.st_mode)) {
|
||||
emsg("Cannot append to a block special file");
|
||||
return;
|
||||
}
|
||||
ok = save(c_argv[0], start_addr, end_addr, saveflag);
|
||||
}
|
||||
} else {
|
||||
if (saveflag == APPEND) {
|
||||
emsg("No such file");
|
||||
return;
|
||||
} else { /* WRITE */
|
||||
/* If we write the block of a partial file to a new file, it will
|
||||
* become a regular file!
|
||||
*/
|
||||
if (filemode == PARTIAL) filemode = REGULAR;
|
||||
ok = save(c_argv[0], start_addr, end_addr, saveflag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!strcmp("wq", cmdname)) {
|
||||
if (ok) quit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
c_argc = 0;
|
||||
cmd = strtok(cmdbuf, " \t");
|
||||
while ((c_argv[c_argc] = strtok(NULL, " \t")) != NULL) c_argc++;
|
||||
|
||||
if (!strncmp("set", cmdname, len) && CMDLNG(3, 2)) {
|
||||
if (chk_comm(NO_ADDR)) return;
|
||||
if (c_argc == 0) {
|
||||
doset(NULL);
|
||||
} else {
|
||||
for (n = 0; n < c_argc; n++) {
|
||||
if (doset(c_argv[n])) return;
|
||||
}
|
||||
}
|
||||
} else if (!strncmp("args", cmdname, len) && CMDLNG(4, 2)) {
|
||||
if (chk_comm(NO_ADDR|NO_ARG)) return;
|
||||
string[0] = '\0';
|
||||
for (n = 0; n < numfiles; n++) {
|
||||
if (n == curfile) strcat(string, "[");
|
||||
strcat(string, files[n]);
|
||||
if (n == curfile) strcat(string, "]");
|
||||
strcat(string, " ");
|
||||
}
|
||||
msg(string);
|
||||
} else if (!strncmp("source", cmdname, len) && CMDLNG(6, 2)) {
|
||||
if (chk_comm(NO_ADDR|ONE_FILE)) return;
|
||||
if (read_rc(c_argv[0])) sysemsg(c_argv[0]);
|
||||
refresh();
|
||||
} else if (!strncmp("cd", cmdname, len) && CMDLNG(2, 2)) {
|
||||
if (chk_comm(NO_ADDR|ONE_FILE)) return;
|
||||
if (!force) {
|
||||
if (edits) {
|
||||
if (P(P_AW)) {
|
||||
save(name, mem, maxpos, WRITE);
|
||||
edits = 0;
|
||||
} else {
|
||||
sprintf(string, nowrtmsg, "cd");
|
||||
emsg(string);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c_argc == 0) {
|
||||
sprintf(string, "%c", DELIM);
|
||||
c_argv[0] = string;
|
||||
}
|
||||
if (chdir(c_argv[0])) sysemsg(c_argv[0]);
|
||||
} else if (!strncmp("edit", cmdname, len) && CMDLNG(4, 1)) {
|
||||
/*
|
||||
* The command ":e#" gets expanded to something like ":efile", so
|
||||
* detect that case here.
|
||||
*/
|
||||
if (*cmd == 'e' && c_argc == 0) {
|
||||
if (cmd[1] == '!')
|
||||
(void) doecmd(&cmd[2], TRUE);
|
||||
else
|
||||
(void) doecmd(&cmd[1], FALSE);
|
||||
return;
|
||||
}
|
||||
if (chk_comm(NO_ADDR|MAX_ONE_FILE)) return;
|
||||
doecmd(c_argv[0], force);
|
||||
} else if (!strncmp("file", cmdname, len) && CMDLNG(4, 1)) {
|
||||
if (chk_comm(NO_ADDR|MAX_ONE_FILE)) return;
|
||||
if (c_argc != 0) name = strdup(c_argv[0]);
|
||||
fileinfo(name);
|
||||
} else if (!strncmp("read", cmdname, len) && CMDLNG(4, 1)) {
|
||||
if (chk_comm(NO_ADDR|MAX_ONE_FILE)) return;
|
||||
/* read reads a file at EOF */
|
||||
if (c_argc == 0) c_argv[0] = name;
|
||||
if (!addfile(c_argv[0])) {
|
||||
edits = U_TRUNC;
|
||||
undosize = filesize;
|
||||
repaint();
|
||||
}
|
||||
} else if (!strncmp("xit", cmdname, len) && CMDLNG(3, 1)) {
|
||||
if (chk_comm(NO_ADDR|NO_ARG)) return;
|
||||
do_exit();
|
||||
} else if (!strncmp("next", cmdname, len) && CMDLNG(4, 1)) {
|
||||
if (chk_comm(NO_ADDR|NO_ARG)) return;
|
||||
if (!force) {
|
||||
if (edits) {
|
||||
if (P(P_AW)) {
|
||||
save(name, mem, maxpos, WRITE);
|
||||
edits = 0;
|
||||
} else {
|
||||
sprintf(string, nowrtmsg, "next");
|
||||
emsg(string);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((curfile + 1) < numfiles) {
|
||||
if (force) stuffin(":e! ");
|
||||
else stuffin(":e ");
|
||||
stuffin(files[++curfile]);
|
||||
stuffin("\n");
|
||||
} else
|
||||
emsg("No more files@to edit!");
|
||||
} else if (!strncmp("rewind", cmdname, len) && CMDLNG(6, 3)) {
|
||||
if (chk_comm(NO_ADDR|NO_ARG)) return;
|
||||
if (numfiles <= 1) /* nothing to rewind */
|
||||
return;
|
||||
if (!force) {
|
||||
if (edits) {
|
||||
if (P(P_AW)) {
|
||||
save(name, mem, maxpos, WRITE);
|
||||
edits = 0;
|
||||
} else {
|
||||
sprintf(string, nowrtmsg, "rewind");
|
||||
emsg(string);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
curfile = 0;
|
||||
if (force) stuffin(":e! ");
|
||||
else stuffin(":e ");
|
||||
stuffin(files[0]);
|
||||
stuffin("\n");
|
||||
} else if (!strncmp("append", cmdname, len) && CMDLNG(6, 1)) {
|
||||
if (chk_comm(NO_ADDR|MAX_ONE_ARG)) return;
|
||||
do_ins_chg(start_addr, c_argc == 1 ? c_argv[0] : "a", U_APPEND);
|
||||
} else if (!strncmp("change", cmdname, len) && CMDLNG(6, 1)) {
|
||||
if (chk_comm(MAX_ONE_ARG)) return;
|
||||
if (!addr_flag) start_addr = current;
|
||||
do_ins_chg(start_addr, c_argc == 1 ? c_argv[0] : "a", U_EDIT);
|
||||
} else if (!strncmp("mark", cmdname, len) && CMDLNG(4, 2)) {
|
||||
if (c_argc == 0) { emsg("Mark what?"); return; }
|
||||
if (c_argc > 1 || (strlen(c_argv[0]) > 1)) { emsg(extra); return; }
|
||||
if (!addr_flag) start_addr = current;
|
||||
do_mark(c_argv[0][0], start_addr);
|
||||
} else if (!strncmp("yank", cmdname, len) && CMDLNG(4, 1)) {
|
||||
if ((yanked = yd_addr()) == 0L) return;
|
||||
if ((yanked = alloc_buf(yanked, &yank_buf)) == 0L) return;
|
||||
memcpy(yank_buf, start_addr, yanked);
|
||||
sprintf(string, "%lu bytes", (long)yanked);
|
||||
msg(string);
|
||||
} else if (!strncmp("overwrite", cmdname, len) && CMDLNG(9, 1)) {
|
||||
if (chk_comm(NO_ARG)) return;
|
||||
if (!addr_flag) start_addr = current;
|
||||
do_over(start_addr, yanked, yank_buf);
|
||||
} else if (!strncmp("undo", cmdname, len) && CMDLNG(4, 1)) {
|
||||
if (chk_comm(NO_ADDR|NO_ARG)) return;
|
||||
do_undo();
|
||||
} else if (!strncmp("version", cmdname, len) && CMDLNG(7, 2)) {
|
||||
if (chk_comm(NO_ADDR|NO_ARG)) return;
|
||||
sprintf(string, "bvi version %s %s", VERSION, copyright);
|
||||
msg(string);
|
||||
} else if (!strncmp("shell", cmdname, len) && CMDLNG(5, 2)) {
|
||||
if (chk_comm(NO_ADDR|NO_ARG)) return;
|
||||
do_shell();
|
||||
clear();
|
||||
repaint();
|
||||
clearstr();
|
||||
} else if (!strncmp("quit", cmdname, len) && CMDLNG(4, 1)) {
|
||||
if (chk_comm(NO_ADDR|NO_ARG)) return;
|
||||
if (!force) {
|
||||
if (edits) {
|
||||
sprintf(string, nowrtmsg, "quit");
|
||||
emsg(string);
|
||||
} else {
|
||||
if ((curfile + 1) < numfiles) {
|
||||
sprintf(string, "%d %s", numfiles - curfile - 1, morefiles);
|
||||
emsg(string);
|
||||
} else
|
||||
quit();
|
||||
}
|
||||
} else quit();
|
||||
} else if (!strncmp("sleft", cmdname, len) && CMDLNG(5, 2)) {
|
||||
if (c_argc == 1) {
|
||||
do_logic(LSHIFT, c_argv[0]);
|
||||
} else if (c_argc == 0) {
|
||||
do_logic(LSHIFT, "1");
|
||||
} else { emsg(ambvalue); return; }
|
||||
} else if (!strncmp("sright", cmdname, len) && CMDLNG(6, 2)) {
|
||||
if (c_argc == 1) {
|
||||
do_logic(RSHIFT, c_argv[0]);
|
||||
} else if (c_argc == 0) {
|
||||
do_logic(RSHIFT, "1");
|
||||
} else { emsg(ambvalue); return; }
|
||||
} else if (!strncmp("rleft", cmdname, len) && CMDLNG(5, 2)) {
|
||||
if (c_argc == 1) {
|
||||
do_logic(LROTATE, c_argv[0]);
|
||||
} else if (c_argc == 0) {
|
||||
do_logic(LROTATE, "1");
|
||||
} else { emsg(ambvalue); return; }
|
||||
} else if (!strncmp("rright", cmdname, len) && CMDLNG(6, 2)) {
|
||||
if (c_argc == 1) {
|
||||
do_logic(RROTATE, c_argv[0]);
|
||||
} else if (c_argc == 0) {
|
||||
do_logic(RROTATE, "1");
|
||||
} else { emsg(ambvalue); return; }
|
||||
} else if (!strcmp("and", cmdname)) {
|
||||
if (c_argc == 1) {
|
||||
do_logic(AND, c_argv[0]);
|
||||
} else if (c_argc == 0) {
|
||||
emsg(noval); return;
|
||||
} else { emsg(ambvalue); return; }
|
||||
} else if (!strcmp("or", cmdname)) {
|
||||
if (c_argc == 1) {
|
||||
do_logic(OR, c_argv[0]);
|
||||
} else if (c_argc == 0) {
|
||||
emsg(noval); return;
|
||||
} else { emsg(ambvalue); return; }
|
||||
} else if (!strcmp("xor", cmdname)) {
|
||||
if (c_argc == 1) {
|
||||
do_logic(XOR, c_argv[0]);
|
||||
} else if (c_argc == 0) {
|
||||
emsg(noval); return;
|
||||
} else { emsg(ambvalue); return; }
|
||||
} else if (!strcmp("neg", cmdname)) {
|
||||
if (c_argc != 0) { emsg(extra); return; }
|
||||
do_logic(NEG, "255");
|
||||
} else if (!strcmp("not", cmdname)) {
|
||||
if (c_argc != 0) { emsg(extra); return; }
|
||||
do_logic(NOT, "255");
|
||||
} else {
|
||||
sprintf(string, "What?|%s: Not an editor command", cmd);
|
||||
if P(P_MM) {
|
||||
if (!strncmp("delete", cmdname, len) && CMDLNG(6, 1)) {
|
||||
if ((undo_count = yd_addr()) == 0L) return;
|
||||
do_delete(undo_count, start_addr);
|
||||
sprintf(string, "%lu bytes", (long)undo_count);
|
||||
msg(string);
|
||||
} else if (!strncmp("insert", cmdname, len) && CMDLNG(6, 1)) {
|
||||
if (chk_comm(MAX_ONE_ARG)) return;
|
||||
if (!addr_flag) start_addr = current;
|
||||
do_ins_chg(start_addr - 1, c_argc == 1 ? c_argv[0] : "a", U_INSERT);
|
||||
} else if (!strncmp("put", cmdname, len) && CMDLNG(3, 2)) {
|
||||
if (chk_comm(NO_ARG)) return;
|
||||
if (!addr_flag) start_addr = current;
|
||||
do_put(start_addr, yanked, yank_buf);
|
||||
} else {
|
||||
emsg(string);
|
||||
}
|
||||
} else {
|
||||
if (!strncmp("delete", cmdname, len) && CMDLNG(6, 1)) {
|
||||
movebyte();
|
||||
} else if (!strncmp("insert", cmdname, len) && CMDLNG(6, 1)) {
|
||||
movebyte();
|
||||
} else if (!strncmp("put", cmdname, len) && CMDLNG(3, 2)) {
|
||||
movebyte();
|
||||
} else {
|
||||
emsg(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* calculate address range for :yank and :delete command */
|
||||
off_t
|
||||
yd_addr()
|
||||
{
|
||||
off_t count = 0;
|
||||
|
||||
if (c_argc == 0) {
|
||||
switch (addr_flag) {
|
||||
case 0: start_addr = current;
|
||||
case 1: count = 1;
|
||||
break;
|
||||
case 2: count = end_addr - start_addr + 1;
|
||||
break;
|
||||
}
|
||||
} else if (c_argc == 1) {
|
||||
count = atoi(c_argv[0]);
|
||||
switch (addr_flag) {
|
||||
case 0: start_addr = current;
|
||||
case 1: end_addr = start_addr + count - 1;
|
||||
break;
|
||||
case 2: start_addr = end_addr;
|
||||
end_addr = start_addr + count - 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
emsg(ambvalue);
|
||||
return 0;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_exit()
|
||||
{
|
||||
if (edits) {
|
||||
if (!save(name, mem, maxpos - 1L, WRITE)) return;
|
||||
}
|
||||
if ((curfile + 1) < numfiles) {
|
||||
sprintf(string, "%d %s", numfiles - curfile - 1, morefiles);
|
||||
emsg(string);
|
||||
} else quit();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
doecmd(arg, force)
|
||||
char *arg;
|
||||
int force;
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
if (*arg == '\0') arg = NULL;
|
||||
if (!force && edits) {
|
||||
sprintf(string, nowrtmsg, "edit");
|
||||
emsg(string);
|
||||
/*
|
||||
if (altfile)
|
||||
free(altfile);
|
||||
altfile = strdup(arg);
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
if (arg != NULL) {
|
||||
if (name != NULL && !strcmp(arg, name)) {
|
||||
if (!edits || (edits && !force))
|
||||
return TRUE;
|
||||
}
|
||||
if (name != NULL && !strcmp(arg, "#")) {
|
||||
if (altfile == NULL) {
|
||||
emsg("No alternate filename@to substitute for #");
|
||||
return FALSE;
|
||||
}
|
||||
tmp = name;
|
||||
name = altfile;
|
||||
altfile = tmp;
|
||||
} else {
|
||||
if (altfile) {
|
||||
free(altfile);
|
||||
}
|
||||
altfile = name;
|
||||
name = strdup(arg);
|
||||
}
|
||||
}
|
||||
if (name == NULL) {
|
||||
emsg("No file|No current filename");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
edits = 0;
|
||||
filesize = load(name);
|
||||
if (arg == NULL) {
|
||||
setpage(current < maxpos ? current : maxpos - 1L);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
clearstr()
|
||||
{
|
||||
int n;
|
||||
|
||||
move(maxy, 0);
|
||||
for (n = 0; n < maxx; n++) addch(' ');
|
||||
move(maxy, 0);
|
||||
}
|
||||
|
||||
|
||||
/**** displays an error message *****/
|
||||
void
|
||||
emsg(s)
|
||||
char *s;
|
||||
{
|
||||
int cnt;
|
||||
|
||||
if (P(P_EB)) beep();
|
||||
clearstr();
|
||||
attrset(A_REVERSE);
|
||||
cnt = outmsg(s);
|
||||
attrset(A_NORMAL);
|
||||
if (cnt >= (maxx - 25)) { /* 25 = status */
|
||||
addch('\n');
|
||||
wait_return(TRUE); }
|
||||
}
|
||||
|
||||
|
||||
/*** System error message *****/
|
||||
void
|
||||
sysemsg(s)
|
||||
char *s;
|
||||
{
|
||||
char string[256];
|
||||
|
||||
sprintf(string, "%s: %s", s, sys_errlist[errno]);
|
||||
emsg(string);
|
||||
}
|
||||
|
||||
|
||||
/*** displays mode if showmode set *****/
|
||||
void
|
||||
smsg(s)
|
||||
char *s;
|
||||
{
|
||||
if (P(P_MO)) {
|
||||
msg(s);
|
||||
setcur();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************* displays s on status line *****************/
|
||||
void
|
||||
msg(s)
|
||||
char *s;
|
||||
{
|
||||
clearstr();
|
||||
if (outmsg(s) >= (maxx - 25)) { /* 25 = status */
|
||||
addch('\n');
|
||||
wait_return(TRUE); }
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
outmsg(s)
|
||||
char *s;
|
||||
{
|
||||
char *poi;
|
||||
int cnt = 0;
|
||||
|
||||
move(maxy, 0);
|
||||
poi = strchr(s, '|');
|
||||
|
||||
if (P(P_TE)) {
|
||||
poi = s;
|
||||
while (*poi != '\0' && *poi != '@' && *poi != '|') {
|
||||
addch(*poi++);
|
||||
cnt++; }
|
||||
} else {
|
||||
if (poi) poi++;
|
||||
else poi = s;
|
||||
while (*poi) {
|
||||
if (*poi == '@') addch(' ');
|
||||
else addch(*poi);
|
||||
poi++;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* If flag == TRUE we do a repaint
|
||||
*
|
||||
*/
|
||||
int
|
||||
wait_return(flag)
|
||||
int flag;
|
||||
{
|
||||
int c;
|
||||
|
||||
signal(SIGINT, jmpproc);
|
||||
clearstr();
|
||||
attrset(A_REVERSE);
|
||||
mvaddstr(maxy, 0, "[Hit return to continue]");
|
||||
attrset(A_NORMAL);
|
||||
refresh();
|
||||
c = getch();
|
||||
if (flag) {
|
||||
clear();
|
||||
repaint();
|
||||
}
|
||||
clearstr();
|
||||
signal(SIGINT, SIG_IGN);
|
||||
if (c != CR && c != NL && c != ' ' && c != ':' && c != KEY_ENTER) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
chk_comm(flag)
|
||||
int flag;
|
||||
{
|
||||
if ((flag & NO_ADDR) && (addr_flag > 0)) {
|
||||
emsg(noaddr); return 1; }
|
||||
if ((flag & NO_ARG) && (c_argc > 0)) {
|
||||
emsg(extra); return 1; }
|
||||
if ((flag & MAX_ONE_ARG) && (c_argc > 1)) {
|
||||
emsg(ambvalue); return 1; }
|
||||
if ((flag & ONE_FILE) && (c_argc == 0)) {
|
||||
emsg("Missing filename"); return 1; }
|
||||
if ((flag & MAX_ONE_FILE) && (c_argc > 1)) {
|
||||
emsg(ambigous); return 1; }
|
||||
return 0;
|
||||
}
|
883
config.guess
vendored
Executable file
883
config.guess
vendored
Executable file
|
@ -0,0 +1,883 @@
|
|||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file 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
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Written by Per Bothner <bothner@cygnus.com>.
|
||||
# The master version of this file is at the FSF in /home/gd/gnu/lib.
|
||||
#
|
||||
# This script attempts to guess a canonical system name similar to
|
||||
# config.sub. If it succeeds, it prints the system name on stdout, and
|
||||
# exits with 0. Otherwise, it exits with 1.
|
||||
#
|
||||
# The plan is that this can be called by configure scripts if you
|
||||
# don't specify an explicit system type (host/target name).
|
||||
#
|
||||
# Only a few systems have been added to this list; please add others
|
||||
# (but try to keep the structure clean).
|
||||
#
|
||||
|
||||
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
|
||||
# (ghazi@noc.rutgers.edu 8/24/94.)
|
||||
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
|
||||
PATH=$PATH:/.attbin ; export PATH
|
||||
fi
|
||||
|
||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
|
||||
trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
|
||||
|
||||
# Note: order is significant - the case branches are not exclusive.
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
alpha:OSF1:*:*)
|
||||
if test $UNAME_RELEASE = "V4.0"; then
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
fi
|
||||
# A Vn.n version is a released version.
|
||||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
cat <<EOF >dummy.s
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,0,\$26,0
|
||||
.prologue 0
|
||||
.long 0x47e03d80 # implver $0
|
||||
lda \$2,259
|
||||
.long 0x47e20c21 # amask $2,$1
|
||||
srl \$1,8,\$2
|
||||
sll \$2,2,\$2
|
||||
sll \$0,3,\$0
|
||||
addl \$1,\$0,\$0
|
||||
addl \$2,\$0,\$0
|
||||
ret \$31,(\$26),1
|
||||
.end main
|
||||
EOF
|
||||
${CC-cc} dummy.s -o dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
./dummy
|
||||
case "$?" in
|
||||
7)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
15)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
14)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
10)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
16)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -f dummy.s dummy
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
|
||||
exit 0 ;;
|
||||
21064:Windows_NT:50:3)
|
||||
echo alpha-dec-winnt3.5
|
||||
exit 0 ;;
|
||||
Amiga*:UNIX_System_V:4.0:*)
|
||||
echo m68k-cbm-sysv4
|
||||
exit 0;;
|
||||
amiga:NetBSD:*:*)
|
||||
echo m68k-cbm-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amiga:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc64:OpenBSD:*:*)
|
||||
echo mips64el-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hkmips:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pmax:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sgi:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
wgrisc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit 0;;
|
||||
arm32:NetBSD:*:*)
|
||||
echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
SR2?01:HI-UX/MPP:*:*)
|
||||
echo hppa1.1-hitachi-hiuxmpp
|
||||
exit 0;;
|
||||
Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
|
||||
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
|
||||
if test "`(/bin/universe) 2>/dev/null`" = att ; then
|
||||
echo pyramid-pyramid-sysv3
|
||||
else
|
||||
echo pyramid-pyramid-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
NILE:*:*:dcosx)
|
||||
echo pyramid-pyramid-svr4
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
i86pc:SunOS:5.*:*)
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
# According to config.sub, this is the proper way to canonicalize
|
||||
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
|
||||
# it's likely to be more like Solaris than SunOS4.
|
||||
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:*:*)
|
||||
case "`/usr/bin/arch -k`" in
|
||||
Series*|S4*)
|
||||
UNAME_RELEASE=`uname -v`
|
||||
;;
|
||||
esac
|
||||
# Japanese Language versions have a version number like `4.1.3-JL'.
|
||||
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
|
||||
exit 0 ;;
|
||||
sun3*:SunOS:*:*)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun*:*:4.2BSD:*)
|
||||
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
|
||||
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
|
||||
case "`/bin/arch`" in
|
||||
sun3)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
;;
|
||||
sun4)
|
||||
echo sparc-sun-sunos${UNAME_RELEASE}
|
||||
;;
|
||||
esac
|
||||
exit 0 ;;
|
||||
aushp:SunOS:*:*)
|
||||
echo sparc-auspex-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:NetBSD:*:*)
|
||||
echo m68k-atari-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:NetBSD:*:*)
|
||||
echo m68k-sun-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:NetBSD:*:*)
|
||||
echo m68k-apple-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme88k:OpenBSD:*:*)
|
||||
echo m88k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
powerpc:machten:*:*)
|
||||
echo powerpc-apple-machten${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RISC*:Mach:*:*)
|
||||
echo mips-dec-mach_bsd4.3
|
||||
exit 0 ;;
|
||||
RISC*:ULTRIX:*:*)
|
||||
echo mips-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
VAX*:ULTRIX*:*:*)
|
||||
echo vax-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
2020:CLIX:*:*)
|
||||
echo clipper-intergraph-clix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mips:*:*:UMIPS | mips:*:*:RISCos)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
int main (argc, argv) int argc; char **argv; {
|
||||
#if defined (host_mips) && defined (MIPSEB)
|
||||
#if defined (SYSTYPE_SYSV)
|
||||
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_SVR4)
|
||||
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
|
||||
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
exit (-1);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy \
|
||||
&& ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo mips-mips-riscos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Night_Hawk:Power_UNIX:*:*)
|
||||
echo powerpc-harris-powerunix
|
||||
exit 0 ;;
|
||||
m88k:CX/UX:7*:*)
|
||||
echo m88k-harris-cxux7
|
||||
exit 0 ;;
|
||||
m88k:*:4*:R4*)
|
||||
echo m88k-motorola-sysv4
|
||||
exit 0 ;;
|
||||
m88k:*:3*:R3*)
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
AViiON:dgux:*:*)
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
|
||||
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
|
||||
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
|
||||
echo m88k-dg-dgux${UNAME_RELEASE}
|
||||
else
|
||||
echo m88k-dg-dguxbcs${UNAME_RELEASE}
|
||||
fi
|
||||
else echo i586-dg-dgux${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
|
||||
echo m88k-dolphin-sysv3
|
||||
exit 0 ;;
|
||||
M88*:*:R3*:*)
|
||||
# Delta 88k system running SVR3
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
|
||||
echo m88k-tektronix-sysv3
|
||||
exit 0 ;;
|
||||
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
|
||||
echo m68k-tektronix-bsd
|
||||
exit 0 ;;
|
||||
*:IRIX*:*:*)
|
||||
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
|
||||
exit 0 ;;
|
||||
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
|
||||
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
|
||||
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
|
||||
i?86:AIX:*:*)
|
||||
echo i386-ibm-aix
|
||||
exit 0 ;;
|
||||
*:AIX:2:3)
|
||||
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <sys/systemcfg.h>
|
||||
|
||||
main()
|
||||
{
|
||||
if (!__power_pc())
|
||||
exit(1);
|
||||
puts("powerpc-ibm-aix3.2.5");
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo rs6000-ibm-aix3.2.5
|
||||
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
echo rs6000-ibm-aix3.2.4
|
||||
else
|
||||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit 0 ;;
|
||||
*:AIX:*:4)
|
||||
if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
else
|
||||
IBM_ARCH=powerpc
|
||||
fi
|
||||
if [ -x /usr/bin/oslevel ] ; then
|
||||
IBM_REV=`/usr/bin/oslevel`
|
||||
else
|
||||
IBM_REV=4.${UNAME_RELEASE}
|
||||
fi
|
||||
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
|
||||
exit 0 ;;
|
||||
*:AIX:*:*)
|
||||
echo rs6000-ibm-aix
|
||||
exit 0 ;;
|
||||
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
|
||||
echo romp-ibm-bsd4.4
|
||||
exit 0 ;;
|
||||
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
|
||||
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
|
||||
exit 0 ;; # report: romp-ibm BSD 4.3
|
||||
*:BOSX:*:*)
|
||||
echo rs6000-bull-bosx
|
||||
exit 0 ;;
|
||||
DPX/2?00:B.O.S.:*:*)
|
||||
echo m68k-bull-sysv3
|
||||
exit 0 ;;
|
||||
9000/[34]??:4.3bsd:1.*:*)
|
||||
echo m68k-hp-bsd
|
||||
exit 0 ;;
|
||||
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
|
||||
echo m68k-hp-bsd4.4
|
||||
exit 0 ;;
|
||||
9000/[3478]??:HP-UX:*:*)
|
||||
case "${UNAME_MACHINE}" in
|
||||
9000/31? ) HP_ARCH=m68000 ;;
|
||||
9000/[34]?? ) HP_ARCH=m68k ;;
|
||||
9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
|
||||
9000/8?? ) HP_ARCH=hppa1.0 ;;
|
||||
esac
|
||||
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
|
||||
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
|
||||
exit 0 ;;
|
||||
3050*:HI-UX:*:*)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <unistd.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
|
||||
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
|
||||
results, however. */
|
||||
if (CPU_IS_PA_RISC (cpu))
|
||||
{
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
|
||||
default: puts ("hppa-hitachi-hiuxwe2"); break;
|
||||
}
|
||||
}
|
||||
else if (CPU_IS_HP_MC68K (cpu))
|
||||
puts ("m68k-hitachi-hiuxwe2");
|
||||
else puts ("unknown-hitachi-hiuxwe2");
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit 0 ;;
|
||||
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
|
||||
echo hppa1.1-hp-bsd
|
||||
exit 0 ;;
|
||||
9000/8??:4.3bsd:*:*)
|
||||
echo hppa1.0-hp-bsd
|
||||
exit 0 ;;
|
||||
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
|
||||
echo hppa1.1-hp-osf
|
||||
exit 0 ;;
|
||||
hp8??:OSF1:*:*)
|
||||
echo hppa1.0-hp-osf
|
||||
exit 0 ;;
|
||||
i?86:OSF1:*:*)
|
||||
if [ -x /usr/sbin/sysversion ] ; then
|
||||
echo ${UNAME_MACHINE}-unknown-osf1mk
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-osf1
|
||||
fi
|
||||
exit 0 ;;
|
||||
parisc*:Lites*:*:*)
|
||||
echo hppa1.1-hp-lites
|
||||
exit 0 ;;
|
||||
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
CRAY*X-MP:*:*:*)
|
||||
echo xmp-cray-unicos
|
||||
exit 0 ;;
|
||||
CRAY*Y-MP:*:*:*)
|
||||
echo ymp-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY*[A-Z]90:*:*:*)
|
||||
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
|
||||
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
|
||||
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
|
||||
exit 0 ;;
|
||||
CRAY*TS:*:*:*)
|
||||
echo t90-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY-2:*:*:*)
|
||||
echo cray2-cray-unicos
|
||||
exit 0 ;;
|
||||
F300:UNIX_System_V:*:*)
|
||||
FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
F301:UNIX_System_V:*:*)
|
||||
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
|
||||
exit 0 ;;
|
||||
hp3[0-9][05]:NetBSD:*:*)
|
||||
echo m68k-hp-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hp300:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
i?86:BSD/386:*:* | *:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit 0 ;;
|
||||
*:NetBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
*:OpenBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo i386-pc-cygwin32
|
||||
exit 0 ;;
|
||||
i*:MINGW*:*)
|
||||
echo i386-pc-mingw32
|
||||
exit 0 ;;
|
||||
p*:CYGWIN*:*)
|
||||
echo powerpcle-unknown-cygwin32
|
||||
exit 0 ;;
|
||||
prep*:SunOS:5.*:*)
|
||||
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
*:GNU:*:*)
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit 0 ;;
|
||||
*:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us.
|
||||
ld_help_string=`ld --help 2>&1`
|
||||
ld_supported_emulations=`echo $ld_help_string \
|
||||
| sed -ne '/supported emulations:/!d
|
||||
s/[ ][ ]*/ /g
|
||||
s/.*supported emulations: *//
|
||||
s/ .*//
|
||||
p'`
|
||||
case "$ld_supported_emulations" in
|
||||
i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;;
|
||||
i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;;
|
||||
sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;;
|
||||
esac
|
||||
|
||||
if test "${UNAME_MACHINE}" = "alpha" ; then
|
||||
sed 's/^ //' <<EOF >dummy.s
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,0,\$26,0
|
||||
.prologue 0
|
||||
.long 0x47e03d80 # implver $0
|
||||
lda \$2,259
|
||||
.long 0x47e20c21 # amask $2,$1
|
||||
srl \$1,8,\$2
|
||||
sll \$2,2,\$2
|
||||
sll \$0,3,\$0
|
||||
addl \$1,\$0,\$0
|
||||
addl \$2,\$0,\$0
|
||||
ret \$31,(\$26),1
|
||||
.end main
|
||||
EOF
|
||||
LIBC=""
|
||||
${CC-cc} dummy.s -o dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
./dummy
|
||||
case "$?" in
|
||||
7)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
15)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
14)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
10)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
16)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
esac
|
||||
|
||||
objdump --private-headers dummy | \
|
||||
grep ld.so.1 > /dev/null
|
||||
if test "$?" = 0 ; then
|
||||
LIBC="libc1"
|
||||
fi
|
||||
fi
|
||||
rm -f dummy.s dummy
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "mips" ; then
|
||||
cat >dummy.c <<EOF
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __MIPSEB__
|
||||
printf ("%s-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
#ifdef __MIPSEL__
|
||||
printf ("%sel-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
else
|
||||
# Either a pre-BFD a.out linker (linux-gnuoldld)
|
||||
# or one that does not give us useful --help.
|
||||
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
|
||||
# If ld does not provide *any* "supported emulations:"
|
||||
# that means it is gnuoldld.
|
||||
echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
|
||||
test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
|
||||
|
||||
case "${UNAME_MACHINE}" in
|
||||
i?86)
|
||||
VENDOR=pc;
|
||||
;;
|
||||
*)
|
||||
VENDOR=unknown;
|
||||
;;
|
||||
esac
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
cat >dummy.c <<EOF
|
||||
#include <features.h>
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __ELF__
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ >= 2
|
||||
printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
|
||||
# else
|
||||
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
# else
|
||||
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
#else
|
||||
printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
fi ;;
|
||||
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
|
||||
# are messed up and put the nodename in both sysname and nodename.
|
||||
i?86:DYNIX/ptx:4*:*)
|
||||
echo i386-sequent-sysv4
|
||||
exit 0 ;;
|
||||
i?86:UNIX_SV:4.2MP:2.*)
|
||||
# Unixware is an offshoot of SVR4, but it has its own version
|
||||
# number series starting with 2...
|
||||
# I am not positive that other SVR4 systems won't match this,
|
||||
# I just have to hope. -- rms.
|
||||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
|
||||
exit 0 ;;
|
||||
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
|
||||
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
|
||||
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
i?86:*:3.2:*)
|
||||
if test -f /usr/options/cb.name; then
|
||||
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
|
||||
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
|
||||
elif /bin/uname -X 2>/dev/null >/dev/null ; then
|
||||
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
|
||||
&& UNAME_MACHINE=i586
|
||||
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv32
|
||||
fi
|
||||
exit 0 ;;
|
||||
pc:*:*:*)
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
# the processor, so we play safe by assuming i386.
|
||||
echo i386-pc-msdosdjgpp
|
||||
exit 0 ;;
|
||||
Intel:Mach:3*:*)
|
||||
echo i386-pc-mach3
|
||||
exit 0 ;;
|
||||
paragon:*:*:*)
|
||||
echo i860-intel-osf1
|
||||
exit 0 ;;
|
||||
i860:*:4.*:*) # i860-SVR4
|
||||
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
|
||||
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
|
||||
else # Add other i860-SVR4 vendors below as they are discovered.
|
||||
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
|
||||
fi
|
||||
exit 0 ;;
|
||||
mini*:CTIX:SYS*5:*)
|
||||
# "miniframe"
|
||||
echo m68010-convergent-sysv
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
|
||||
3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4.3${OS_REL} && exit 0
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
|
||||
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4 && exit 0 ;;
|
||||
m68*:LynxOS:2.*:*)
|
||||
echo m68k-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mc68030:UNIX_System_V:4.*:*)
|
||||
echo m68k-atari-sysv4
|
||||
exit 0 ;;
|
||||
i?86:LynxOS:2.*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
TSUNAMI:LynxOS:2.*:*)
|
||||
echo sparc-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
|
||||
echo rs6000-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
SM[BE]S:UNIX_SV:*:*)
|
||||
echo mips-dde-sysv${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RM*:SINIX-*:*:*)
|
||||
echo mips-sni-sysv4
|
||||
exit 0 ;;
|
||||
*:SINIX-*:*:*)
|
||||
if uname -p 2>/dev/null >/dev/null ; then
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
echo ${UNAME_MACHINE}-sni-sysv4
|
||||
else
|
||||
echo ns32k-sni-sysv
|
||||
fi
|
||||
exit 0 ;;
|
||||
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit 0 ;;
|
||||
*:UNIX_System_V:4*:FTX*)
|
||||
# From Gerald Hewes <hewes@openmarket.com>.
|
||||
# How about differentiating between stratus architectures? -djm
|
||||
echo hppa1.1-stratus-sysv4
|
||||
exit 0 ;;
|
||||
*:*:*:FTX*)
|
||||
# From seanf@swdc.stratus.com.
|
||||
echo i860-stratus-sysv4
|
||||
exit 0 ;;
|
||||
mc68*:A/UX:*:*)
|
||||
echo m68k-apple-aux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
news*:NEWS-OS:*:6*)
|
||||
echo mips-sony-newsos6
|
||||
exit 0 ;;
|
||||
R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
|
||||
|
||||
cat >dummy.c <<EOF
|
||||
#ifdef _SEQUENT_
|
||||
# include <sys/types.h>
|
||||
# include <sys/utsname.h>
|
||||
#endif
|
||||
main ()
|
||||
{
|
||||
#if defined (sony)
|
||||
#if defined (MIPSEB)
|
||||
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
|
||||
I don't know.... */
|
||||
printf ("mips-sony-bsd\n"); exit (0);
|
||||
#else
|
||||
#include <sys/param.h>
|
||||
printf ("m68k-sony-newsos%s\n",
|
||||
#ifdef NEWSOS4
|
||||
"4"
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__arm) && defined (__acorn) && defined (__unix)
|
||||
printf ("arm-acorn-riscix"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (hp300) && !defined (hpux)
|
||||
printf ("m68k-hp-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (NeXT)
|
||||
#if !defined (__ARCHITECTURE__)
|
||||
#define __ARCHITECTURE__ "m68k"
|
||||
#endif
|
||||
int version;
|
||||
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
|
||||
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
|
||||
exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (MULTIMAX) || defined (n16)
|
||||
#if defined (UMAXV)
|
||||
printf ("ns32k-encore-sysv\n"); exit (0);
|
||||
#else
|
||||
#if defined (CMU)
|
||||
printf ("ns32k-encore-mach\n"); exit (0);
|
||||
#else
|
||||
printf ("ns32k-encore-bsd\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__386BSD__)
|
||||
printf ("i386-pc-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (sequent)
|
||||
#if defined (i386)
|
||||
printf ("i386-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#if defined (ns32000)
|
||||
printf ("ns32k-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (_SEQUENT_)
|
||||
struct utsname un;
|
||||
|
||||
uname(&un);
|
||||
|
||||
if (strncmp(un.version, "V2", 2) == 0) {
|
||||
printf ("i386-sequent-ptx2\n"); exit (0);
|
||||
}
|
||||
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
|
||||
printf ("i386-sequent-ptx1\n"); exit (0);
|
||||
}
|
||||
printf ("i386-sequent-ptx\n"); exit (0);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (vax)
|
||||
#if !defined (ultrix)
|
||||
printf ("vax-dec-bsd\n"); exit (0);
|
||||
#else
|
||||
printf ("vax-dec-ultrix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (alliant) && defined (i860)
|
||||
printf ("i860-alliant-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
exit (1);
|
||||
}
|
||||
EOF
|
||||
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
|
||||
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
|
||||
|
||||
# Convex versions that predate uname can use getsysinfo(1)
|
||||
|
||||
if [ -x /usr/convex/getsysinfo ]
|
||||
then
|
||||
case `getsysinfo -f cpu_type` in
|
||||
c1*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
c2*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
c34*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
c38*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
c4*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#echo '(Unable to guess system type)' 1>&2
|
||||
|
||||
exit 1
|
45
config.h.in
Normal file
45
config.h.in
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef mode_t */
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
#undef NO_SYSERRL
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define if you have the strtol function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define if you have the <curses.h> header file. */
|
||||
#undef HAVE_CURSES_H
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <ncurses.h> header file. */
|
||||
#undef HAVE_NCURSES_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the ncurses library (-lncurses). */
|
||||
#undef HAVE_LIBNCURSES
|
||||
|
||||
/* Define if your tputs need putc(char) */
|
||||
#undef NEED_PUTC_CHAR
|
954
config.sub
vendored
Executable file
954
config.sub
vendored
Executable file
|
@ -0,0 +1,954 @@
|
|||
#! /bin/sh
|
||||
# Configuration validation subroutine script, version 1.1.
|
||||
# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
# can handle that machine. It does not imply ALL GNU software can.
|
||||
#
|
||||
# This file 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
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Configuration subroutine to validate and canonicalize a configuration type.
|
||||
# Supply the specified configuration type as an argument.
|
||||
# If it is invalid, we print an error message on stderr and exit with code 1.
|
||||
# Otherwise, we print the canonical config type on stdout and succeed.
|
||||
|
||||
# This file is supposed to be the same for all GNU packages
|
||||
# and recognize all the CPU types, system types and aliases
|
||||
# that are meaningful with *any* GNU software.
|
||||
# Each package is responsible for reporting which valid configurations
|
||||
# it does not support. The user should be able to distinguish
|
||||
# a failure to support a valid configuration from a meaningless
|
||||
# configuration.
|
||||
|
||||
# The goal of this file is to map all the various variations of a given
|
||||
# machine specification into a single specification in the form:
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
||||
# or in some cases, the newer four-part form:
|
||||
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
||||
# It is wrong to echo any other type of specification.
|
||||
|
||||
if [ x$1 = x ]
|
||||
then
|
||||
echo Configuration name missing. 1>&2
|
||||
echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
|
||||
echo "or $0 ALIAS" 1>&2
|
||||
echo where ALIAS is a recognized configuration type. 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# First pass through any local machine types.
|
||||
case $1 in
|
||||
*local*)
|
||||
echo $1
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
linux-gnu*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
*)
|
||||
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
|
||||
if [ $basic_machine != $1 ]
|
||||
then os=`echo $1 | sed 's/.*-/-/'`
|
||||
else os=; fi
|
||||
;;
|
||||
esac
|
||||
|
||||
### Let's recognize common machines as not being operating systems so
|
||||
### that things like config.sub decstation-3100 work. We also
|
||||
### recognize some manufacturers as not being operating systems, so we
|
||||
### can provide default operating systems below.
|
||||
case $os in
|
||||
-sun*os*)
|
||||
# Prevent following clause from handling this invalid input.
|
||||
;;
|
||||
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
|
||||
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
|
||||
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
-hiux*)
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
-sco5)
|
||||
os=sco3.2v5
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco4)
|
||||
os=-sco3.2v4
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2.[4-9]*)
|
||||
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2v[4-9]*)
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco*)
|
||||
os=-sco3.2v2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-isc)
|
||||
os=-isc2.2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-clix*)
|
||||
basic_machine=clipper-intergraph
|
||||
;;
|
||||
-isc*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-lynx*)
|
||||
os=-lynxos
|
||||
;;
|
||||
-ptx*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
|
||||
;;
|
||||
-windowsnt*)
|
||||
os=`echo $os | sed -e 's/windowsnt/winnt/'`
|
||||
;;
|
||||
-psos*)
|
||||
os=-psos
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode aliases for certain CPU-COMPANY combinations.
|
||||
case $basic_machine in
|
||||
# Recognize the basic CPU types without company name.
|
||||
# Some are omitted here because they have special meanings below.
|
||||
tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
|
||||
| arme[lb] | pyramid | mn10200 | mn10300 \
|
||||
| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
|
||||
| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
|
||||
| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
|
||||
| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| sparc | sparclet | sparclite | sparc64 | v850)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
# (2) the word "unknown" tends to confuse beginning users.
|
||||
i[3456]86)
|
||||
basic_machine=$basic_machine-pc
|
||||
;;
|
||||
# Object if more than one company name word.
|
||||
*-*-*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
# Recognize the basic CPU types with company name.
|
||||
vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \
|
||||
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
|
||||
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
|
||||
| power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
|
||||
| xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \
|
||||
| alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
|
||||
| ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
|
||||
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
|
||||
| sparc64-* | mips64-* | mipsel-* \
|
||||
| mips64el-* | mips64orion-* | mips64orionel-* \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
| f301-*)
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
|
||||
basic_machine=m68000-att
|
||||
;;
|
||||
3b*)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
alliant | fx80)
|
||||
basic_machine=fx80-alliant
|
||||
;;
|
||||
altos | altos3068)
|
||||
basic_machine=m68k-altos
|
||||
;;
|
||||
am29k)
|
||||
basic_machine=a29k-none
|
||||
os=-bsd
|
||||
;;
|
||||
amdahl)
|
||||
basic_machine=580-amdahl
|
||||
os=-sysv
|
||||
;;
|
||||
amiga | amiga-*)
|
||||
basic_machine=m68k-cbm
|
||||
;;
|
||||
amigaos | amigados)
|
||||
basic_machine=m68k-cbm
|
||||
os=-amigaos
|
||||
;;
|
||||
amigaunix | amix)
|
||||
basic_machine=m68k-cbm
|
||||
os=-sysv4
|
||||
;;
|
||||
apollo68)
|
||||
basic_machine=m68k-apollo
|
||||
os=-sysv
|
||||
;;
|
||||
aux)
|
||||
basic_machine=m68k-apple
|
||||
os=-aux
|
||||
;;
|
||||
balance)
|
||||
basic_machine=ns32k-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
convex-c1)
|
||||
basic_machine=c1-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c2)
|
||||
basic_machine=c2-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c32)
|
||||
basic_machine=c32-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c34)
|
||||
basic_machine=c34-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c38)
|
||||
basic_machine=c38-convex
|
||||
os=-bsd
|
||||
;;
|
||||
cray | ymp)
|
||||
basic_machine=ymp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
cray2)
|
||||
basic_machine=cray2-cray
|
||||
os=-unicos
|
||||
;;
|
||||
[ctj]90-cray)
|
||||
basic_machine=c90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
crds | unos)
|
||||
basic_machine=m68k-crds
|
||||
;;
|
||||
da30 | da30-*)
|
||||
basic_machine=m68k-da30
|
||||
;;
|
||||
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
|
||||
basic_machine=mips-dec
|
||||
;;
|
||||
delta | 3300 | motorola-3300 | motorola-delta \
|
||||
| 3300-motorola | delta-motorola)
|
||||
basic_machine=m68k-motorola
|
||||
;;
|
||||
delta88)
|
||||
basic_machine=m88k-motorola
|
||||
os=-sysv3
|
||||
;;
|
||||
dpx20 | dpx20-*)
|
||||
basic_machine=rs6000-bull
|
||||
os=-bosx
|
||||
;;
|
||||
dpx2* | dpx2*-bull)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv3
|
||||
;;
|
||||
ebmon29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-ebmon
|
||||
;;
|
||||
elxsi)
|
||||
basic_machine=elxsi-elxsi
|
||||
os=-bsd
|
||||
;;
|
||||
encore | umax | mmax)
|
||||
basic_machine=ns32k-encore
|
||||
;;
|
||||
fx2800)
|
||||
basic_machine=i860-alliant
|
||||
;;
|
||||
genix)
|
||||
basic_machine=ns32k-ns
|
||||
;;
|
||||
gmicro)
|
||||
basic_machine=tron-gmicro
|
||||
os=-sysv
|
||||
;;
|
||||
h3050r* | hiux*)
|
||||
basic_machine=hppa1.1-hitachi
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
h8300hms)
|
||||
basic_machine=h8300-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
harris)
|
||||
basic_machine=m88k-harris
|
||||
os=-sysv3
|
||||
;;
|
||||
hp300-*)
|
||||
basic_machine=m68k-hp
|
||||
;;
|
||||
hp300bsd)
|
||||
basic_machine=m68k-hp
|
||||
os=-bsd
|
||||
;;
|
||||
hp300hpux)
|
||||
basic_machine=m68k-hp
|
||||
os=-hpux
|
||||
;;
|
||||
hp9k2[0-9][0-9] | hp9k31[0-9])
|
||||
basic_machine=m68000-hp
|
||||
;;
|
||||
hp9k3[2-9][0-9])
|
||||
basic_machine=m68k-hp
|
||||
;;
|
||||
hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
|
||||
basic_machine=hppa1.1-hp
|
||||
;;
|
||||
hp9k8[0-9][0-9] | hp8[0-9][0-9])
|
||||
basic_machine=hppa1.0-hp
|
||||
;;
|
||||
hppa-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
i370-ibm* | ibm*)
|
||||
basic_machine=i370-ibm
|
||||
os=-mvs
|
||||
;;
|
||||
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
|
||||
i[3456]86v32)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv32
|
||||
;;
|
||||
i[3456]86v4*)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv4
|
||||
;;
|
||||
i[3456]86v)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv
|
||||
;;
|
||||
i[3456]86sol2)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-solaris2
|
||||
;;
|
||||
iris | iris4d)
|
||||
basic_machine=mips-sgi
|
||||
case $os in
|
||||
-irix*)
|
||||
;;
|
||||
*)
|
||||
os=-irix4
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
isi68 | isi)
|
||||
basic_machine=m68k-isi
|
||||
os=-sysv
|
||||
;;
|
||||
m88k-omron*)
|
||||
basic_machine=m88k-omron
|
||||
;;
|
||||
magnum | m3230)
|
||||
basic_machine=mips-mips
|
||||
os=-sysv
|
||||
;;
|
||||
merlin)
|
||||
basic_machine=ns32k-utek
|
||||
os=-sysv
|
||||
;;
|
||||
miniframe)
|
||||
basic_machine=m68000-convergent
|
||||
;;
|
||||
mipsel*-linux*)
|
||||
basic_machine=mipsel-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
mips*-linux*)
|
||||
basic_machine=mips-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
mips3*-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
|
||||
;;
|
||||
mips3*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
|
||||
;;
|
||||
ncr3000)
|
||||
basic_machine=i486-ncr
|
||||
os=-sysv4
|
||||
;;
|
||||
news | news700 | news800 | news900)
|
||||
basic_machine=m68k-sony
|
||||
os=-newsos
|
||||
;;
|
||||
news1000)
|
||||
basic_machine=m68030-sony
|
||||
os=-newsos
|
||||
;;
|
||||
news-3600 | risc-news)
|
||||
basic_machine=mips-sony
|
||||
os=-newsos
|
||||
;;
|
||||
next | m*-next )
|
||||
basic_machine=m68k-next
|
||||
case $os in
|
||||
-nextstep* )
|
||||
;;
|
||||
-ns2*)
|
||||
os=-nextstep2
|
||||
;;
|
||||
*)
|
||||
os=-nextstep3
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
nh3000)
|
||||
basic_machine=m68k-harris
|
||||
os=-cxux
|
||||
;;
|
||||
nh[45]000)
|
||||
basic_machine=m88k-harris
|
||||
os=-cxux
|
||||
;;
|
||||
nindy960)
|
||||
basic_machine=i960-intel
|
||||
os=-nindy
|
||||
;;
|
||||
np1)
|
||||
basic_machine=np1-gould
|
||||
;;
|
||||
pa-hitachi)
|
||||
basic_machine=hppa1.1-hitachi
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
paragon)
|
||||
basic_machine=i860-intel
|
||||
os=-osf
|
||||
;;
|
||||
pbd)
|
||||
basic_machine=sparc-tti
|
||||
;;
|
||||
pbb)
|
||||
basic_machine=m68k-tti
|
||||
;;
|
||||
pc532 | pc532-*)
|
||||
basic_machine=ns32k-pc532
|
||||
;;
|
||||
pentium | p5)
|
||||
basic_machine=i586-intel
|
||||
;;
|
||||
pentiumpro | p6)
|
||||
basic_machine=i686-intel
|
||||
;;
|
||||
pentium-* | p5-*)
|
||||
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumpro-* | p6-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
k5)
|
||||
# We don't have specific support for AMD's K5 yet, so just call it a Pentium
|
||||
basic_machine=i586-amd
|
||||
;;
|
||||
nexen)
|
||||
# We don't have specific support for Nexgen yet, so just call it a Pentium
|
||||
basic_machine=i586-nexgen
|
||||
;;
|
||||
pn)
|
||||
basic_machine=pn-gould
|
||||
;;
|
||||
power) basic_machine=rs6000-ibm
|
||||
;;
|
||||
ppc) basic_machine=powerpc-unknown
|
||||
;;
|
||||
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppcle | powerpclittle | ppc-le | powerpc-little)
|
||||
basic_machine=powerpcle-unknown
|
||||
;;
|
||||
ppcle-* | powerpclittle-*)
|
||||
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ps2)
|
||||
basic_machine=i386-ibm
|
||||
;;
|
||||
rm[46]00)
|
||||
basic_machine=mips-siemens
|
||||
;;
|
||||
rtpc | rtpc-*)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
sequent)
|
||||
basic_machine=i386-sequent
|
||||
;;
|
||||
sh)
|
||||
basic_machine=sh-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
sps7)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv2
|
||||
;;
|
||||
spur)
|
||||
basic_machine=spur-unknown
|
||||
;;
|
||||
sun2)
|
||||
basic_machine=m68000-sun
|
||||
;;
|
||||
sun2os3)
|
||||
basic_machine=m68000-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun2os4)
|
||||
basic_machine=m68000-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun3os3)
|
||||
basic_machine=m68k-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun3os4)
|
||||
basic_machine=m68k-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun4os3)
|
||||
basic_machine=sparc-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun4os4)
|
||||
basic_machine=sparc-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun4sol2)
|
||||
basic_machine=sparc-sun
|
||||
os=-solaris2
|
||||
;;
|
||||
sun3 | sun3-*)
|
||||
basic_machine=m68k-sun
|
||||
;;
|
||||
sun4)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
sun386 | sun386i | roadrunner)
|
||||
basic_machine=i386-sun
|
||||
;;
|
||||
symmetry)
|
||||
basic_machine=i386-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
tx39)
|
||||
basic_machine=mipstx39-unknown
|
||||
;;
|
||||
tx39el)
|
||||
basic_machine=mipstx39el-unknown
|
||||
;;
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
udi29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
;;
|
||||
ultra3)
|
||||
basic_machine=a29k-nyu
|
||||
os=-sym1
|
||||
;;
|
||||
vaxv)
|
||||
basic_machine=vax-dec
|
||||
os=-sysv
|
||||
;;
|
||||
vms)
|
||||
basic_machine=vax-dec
|
||||
os=-vms
|
||||
;;
|
||||
vpp*|vx|vx-*)
|
||||
basic_machine=f301-fujitsu
|
||||
;;
|
||||
vxworks960)
|
||||
basic_machine=i960-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
vxworks68)
|
||||
basic_machine=m68k-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
vxworks29k)
|
||||
basic_machine=a29k-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
xmp)
|
||||
basic_machine=xmp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
none)
|
||||
basic_machine=none-none
|
||||
os=-none
|
||||
;;
|
||||
|
||||
# Here we handle the default manufacturer of certain CPU types. It is in
|
||||
# some cases the only manufacturer, in others, it is the most popular.
|
||||
mips)
|
||||
if [ x$os = x-linux-gnu ]; then
|
||||
basic_machine=mips-unknown
|
||||
else
|
||||
basic_machine=mips-mips
|
||||
fi
|
||||
;;
|
||||
romp)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
rs6000)
|
||||
basic_machine=rs6000-ibm
|
||||
;;
|
||||
vax)
|
||||
basic_machine=vax-dec
|
||||
;;
|
||||
pdp11)
|
||||
basic_machine=pdp11-dec
|
||||
;;
|
||||
we32k)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
sparc)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
cydra)
|
||||
basic_machine=cydra-cydrome
|
||||
;;
|
||||
orion)
|
||||
basic_machine=orion-highlevel
|
||||
;;
|
||||
orion105)
|
||||
basic_machine=clipper-highlevel
|
||||
;;
|
||||
*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Here we canonicalize certain aliases for manufacturers.
|
||||
case $basic_machine in
|
||||
*-digital*)
|
||||
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
|
||||
;;
|
||||
*-commodore*)
|
||||
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode manufacturer-specific aliases for certain operating systems.
|
||||
|
||||
if [ x"$os" != x"" ]
|
||||
then
|
||||
case $os in
|
||||
# First match some system type aliases
|
||||
# that might get confused with valid system types.
|
||||
# -solaris* is a basic system type, with this one exception.
|
||||
-solaris1 | -solaris1.*)
|
||||
os=`echo $os | sed -e 's|solaris1|sunos4|'`
|
||||
;;
|
||||
-solaris)
|
||||
os=-solaris2
|
||||
;;
|
||||
-svr4*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-unixware*)
|
||||
os=-sysv4.2uw
|
||||
;;
|
||||
-gnu/linux*)
|
||||
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
|
||||
;;
|
||||
# First accept the basic system types.
|
||||
# The portable systems comes first.
|
||||
# Each alternative MUST END IN A *, to match a version number.
|
||||
# -sysv* is not here because it comes later, after sysvr4.
|
||||
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
|
||||
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
|
||||
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
|
||||
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -uxpv*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-linux*)
|
||||
os=`echo $os | sed -e 's|linux|linux-gnu|'`
|
||||
;;
|
||||
-sunos5*)
|
||||
os=`echo $os | sed -e 's|sunos5|solaris2|'`
|
||||
;;
|
||||
-sunos6*)
|
||||
os=`echo $os | sed -e 's|sunos6|solaris3|'`
|
||||
;;
|
||||
-osfrose*)
|
||||
os=-osfrose
|
||||
;;
|
||||
-osf*)
|
||||
os=-osf
|
||||
;;
|
||||
-utek*)
|
||||
os=-bsd
|
||||
;;
|
||||
-dynix*)
|
||||
os=-bsd
|
||||
;;
|
||||
-acis*)
|
||||
os=-aos
|
||||
;;
|
||||
-ctix* | -uts*)
|
||||
os=-sysv
|
||||
;;
|
||||
-ns2 )
|
||||
os=-nextstep2
|
||||
;;
|
||||
# Preserve the version number of sinix5.
|
||||
-sinix5.*)
|
||||
os=`echo $os | sed -e 's|sinix|sysv|'`
|
||||
;;
|
||||
-sinix*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-triton*)
|
||||
os=-sysv3
|
||||
;;
|
||||
-oss*)
|
||||
os=-sysv3
|
||||
;;
|
||||
-svr4)
|
||||
os=-sysv4
|
||||
;;
|
||||
-svr3)
|
||||
os=-sysv3
|
||||
;;
|
||||
-sysvr4)
|
||||
os=-sysv4
|
||||
;;
|
||||
# This must come after -sysvr4.
|
||||
-sysv*)
|
||||
;;
|
||||
-xenix)
|
||||
os=-xenix
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
# Get rid of the `-' at the beginning of $os.
|
||||
os=`echo $os | sed 's/[^-]*-//'`
|
||||
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
||||
# Here we handle the default operating systems that come with various machines.
|
||||
# The value should be what the vendor currently ships out the door with their
|
||||
# machine or put another way, the most popular os provided with the machine.
|
||||
|
||||
# Note that if you're going to try to match "-MANUFACTURER" here (say,
|
||||
# "-sun"), then you have to tell the case statement up towards the top
|
||||
# that MANUFACTURER isn't an operating system. Otherwise, code above
|
||||
# will signal an error saying that MANUFACTURER isn't an operating
|
||||
# system, and we'll never get to this point.
|
||||
|
||||
case $basic_machine in
|
||||
*-acorn)
|
||||
os=-riscix1.2
|
||||
;;
|
||||
arm*-semi)
|
||||
os=-aout
|
||||
;;
|
||||
pdp11-*)
|
||||
os=-none
|
||||
;;
|
||||
*-dec | vax-*)
|
||||
os=-ultrix4.2
|
||||
;;
|
||||
m68*-apollo)
|
||||
os=-domain
|
||||
;;
|
||||
i386-sun)
|
||||
os=-sunos4.0.2
|
||||
;;
|
||||
m68000-sun)
|
||||
os=-sunos3
|
||||
# This also exists in the configure program, but was not the
|
||||
# default.
|
||||
# os=-sunos4
|
||||
;;
|
||||
*-tti) # must be before sparc entry or we get the wrong os.
|
||||
os=-sysv3
|
||||
;;
|
||||
sparc-* | *-sun)
|
||||
os=-sunos4.1.1
|
||||
;;
|
||||
*-ibm)
|
||||
os=-aix
|
||||
;;
|
||||
*-hp)
|
||||
os=-hpux
|
||||
;;
|
||||
*-hitachi)
|
||||
os=-hiux
|
||||
;;
|
||||
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
|
||||
os=-sysv
|
||||
;;
|
||||
*-cbm)
|
||||
os=-amigaos
|
||||
;;
|
||||
*-dg)
|
||||
os=-dgux
|
||||
;;
|
||||
*-dolphin)
|
||||
os=-sysv3
|
||||
;;
|
||||
m68k-ccur)
|
||||
os=-rtu
|
||||
;;
|
||||
m88k-omron*)
|
||||
os=-luna
|
||||
;;
|
||||
*-next )
|
||||
os=-nextstep
|
||||
;;
|
||||
*-sequent)
|
||||
os=-ptx
|
||||
;;
|
||||
*-crds)
|
||||
os=-unos
|
||||
;;
|
||||
*-ns)
|
||||
os=-genix
|
||||
;;
|
||||
i370-*)
|
||||
os=-mvs
|
||||
;;
|
||||
*-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
*-gould)
|
||||
os=-sysv
|
||||
;;
|
||||
*-highlevel)
|
||||
os=-bsd
|
||||
;;
|
||||
*-encore)
|
||||
os=-bsd
|
||||
;;
|
||||
*-sgi)
|
||||
os=-irix
|
||||
;;
|
||||
*-siemens)
|
||||
os=-sysv4
|
||||
;;
|
||||
*-masscomp)
|
||||
os=-rtu
|
||||
;;
|
||||
f301-fujitsu)
|
||||
os=-uxpv
|
||||
;;
|
||||
*)
|
||||
os=-none
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Here we handle the case where we know the os, and the CPU type, but not the
|
||||
# manufacturer. We pick the logical manufacturer.
|
||||
vendor=unknown
|
||||
case $basic_machine in
|
||||
*-unknown)
|
||||
case $os in
|
||||
-riscix*)
|
||||
vendor=acorn
|
||||
;;
|
||||
-sunos*)
|
||||
vendor=sun
|
||||
;;
|
||||
-aix*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-hpux*)
|
||||
vendor=hp
|
||||
;;
|
||||
-hiux*)
|
||||
vendor=hitachi
|
||||
;;
|
||||
-unos*)
|
||||
vendor=crds
|
||||
;;
|
||||
-dgux*)
|
||||
vendor=dg
|
||||
;;
|
||||
-luna*)
|
||||
vendor=omron
|
||||
;;
|
||||
-genix*)
|
||||
vendor=ns
|
||||
;;
|
||||
-mvs*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-ptx*)
|
||||
vendor=sequent
|
||||
;;
|
||||
-vxsim* | -vxworks*)
|
||||
vendor=wrs
|
||||
;;
|
||||
-aux*)
|
||||
vendor=apple
|
||||
;;
|
||||
esac
|
||||
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
|
||||
;;
|
||||
esac
|
||||
|
||||
echo $basic_machine$os
|
88
configure.in
Normal file
88
configure.in
Normal file
|
@ -0,0 +1,88 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(bvi.c)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
dnl On SunOS4 systems you have to use the /usr/5bin/cc compiler
|
||||
dnl to get the SYSV curses library:
|
||||
case "$host_os" in
|
||||
sunos4*)
|
||||
AC_MSG_RESULT("using /usr/5bin/cc")
|
||||
CC="/usr/5bin/cc"
|
||||
;;
|
||||
*)
|
||||
AC_PROG_CC
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
dnl Some curses specials
|
||||
dnl Solaris needs for tputs 'putc(char)' instead of 'putc(int)'
|
||||
case "$host_os" in
|
||||
solaris*)
|
||||
CPPFLAGS="${CPPFLAGS} -D_MSE_INT_H"
|
||||
AC_DEFINE(NEED_PUTC_CHAR)
|
||||
;;
|
||||
hpux9*) DEFS=${DEFS-"-DMINICURSES"}
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_INSTALL
|
||||
|
||||
dnl Check for typedefs
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
|
||||
AC_CHECK_TYPE(size_t, unsigned int)
|
||||
AC_CHECK_TYPE(off_t, int)
|
||||
AC_CHECK_TYPE(mode_t, u_short)
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h termcap.h termio.h termios.h unistd.h)
|
||||
|
||||
dnl Check if ncurses requested
|
||||
_cppflags="${CPPFLAGS}"
|
||||
_ldflags="${LDFLAGS}"
|
||||
|
||||
AC_ARG_WITH(ncurses,
|
||||
[ --with-ncurses[=DIR] path to ncurses],[
|
||||
if test "$withval" != "no"; then
|
||||
CPPFLAGS="${CPPFLAGS} -I$withval/include -I$withval/include/ncurses"
|
||||
LDFLAGS="${LDFLAGS} -L$withval/lib"
|
||||
fi
|
||||
])
|
||||
|
||||
AC_CHECK_HEADER(ncurses.h,
|
||||
AC_CHECK_LIB(ncurses, initscr,
|
||||
AC_DEFINE(HAVE_NCURSES_H) LIBS="${LIBS} -lncurses",
|
||||
AC_CHECK_LIB(curses, initscr,
|
||||
AC_DEFINE(HAVE_CURSES_H) LIBS="${LIBS} -lcurses",
|
||||
AC_MSG_ERROR([bvi requires the curses library]))),
|
||||
AC_CHECK_HEADER(curses.h,
|
||||
AC_CHECK_LIB(curses, initscr,
|
||||
AC_DEFINE(HAVE_CURSES_H) LIBS="${LIBS} -lcurses",
|
||||
AC_MSG_ERROR([bvi requires the curses library])),
|
||||
AC_MSG_ERROR([bvi requires the curses library])))
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
dnl AC_TYPE_SIZE_T
|
||||
|
||||
dnl Checks for library functions.
|
||||
dnl AC_TYPE_SIGNAL
|
||||
AC_CHECK_FUNCS(strdup strtol memmove)
|
||||
|
||||
AC_EGREP_HEADER(sys_errlist, stdio.h, errl=ok, errl=no)
|
||||
AC_EGREP_HEADER(sys_errlist, errno.h, errl=ok,)
|
||||
AC_EGREP_HEADER(sys_errlist, sys/types.h, errl=ok,)
|
||||
if test $errl = no; then
|
||||
AC_DEFINE(NO_SYSERRL)
|
||||
fi
|
||||
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_OUTPUT(Makefile)
|
27
configure.scan
Normal file
27
configure.scan
Normal file
|
@ -0,0 +1,27 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(bvi.c)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
dnl Checks for libraries.
|
||||
dnl Replace `main' with a function in -lcurses:
|
||||
AC_CHECK_LIB(curses, main)
|
||||
dnl Replace `main' with a function in -lncurses:
|
||||
AC_CHECK_LIB(ncurses, main)
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h unistd.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
AC_CHECK_FUNCS(strdup strtol)
|
||||
|
||||
AC_OUTPUT(Makefile)
|
46
dosconf.h
Normal file
46
dosconf.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* dosconf.h
|
||||
*
|
||||
* 1996-02-28 V 1.0.0
|
||||
* 1999-01-21 V 1.1.0
|
||||
* 1999-03-17 V 1.1.1
|
||||
* 1999-07-01 V 1.2.0 beta
|
||||
* 1999-08-27 V 1.2.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-1969 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have the strtol function. */
|
||||
#define HAVE_STRTOL 1
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define if you have the <locale.h> header file. */
|
||||
#if __TURBOC__ > 0x0400
|
||||
# define HAVE_LOCALE_H 1
|
||||
#endif
|
||||
|
149
doscur.h
Normal file
149
doscur.h
Normal file
|
@ -0,0 +1,149 @@
|
|||
/* DOSCUR.H - CURSES.H for TURBO C
|
||||
*
|
||||
* Copyright 1996 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 1996-02-28 V 1.0.0
|
||||
* 1998-04-12 V 1.0.1
|
||||
* 1999-01-14 V 1.1.1
|
||||
* 1999-07-01 V 1.2.0
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <dos.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define ESC 27
|
||||
#define KEY_F0 0x3A00
|
||||
#define KEY_F(n) (KEY_F0+(n<<8))
|
||||
#define KEY_DOWN 0x5000
|
||||
#define KEY_UP 0x4800
|
||||
#define KEY_LEFT 0x4B00
|
||||
#define KEY_RIGHT 0x4D00
|
||||
#define KEY_NPAGE 0x5100
|
||||
#define KEY_PPAGE 0x4900
|
||||
#define KEY_RETURN 0x0d
|
||||
#define KEY_ENTER 0x0a
|
||||
#define KEY_BACKSPACE 0x0E08
|
||||
#define KEY_HOME 0x4700
|
||||
#define KEY_LL 0x4f00 /* HOME DOWN, End */
|
||||
#define KEY_DC 0x5300
|
||||
#define KEY_IC 0x5200
|
||||
|
||||
|
||||
|
||||
#define A_NORMAL 3
|
||||
#define A_STANDOUT 8
|
||||
#define A_BOLD 8
|
||||
#define A_REVERSE 127
|
||||
#define A_BLINK 128
|
||||
#define A_CHARTEXT 0x00ff
|
||||
#define A_ATTRIBUTES 0xff00
|
||||
|
||||
#define chtype unsigned int
|
||||
|
||||
#define WINDOW text_info
|
||||
|
||||
extern struct WINDOW scr;
|
||||
|
||||
extern int stdscr;
|
||||
|
||||
extern int COLS;
|
||||
extern int LINES;
|
||||
extern int ECHO;
|
||||
extern int NODEL;
|
||||
|
||||
void attrset(int);
|
||||
|
||||
#define initscr() clrscr();window(1,1,COLS,LINES);gettextinfo(&scr)
|
||||
#define newwin(h,b,y,x) window(x+1,y+1,x+b+1,y+h+1);gettextinfo(&scr)
|
||||
#define erasechar() KEY_ERASE
|
||||
#define beep() putch(7)
|
||||
#define flash() putch(7)
|
||||
#define wclrtoeol(w) clreol()
|
||||
#define clrtoeol() clreol()
|
||||
#define werase(w) window(scr.winleft,scr.wintop,scr.winright,scr.winbottom)
|
||||
#define erase() clrscr()
|
||||
#define wclear(w) werase(w)
|
||||
#define clear() clrscr()
|
||||
/*
|
||||
#define wattrset(w,a) textattr(a)
|
||||
#define attrset(a) textattr(a)
|
||||
*/
|
||||
#define standout() highvideo()
|
||||
#define standend() normvideo()
|
||||
#define wmove(w,y,x) gotoxy(x+1,y+1)
|
||||
#define move(y,x) gotoxy(x+1,y+1)
|
||||
#define mvwaddch(w,y,x,c) gotoxy(x+1,y+1);putch(c)
|
||||
#define mvaddch(y,x,c) gotoxy(x+1,y+1);putch(c)
|
||||
#define waddch(w,c) putch(c)
|
||||
#define addch(c) putch(c)
|
||||
#define mvwaddstr(w,y,x,s) gotoxy(x+1,y+1);cputs(s)
|
||||
#define mvaddstr(y,x,s) gotoxy(x+1,y+1);cputs(s)
|
||||
#define waddstr(s) cputs(s)
|
||||
#define addstr(s) cputs(s)
|
||||
#define mvwprintw(w,y,x,s) gotoxy(x+1,y+1);cprintf(s)
|
||||
#define mvprintw(y,x,s,a) gotoxy(x+1,y+1);cprintf(s,a)
|
||||
#define wprintw(w,s) cprintf(s)
|
||||
#define printw cprintf
|
||||
#define getyx(w,y,x) x=wherex()-1;y=wherey()-1
|
||||
#define getbegyx(w,y,x) x=scr.winleft;y=scr.wintop;
|
||||
#define getmaxyx(w,y,x) x=(scr.winright)-(scr.winleft);y=(scr.winbottom)-(scr.wintop)+1
|
||||
#define winsertln() insline()
|
||||
#define insertln() insline()
|
||||
#define wdeleteln(w) delline()
|
||||
#define deleteln() delline()
|
||||
#define mvwgetch(w,y,x) gotoxy(x+1,y+1);ugetch()
|
||||
#define mvgetch(y,x) gotoxy(x+1,y+1);ugetch()
|
||||
#define wgetch(w) ugetch()
|
||||
#define mvwgetstr(w,y,x,s) gotoxy(x+1,y+1);gets(s)
|
||||
#define mvgetstr(y,x,s) gotoxy(x+1,y+1);gets(s)
|
||||
#define wgetstr(w,s) gets(s)
|
||||
/*
|
||||
#define getstr(s) gets(s)
|
||||
*/
|
||||
#define flushinp() fflush(stdin)
|
||||
#define mvwscanw(w,y,x,s) gotoxy(x+1,y+1);cscanf(s)
|
||||
#define mvscanw(y,x,s) gotoxy(x+1,y+1);cscanf(s)
|
||||
#define wscanw(w,s) wscanw(s)
|
||||
#define scanw cscanf
|
||||
#define mvinsch(y,x,c) gotoxy(x+1,y+1);insch(c)
|
||||
|
||||
#define nodelay(w,b) NODEL=b
|
||||
#define echo() ECHO=TRUE
|
||||
#define noecho() ECHO=FALSE
|
||||
|
||||
#define nl()
|
||||
#define nonl()
|
||||
#define keypad(a,b)
|
||||
#define refresh()
|
||||
#define wrefresh(w)
|
||||
#define cbreak()
|
||||
#define endwin()
|
||||
#define raw()
|
||||
#define noraw()
|
||||
#define notimeout(w,t)
|
||||
#define idlok(w,b)
|
||||
#define scrollok(a,b)
|
||||
#define doupdate()
|
||||
#define savetty()
|
||||
#define resetty()
|
||||
|
||||
#define ERR (-1)
|
||||
|
||||
|
464
dosio.c
Normal file
464
dosio.c
Normal file
|
@ -0,0 +1,464 @@
|
|||
/* DOSIO.C - file I/O and alloc subroutines for MSDOS - BVI
|
||||
*
|
||||
* 1996-02-28 V 1.0.0
|
||||
* 1998-04-12 V 1.0.1
|
||||
* 1999-01-14 V 1.1.0
|
||||
* 1999-04-27 V 1.1.1
|
||||
* 1999-07-02 V 1.2.0 beta
|
||||
* 1999-09-01 V 1.2.0 final
|
||||
* 2000-05-02 V 1.3.0 alpha
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include <conio.h>
|
||||
#include <alloc.h>
|
||||
#include <fcntl.h>
|
||||
#include <bios.h>
|
||||
#include <io.h>
|
||||
#include <mem.h>
|
||||
#include "bvi.h"
|
||||
#include "set.h"
|
||||
|
||||
char *terminal = "ansi";
|
||||
|
||||
extern maxy;
|
||||
struct WINDOW scr;
|
||||
|
||||
int stdscr = 0;
|
||||
|
||||
int COLS = 80;
|
||||
int LINES = 25;
|
||||
int ECHO = TRUE;
|
||||
int NODEL = FALSE;
|
||||
|
||||
static struct stat buf;
|
||||
int filemode;
|
||||
|
||||
int inch(void);
|
||||
|
||||
void
|
||||
attrset(int attr)
|
||||
{
|
||||
switch(attr) {
|
||||
case A_NORMAL: textcolor(P(P_CO) & 0x07);
|
||||
textbackground((P(P_CO) & 0xf0) >> 4);
|
||||
break;
|
||||
case A_BOLD: textcolor((P(P_CO) & 0x07) | 0x08);
|
||||
textbackground((P(P_CO) & 0xf0) >> 4);
|
||||
break;
|
||||
case A_REVERSE: textcolor((P(P_CO) & 0xf0) >> 4);
|
||||
textbackground(P(P_CO) & 0x0f);
|
||||
break;
|
||||
case A_BLINK: textcolor((P(P_CO) & 0xf0) >> 4);
|
||||
textbackground(P(P_CO) & 0x0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
getch()
|
||||
{
|
||||
int x;
|
||||
|
||||
if (NODEL) if (!kbhit()) return(ERR);
|
||||
x = bioskey(0);
|
||||
if ((x & 0xff) == 0) return(x);
|
||||
else {
|
||||
x &= 0xff;
|
||||
if (ECHO) putch(x);
|
||||
return(x); }
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
delch()
|
||||
{
|
||||
int x, y;
|
||||
|
||||
x = wherex(); y = wherey();
|
||||
movetext(x + 1, y, COLS - x, y, x, y);
|
||||
gotoxy(COLS, y);
|
||||
putch(' ');
|
||||
gotoxy(x, y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
insch(int c)
|
||||
{
|
||||
char line[80];
|
||||
int x, y;
|
||||
|
||||
x = wherex(); y = wherey();
|
||||
gettext(x, y, COLS - x, y, line);
|
||||
puttext(x + 1, y, COLS - x + 1, y, line);
|
||||
putch(c);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
inch()
|
||||
{
|
||||
return peek(0xb800, (wherex() - 1) + (wherey() - 1) * COLS);
|
||||
}
|
||||
|
||||
int
|
||||
mvinch(int y, int x)
|
||||
{
|
||||
gotoxy(x + 1, y + 1);
|
||||
return inch();
|
||||
}
|
||||
|
||||
|
||||
/*********** Save the patched file ********************/
|
||||
int
|
||||
save(char *fname, PTR start, PTR end, int flags)
|
||||
{
|
||||
int fd;
|
||||
char string[255];
|
||||
char *newstr;
|
||||
off_t written;
|
||||
off_t filesize;
|
||||
unsigned n, to_write;
|
||||
|
||||
if (!fname) {
|
||||
emsg("No file|No current filename");
|
||||
return 0;
|
||||
}
|
||||
if (stat(fname, &buf) == -1) {
|
||||
newstr = "[New file] ";
|
||||
} else {
|
||||
if (S_ISDIR(buf.st_mode)) {
|
||||
sprintf(string, "\"%s\" Is a directory", fname);
|
||||
msg(string);
|
||||
return 0;
|
||||
}
|
||||
newstr = "";
|
||||
}
|
||||
|
||||
if (filemode == PARTIAL) flags = O_RDWR;
|
||||
if ((fd = open(fname, flags, 0666)) < 0) {
|
||||
sysemsg(fname);
|
||||
return 0;
|
||||
}
|
||||
if (filemode == PARTIAL) {
|
||||
if (block_read) {
|
||||
filesize = block_read;
|
||||
sprintf(string, "\"%s\" range %lu-%lu", fname,
|
||||
(unsigned long)block_begin,
|
||||
(unsigned long)(block_begin - 1 + filesize));
|
||||
if (lseek(fd, block_begin, SEEK_SET) < 0) {
|
||||
sysemsg(fname);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
msg("Null range");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
filesize = end - start + 1L;
|
||||
sprintf(string, "\"%s\" %s%lu@bytes", fname, newstr, (long)filesize);
|
||||
}
|
||||
|
||||
written = 0;
|
||||
do {
|
||||
to_write = (filesize - written) > 0xfffe ? 0xfffe : (filesize - written);
|
||||
if ((n = write(fd, start + written, to_write)) == 0xffff) {
|
||||
sysemsg(fname);
|
||||
close(fd);
|
||||
return(0L);
|
||||
}
|
||||
written += (off_t)n;
|
||||
} while (written < filesize);
|
||||
close(fd);
|
||||
edits = 0;
|
||||
msg(string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
off_t
|
||||
load(char *fname)
|
||||
{
|
||||
int fd = -1;
|
||||
char string[MAXCMD];
|
||||
unsigned chunk, n;
|
||||
|
||||
buf.st_size = filesize = 0L;
|
||||
if (fname != NULL) {
|
||||
if (stat(fname, &buf) == -1) {
|
||||
filemode = NEW;
|
||||
} else if (S_ISDIR(buf.st_mode)) {
|
||||
filemode = DIRECTORY;
|
||||
} else if (S_ISREG(buf.st_mode)) {
|
||||
if ((fd = open(fname, O_RDONLY|O_BINARY)) > 0) {
|
||||
filemode = REGULAR;
|
||||
if (access(fname, 2)) {
|
||||
P(P_RO) = TRUE;
|
||||
params[P_RO].flags |= P_CHANGED;
|
||||
}
|
||||
} else {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
filemode = NEW;
|
||||
}
|
||||
if (mem != NULL) farfree(mem);
|
||||
if (block_flag) {
|
||||
memsize = block_size + 1000;
|
||||
} else if (filemode == REGULAR) {
|
||||
memsize = buf.st_size + 100;
|
||||
} else {
|
||||
memsize = 1000;
|
||||
}
|
||||
|
||||
if (farcoreleft() < memsize) {
|
||||
move(maxy, 0);
|
||||
endwin();
|
||||
printf("\n\nOut of memory\n");
|
||||
exit(0);
|
||||
}
|
||||
mem = (char huge *)farmalloc(memsize);
|
||||
|
||||
clear_marks();
|
||||
if (block_flag && (filemode == REGULAR)) {
|
||||
if (lseek(fd, block_begin, SEEK_SET) < 0) {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
} else {
|
||||
chunk = block_size > 0xfffe ? 0xfffe : block_size;
|
||||
do {
|
||||
if ((n = read(fd, mem + filesize, chunk)) == 0xffff) {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
break;
|
||||
}
|
||||
filesize += (off_t)n;
|
||||
} while (filesize < buf.st_size);
|
||||
if ((filesize == 0) {
|
||||
sprintf(string, "\"%s\" No such range: %lu-%lu", fname,
|
||||
(unsigned long)block_begin, (unsigned long)(block_end));
|
||||
} else {
|
||||
sprintf(string, "\"%s\" range %lu-%lu", fname,
|
||||
(unsigned long)block_begin,
|
||||
(unsigned long)(block_begin + filesize - 1));
|
||||
}
|
||||
filemode = PARTIAL;
|
||||
block_read = filesize;
|
||||
msg(string);
|
||||
P(P_OF) = block_begin;
|
||||
params[P_OF].flags |= P_CHANGED;
|
||||
}
|
||||
} else if (filemode == REGULAR) {
|
||||
chunk = buf.st_size > 0xfffe ? 0xfffe : buf.st_size;
|
||||
do {
|
||||
if ((n = read(fd, mem + filesize, chunk)) == 0xffff) {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
break;
|
||||
}
|
||||
filesize += (off_t)n;
|
||||
} while (filesize < buf.st_size);
|
||||
}
|
||||
if (fd > 0) close(fd);
|
||||
if (filemode != REGULAR) {
|
||||
filesize = 0L;
|
||||
}
|
||||
if (fname != NULL) {
|
||||
switch (filemode) {
|
||||
case NEW:
|
||||
sprintf(string, "\"%s\" [New File]", fname);
|
||||
break;
|
||||
case REGULAR:
|
||||
sprintf(string, "\"%s\" %s%lu bytes", fname,
|
||||
P(P_RO) ? "[Read only] " : "", (long)filesize);
|
||||
break;
|
||||
case DIRECTORY:
|
||||
sprintf(string, "\"%s\" Directory", fname);
|
||||
break;
|
||||
}
|
||||
if (filemode != ERROR) msg(string);
|
||||
}
|
||||
pagepos = mem;
|
||||
maxpos = (PTR)(mem + filesize);
|
||||
loc = HEX;
|
||||
x = AnzAdd; y = 0;
|
||||
repaint();
|
||||
return(filesize);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
addfile(char *fname)
|
||||
{
|
||||
int fd;
|
||||
off_t oldsize;
|
||||
unsigned chunk, n;
|
||||
|
||||
if (stat(fname, &buf)) {
|
||||
sysemsg(fname);
|
||||
return 1;
|
||||
}
|
||||
if ((fd = open(fname, O_RDONLY)) == -1) {
|
||||
sysemsg(fname);
|
||||
return 1;
|
||||
}
|
||||
oldsize = filesize;
|
||||
if (enlarge(buf.st_size)) return 1;
|
||||
chunk = buf.st_size > 0xfffe ? 0xfffe : buf.st_size;
|
||||
do {
|
||||
if ((n = read(fd, mem + filesize, chunk)) == 0xffff) {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
return 1;
|
||||
}
|
||||
filesize += (off_t)n;
|
||||
} while (filesize < buf.st_size);
|
||||
maxpos = mem + filesize;
|
||||
close(fd);
|
||||
setpage(mem + oldsize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bvi_init(char *dir)
|
||||
{
|
||||
char *poi;
|
||||
char *initstr;
|
||||
char rcpath[255];
|
||||
|
||||
shell = getenv("COMSPEC");
|
||||
if (shell == NULL || *shell == '\0')
|
||||
shell = "COMMAND.COM";
|
||||
|
||||
strcpy(rcpath, dir);
|
||||
poi = strrchr(rcpath, '\\');
|
||||
*poi = '\0';
|
||||
strcat(rcpath, "\\BVI.RC");
|
||||
|
||||
if ((initstr = getenv("BVIINIT")) != NULL) {
|
||||
docmdline(initstr);
|
||||
}
|
||||
read_rc("BVI.RC");
|
||||
read_rc(rcpath);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
enlarge(off_t add)
|
||||
{
|
||||
PTR newmem;
|
||||
off_t savecur, savepag, savemax, saveundo;
|
||||
|
||||
savecur = curpos - mem;
|
||||
savepag = pagepos - mem;
|
||||
savemax = maxpos - mem;
|
||||
saveundo = undo_start - mem;
|
||||
|
||||
newmem = (PTR)farrealloc(mem, memsize + add);
|
||||
if (newmem == NULL) {
|
||||
emsg("Out of memory");
|
||||
return 1;
|
||||
}
|
||||
mem = newmem;
|
||||
memsize += add;
|
||||
curpos = mem + savecur;
|
||||
pagepos = mem + savepag;
|
||||
maxpos = mem + savemax;
|
||||
undo_start = mem + saveundo;
|
||||
current = curpos + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_shell()
|
||||
{
|
||||
system("");
|
||||
}
|
||||
|
||||
|
||||
off_t
|
||||
alloc_buf(off_t n, char **buffer)
|
||||
{
|
||||
if ((*buffer = (char *)farrealloc(*buffer, n)) == NULL) {
|
||||
emsg("No buffer space available");
|
||||
return 0L;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
d_memmove(PTR dest, PTR src, off_t n)
|
||||
{
|
||||
unsigned len;
|
||||
long chunk;
|
||||
PTR source;
|
||||
PTR destin;
|
||||
|
||||
chunk = n;
|
||||
if (dest < src) {
|
||||
/* copy forward */
|
||||
source = src;
|
||||
destin = dest;
|
||||
while (chunk > 0L) {
|
||||
len = chunk > 0x7ffe ? 0x7ffe : chunk;
|
||||
movmem(source, destin, len);
|
||||
chunk -= len;
|
||||
source += len;
|
||||
destin += len;
|
||||
}
|
||||
} else {
|
||||
/* copy backward */
|
||||
source = src + n;
|
||||
destin = dest + n;
|
||||
while (chunk > 0L) {
|
||||
len = chunk > 0x7ffe ? 0x7ffe : chunk;
|
||||
chunk -= len;
|
||||
source -= len;
|
||||
destin -= len;
|
||||
movmem(source, destin, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
d_memcpy(PTR dest, PTR src, off_t n)
|
||||
{
|
||||
unsigned len;
|
||||
long chunk;
|
||||
PTR source;
|
||||
PTR destin;
|
||||
|
||||
source = src;
|
||||
destin = dest;
|
||||
chunk = n;
|
||||
while (chunk > 0L) {
|
||||
len = chunk > 0x7ffe ? 0x7ffe : chunk;
|
||||
movmem(source, destin, len);
|
||||
chunk -= len;
|
||||
source += len;
|
||||
destin += len;
|
||||
}
|
||||
}
|
897
edit.c
Normal file
897
edit.c
Normal file
|
@ -0,0 +1,897 @@
|
|||
/* edit - the edit commands
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* 1999-04-19 V 1.1.2
|
||||
* 1999-07-02 V 1.2.0 beta
|
||||
* 1999-10-30 V 1.2.0 final
|
||||
* 2000-05-14 V 1.3.0 alpha
|
||||
* 2000-07-15 V 1.3.0 final
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include "bvi.h"
|
||||
#include "set.h"
|
||||
|
||||
extern int precount;
|
||||
|
||||
char contrd[][4] = {"NUL", " ^A", " ^B", " ^C", " ^D", " ^E", " ^F", "BEL",
|
||||
" BS", "TAB", " NL", "HOM", "CLR", " CR", " ^N", " ^O",
|
||||
" ^P", " ^Q", " ^R", " ^S", " ^T", " ^U", " ^V", " ^W",
|
||||
" ^X", " ^Y", " ^Z", "ESC", " FS", " GS", " RS", " US",
|
||||
"DEL" };
|
||||
char contru[][4] = {"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
|
||||
" BS", " HT", " NL", " VT", " NP", " CR", " SO", " SI",
|
||||
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
|
||||
"CAN", " EM", "SUB", "ESC", " FS", " GS", " RS", " US",
|
||||
"DEL" };
|
||||
char tmpbuf[10];
|
||||
char linbuf[256];
|
||||
|
||||
static char getcbuff[BUFFER];
|
||||
static char *getcnext = NULL;
|
||||
|
||||
|
||||
/* mode: ('A') append
|
||||
* ('R') replace one or more different characters
|
||||
* ('r') replace 1 character
|
||||
* ('i') insert characters
|
||||
* ('a') insert after cursor
|
||||
* a precount can be used
|
||||
*
|
||||
* for insert and append we misuse the undo buffer for the inserted
|
||||
* characters (for "." command)
|
||||
*/
|
||||
off_t
|
||||
edit(mode)
|
||||
int mode;
|
||||
{
|
||||
int ch, ch1;
|
||||
size_t len;
|
||||
off_t count = 0L;
|
||||
off_t buffer = BUFFER;
|
||||
off_t psize;
|
||||
|
||||
if (!filesize && mode == 'i') {
|
||||
mode = 'A';
|
||||
}
|
||||
if (mode != 'A' && mode != 'a') {
|
||||
if (current - mem >= filesize) {
|
||||
beep();
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
if (precount < 1) precount = 1;
|
||||
len = strlen(rep_buf);
|
||||
if (mode == 'r' && current + precount > maxpos) {
|
||||
beep();
|
||||
rep_buf[len] = '\0';
|
||||
return 0L;
|
||||
}
|
||||
if (alloc_buf(buffer, &undo_buf) == 0L) {
|
||||
rep_buf[len] = '\0';
|
||||
return 0L;
|
||||
}
|
||||
switch(mode) {
|
||||
case 'A': edits = U_APPEND;
|
||||
break;
|
||||
case 'R': edits = U_EDIT;
|
||||
smsg("REPLACE MODE");
|
||||
break;
|
||||
case 'r': edits = U_EDIT;
|
||||
smsg("REPLACE 1 CHAR");
|
||||
break;
|
||||
case 'a':
|
||||
case 'i': edits = U_INSERT;
|
||||
smsg("INSERT MODE");
|
||||
break;
|
||||
}
|
||||
|
||||
undo_start = current;
|
||||
|
||||
while((ch = vgetc()) != ESC) {
|
||||
ch &= 0xff;
|
||||
rep_buf[len++] = ch;
|
||||
if (ch == '\t') {
|
||||
toggle();
|
||||
setcur();
|
||||
continue;
|
||||
}
|
||||
if (ch == KEY_BACKSPACE || ch == CTRL('H')) {
|
||||
if (count > 0) {
|
||||
len--;
|
||||
count--;
|
||||
if (mode == 'A' || mode == 'a' || mode == 'i') {
|
||||
filesize--;
|
||||
maxpos--;
|
||||
}
|
||||
current--;
|
||||
cur_back();
|
||||
setcur();
|
||||
} else beep();
|
||||
continue;
|
||||
}
|
||||
if (loc == HEX) {
|
||||
if (isxdigit(ch)) {
|
||||
mvaddch(y, x + 1, ' ');
|
||||
mvaddch(y, x, ch);
|
||||
do {
|
||||
ch1 = vgetc() & 0xff;
|
||||
if (ch1 == ESC) {
|
||||
mvaddch(y, x, ' ');
|
||||
current--;
|
||||
cur_back();
|
||||
goto escape;
|
||||
}
|
||||
if (!isxdigit(ch1)) {
|
||||
beep();
|
||||
ch1 = -1;
|
||||
}
|
||||
} while (ch1 == -1);
|
||||
rep_buf[len++] = ch;
|
||||
mvaddch(y, x + 1, ch1);
|
||||
sprintf(tmpbuf, "%c%c", ch, ch1);
|
||||
sscanf(tmpbuf, "%2x", &ch);
|
||||
} else {
|
||||
beep();
|
||||
len--;
|
||||
goto wrong;
|
||||
}
|
||||
} else { /*** ASCII - Bereich ***/
|
||||
if (isprint(ch)) {
|
||||
mvaddch(y, x, ch);
|
||||
} else {
|
||||
beep();
|
||||
goto wrong;
|
||||
}
|
||||
}
|
||||
curpos = current++;
|
||||
if (mode == 'i' || mode == 'a') {
|
||||
memmove(current, curpos, maxpos - curpos);
|
||||
}
|
||||
if (mode == 'A' || mode == 'i' || mode == 'a') {
|
||||
maxpos++;
|
||||
filesize++;
|
||||
/* NEU
|
||||
undo_buf[count++] = ch;
|
||||
*/
|
||||
count++;
|
||||
} else {
|
||||
undo_buf[count++] = *curpos;
|
||||
}
|
||||
if (count == buffer) {
|
||||
buffer += BUFFER;
|
||||
if (alloc_buf(buffer, &undo_buf) == 0L) {
|
||||
rep_buf[len] = '\0';
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
*curpos = (char)ch;
|
||||
cur_forw(0);
|
||||
statpos();
|
||||
if (mode == 'i' || mode == 'a') {
|
||||
repaint();
|
||||
} else {
|
||||
lineout();
|
||||
}
|
||||
setcur();
|
||||
|
||||
if (filesize > memsize - 2L) {
|
||||
if (enlarge(100L)) break;
|
||||
}
|
||||
|
||||
if ((mode != 'A' && mode != 'a') && curpos == maxpos - 1) break;
|
||||
if (mode == 'r') { break; }
|
||||
wrong:
|
||||
continue;
|
||||
}
|
||||
rep_buf[len++] = ESC;
|
||||
rep_buf[len] = '\0';
|
||||
if (!count) goto escape;
|
||||
|
||||
if (precount > 1) {
|
||||
switch (mode) {
|
||||
case 'i':
|
||||
case 'a':
|
||||
case 'A':
|
||||
psize = count * (precount - 1);
|
||||
if (filesize + psize > memsize - 2L) {
|
||||
if (enlarge(psize + 100L)) return count;
|
||||
}
|
||||
if (psize + count > buffer) {
|
||||
if (alloc_buf(psize + count, &undo_buf) == 0L)
|
||||
return count;
|
||||
}
|
||||
|
||||
if (mode == 'i' || mode == 'a') {
|
||||
memmove(current + psize, current, maxpos - curpos);
|
||||
}
|
||||
|
||||
/* NEU
|
||||
undo_pos = undo_buf + count - 1L;
|
||||
*/
|
||||
while (--precount) {
|
||||
/* NEU
|
||||
memcpy(undo_pos + 1L, undo_pos - count + 1L, count);
|
||||
undo_pos += count;
|
||||
*/
|
||||
memcpy(curpos + 1L, curpos - count + 1L, count);
|
||||
curpos += count;
|
||||
}
|
||||
filesize += psize;
|
||||
count += psize;
|
||||
maxpos += psize;
|
||||
undo_count += psize;
|
||||
current = curpos + 1L;
|
||||
setpage(current);
|
||||
repaint();
|
||||
break;
|
||||
case 'R':
|
||||
if (current + count * (precount - 1) > maxpos) break;
|
||||
psize = count;
|
||||
while (--precount) {
|
||||
memcpy(undo_buf + psize, curpos + 1L, count);
|
||||
psize += count;
|
||||
memcpy(curpos + 1L, curpos - count + 1L, count);
|
||||
curpos += count;
|
||||
}
|
||||
count = psize;
|
||||
setpage(++curpos);
|
||||
repaint();
|
||||
break;
|
||||
case 'r':
|
||||
while (--precount) {
|
||||
undo_buf[count++] = *(++curpos);
|
||||
*curpos = (char)ch;
|
||||
cur_forw(0);
|
||||
statpos();
|
||||
lineout();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
cur_back();
|
||||
escape:
|
||||
setcur();
|
||||
smsg("");
|
||||
return(count);
|
||||
}
|
||||
|
||||
|
||||
/* Do the f, F, t ot T command
|
||||
* If flag == 1 save the character in rep_buf
|
||||
* else setpage()
|
||||
*/
|
||||
PTR
|
||||
do_ft(ch, flag)
|
||||
int ch, flag;
|
||||
{
|
||||
static int chi;
|
||||
static int chp = 1;
|
||||
int dir;
|
||||
size_t n;
|
||||
PTR ptr;
|
||||
|
||||
switch (ch) {
|
||||
case 1: beep();
|
||||
return NULL; /* no previous command */
|
||||
case -1: if (chp == 'f' || chp == 't') dir = BACKWARD;
|
||||
else dir = FORWARD;
|
||||
break; /* same again */
|
||||
case 0: if (chp == 'f' || chp == 't') dir = FORWARD;
|
||||
else dir = BACKWARD;
|
||||
break; /* same again */
|
||||
default: chp = ch;
|
||||
if (chp == 'f' || chp == 't') dir = FORWARD;
|
||||
else dir = BACKWARD;
|
||||
chi = vgetc();
|
||||
if (flag) {
|
||||
n = strlen(rep_buf);
|
||||
rep_buf[n++] = chi;
|
||||
rep_buf[n] = '\0';
|
||||
}
|
||||
}
|
||||
ptr = current;
|
||||
do {
|
||||
if (dir == FORWARD) {
|
||||
do {
|
||||
ptr++;
|
||||
if (ptr > maxpos) break;
|
||||
} while (*ptr != chi);
|
||||
if (ptr > maxpos) break;
|
||||
} else {
|
||||
do {
|
||||
ptr--;
|
||||
if (ptr < mem) break;
|
||||
} while (*ptr != chi);
|
||||
if (ptr < mem) break;
|
||||
}
|
||||
} while (--precount > 0);
|
||||
if (*ptr == chi) {
|
||||
if (loc == HEX) toggle();
|
||||
if (chp == 't') ptr--;
|
||||
if (chp == 'T') ptr++;
|
||||
if (!flag) {
|
||||
setpage(ptr);
|
||||
}
|
||||
return(ptr);
|
||||
}
|
||||
beep();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_z(mode)
|
||||
int mode;
|
||||
{
|
||||
switch (mode) {
|
||||
case '.': while (y != maxy / 2) {
|
||||
if (y > maxy / 2) {
|
||||
pagepos += Anzahl;
|
||||
y--;
|
||||
} else {
|
||||
if (pagepos == mem) break;
|
||||
pagepos -= Anzahl;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '-': while (y < maxy - 1) {
|
||||
if (pagepos == mem) break;
|
||||
pagepos -= Anzahl;
|
||||
y++;
|
||||
}
|
||||
break;
|
||||
case '\0':
|
||||
case '\n':
|
||||
case '\r': while (y > 0) {
|
||||
y--;
|
||||
pagepos += Anzahl;
|
||||
}
|
||||
break;
|
||||
default : beep();
|
||||
break;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
scrolldown(lns)
|
||||
int lns;
|
||||
{
|
||||
while (lns--) {
|
||||
if (maxpos >= (pagepos + Anzahl)) pagepos += Anzahl;
|
||||
else { beep(); lns = 0; }
|
||||
repaint();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
scrollup(lns)
|
||||
int lns;
|
||||
{
|
||||
while (lns--) {
|
||||
if (mem <= (PTR)(pagepos - Anzahl)) pagepos -= Anzahl;
|
||||
else { beep(); lns = 0; }
|
||||
repaint();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
xpos()
|
||||
{
|
||||
if (loc == HEX) return((x - AnzAdd) / 3);
|
||||
else return(x - AnzAdd - Anzahl3);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
toggle()
|
||||
{
|
||||
if (loc == HEX) {
|
||||
x = xpos() + AnzAdd + Anzahl3;
|
||||
loc = ASCII;
|
||||
} else {
|
||||
x = xpos() * 3 + AnzAdd;
|
||||
loc = HEX;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
setcur()
|
||||
{
|
||||
move(y, x);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
||||
/************* display current position *************/
|
||||
void
|
||||
statpos()
|
||||
{
|
||||
unsigned char Char1;
|
||||
off_t bytepos;
|
||||
char string[30], str[6];
|
||||
|
||||
if (!P(P_MO)) return;
|
||||
bytepos = current - mem;
|
||||
if (bytepos >= filesize) {
|
||||
mvaddstr(maxy, status, " ");
|
||||
return; }
|
||||
Char1 = *(mem + bytepos);
|
||||
|
||||
if (isprint(Char1)) {
|
||||
sprintf(str, "'%c'", Char1);
|
||||
} else if (Char1 < 32) {
|
||||
if (P(P_US)) strcpy(str, contru[Char1]);
|
||||
else strcpy(str, contrd[Char1]);
|
||||
} else if (Char1 == 127) {
|
||||
if (P(P_US)) strcpy(str, contru[32]);
|
||||
else strcpy(str, contrd[32]);
|
||||
} else strcpy(str, " ");
|
||||
|
||||
sprintf(string, "%08lX \\%03o 0x%02X %3d %3s",
|
||||
(long)(bytepos + P(P_OF)), Char1, Char1, Char1, str);
|
||||
attrset(A_BOLD);
|
||||
mvaddstr(maxy, status, string);
|
||||
attrset(A_NORMAL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
printline(mempos, scpos)
|
||||
PTR mempos;
|
||||
int scpos;
|
||||
{
|
||||
int print_pos;
|
||||
unsigned char Zeichen;
|
||||
|
||||
if (mempos > maxpos) {
|
||||
strcpy(linbuf, "~ ");
|
||||
} else {
|
||||
sprintf(linbuf, addr_form, (long)(mempos - mem + P(P_OF)));
|
||||
*string = '\0';
|
||||
}
|
||||
for (print_pos = 0; print_pos < Anzahl; print_pos++) {
|
||||
if (mempos + print_pos >= maxpos) {
|
||||
sprintf(tmpbuf, " ");
|
||||
Zeichen = ' ';
|
||||
} else {
|
||||
Zeichen = *(mempos + print_pos);
|
||||
sprintf(tmpbuf, "%02X ", Zeichen);
|
||||
}
|
||||
strcat(linbuf, tmpbuf);
|
||||
if (isprint(Zeichen))
|
||||
*(string + print_pos) = Zeichen;
|
||||
else
|
||||
*(string + print_pos) = '.';
|
||||
}
|
||||
*(string + Anzahl) = '\0';
|
||||
strcat(linbuf, string);
|
||||
mvaddstr(scpos, 0, linbuf);
|
||||
}
|
||||
|
||||
|
||||
/* displays a line on screen
|
||||
* at pagepos + line y
|
||||
*/
|
||||
int
|
||||
lineout()
|
||||
{
|
||||
off_t Adresse;
|
||||
|
||||
Adresse = pagepos - mem + y * Anzahl;
|
||||
printline(mem + Adresse, y);
|
||||
move(y, x);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
new_screen()
|
||||
{
|
||||
screen = Anzahl * (maxy - 1);
|
||||
clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
repaint() /***** redraw screen *********************/
|
||||
{
|
||||
int save_y;
|
||||
|
||||
save_y = y;
|
||||
for (y = 0; y < maxy; y++) lineout();
|
||||
y = save_y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******* display an arbitrary address on screen *******/
|
||||
void
|
||||
setpage(addr)
|
||||
PTR addr;
|
||||
{
|
||||
if ((addr >= pagepos) && ((addr - pagepos) < screen)) {
|
||||
y = (addr - pagepos) / Anzahl;
|
||||
if (loc == HEX)
|
||||
x = AnzAdd + ((addr - pagepos) - y * Anzahl) * 3;
|
||||
else
|
||||
x = AnzAdd + Anzahl3 + ((addr - pagepos) - y * Anzahl);
|
||||
} else {
|
||||
pagepos = (((addr - mem) / Anzahl) * Anzahl + mem)
|
||||
- (Anzahl * (maxy / 2));
|
||||
if (pagepos < mem) pagepos = mem;
|
||||
y = (addr - pagepos) / Anzahl;
|
||||
if (loc == HEX)
|
||||
x = AnzAdd + ((addr - pagepos) - y * Anzahl) * 3;
|
||||
else
|
||||
x = AnzAdd + Anzahl3 + ((addr - pagepos) - y * Anzahl);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
cur_forw(check)
|
||||
int check;
|
||||
{
|
||||
if (check) {
|
||||
if (current - mem >= filesize) {
|
||||
beep();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (loc == ASCII) {
|
||||
if (x < AnzAdd - 1 + Anzahl3 + Anzahl) {
|
||||
x++ ;
|
||||
return 0;
|
||||
} else x = AnzAdd + Anzahl3;
|
||||
} else {
|
||||
if (x < 5 + Anzahl3) {
|
||||
x += 3;
|
||||
return 0;
|
||||
} else x = AnzAdd;
|
||||
}
|
||||
statpos();
|
||||
lineout();
|
||||
if (y < maxy - 1) {
|
||||
y++;
|
||||
return 0;
|
||||
} else {
|
||||
if (pagepos < (PTR)(mem + filesize)) {
|
||||
pagepos += Anzahl;
|
||||
repaint();
|
||||
return 0;
|
||||
} else {
|
||||
beep();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
cur_back()
|
||||
{
|
||||
if (loc == ASCII) {
|
||||
if (x > AnzAdd + Anzahl3) {
|
||||
x-- ;
|
||||
return 0;
|
||||
} else {
|
||||
x = AnzAdd - 1 + Anzahl3 + Anzahl;
|
||||
}
|
||||
} else {
|
||||
if (x > AnzAdd + 2) {
|
||||
x -= 3;
|
||||
return 0;
|
||||
} else {
|
||||
if (current == mem) return 0;
|
||||
x = AnzAdd + Anzahl3 - 3;
|
||||
}
|
||||
}
|
||||
statpos();
|
||||
lineout();
|
||||
if (y > 0) {
|
||||
y--;
|
||||
return 0;
|
||||
} else {
|
||||
if (pagepos > mem) {
|
||||
pagepos -= Anzahl;
|
||||
repaint();
|
||||
return 0;
|
||||
} else {
|
||||
beep();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fileinfo(fname)
|
||||
char *fname;
|
||||
{
|
||||
off_t bytepos;
|
||||
char fstatus[64];
|
||||
|
||||
if (fname) {
|
||||
sprintf(string, "\"%s\" ", fname);
|
||||
} else {
|
||||
strcpy(string, "No file ");
|
||||
}
|
||||
if (filemode != NEW && filemode != REGULAR)
|
||||
strcat(string, "[Not edited] ");
|
||||
if (P(P_RO)) strcat(string, "[Read only] ");
|
||||
if (edits) strcat(string, "[Modified] ");
|
||||
if (filesize) {
|
||||
bytepos = (pagepos + y * Anzahl + xpos()) - mem + 1L;
|
||||
sprintf(fstatus, "byte %lu of %lu --%lu%%--", (long)bytepos,
|
||||
(long)filesize, (long)(bytepos * 100L / filesize));
|
||||
strcat(string, fstatus);
|
||||
} else {
|
||||
strcat(string, " 0 bytes");
|
||||
}
|
||||
msg(string);
|
||||
}
|
||||
|
||||
|
||||
/********** END ************/
|
||||
void
|
||||
quit()
|
||||
{
|
||||
move(maxy, 0);
|
||||
endwin();
|
||||
printf("\nbvi version %s %s\n", VERSION, copyright);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
vgetc()
|
||||
{
|
||||
int nextc;
|
||||
|
||||
if (getcnext != NULL) {
|
||||
nextc = *getcnext++;
|
||||
if (*getcnext == '\0') {
|
||||
*getcbuff = '\0';
|
||||
getcnext = NULL;
|
||||
}
|
||||
return(nextc);
|
||||
}
|
||||
return getch();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
stuffin(s)
|
||||
char *s;
|
||||
{
|
||||
if (s == NULL) { /* clear the stuff buffer */
|
||||
getcnext = NULL;
|
||||
return;
|
||||
}
|
||||
if (getcnext == NULL) {
|
||||
strcpy(getcbuff, s);
|
||||
getcnext = getcbuff;
|
||||
} else
|
||||
strcat(getcbuff, s);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_back(n, start)
|
||||
off_t n;
|
||||
PTR start;
|
||||
{
|
||||
if (start - n < mem) {
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
if ((undo_count = alloc_buf(n, &undo_buf)) == 0L)
|
||||
return;
|
||||
yanked = alloc_buf(n, &yank_buf);
|
||||
edits = U_BACK;
|
||||
undo_start = start - n;
|
||||
memcpy(undo_buf, start - undo_count, undo_count);
|
||||
memcpy(yank_buf, start - undo_count, undo_count);
|
||||
memmove(start - undo_count, start, maxpos - start);
|
||||
filesize -= undo_count;
|
||||
maxpos -= undo_count;
|
||||
setpage(start - undo_count);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
do_delete(n, start)
|
||||
off_t n;
|
||||
PTR start;
|
||||
{
|
||||
if (n + start > maxpos) {
|
||||
beep();
|
||||
return 1;
|
||||
}
|
||||
if ((undo_count = alloc_buf(n, &undo_buf)) == 0L)
|
||||
return 1;
|
||||
yanked = alloc_buf(n, &yank_buf);
|
||||
edits = U_DELETE;
|
||||
undo_start = start;
|
||||
memcpy(undo_buf, start, undo_count);
|
||||
memcpy(yank_buf, start, undo_count);
|
||||
memmove(start, start + undo_count, maxpos - (start + undo_count));
|
||||
filesize -= undo_count;
|
||||
maxpos -= undo_count;
|
||||
if (start == maxpos) {
|
||||
start--;
|
||||
cur_back();
|
||||
}
|
||||
setpage(start);
|
||||
repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The :insert, :append and :change command
|
||||
*/
|
||||
void
|
||||
do_ins_chg(start, arg, mode)
|
||||
PTR start;
|
||||
char *arg;
|
||||
int mode;
|
||||
{
|
||||
int base;
|
||||
off_t buffer = BUFFER;
|
||||
off_t count = 0L;
|
||||
size_t len;
|
||||
long val;
|
||||
char *tempbuf = NULL;
|
||||
char *poi, *epoi;
|
||||
|
||||
if ((mode == U_EDIT) && (current - mem >= filesize)) {
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
len = strlen(arg);
|
||||
if (!strncmp("ascii", arg, len) && CMDLNG(5, 1)) {
|
||||
base = 1;
|
||||
} else if (!strncmp("binary", arg, len) && CMDLNG(6, 1)) {
|
||||
base = 2;
|
||||
} else if (!strncmp("octal", arg, len) && CMDLNG(5, 1)) {
|
||||
base = 8;
|
||||
} else if (!strncmp("decimal", arg, len) && CMDLNG(7, 1)) {
|
||||
base = 10;
|
||||
} else if (!strncmp("hexadecimal", arg, len) && CMDLNG(11, 1)) {
|
||||
base = 16;
|
||||
} else {
|
||||
emsg("No such option");
|
||||
return;
|
||||
}
|
||||
addch('\n');
|
||||
if (getcmdstr(cmdstr, 0) == 1) {
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
if (alloc_buf(buffer, &tempbuf) == 0L) return;
|
||||
while(strcmp(cmdstr, ".")) {
|
||||
poi = cmdstr;
|
||||
if (base == 1) { /* ASCII */
|
||||
while (*poi != '\0') {
|
||||
if (*poi == '\\') {
|
||||
switch (*(++poi)) {
|
||||
case 'n': val = '\n'; break;
|
||||
case 'r': val = '\r'; break;
|
||||
case 't': val = '\t'; break;
|
||||
case '0': val = '\0'; break;
|
||||
case '\\': val = '\\'; break;
|
||||
default : val = '\\'; poi--;
|
||||
}
|
||||
poi++;
|
||||
} else {
|
||||
val = *poi++;
|
||||
}
|
||||
*(tempbuf + count++) = val;
|
||||
}
|
||||
} else {
|
||||
while (isspace(cmdstr[strlen(cmdstr) - 1]))
|
||||
cmdstr[strlen(cmdstr) - 1] = '\0';
|
||||
while (*poi != '\0') {
|
||||
val = strtol(poi, &epoi, base);
|
||||
if (val > 255 || val < 0 || poi == epoi) {
|
||||
repaint();
|
||||
emsg("Invalid value");
|
||||
goto mfree;
|
||||
}
|
||||
poi = epoi;
|
||||
*(tempbuf + count++) = val;
|
||||
}
|
||||
}
|
||||
addch('\n');
|
||||
if (getcmdstr(cmdstr, 0) == 1) {
|
||||
repaint();
|
||||
goto mfree;
|
||||
}
|
||||
}
|
||||
if (count == 0) {
|
||||
repaint();
|
||||
goto mfree;
|
||||
}
|
||||
switch (mode) {
|
||||
case U_INSERT:
|
||||
do_put(start, count, tempbuf);
|
||||
break;
|
||||
case U_EDIT:
|
||||
do_over(start, count, tempbuf);
|
||||
break;
|
||||
case U_APPEND:
|
||||
if ((undo_count = alloc_buf(count, &undo_buf)) == 0L) {
|
||||
repaint();
|
||||
goto mfree;
|
||||
}
|
||||
do_append(count, tempbuf);
|
||||
memcpy(undo_buf, tempbuf, count);
|
||||
repaint();
|
||||
break;
|
||||
}
|
||||
mfree:
|
||||
#ifdef __MSDOS__
|
||||
farfree(tempbuf);
|
||||
#else
|
||||
free(tempbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
clear_marks()
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < 26; markbuf[n++] = NULL);
|
||||
undo_count = 0;
|
||||
last_motion = mem;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_mark(mark, addr)
|
||||
int mark;
|
||||
PTR addr;
|
||||
{
|
||||
if (mark < 'a' || mark > 'z' || current >= maxpos)
|
||||
return;
|
||||
markbuf[mark - 'a'] = addr;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
movebyte()
|
||||
{
|
||||
emsg("Command disabled@- use ':set memmove' to enable");
|
||||
}
|
156
html/bmore.html
Normal file
156
html/bmore.html
Normal file
|
@ -0,0 +1,156 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: bmore</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<font color="#ffffff" class="thl">bmore<br></font>
|
||||
<a class="ths" href="bmore_cmd.html">Commands</a><br>
|
||||
<a class="ths" href="bmore_opt.html">Options</a><br>
|
||||
<a class="ths" href="man_bmore.html">man - Page</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">bmore</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
<STRONG>bmore</STRONG> is a filter that displays the contents of a binary
|
||||
file on the terminal, one screenful at a time. It normally pauses after each
|
||||
screenful, and prints <B>--More--</B> at the bottom of the screen.
|
||||
<STRONG>bmore</STRONG> provides a two-line over lap between screens for
|
||||
continuity. If bmore is reading from a file rather than a pipe,
|
||||
the percentage of characters displayed so far is also shown.
|
||||
<P>
|
||||
<STRONG>bmore</STRONG> scrolls up to display one more screen line in
|
||||
response to a RETURN character; it displays another
|
||||
screenful in response to a SPACE character. Other commands are listed below.
|
||||
<P>
|
||||
The screen is divided in three sections or panes: The byte
|
||||
offset (extreme left), the hex pane (middle), and an ascii
|
||||
pane (right) which shows as printable characters those
|
||||
bytes in the hex pane. On an 80 column terminal there
|
||||
will be sixteen hex values and their ASCII values on each
|
||||
screen line. Note that (as one would expect) the first
|
||||
byte has the offset 0 (zero).
|
||||
<P>
|
||||
<center>
|
||||
<TABLE WIDTH="10" CELLSPACING="0" CELLPADDING="0" BORDER="0">
|
||||
<TR><TD BGCOLOR=#ffccff><PRE CLASS="examp">
|
||||
000000
|
||||
00000C
|
||||
000018
|
||||
000024
|
||||
000030
|
||||
00003C
|
||||
000048
|
||||
000054
|
||||
000060
|
||||
*
|
||||
00016C
|
||||
000178
|
||||
000184
|
||||
000190
|
||||
00009C</PRE></TD><TD BGCOLOR=#ccffcc><PRE CLASS="examp">
|
||||
7F 45 4C 46 01 01
|
||||
00 00 00 00 01 00
|
||||
00 00 00 00 00 00
|
||||
00 00 00 00 34 00
|
||||
0C 00 09 00 00 00
|
||||
00 00 00 00 55 89
|
||||
53 C7 45 A4 00 00
|
||||
00 00 00 83 7D 08
|
||||
8C 02 00 00 E9 6F
|
||||
|
||||
00 00 00 00 6A 03
|
||||
45 08 50 E8 FC FF
|
||||
0C 85 D2 75 17 6A
|
||||
E9 43 02 00 00 8D
|
||||
0C 85 D2 75 0D C7</PRE></TD><TD BGCOLOR=#ccffcc><PRE CLASS="examp">
|
||||
01 00 00 00 00 00
|
||||
03 00 01 00 00 00
|
||||
00 00 0C 07 00 00
|
||||
00 00 00 00 28 00
|
||||
00 00 00 00 00 00
|
||||
E5 83 EC 68 57 56
|
||||
00 00 C7 45 A0 01
|
||||
00 75 13 6A 00 E8
|
||||
02 00 00 8D B4 26
|
||||
|
||||
68 90 00 00 00 8B
|
||||
FF FF 89 C2 83 C4
|
||||
01 E8 60 02 00 00
|
||||
74 26 00 8D BC 27
|
||||
45 A0 00 00 00 00</PRE></TD><TD BGCOLOR=#FFCCCC><PRE CLASS="examp">
|
||||
.ELF........
|
||||
............
|
||||
............
|
||||
....4.....(.
|
||||
............
|
||||
....U....hWV
|
||||
S.E......E..
|
||||
....}..u.j..
|
||||
.....o.....&
|
||||
|
||||
....j.h.....
|
||||
E.P.........
|
||||
...u.j..`...
|
||||
.C....t&...'
|
||||
...u..E.....</PRE></TD></TR>
|
||||
<TR BGCOLOR=#FFFFCC><TD COLSPAN=4 CLASS="examp">
|
||||
<font class="inv">--More--(5%) </font>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
<p>
|
||||
Equal lines will only displayed once, a star (*) is the placeholder
|
||||
for one or more lines equal to the line above.
|
||||
</p>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Fri Oct 13 22:30:06 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
116
html/bmore_cmd.html
Normal file
116
html/bmore_cmd.html
Normal file
|
@ -0,0 +1,116 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Commands</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
<font color="#ffffff" class="ths">Commands<br></font>
|
||||
<a class="ths" href="bmore_opt.html">Options</a><br>
|
||||
<a class="ths" href="man_bmore.html">man - Page</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">bmore</font>
|
||||
<br><font class="sub">Commands</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
Most commands optionally preceded by integer argument <I>k</I>. Defaults in brackets.
|
||||
Star (*) indicates argument becomes new default.
|
||||
<P>
|
||||
<TABLE>
|
||||
<TR><TH><FONT COLOR=#888888>SPACE</FONT></TH>
|
||||
<TD>Display next <I>k</I> lines of bytes </TD><TD>current screen size</TD></TR>
|
||||
<TR><TH>z</TH><TD>Display next <I>k</I> lines of bytes </TD>
|
||||
<TD>current screen size*</TD></TR>
|
||||
<TR><TH><FONT COLOR=#888888>RETURN</FONT></TH>
|
||||
<TD>Display next <I>k</I> lines of bytes </TD><TD>1*</TD></TR>
|
||||
<TR><TD ALIGN=CENTER><B>d</B> or <B><FONT COLOR=#888888>CTRL</FONT> D</B></TH>
|
||||
<TD>Scroll <I>k</I> lines </TD><TD>current scroll size, initially 11*</TD></TR>
|
||||
<TR><TD ALIGN=CENTER><B>q</B> or <B>Q</B> or Interrupt</TD>
|
||||
<TD>Exit from bmore</TD></TR>
|
||||
<TR><TH>s</TH>
|
||||
<TD>Skip forward <I>k</I> lines of bytes </TD><TD>1</TD></TR>
|
||||
<TR><TH>f</TH>
|
||||
<TD>Skip forward <I>k</I> screenfuls of bytes </TD><TD>1</TD></TR>
|
||||
<TR><TD ALIGN=CENTER><B>b</B> or <B><FONT COLOR=#888888>CTRL</FONT> B</B></TH>
|
||||
<TD>Skip backwards <I>k</I> screenfuls of bytes </TD><TD>1</TD></TR>
|
||||
<TR><TH>'</TH>
|
||||
<TD>Go to place where previous search started</TD></TR>
|
||||
<TR><TH>=</TH>
|
||||
<TD>Display current byte number</TD></TR>
|
||||
<TR><TH>/<FONT COLOR=#FF0000>regular expr</FONT></TH>
|
||||
<TD>Search for <I>k</I><SUP>th</SUP> occurrence of ascii regular expr </TD><TD>1</TD></TR>
|
||||
<TR><TH>\<FONT COLOR=#FF0000>regular expr</FONT></TH>
|
||||
<TD>Search for <I>k</I><SUP>th</SUP> occurrence of binary regular expr </TD><TD>1</TD></TR>
|
||||
<TR><TH>n</TH>
|
||||
<TD>Search for <I>k</I><SUP>th</SUP> occurrence of last r.e </TD><TD>1</TD></TR>
|
||||
<TR><TD ALIGN=CENTER><B>!<I>cmd</I></B> or <B>:!<I>cmd</I></B></TH>
|
||||
<TD>Execute <I>cmd</I> in a subshell</TD></TR>
|
||||
<TR><TH>v</TH>
|
||||
<TD>Start up <B>bvi</B> at current position</TD></TR>
|
||||
<TR><TH>w</TH>
|
||||
<TD>Start up <B>bvi</B> reading only a screenful of bytes</TD><TD>screen</TD></TR>
|
||||
<TR><TH><FONT COLOR=#888888>CTRL</FONT> L</TH>
|
||||
<TD>Redraw screen</TD></TR>
|
||||
<TR><TH>:n</TH>
|
||||
<TD>Go to <I>k</I><SUP>th</SUP> next file</TD><TD>1</TD></TR>
|
||||
<TR><TH>:p</TH>
|
||||
<TD>Go to <I>k</I><SUP>th</SUP> previous file</TD><TD>1</TD></TR>
|
||||
<TR><TH>:f</TH>
|
||||
<TD>Display current file name and byte position</TD></TR>
|
||||
<TR><TH>.</TH>
|
||||
<TD>Repeat previous command</TD></TR>
|
||||
</TABLE>
|
||||
<P>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Fri Jun 30 22:05:32 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
133
html/bmore_opt.html
Normal file
133
html/bmore_opt.html
Normal file
|
@ -0,0 +1,133 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Command Line Options</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
<a class="ths" href="bmore_cmd.html">Commands</a><br>
|
||||
<font color="#ffffff" class="ths">Options<br></font>
|
||||
<a class="ths" href="man_bmore.html">man - Page</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">bmore</font>
|
||||
<br><font class="sub">Command Line Options</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
<table>
|
||||
<tr><th valign="top">-a</th><td>ASCII mode</td></tr>
|
||||
<tr><th valign="top">-d</th><td>Display error messages rather than ringing the
|
||||
terminal bell if an unrecognized command is used.
|
||||
This is helpful for inexperienced users.
|
||||
</td></tr>
|
||||
<tr><th valign="top">-i</th><td>Ignore case for searching.</td></tr>
|
||||
<tr><th valign="top">+<I>linenumber</i></th>
|
||||
<td>Start up at <I>linenumber</i></td></tr>
|
||||
<tr><th valign="top">+/<font color="#FF0000">ASCII-pattern</font></th>
|
||||
<td>Start up at the line containing the regular expression
|
||||
<font color="#FF0000"><b>ASCII-pattern</b></font></td></tr>
|
||||
<tr><th valign="top">+\<font color="#FF0000">HEX-pattern</font></th>
|
||||
<td>Start up at the line containing the regular expression
|
||||
<font color="#FF0000"><b>HEX-pattern</b></font></td></tr>
|
||||
</table>
|
||||
<p>
|
||||
This is the default display:</p>
|
||||
<center>
|
||||
<table width="10" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td bgcolor=#ccFFff>
|
||||
<pre class="examp">
|
||||
00000000 7F 45 4C 46 01 01 01 00 00 00 00 00 00 00 00 00 .ELF............
|
||||
00000010 01 00 03 00 01 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||
00000020 F4 60 00 00 00 00 00 00 34 00 00 00 00 00 28 00 .`......4.....(.
|
||||
00000030 0F 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||
00000040 55 89 E5 68 04 00 00 00 68 4C 00 00 00 68 00 00 U..h....hL...h..
|
||||
00000050 00 00 E8 FC FF FF FF 6A 01 E8 FC FF FF FF 89 F6 .......j........
|
||||
00000060 55 89 E5 83 EC 14 57 56 53 8B 7D 0C C7 45 FC 00 U.....WVS.}..E..
|
||||
00000070 00 00 00 C7 45 F8 00 00 00 00 C7 45 F4 00 00 00 ....E......E....
|
||||
00000080 00 BE 01 00 00 00 6A 2F 8B 07 50 E8 FC FF FF FF ......j/..P.....
|
||||
00000090 83 C4 08 85 C0 74 09 40 EB 08 8D B6 00 00 00 00 .....t.@........
|
||||
000000A0 8B 07 50 68 04 00 00 00 E8 FC FF FF FF 83 C4 08 ..Ph............
|
||||
000000B0 68 85 00 00 00 68 04 00 00 00 E8 FC FF FF FF 83 h....h..........
|
||||
000000C0 C4 08 39 75 08 0F 8E 35 01 00 00 8B 04 B7 89 45 ..9u...5.......E
|
||||
000000D0 EC 8A 10 80 FA 2B 0F 84 94 00 00 00 80 FA 2D 0F .....+........-.
|
||||
000000E0 85 EB 00 00 00 BB 01 00 00 00 80 78 01 00 0F 84 ...........x....
|
||||
000000F0 D1 00 00 00 8B 4D EC 8A 04 0B 3C 64 74 32 7F 10 .....M....^dt2..</pre>
|
||||
<font class="inv">--More--(5%) </font>
|
||||
</td></tr></table>
|
||||
</center><p>
|
||||
With the <tt><b>-a</b></tt> option the display looks like this:
|
||||
</p>
|
||||
<center>
|
||||
<table width="10" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td bgcolor=#ccFFcc>
|
||||
<pre class="examp">
|
||||
00000000 .ELF....................@...4... .......4. ...(.........4...4...
|
||||
00000040 4...............................................................
|
||||
00000080 .....1...1...............1..............,................4......
|
||||
000000C0 .................................... ... .........../lib/ld-linu
|
||||
00000100 x.so.2..............GNU.................%...8.......4... .......
|
||||
00000140 ........,.......6.......................3...!...........%...1...
|
||||
00000180 ....7..............."...........2...&...+...)...................
|
||||
000001C0 ................................................................
|
||||
00000200 ................................................................
|
||||
00000240 ............................#...........(...................'...
|
||||
00000280 *...$.......-.../.......0.......5...................U...........
|
||||
000002C0 .... .......................g.......(...........................
|
||||
00000300 ............t...-...........5...............o...............$...
|
||||
00000340 ........................$...............4...............D...H...
|
||||
00000380 ....y...T...............d...............t...........1...d.......
|
||||
000003C0 ................................-...................j...........</pre>
|
||||
<font class="inv">--More--(18%) </font>
|
||||
</td></tr></table>
|
||||
</center>
|
||||
<p> </p>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Fri Oct 13 21:38:17 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
11
html/bvi.css
Normal file
11
html/bvi.css
Normal file
|
@ -0,0 +1,11 @@
|
|||
TD {font-family: Helvetica, Arial, sans-serif;}
|
||||
TH {font-family: Helvetica, Arial, sans-serif;}
|
||||
STRONG {color:red;}
|
||||
.thl {font-family: Helvetica, Arial Narrow, sans-serif; font-size: 12pt; font-weight: bold; text-decoration:none;}
|
||||
.ths {font-family: Helvetica, Arial Narrow, sans-serif; font-size: 10pt; text-decoration:none;}
|
||||
.btop {text-decoration:none; color:black;}
|
||||
.examp {font-family: Courier, monospace;}
|
||||
.inv {font-family: Courier, monospace; color: rgb(255,255,255); background-color: rgb(0,0,0);}
|
||||
.head {font-family: Helvetica, Arial, sans-serif; font-size: 22pt; font-weight: bold; text-decoration:none;}
|
||||
.sub {font-family: Helvetica, Arial, sans-serif; font-size: 16pt; font-weight: bold;}
|
||||
.new {font-family: Times, serif; font-weight: bold; font-size: 28pt; color: red;}
|
208
html/colon.html
Normal file
208
html/colon.html
Normal file
|
@ -0,0 +1,208 @@
|
|||
<HTML><HEAD>
|
||||
<TITLE>BVI: Colon (ex) Commands</TITLE>
|
||||
<LINK REL=STYLESHEET TYPE="text/css" HREF="bvi.css">
|
||||
</HEAD><BODY BGCOLOR="#ffffff">
|
||||
<A NAME="top"></A>
|
||||
|
||||
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>
|
||||
<TR><TD WIDTH=99%>
|
||||
<A CLASS=head HREF="overview.html">Command Overview</A>
|
||||
<BR><FONT CLASS=sub>Colon (ex) Commands</FONT>
|
||||
</TD><TD ALIGN=RIGHT VALIGN=BOTTOM WIDTH=116 ROWSPAN=2>
|
||||
<A HREF="index.html">
|
||||
<IMG SRC="gif/bvi_s.gif" ALT="BVI" WIDTH="116" HEIGHT="62" BORDER=0></A>
|
||||
</TD></TR>
|
||||
<TR><TD VALIGN=BOTTOM>
|
||||
<HR NOSHADE>
|
||||
</TD></TR></TABLE>
|
||||
<P>
|
||||
|
||||
<CENTER>
|
||||
[ <A CLASS="thl" HREF="cursor.html">Cursor Movements</A>
|
||||
| <A CLASS="thl" HREF="edit.html">Edit Cmds</A>
|
||||
| <A CLASS="thl" HREF="yank.html">Yank and Put Cmds</A>
|
||||
| <A CLASS="thl" HREF="set.html">Set Options</A>
|
||||
| Colon (ex) Cmds
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
<BLOCKQUOTE>
|
||||
When forming a colon command, the first character, the colon, can be
|
||||
followed by zero, one or two addresses. These addresses are byte
|
||||
addresses, in contrast to vi, which uses line addresses.<BR>
|
||||
The byte addresses can be given in decimal notation or, with a
|
||||
leading zero, in hexadecimal notation. If you have specified an
|
||||
address offset (e.g. <B>:set offset=256</B>), this offset has to be
|
||||
added to the byte addresses.<BR>
|
||||
Without an address, the whole file is affected or the current cursor
|
||||
position is used (depending of the command).
|
||||
<P>
|
||||
<CENTER>
|
||||
<TABLE BORDER=1 CELLPADDING=4>
|
||||
<TR><TH>Address</TH><TH>Corresponding bytes</TH></TR>
|
||||
<TR><TH>.</TH><TD>The current byte</TD></TR>
|
||||
<TR><TH>7</TH><TD>The seventh byte of file (if offset=0)</TD></TR>
|
||||
<TR><TH>.-<I>n</I></TH><TD><I>n</I> bytes before the current byte</TD></TR>
|
||||
<TR><TH>.+<I>n</I></TH><TD><I>n</I> bytes after the current byte</TD></TR>
|
||||
<TR><TH>'<I>x</I></TH><TD>The byte marked with <I>x</I></TD></TR>
|
||||
<TR><TH>^</TH><TD>The first byte in file</TD></TR>
|
||||
<TR><TH>$</TH><TD>The last byte</TD></TR>
|
||||
<TR><TH>''</TH><TD>The previous current byte</TD></TR>
|
||||
<TR><TH>/pat/</TH><TD>The first byte that matches <I>pat</I></TD></TR>
|
||||
<TR><TH>#12 A4 6F#</TH><TD>The first byte that matches hex pattern</TD></TR>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<TABLE WIDTH=100%>
|
||||
<TR BGCOLOR=#CCCCCC><TH WIDTH=20%>Command</TH><TH WIDTH=40%>BVI</TH><TH WIDTH=40%>VI</TH></TR>
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>File<BR>Commands</TD><TD BGCOLOR=#CCFFCC COLSPAN=2>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD><B>:w</B><BR>
|
||||
<B>:w</B> %.new<BR>
|
||||
<B>:w</B> filename<BR>
|
||||
<B>:w>></B> existingfile<BR>
|
||||
<B>:w!</B> file<BR>
|
||||
<B>:e</B> newfile<BR>
|
||||
<B>:e!</B><BR>
|
||||
<B>:f</B><BR>
|
||||
<B>:f</B> newname<BR>
|
||||
</TD>
|
||||
<TD>Write to the current file<BR>
|
||||
Write to current.new<BR>
|
||||
Write to filename<BR>
|
||||
Append to existing file<BR>
|
||||
Overwrite existing file<BR>
|
||||
Terminate session and edit <I>newfile</I><BR>
|
||||
Reload the current file<BR>
|
||||
Prints current filename and some additional info<BR>
|
||||
Changes the current filename to <I>newname</I>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER ROWSPAN=2>Substitute<BR>Commands</TD>
|
||||
<TD BGCOLOR=#CCFFCC COLSPAN=2>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD><B>:s/pattern/replace/</B><BR>
|
||||
<B>:s/pattern/replace/g</B><BR>
|
||||
<B>:s/pattern/replace/gc</B></TD>
|
||||
<TD>Search for pattern and replace it once<BR>
|
||||
Search for pattern and replace it global<BR>
|
||||
Search for pattern and replace it global conditional (ask)
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
<TR><TD>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD><B>:s\80 af\ff ff\</B></TD>
|
||||
<TD>Binary search and replace
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
<TD BGCOLOR=#FFCCCC>Not available</TD></TR>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Edit<BR>Commands</TD>
|
||||
<TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD VALIGN=TOP><B>:a</B> <I>m</I><BR>
|
||||
<B>:c</B> <I>m</I> <BR>
|
||||
<B>:i</B> <I>m</I></B></TD>
|
||||
<TD>append<BR>
|
||||
change<BR>
|
||||
insert
|
||||
bytes, where <I>m</I> is a(scii), b(inary), d(ecimal), h(exadecimal)
|
||||
or o(ctal). You can type in several (screen) lines of bytes, a line
|
||||
with only a '<B>.</B>' in it terminates the command.
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFCCCC>
|
||||
Usually not available in vi but in ex (without the <I>m</I> - modifier).
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Logical<BR>Operations</TD>
|
||||
<TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD><B>:and</B> <I>n</I><BR>
|
||||
<B>:or</B> <I>n</I><BR>
|
||||
<B>:xor</B> <I>n</I><BR>
|
||||
<B>:neg<BR>
|
||||
:not<BR>
|
||||
:sl</B> <I>i</I><BR>
|
||||
<B>:sr</B> <I>i</I><BR>
|
||||
<B>:rr</B> <I>i</I><BR>
|
||||
<B>:rl</B> <I>i</I></TD>
|
||||
<TD>and <I>n</I><BR>
|
||||
or <I>n</I><BR>
|
||||
exclusive or <I>n</I><BR>
|
||||
negate<BR>
|
||||
invert<BR>
|
||||
shift left <I>i</I> bits<BR>
|
||||
shift right <I>i</I> bits<BR>
|
||||
rotate left <I>i</I> bits<BR>
|
||||
rotate right <I>i</I> bits
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFCCCC>
|
||||
Not available.
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER ROWSPAN=2>Miscellaneous</TD>
|
||||
<TD BGCOLOR=#CCFFCC COLSPAN=2>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD>
|
||||
<B>:g</B>/<I>pat</I>/p<BR>
|
||||
<B>:n<BR>
|
||||
:q<BR>
|
||||
:rew<BR>
|
||||
:sh<BR>
|
||||
:so</B> file<BR>
|
||||
<B>:ve<BR>
|
||||
:x<BR>
|
||||
:!</B> <I>command</I><BR>
|
||||
</TD><TD>
|
||||
Global search for pattern <I>pat</I><BR>
|
||||
Next file to edit<BR>
|
||||
Exit session without saving the file<BR>
|
||||
Rewind to first file<BR>
|
||||
spawn a new shell<BR>
|
||||
Read and execute a file with colon commands<BR>
|
||||
Version of the editor<BR>
|
||||
Exit session, save the file if changed<BR>
|
||||
execute a system <I>command</I><BR>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#FFCCCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD>Currently not available</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD>
|
||||
<B>:map</B><BR>
|
||||
<B>:unm</B>(ap)<BR>
|
||||
<B>:ab</B>(breviate)<BR>
|
||||
<B>:una</B>(bbreviate)<BR>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
<P>
|
||||
<CENTER>
|
||||
[ <A CLASS="thl" HREF="cursor.html">Cursor Movements</A>
|
||||
| <A CLASS="thl" HREF="edit.html">Edit Cmds</A>
|
||||
| <A CLASS="thl" HREF="yank.html">Yank and Put Cmds</A>
|
||||
| <A CLASS="thl" HREF="set.html">Set Options</A>
|
||||
| Colon (ex) Cmds
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
<FONT SIZE=-1>
|
||||
<A CLASS="btop" HREF="#top"><IMG BORDER=0 WIDTH=16 HEIGHT=7 SRC="gif/up.gif"
|
||||
ALT="Back to the top">Back to the top</A>
|
||||
</FONT>
|
||||
<HR NOSHADE>
|
||||
<I>Last update: October 30<SUP>th</SUP> 1999 by Gerhard Bürgmann</I>
|
||||
|
||||
|
||||
</BODY></HTML>
|
116
html/cursor.html
Normal file
116
html/cursor.html
Normal file
|
@ -0,0 +1,116 @@
|
|||
<HTML><HEAD>
|
||||
<TITLE>BVI: Cursor Movements</TITLE>
|
||||
<LINK REL=STYLESHEET TYPE="text/css" HREF="bvi.css">
|
||||
</HEAD><BODY BGCOLOR="#ffffff">
|
||||
<A NAME="top"></A>
|
||||
|
||||
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>
|
||||
<TR><TD WIDTH=99%>
|
||||
<A CLASS=head HREF="overview.html">Command Overview</A>
|
||||
<BR><FONT CLASS=sub>Cursor Movements</FONT>
|
||||
</TD><TD ALIGN=RIGHT VALIGN=BOTTOM WIDTH=116 ROWSPAN=2>
|
||||
<A HREF="index.html">
|
||||
<IMG SRC="gif/bvi_s.gif" ALT="BVI" WIDTH="116" HEIGHT="62" BORDER=0></A>
|
||||
</TD></TR>
|
||||
<TR><TD VALIGN=BOTTOM>
|
||||
<HR NOSHADE>
|
||||
</TD></TR></TABLE>
|
||||
<P>
|
||||
<CENTER>
|
||||
[ Cursor Movements
|
||||
| <A CLASS="thl" HREF="edit.html">Edit Cmds</A>
|
||||
| <A CLASS="thl" HREF="yank.html">Yank and Put Cmds</A>
|
||||
| <A CLASS="thl" HREF="set.html">Set Options</A>
|
||||
| <A CLASS="thl" HREF="colon.html">Colon (ex) Cmds</A>
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
<TABLE WIDTH=100%>
|
||||
<TR BGCOLOR=#CCCCCC><TH WIDTH=20%>Command</TH><TH WIDTH=40%>BVI</TH><TH WIDTH=40%>VI</TH></TR>
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Cursor<BR>movements</TD><TD BGCOLOR=#CCFFCC COLSPAN=2>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>h, <FONT COLOR=#888888>ARROW_LEFT</FONT></TH>
|
||||
<TD>move cursor one character to the left</TD></TR>
|
||||
<TR><TH>j, +, ^N, ^J, <FONT COLOR=#888888>ARROW_DOWN</FONT>,
|
||||
<FONT COLOR=#888888>RETURN</FONT>
|
||||
</TH><TD>move cursor down one line</TD></TR>
|
||||
<TR><TH>k, -, <FONT COLOR=#888888>ARROW_UP</FONT></TH>
|
||||
<TD>move cursor up one line</TD></TR>
|
||||
<TR><TH>l, <FONT COLOR=#888888>ARROW_RIGHT</FONT>,
|
||||
<FONT COLOR=#888888>SPACE</FONT>
|
||||
</TH><TD>move cursor one character to the right</TD></TR>
|
||||
<TR><TH>H</TH><TD>move cursor to home position, upper left corner of screen</TD></TR>
|
||||
<TR><TH>M</TH><TD>move cursor to the begin of the middle line of the screen</TD></TR>
|
||||
<TR><TH>L</TH><TD>move cursor to the begin of the last line of the screen</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Move to<BR>begin<BR>and end of<BR>(screen) line</TD>
|
||||
<TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>^</TH><TD>move cursor to the first byte of Hex section</TD></TR>
|
||||
<TR><TH>$</TH><TD>move cursor to the last byte of Ascii section</TD></TR>
|
||||
<TR><TH><FONT COLOR=#888888>TAB</FONT></TH><TD>toggle cursor between the same byte in Hex and Ascii section</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> ^ </TH>
|
||||
<TD>move cursor to the first nonblank character of line</TD></TR>
|
||||
<TR><TH>$</TH><TD>move cursor to end of line</TD></TR>
|
||||
<TR><TH>0</TH><TD>move cursor to the real begin of line</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Move<BR>by<BR>words</TD>
|
||||
<TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> w </TH>
|
||||
<TD>forward to next string delimited with a nonprinting char</TD></TR>
|
||||
<TR><TH>b</TH>
|
||||
<TD>back to previous string delimited with a nonprinting char</TD></TR>
|
||||
<TR><TH>e</TH>
|
||||
<TD>end of current word </TD></TR>
|
||||
<TR><TH>W</TH>
|
||||
<TD>forward to next string delimited with a \0 or \n</TD></TR>
|
||||
<TR><TH>B</TH>
|
||||
<TD>back to previous string delimited with a nonprinting char</TD></TR>
|
||||
<TR><TH>E</TH>
|
||||
<TD>end of a blank-delimited word</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> w </TH>
|
||||
<TD>move cursor forward to begin of next word</TD></TR>
|
||||
<TR><TH>e</TH>
|
||||
<TD>move cursor to end of current word</TD></TR>
|
||||
<TR><TH>b</TH>
|
||||
<TD>move cursor back to begin of current or previous word</TD></TR>
|
||||
<TR><TH>W</TH>
|
||||
<TD>move cursor forward to begin of next word, ignoring punctuation</TD>
|
||||
</TR>
|
||||
<TR><TH>B</TH>
|
||||
<TD>move cursor back to begin of last word, ignoring punctuation</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
</TABLE>
|
||||
<P>
|
||||
<CENTER>
|
||||
[ Cursor Movements
|
||||
| <A CLASS="thl" HREF="edit.html">Edit Cmds</A>
|
||||
| <A CLASS="thl" HREF="yank.html">Yank and Put Cmds</A>
|
||||
| <A CLASS="thl" HREF="set.html">Set Options</A>
|
||||
| <A CLASS="thl" HREF="colon.html">Colon (ex) Cmds</A>
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
<FONT SIZE=-1>
|
||||
<A CLASS="btop" HREF="#top"><IMG BORDER=0 WIDTH=16 HEIGHT=7 SRC="gif/up.gif"
|
||||
ALT="Back to the top">Back to the top</A>
|
||||
</FONT>
|
||||
<HR NOSHADE>
|
||||
<I>Last update: October 30<SUP>th</SUP> 1999 by Gerhard Bürgmann</I>
|
||||
|
||||
|
||||
</BODY></HTML>
|
98
html/download.html
Normal file
98
html/download.html
Normal file
|
@ -0,0 +1,98 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Download Page</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<font color="#ffffff" class="thl">Download<br></font>
|
||||
<a class="ths" href="new130.html">New in 1.3.0</a><br>
|
||||
<a class="ths" href="new120.html">New in 1.2.0</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Download Page</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
NOTE: All packages are compressed with the GNU gzip program. You
|
||||
can download it from <A HREF="ftp://ftp.gnu.org/gnu/gzip/">ftp://ftp.gnu.org/gnu/gzip/</A>.
|
||||
<P>
|
||||
Current stable release of bvi is <B>1.3.0</B>
|
||||
(Check out what's <A HREF="new130.html">new</A>):
|
||||
<P>
|
||||
<H3>Sources</H3>
|
||||
<UL>
|
||||
<LI><A HREF="http://bvi.linuxave.net/download/bvi-1.3.0.src.tar.gz">bvi-1.3.0.src.tar.gz</A>
|
||||
(147284 bytes)
|
||||
<LI><A HREF="http://bvi.linuxave.net/download/bvi-1.3.0.lsm">bvi-1.3.0.lsm</A>
|
||||
(645 bytes)<P>
|
||||
<LI><A HREF="http://bvi.linuxave.net/download/bvi-1.1.1.src.tar.gz">bvi-1.1.1.src.tar.gz</A>
|
||||
(46168 bytes)
|
||||
</UL>
|
||||
<H3>Executables</H3>
|
||||
<UL>
|
||||
<LI>Linux: <A HREF="http://bvi.linuxave.net/download/bvi-1.3.0-linux_static_elf.gz">bvi-1.3.0-linux_static_elf.gz</A>
|
||||
(109917 bytes)
|
||||
<LI>SunOS 4.1.3_U1: <A HREF="http://bvi.linuxave.net/download/bvi-1.3.0-sun4.gz">bvi-1.3.0-sun4.gz</A>
|
||||
(59357 bytes)
|
||||
<LI>Solaris 2.6: <A HREF="http://bvi.linuxave.net/download/bvi-1.3.0-solaris.gz">bvi-1.3.0-solaris.gz</A>
|
||||
(61368 bytes)
|
||||
<LI>AIX 4.1: <A HREF="download/bvi-1.2.0-aix.gz">bvi-1.2.0-aix.gz</A>
|
||||
(29095 bytes)
|
||||
<LI>IRIX 6.5.5: <A HREF="http://bvi.linuxave.net/download/bvi-1.2.0-irix.gz">bvi-1.2.0-irix.gz</A>
|
||||
(33888 bytes)
|
||||
<LI>HP-UX B.10.20: <A HREF="http://bvi.linuxave.net/download/bvi-1.2.0-hpux.gz">bvi-1.2.0-hpux.gz</A>
|
||||
(36175 bytes)
|
||||
<LI>MSDOS: <A HREF="http://bvi.linuxave.net/download/bvi120.zip">bvi120.zip</A>
|
||||
(43233 bytes)<P>
|
||||
<LI>MSDOS: <A HREF="http://bvi.linuxave.net/download/bvi110.zip">bvi110.zip</A>
|
||||
(44690 bytes)<P>
|
||||
</UL>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: October 23<sup>rd</sup> 22:36:45 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
194
html/edit.html
Normal file
194
html/edit.html
Normal file
|
@ -0,0 +1,194 @@
|
|||
<HTML><HEAD>
|
||||
<TITLE>BVI: Edit Commands</TITLE>
|
||||
<LINK REL=STYLESHEET TYPE="text/css" HREF="bvi.css">
|
||||
</HEAD><BODY BGCOLOR="#ffffff">
|
||||
<A NAME="top"></A>
|
||||
|
||||
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>
|
||||
<TR><TD WIDTH=99%>
|
||||
<A CLASS=head HREF="overview.html">Command Overview</A>
|
||||
<BR><FONT CLASS=sub>Edit Movements</FONT>
|
||||
</TD><TD ALIGN=RIGHT VALIGN=BOTTOM WIDTH=116 ROWSPAN=2>
|
||||
<A HREF="index.html">
|
||||
<IMG SRC="gif/bvi_s.gif" ALT="BVI" WIDTH="116" HEIGHT="62" BORDER=0></A>
|
||||
</TD></TR>
|
||||
<TR><TD VALIGN=BOTTOM>
|
||||
<HR NOSHADE>
|
||||
</TD></TR></TABLE>
|
||||
<P>
|
||||
|
||||
<CENTER>
|
||||
[ <A CLASS="thl" HREF="cursor.html">Cursor Movements</A>
|
||||
| Edit Cmds
|
||||
| <A CLASS="thl" HREF="yank.html">Yank and Put Cmds</A>
|
||||
| <A CLASS="thl" HREF="set.html">Set Options</A>
|
||||
| <A CLASS="thl" HREF="colon.html">Colon (ex) Cmds</A>
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
If you would like to use the insert and delete commands, you have to
|
||||
enable them with the <B>:set memmove</B> option. These commands are
|
||||
locked per default, because you must not move bytes to a different
|
||||
address for many types of binary files (e.g. executables, database files,
|
||||
etc.). If you usually edit files where bytes can be moved, you can add
|
||||
the <B>:set memmove</B> directive to your <B><TT>.bvirc</TT></B> file.
|
||||
<P>
|
||||
<TABLE WIDTH=100%>
|
||||
<TR BGCOLOR=#CCCCCC><TH WIDTH=20%>Command</TH><TH WIDTH=40%>BVI</TH><TH WIDTH=40%>VI</TH></TR>
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Replace<BR>bytes</TD><TD BGCOLOR=#CCFFCC COLSPAN=2>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> r </TH>
|
||||
<TD>replace a single byte, no ESC needed</TD></TR>
|
||||
<TR><TH>R</TH>
|
||||
<TD>replace multiple bytes until you type ESC</TD></TR>
|
||||
<TR><TH>~</TH>
|
||||
<TD>toggle between uppercase and lowercase of a byte</TD></TR>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Append<BR>bytes</TD>
|
||||
<TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> A </TH><TD>append bytes at end of file</TD></TR>
|
||||
<TR><TH>D</TH><TD>delete bytes to end of file</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> A </TH><TD>append characters at end of line</TD></TR>
|
||||
<TR><TH>D</TH><TD>delete characters to end of line</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER ROWSPAN=3>Insert<BR>bytes</TD>
|
||||
<TD COLSPAN=2 BGCOLOR=#CCFFCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> i </TH>
|
||||
<TD>insert byte in front of cursor position</TD></TR>
|
||||
<TR><TH>a</TH>
|
||||
<TD>insert byte after cursor position</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> I </TH><TD>insert byte at begin of file</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> I </TH><TD>insert characters at begin of line</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#FFCCCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD ROWSPAN=2>not available</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>o</TH><TD>insert new line below current line</TD></TR>
|
||||
<TR><TH>O</TH><TD>insert new line above current line</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER ROWSPAN=4>Delete<BR>bytes</TD>
|
||||
<TD COLSPAN=2 BGCOLOR=#CCFFCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> x </TH>
|
||||
<TD>delete byte at of cursor position</TD></TR>
|
||||
<TR><TH>X</TH><TD>delete byte in front of cursor position</TD></TR>
|
||||
<TR><TH>d<FONT COLOR=#888888>SPACE</FONT></TH><TD>delete byte at cursor position</TD></TR>
|
||||
<TR><TH>df<FONT COLOR=#FF0000>C</FONT></TH>
|
||||
<TD>delete from current position to next character <FONT COLOR=#FF0000>C</FONT></TD></TR>
|
||||
<TR><TH>d/<FONT COLOR=#FF0000>xyz</FONT></TH>
|
||||
<TD>delete from current position to first occurance of matching pattern
|
||||
<FONT COLOR=#FF0000>xyz</FONT>
|
||||
</TD></TR>
|
||||
<TR><TH>d?<FONT COLOR=#FF0000>xyz</FONT></TH>
|
||||
<TD>delete from current position to first occurance of matching pattern
|
||||
<FONT COLOR=#FF0000>xyz</FONT> in reverse direction
|
||||
</TD></TR>
|
||||
<TR><TH>d'<FONT COLOR=#FF0000>a</FONT></TH><TD>delete from current position to mark <FONT COLOR=#FF0000>a</FONT></TD></TR>
|
||||
<TR><TH>d<FONT COLOR=#FF0000>n</FONT>G</TH><TD>delete from current position to byte with (decimal) address <FONT COLOR=#FF0000>n</FONT></TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#FFCCCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD ROWSPAN=2>not available, because there are no lines, sentences,
|
||||
paragraphs or sections in a binary file</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>dd </TH><TD>delete line</TD></TR>
|
||||
<TR><TH>d)</TH><TD>delete from cursor position through first
|
||||
following end of sentence</TD></TR>
|
||||
<TR><TH>d}</TH><TD>delete from cursor position through first
|
||||
following end of paragraph</TD></TR>
|
||||
<TR><TH>d]</TH><TD>delete from cursor position through first
|
||||
following end of section</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>d\<FONT COLOR=#FF0000>6a 56 ff</FONT> </TH>
|
||||
<TD>delete from cursor position to first occurance of hex pattern
|
||||
<FONT COLOR=#FF0000>6a 56 ff</FONT></TD></TR>
|
||||
<TR><TH>d#<FONT COLOR=#FF0000>6a 56 ff</FONT> </TH>
|
||||
<TD>delete from cursor position to first occurance of hex pattern
|
||||
<FONT COLOR=#FF0000>6a 56 ff</FONT> in reverse direction</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFCCCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD ROWSPAN=2>not available</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>D</TH><TD ROWSPAN=2>delete from current position to EOF</TD></TR>
|
||||
<TR><TH> d$ </TH></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>D</TH><TD ROWSPAN=2>delete from current position to end of line</TD></TR>
|
||||
<TR><TH> d$ </TH></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER ROWSPAN=2>Undo<BR>edits</TD>
|
||||
<TD COLSPAN=2 BGCOLOR=#CCFFCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> u </TH>
|
||||
<TD>Undo the most recent change</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#FFCCCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD ROWSPAN=2>not available</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> U </TH><TD>Undo all of the changes made to the current line</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
</TABLE>
|
||||
<P>
|
||||
Note that most of the commands can be used with a decimal repeat count in front
|
||||
of the command!
|
||||
<P>
|
||||
<CENTER>
|
||||
[ <A CLASS="thl" HREF="cursor.html">Cursor Movements</A>
|
||||
| Edit Cmds
|
||||
| <A CLASS="thl" HREF="yank.html">Yank and Put Cmds</A>
|
||||
| <A CLASS="thl" HREF="set.html">Set Options</A>
|
||||
| <A CLASS="thl" HREF="colon.html">Colon (ex) Cmds</A>
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
<FONT SIZE=-1>
|
||||
<A CLASS="btop" HREF="#top"><IMG BORDER=0 WIDTH=16 HEIGHT=7 SRC="gif/up.gif"
|
||||
ALT="Back to the top">Back to the top</A>
|
||||
</FONT>
|
||||
<HR NOSHADE>
|
||||
<I>Last update: September 30<SUP>th</SUP> 1999 by Gerhard Bürgmann</I>
|
||||
|
||||
|
||||
</BODY></HTML>
|
214
html/german.html
Normal file
214
html/german.html
Normal file
|
@ -0,0 +1,214 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Deutsche Beschreibung</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<font color="#ffffff" class="thl">Deutsche Beschreibung<br></font>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Deutsche Beschreibung</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
Der BVI (Binary-VI) ist ein Editor für Binärfiles. Seine Kommandos sind
|
||||
weitgehend an den Standard UNIX Editor VI(1) angelehnt. Der Bildschirm
|
||||
ist in einen hexadezimalen und einen ASCII-Bereich geteilt. Einige zusätzliche
|
||||
Kommandos wurden zugefügt, einige Kommandos adaptiert und einige Kommandos,
|
||||
die bei Binärfiles keinen Sinn machen, wurden weggelassen. Für eine
|
||||
Gesamtübersicht siehe Manual Page BVI(1).
|
||||
|
||||
<H2>Zusätzliche Kommandos</H2>
|
||||
|
||||
Eine wichtige Funktion für binäre Files ist das Suchen nach Hexcodes.
|
||||
Dafür gibt es analog zum '/' und '?' - Kommando zusätzlich das '\' und
|
||||
das '#' - Kommando.<BR>
|
||||
|
||||
Beispiel:<BR>
|
||||
\1e f4 56 - Sucht die angegebene Bytefolge in vorwärts-Richtung<BR>
|
||||
#34 5a a4 - Sucht Bytefolge rückwärts.
|
||||
<P>
|
||||
Die normalen Textsuchkommandos sind auch vorhanden, wobei zusätzlich ein
|
||||
Return, Linefeed oder NULL im Suchstring aufscheinen darf (\n \r oder \0).
|
||||
<P>
|
||||
Die Kommandos w, W, b, B (nächstes oder vorhergehendes Wort) wurden insoweit
|
||||
abgeändert, daß sie eher dem STRINGS(1) - Kommando entsprechen, also in
|
||||
einem Binärfile Textstrings suchen. Dabei sucht W und B nach Strings, die
|
||||
mit einem \0 oder \n enden, w und b sucht nach Strings, die mit einem
|
||||
beliebigen, nicht druckbaren Zeichen enden. Die Stringlänge beträgt 4 Zeichen,
|
||||
wobei mit ":set wordlength=x" die Stringlänge auf x Zeichen eingestellt werden
|
||||
kann.
|
||||
<P>
|
||||
Der Bildschirm ist in einen HEX und einen ASCII-Bereich aufgeteilt, wobei
|
||||
jederzeit mit der TAB - Taste von einem Bereich in den anderen gewechselt
|
||||
werden kann (auch im Eingabemodus). Es kann also bei der Eingabe zwischen
|
||||
normalen ASCII-Zeichen und Hex-Eingabe hin- und hergesprungen werden.
|
||||
<P>
|
||||
|
||||
Am unteren Bildrand befindet sich eine Statusanzeige, welche die Adresse des
|
||||
Bytes, auf welchem der Cursor momentan steht, anzeigt. Außerdem wird das Byte
|
||||
in oktaler, hexadezimaler, dezimaler und ASCII-Repräsentation anzeigt. Die
|
||||
ASCII-Anzeige kann von DOS-Style (27 entspricht ^Z) auf UNIX-Style entsprechend
|
||||
Manual Page ASCII(7) umgeschaltet werden (27 entspricht SUB).
|
||||
Kommando ist ":set unixstyle". Die Statusanzeige kann mit ":set noshowmode"
|
||||
ausgeschaltet werden.
|
||||
|
||||
<H2>Regular Expressions</H2>
|
||||
|
||||
Für die Suchkommandos sowohl für Text als auch Hex sind Regular Expressions
|
||||
zulässig, wobei es die Zeichen ^ und $ für Zeilenanfang und Zeilenende nicht
|
||||
gibt. Die Kombination .* ist unzulässig, da sie sich auf jeden Fall auf das
|
||||
Ende des Files beziehen würde.
|
||||
|
||||
<H2>Zeilen</H2>
|
||||
|
||||
Da es in binären Files keine Zeilen gibt (die Darstellung der einzelnen
|
||||
Zeilen am Bildschirm hat keinen Bezug zum File) gibt es keinerlei
|
||||
zeilenorientierte Kommandos (dd, o, O, yy). Ein Kommando
|
||||
wie :s/XXX/UUU/g ändert somit das gesamte File. Zu beachten ist auch, daß
|
||||
:s/XX/UUUU/ nicht die beiden X durch vier U ersetzt, sondern die beiden den
|
||||
X folgenden Zeichen auch durch U überschrieben werden.
|
||||
|
||||
<H2>Editierkommandos</H2>
|
||||
|
||||
Da binäre Files häufig ausführbare Programme oder Datenbankfiles sind,
|
||||
bei denen Bytes nicht einfach an eine andere Adresse verschoben werden
|
||||
dürfen, sind Einfüge- und Löschkommandos (z.B. a, i, x)
|
||||
deaktiviert. Mit dem Kommando <B>:set memmove</B> können sie
|
||||
aktiviert werden.
|
||||
<P>
|
||||
Die Kommandos <B>:a</B> (append), <B>:c</B> (change) und <B>:i</B> (insert)
|
||||
können benutzt werden, um ein oder mehrere Bytes in ASCII, binärer,
|
||||
dezimaler, hexadezimaler oder oktaler Schreibweise einzugeben
|
||||
(a, b, d, h oder o). Es
|
||||
können mehrere (Bildschirm) Zeilen eingegeben werden. Das Kommando
|
||||
wird beendet, sobald eine Zeile, die nur aus einem Punkt besteht,
|
||||
eingegeben wird.
|
||||
<P>
|
||||
Beispiel:
|
||||
<BLOCKQUOTE>
|
||||
<PRE>
|
||||
:i b
|
||||
1 1001 010101 1111
|
||||
11111 1010 1 0 1
|
||||
.
|
||||
</PRE>
|
||||
</BLOCKQUOTE>
|
||||
Zu beachten ist, daß kein Einzelwert den maximalen Byte-Wert (255)
|
||||
überschreiten darf, da sonst die Eingabe abgebrochen wird. Das
|
||||
Drücken der RETURN - Taste führt zu keinem "RETURN" - Zeichen in
|
||||
der Datei, im ASCII - Modus können allerdings die Sonderzeichen
|
||||
\n, \r, \t und \0 benutzt werden.
|
||||
|
||||
<H2>Yank und Put</H2>
|
||||
|
||||
Auch hier gilt eine etwas geänderte Funktion. Das <B>y</B> (yank) -
|
||||
Kommando ist allerdings ab Version 1.2.0 dem Vi angenähert:<BR>
|
||||
<TABLE>
|
||||
<TR><TD>5ySPACE</TD><TD>kopiert 5 Zeichen in den Yank-Buffer</TD></TR>
|
||||
<TR><TD>o</TD><TD>überschreibt an Cursor - Position die folgenden Zeichen
|
||||
mit dem Inhalt des Yank- oder Delete - Puffers</TD></TR>
|
||||
<TR><TD>p</TD><TD>fügt an der Cursor - Position den Inhalt des Yank-
|
||||
oder Delete - Puffers ein.</TD></TR>
|
||||
<TR><TD>P</TD><TD>fügt den Inhalt des Yank- oder Delete - Puffers am Dateiendes
|
||||
an.</TD></TR>
|
||||
</TABLE>
|
||||
<P>
|
||||
Das Kommando ":r filename" fügt das angegebene File nicht an der Cursor-
|
||||
Position sondern am Dateiende an.
|
||||
|
||||
<H2>Adressen</H2>
|
||||
|
||||
Das Kommando nG führt nicht zur n. Zeile, sondern zum n. Byte.
|
||||
Die Eingabe der Nummer wird dezimal interpretiert. Um eine Adresse
|
||||
hexdezimal angeben zu können, kann g eingegeben werden. Es erscheint ein
|
||||
Prompt in der Statuszeile, bei dem eine hexadezimale Eingabe erfolgen kann.
|
||||
Das erste Byte hat Adresse 0.<BR>
|
||||
Die Anzeige der Adressen kann mit einem Offset versehen werden
|
||||
(:set offset=256), beispielsweise um für .COM Files in DOS einen Beginn
|
||||
bei Adresse 100Hex anzuzeigen. Wird ein offset=1 angegeben, so ist
|
||||
hat das erste Byte Adresse 1. Das G - Kommando berücksichtigt den Offset.
|
||||
Im Gegensatz dazu zeigt das :f - Kommando immer die Ordnungszahl des
|
||||
Bytes an, beginnend mit 1 ohne Berücksichtigung des Offsets.
|
||||
|
||||
<H2>Bitweise Kommandos</H2>
|
||||
|
||||
Um Manipulationen auf Bit-Ebene durchführen zu können, stehen
|
||||
folgende Kommandos zur Verfügung:
|
||||
<CENTER><TABLE>
|
||||
<TR><TD><B>:rl </B><I>n</I></TD><TD>Rotiert Bits links</TD><TD ROWSPAN=4>
|
||||
<I>n</I> ist eine Zahl zwischen 1 und 7</TD></TR>
|
||||
<TR><TD><B>:rr </B><I>n</I></TD><TD>Rotiert Bits rechts</TD></TR>
|
||||
<TR><TD><B>:sl </B><I>n</I></TD><TD>Schiebt Bits links</TD></TR>
|
||||
<TR><TD><B>:sr </B><I>n</I></TD><TD>Schiebt Bits rechts</TD></TR>
|
||||
<TR><TD><B>:and </B><I>i</I></TD><TD>Und Verknüpfung</TD><TD ROWSPAN=4>
|
||||
<I>i</I> ist eine Zahl zwischen 0 und 255</TD></TR>
|
||||
<TR><TD><B>:or </B><I>i</I></TD><TD>Oder Verknüpfung</TD></TR>
|
||||
<TR><TD><B>:xor </B><I>i</I></TD><TD>Exklusiv-oder Verknüpfung</TD></TR>
|
||||
<TR><TD><B>:not </B></TD><TD>Negiert Bytewert</TD></TR>
|
||||
<TR><TD><B>:neg </B></TD><TD>Zweier-Komplement</TD></TR>
|
||||
</TABLE></CENTER>
|
||||
Wird kein Bereich angegeben, so bezieht sich die Operation auf die gesamte
|
||||
Datei. Es können zwei Adressen in den üblichen Schreibweisen
|
||||
angegeben werden. Normalerweise wird dezimale Eingabe erwartet, bei
|
||||
führender 0 werden die Adressen Hexadezimal interpretiert.
|
||||
<BR>Der Wert <B>i</B> für die logische Verknüpfung kann
|
||||
dezimal, hexadezimal, oder mit führendem <I>B</I> in binärer
|
||||
Schreibweise angegeben werden. Auch bei Eingabe von genau acht 0 und 1
|
||||
Werten wird der Byte - Wert binär interpretiert.<BR>
|
||||
Beispiel:<BR>
|
||||
<BLOCKQUOTE CLASS="examp">
|
||||
<B><TT>:100,500and 01A </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
<B><TT>:03FA,01000or 00001000 </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
<B><TT>:.rr 3 </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
<B><TT>:'a,$sl 1 </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
</BLOCKQUOTE>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
BIN
html/gif/bg2.gif
Normal file
BIN
html/gif/bg2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 86 B |
BIN
html/gif/bvi_m.gif
Normal file
BIN
html/gif/bvi_m.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
BIN
html/gif/bvi_s.gif
Normal file
BIN
html/gif/bvi_s.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
BIN
html/gif/dcbacks.gif
Normal file
BIN
html/gif/dcbacks.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 869 B |
BIN
html/gif/dot.gif
Normal file
BIN
html/gif/dot.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 B |
BIN
html/gif/up.gif
Normal file
BIN
html/gif/up.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 B |
122
html/index.html
Normal file
122
html/index.html
Normal file
|
@ -0,0 +1,122 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI Home Page</title>
|
||||
<script language="JavaScript">
|
||||
<!--
|
||||
if(top.frames.length!=0){top.location=location;}// -->
|
||||
</script>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
<meta name="description" content="Bvi stands for Binary VIsual editor.
|
||||
Bvi is a display oriented editor for binary files.
|
||||
Its command set is based on those of the vi texteditor.">
|
||||
<meta name="keywords" content="bvi, editor, binary, bmore, decimal, dos, hex,
|
||||
hexadecimal, linux, msdos, octal, patch, more, unix, visual, vi">
|
||||
<meta name="robots" content="INDEX,FOLLOW">
|
||||
<meta name="author" content="Gerhard Buergmann">
|
||||
<meta name="publisher" content="Gerhard Buergmann">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><th width="1%" valign="top"><img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
|
||||
<p><a class="thl" href="quick.html">
|
||||
Quick Tutorial
|
||||
</a></p>
|
||||
|
||||
<p><a class="thl" href="download.html">
|
||||
Download
|
||||
</a></p>
|
||||
|
||||
<p><a class="thl" href="install.html">
|
||||
Installation
|
||||
</a></p>
|
||||
|
||||
<p><a class="thl" href="overview.html">
|
||||
Command Overview
|
||||
</a></p>
|
||||
|
||||
<p><a class="thl" href="bmore.html">
|
||||
bmore
|
||||
</a></p>
|
||||
|
||||
<p><a class="thl" href="german.html">
|
||||
Deutsche<br>Beschreibung
|
||||
</a></p>
|
||||
|
||||
<p><a class="thl" href="sitemap.html">
|
||||
Sitemap
|
||||
</a></p>
|
||||
|
||||
<hr noshade width="60%">
|
||||
|
||||
<p><a class="thl" href="http://www.math.fu-berlin.de/~guckes/vi/">
|
||||
VI and Clones
|
||||
</a></p>
|
||||
|
||||
<p><a class="thl" href="http://spin.ch/~tpo/linux/hexeds.html">
|
||||
Hex-Editors
|
||||
</a></p>
|
||||
|
||||
<hr noshade width="60%">
|
||||
|
||||
<p>
|
||||
|
||||
</TH>
|
||||
<td width=1%><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width=99%>
|
||||
<center>
|
||||
<h1>Welcome to the<br>
|
||||
<img src="gif/bvi_m.gif" ALT="bvi" width="232" height="125"><br>
|
||||
Homepage</h1>
|
||||
<b>Here you can find all the informations about <strong>bvi</strong> you need.</B>
|
||||
</center>
|
||||
<hr noshade>
|
||||
The <strong>bvi</strong> is a display-oriented editor for binary files, based on the <strong>vi</strong> texteditor.
|
||||
If you are familiar with <strong>vi</strong>, just start the editor and begin
|
||||
to edit! A <strong>bmore</strong> programm is also included in the package.
|
||||
<br>
|
||||
If you never heard about <strong>vi</strong>, maybe <strong>bvi</strong> is not the best
|
||||
choice for you.
|
||||
|
||||
<p>
|
||||
<h3>Original site: <a href="http://bvi.linuxave.net/">http://bvi.linuxave.net</a></h3>
|
||||
</p>
|
||||
You can download source and compiled versions from the
|
||||
<a href="download.html">download page</a>.<br>
|
||||
Check out whats <a href="new130.html">new in 1.3.0</a>!
|
||||
</p>
|
||||
<p>
|
||||
<b>Newsgroup:</b> <a href="news:comp.editors">comp.editors</a>
|
||||
</p>
|
||||
<b>Mailing List:</b>
|
||||
<blockquote>
|
||||
To join this list, simply send a blank email to
|
||||
<a href="mailto:bvi-subscribe@egroups.com">bvi-subscribe@eGroups.com</a>.
|
||||
You will receive a subscription confirmation message.
|
||||
Simply reply this message and your subscription will be complete.
|
||||
</blockquote>
|
||||
|
||||
<strong>Bvi</strong> was developed by Gerhard Bürgmann and is published
|
||||
under the GNU Public License. Current stable version is 1.3.0.
|
||||
<strong>Bvi</strong> is running on most UNIX - like operating systems and
|
||||
on MSDOS.
|
||||
<p>
|
||||
If you want to contact me:<br>
|
||||
Gerhard Bürgmann, Vienna / Austria / Europe<br>
|
||||
Email: <a href="mailto:gerhard.buergmann@altavista.net">
|
||||
Gerhard.Buergmann@altavista.net</a>
|
||||
|
||||
<p>
|
||||
<font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: October 23<sup>rd</sup> 2000 by Gerhard Bürgmann</i>
|
||||
</p>
|
||||
</td></tr></table>
|
||||
|
||||
</body></html>
|
130
html/install.html
Normal file
130
html/install.html
Normal file
|
@ -0,0 +1,130 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Installation</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<font color="#ffffff" class="thl">Installation<br></font>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Installation</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
The following steps are necessary to get bvi running:
|
||||
<H2>UNIX</H2>
|
||||
The Unix version of bvi needs the curses (ncurses) library
|
||||
for cursor movement.
|
||||
<OL>
|
||||
<LI>Download the source package from the Download Page
|
||||
<LI>Unzip the package with the command:
|
||||
<PRE CLASS="examp">
|
||||
# gunzip -c bvi-1.3.0.src.tar.gz | tar xvf
|
||||
</PRE>
|
||||
<LI>Change to the directory <TT CLASS="examp">bvi-1.3.0</TT> and type
|
||||
<PRE CLASS="examp">
|
||||
# ./configure
|
||||
# make
|
||||
</PRE>
|
||||
|
||||
<li>Type `<tt class="examp">make install</tt>' for copying the executable files
|
||||
and manual pages to the final directories.
|
||||
<br>
|
||||
By default, `<tt class="examp">make install</tt>' will install the package's files in
|
||||
<tt class="examp">`/usr/local/bin', `/usr/local/man'</tt>, etc.
|
||||
You can specify an
|
||||
installation prefix other than `<tt class="examp">/usr/local</tt>' by giving
|
||||
`<tt class="examp">configure</tt>' the option
|
||||
`<tt class="examp">--prefix=PATH</tt>'. Use the
|
||||
`<tt class="examp">--with-ncurses</tt>' option to configure to specify an
|
||||
alternate search path for Ncurses outside the normal
|
||||
<tt class="examp">include/lib</tt> search path.
|
||||
<p>
|
||||
You will find now four new commands:
|
||||
<pre class="examp">
|
||||
bvi The binary editor
|
||||
bview The readonly version of bvi
|
||||
bedit The beginners version of bvi
|
||||
bmore The binary more program
|
||||
</pre>
|
||||
<li>Use `<tt class="examp">make uninstall</tt>' to remove the installed
|
||||
files from your file system.<br>
|
||||
You can remove the program binaries and object files from the
|
||||
source code directory by typing `<tt class="examp">make clean</tt>'.
|
||||
To also remove the files that `<TT CLASS="examp">configure</tt>' created
|
||||
(so you can compile the package for
|
||||
a different kind of computer), type `<tt class="examp">make distclean</tt>'.
|
||||
</ol>
|
||||
|
||||
<H2>MSDOS</H2>
|
||||
You have to convert the sourcefiles from the UNIX textformat to
|
||||
the MSDOS textformat first. This can be done e.g. by loading and
|
||||
saving them with the MSDOS standard editor `edit'.
|
||||
<P>
|
||||
The MSDOS version is using the conio routines of the
|
||||
Borland - C compilers for cursor movement. The <TT>doscur.h</TT>
|
||||
header file substitutes the curses commands.<BR>
|
||||
<strong>Bvi</strong> is using the "HUGE" memory model, <strong>bmore</strong>
|
||||
needs the "TINY" model to
|
||||
be able to convert it to a .COM file.
|
||||
|
||||
<OL>
|
||||
<LI>Download the source package from the Download Page
|
||||
<LI>Unzip the package with the command:
|
||||
<PRE CLASS="examp">
|
||||
gunzip -c bvi-1.3.0.src.tar.gz | tar xvf
|
||||
</PRE>
|
||||
<LI> Load the tcconfig file (located in the <TT>bc</TT> subdirectory
|
||||
for Borland - C).
|
||||
|
||||
<LI> Press F9-Make
|
||||
</OL>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Oct 19 21:31:04 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
171
html/man_bmore.html
Normal file
171
html/man_bmore.html
Normal file
|
@ -0,0 +1,171 @@
|
|||
<xmp>
|
||||
BMORE(1) BMORE(1)
|
||||
|
||||
|
||||
NAME
|
||||
bmore - browse through a binary file
|
||||
|
||||
SYNOPSIS
|
||||
bmore [ -adi ] [ +linenumber ] [ +/ASCII-pattern ] [
|
||||
+\Hex-pattern ] [ filename ... ]
|
||||
|
||||
DESCRIPTION
|
||||
more is a filter that displays the contents of a binary
|
||||
file on the terminal, one screenful at a time. It nor-
|
||||
mally pauses after each screenful, and prints --More-- at
|
||||
the bottom of the screen. bmore provides a two-line over-
|
||||
lap between screens for continuity. If bmore is reading
|
||||
from a file rather than a pipe, the percentage of charac-
|
||||
ters displayed so far is also shown.
|
||||
|
||||
bmore scrolls up to display one more screen line in
|
||||
response to a RETURN character; it displays another
|
||||
screenful in response to a SPACE character. Other com-
|
||||
mands are listed below.
|
||||
|
||||
The screen is divided in three sections or panes: The byte
|
||||
offset (extreme left), the hex pane (middle), and an ascii
|
||||
pane (right) which shows as printable characters those
|
||||
bytes in the hex pane. On an 80 column terminal there
|
||||
will be sixteen hex values and their ASCII values on each
|
||||
screen line. Note that (as one would expect) the first
|
||||
byte has the offset 0 (zero).
|
||||
|
||||
bmore sets the terminal to noecho mode, so that the output
|
||||
can be continuous. Commands that you type do not normally
|
||||
show up on your terminal, except for the / , \ and ! com-
|
||||
mands.
|
||||
|
||||
If the standard output is not a terminal, more acts just
|
||||
like cat(1V), except that a header is printed before each
|
||||
file in a series.
|
||||
|
||||
OPTIONS
|
||||
-a ASCII mode: no hex representation of the contents.
|
||||
Non printable characters are displayed as a dot (.)
|
||||
|
||||
-d Display error messages rather than ringing the ter-
|
||||
minal bell if an unrecognized command is used.
|
||||
This is helpful for inexperienced users.
|
||||
|
||||
-i Ignore case for searching.
|
||||
|
||||
+linenumber
|
||||
Start up at linenumber.
|
||||
|
||||
+/ASCII-pattern
|
||||
Start up at the line containing the regular
|
||||
expression pattern. Note: unlike editors, this
|
||||
construct should not end with a `/'. If it does,
|
||||
then the trailing slash is taken as a character in
|
||||
the search pattern.
|
||||
|
||||
|
||||
USAGE
|
||||
|
||||
Commands
|
||||
The commands take effect immediately; it is not necessary
|
||||
to type a carriage return. Up to the time when the com-
|
||||
mand character itself is given, the user may type the line
|
||||
kill character to cancel the numerical argument being
|
||||
formed. In addition, the user may type the erase charac-
|
||||
ter to redisplay the `--More--(xx%)' message.
|
||||
|
||||
In the following commands, i is a numerical argument (1 by
|
||||
default).
|
||||
|
||||
iSPACE Display another screenful, or i more lines if i
|
||||
is specified.
|
||||
|
||||
iRETURN Display another line, or i more lines, if speci-
|
||||
fied.
|
||||
|
||||
i^D (CTRL-D) Display (scroll down) 11 more lines. i
|
||||
is given, the scroll size is set to i.
|
||||
|
||||
id Same as ^D.
|
||||
|
||||
iz Same as SPACE, except that i, if present,
|
||||
becomes the new default number of lines per
|
||||
screenful.
|
||||
|
||||
is Skip i lines and then print a screenful.
|
||||
|
||||
if Skip i screenfuls and then print a screenful.
|
||||
|
||||
i^B (CTRL-B) Skip back i screenfuls and then print a
|
||||
screenful.
|
||||
|
||||
b Same as ^B (CTRL-D).
|
||||
|
||||
q
|
||||
Q Exit from more.
|
||||
|
||||
= Display the current line number.
|
||||
|
||||
v Drop into the bvi(1) editor at the current off-
|
||||
set of the current file.
|
||||
|
||||
w Drop into the bvi(1) editor at the current off-
|
||||
set of the current file. Only the portion of the
|
||||
file displayed on the screen will be loaded.
|
||||
|
||||
h Help. Give a description of all the more com-
|
||||
mands.
|
||||
|
||||
i/pattern Search for the ith occurrence of the regular
|
||||
expression pattern. Display the screenful
|
||||
starting at the file position that contains the
|
||||
ith match for the regular expression ASCII-pat-
|
||||
tern, or the end of a pipe, whichever comes
|
||||
first. If bmore is displaying a file and there
|
||||
is no such match, its position in the file
|
||||
remains unchanged. Regular expressions can be
|
||||
edited using erase and kill characters. Erasing
|
||||
back past the first column cancels the search
|
||||
command.
|
||||
|
||||
' Single quote. Go to the point from which the
|
||||
last search started. If no search has been per-
|
||||
formed in the current file, go to the beginning
|
||||
of the file.
|
||||
!command Invoke a shell to execute command. The charac-
|
||||
ters % and !, when used within command are
|
||||
replaced with the current filename and the pre-
|
||||
vious shell command, respectively. If there is
|
||||
no current filename, % is not expanded. Prepend
|
||||
a backslash to these characters to escape expan-
|
||||
sion.
|
||||
|
||||
i:n Skip to the ith next filename given in the com-
|
||||
mand line, or to the last filename in the list
|
||||
if i is out of range.
|
||||
|
||||
i:p Skip to the ith previous filename given in the
|
||||
command line, or to the first filename if i is
|
||||
out of range. If given while more is positioned
|
||||
within a file, go to the beginning of the file.
|
||||
If more is reading from a pipe, more simply
|
||||
rings the terminal bell.
|
||||
:f Display the current filename and offset number.
|
||||
|
||||
:q
|
||||
:Q Exit from bmore (same as q or Q ).
|
||||
|
||||
. Dot. Repeat the previous command.
|
||||
|
||||
|
||||
AUTHOR
|
||||
bmore was developed by Gerhard Buergmann, Vienna, Austria
|
||||
Gerhard.Buergmann@altavista.net
|
||||
|
||||
FILES
|
||||
/etc/termcap terminal data base
|
||||
/usr/local/share/bmore.help help file
|
||||
|
||||
SEE ALSO
|
||||
bvi(1), termcap(5)
|
||||
|
||||
|
||||
13/Oct/2000 BMORE Version 1.3.0
|
||||
</xmp>
|
424
html/man_bvi.html
Normal file
424
html/man_bvi.html
Normal file
|
@ -0,0 +1,424 @@
|
|||
<xmp>
|
||||
BVI(1) User Commands BVI(1)
|
||||
|
||||
|
||||
NAME
|
||||
bvi, bview - visual display editor for binary files
|
||||
|
||||
VERSION
|
||||
bvi-1.3.0
|
||||
|
||||
SYNOPSIS
|
||||
bvi [-R] [-c cmd] [-b begin] [-e end] [-s size] [-f script] file...
|
||||
bview [-R] [-c cmd] [-b begin] [-e end] [-s size] [-f script] file...
|
||||
|
||||
OPTIONS
|
||||
file...
|
||||
A list of filenames. The first one will be the
|
||||
current file and will be read into the buffer. The
|
||||
cursor will be positioned on the first line of the
|
||||
buffer. You can get to the other files with the
|
||||
":next" command.
|
||||
|
||||
-R "Readonly": The readonly flag is set for all the
|
||||
files, preventing accidental overwriting with a write
|
||||
command.
|
||||
|
||||
-b begin
|
||||
causes bvi to load a file not from the start but from
|
||||
offset {begin}.
|
||||
|
||||
-e end
|
||||
causes bvi to load a file not till end but till address
|
||||
{end}.
|
||||
|
||||
-s size
|
||||
causes bvi not to load the complete file but only
|
||||
{size} bytes.
|
||||
|
||||
-c cmd
|
||||
{cmd} will be executed after the first file has
|
||||
been read. If the {cmd} contains spaces it must
|
||||
be enclosed in double quotes (this depends on the
|
||||
shell that is used).
|
||||
|
||||
-f script
|
||||
This command provides a means for collecting a series
|
||||
of "ex" (colon) commands into a script file, then
|
||||
using this file to edit other files. Since there is no
|
||||
binary stream editor "bsed", you can use this option
|
||||
to make several global changes in a binary file.
|
||||
|
||||
DESCRIPTION
|
||||
Bvi stands for "Binary VIsual editor". Bvi is a screen
|
||||
oriented editor for binary files; its command set is based
|
||||
on that of the vi(1) text editor. As a binary editor does
|
||||
not have the concept of "lines" there are differences from
|
||||
Vi commands wherever the latter are line orientate.
|
||||
|
||||
COMPARISON
|
||||
The main differences between Vi and Bvi are:
|
||||
|
||||
The screen is divided in three sections or panes: The byte
|
||||
offset (extreme left), the hex pane (middle), and an ascii
|
||||
pane (right) which shows as printable characters those
|
||||
bytes in the hex pane. On an 80 column terminal there
|
||||
will be sixteen hex values and their ASCII values on each
|
||||
screen line. Note that (as one would expect) the first
|
||||
byte has the offset '0' (zero).
|
||||
|
||||
You can toggle between the hex and ascii windows with the
|
||||
tabulator key (TAB). Toggling between these two windows
|
||||
does not change the current position within the file.
|
||||
|
||||
No "lines" concept: Files are treated as one long stream
|
||||
of bytes. The characters "newline" and "carriage return"
|
||||
are not special, id est they never mark the end of lines.
|
||||
Therefore the lines on the screen do not represent lines
|
||||
in the usual way. Data is broken across screen lines
|
||||
arbitarily. As a consequence there are no commands in bvi
|
||||
from ex or vi that are based on line numbers, eg "dd",
|
||||
"yy", 'C', 'S', 'o', 'O'. This also changes the meaning
|
||||
of "range" before the ":write" command to a byte offset,
|
||||
ie the command ":100,200w foo" writes all *bytes* (not
|
||||
lines) from offset 100 to offset 200 to the file "foo".
|
||||
|
||||
No "text objects": There are also no text-specific
|
||||
arrangements like words, paragraphs, sentences, sections
|
||||
and so on.
|
||||
|
||||
Extended "ruler": The bottom line of the screen shows the
|
||||
current address (byte offset) and the current character in
|
||||
these notations:
|
||||
|
||||
octal, hexadecimal, decimal and ascii.
|
||||
|
||||
Search patterns: All search commands understand these
|
||||
special characters:
|
||||
|
||||
. any character
|
||||
[] set of characters
|
||||
* zero or more occurrences of previous char or set
|
||||
|
||||
But as there is no concept of lines you cannot use the
|
||||
standard symbols ("anchors") for "begin-of-line" ('^') and
|
||||
"end-of-line" ('$'). Searching for the start/end of lines
|
||||
must be done explicitly by adding these special characters
|
||||
to your search pattern using these meta sequences:
|
||||
|
||||
\n newline
|
||||
\r return
|
||||
\t tab
|
||||
\0 binary zero
|
||||
|
||||
Additional search commands: Similar to the text search
|
||||
commands there are additional hex-search functions '\' and
|
||||
'#' which allow to search for any byte value. Example:
|
||||
"\62 76 69" will search for the string "bvi". Spaces
|
||||
between hex value are optional, so searching for
|
||||
"6775636B6573" will find "guckes".
|
||||
|
||||
Changing data (insertion, deletion) moves the data to
|
||||
other addresses; this is bad for many cases (eg.
|
||||
databases, program files) and is thus disabled by default.
|
||||
You can enable this commands by typing
|
||||
|
||||
:set memmove
|
||||
|
||||
BVI Modes:
|
||||
|
||||
Command Mode (Normal Mode):
|
||||
|
||||
Input is treated as command. Note that command mode is
|
||||
the default mode after startup and after escaping from
|
||||
input mode. Use ESC (escape) to cancel a partial
|
||||
(uncompleted) command.
|
||||
|
||||
Input Mode:
|
||||
|
||||
Input is treated as replacement of current characters or
|
||||
(after the end of the file) is appended to the current
|
||||
file. This mode is entered from command mode by typing
|
||||
one of 'i', 'I', 'A', 'r', or 'R'. You can enter the
|
||||
characters from the keyboard (in the ASCII window) or
|
||||
hexadecimal values (in the HEX window). Type TAB to
|
||||
switch between these two windows. Type ESC to finish the
|
||||
current input and return to command mode. Type CTRL-C to
|
||||
cancel current command abnormally.
|
||||
|
||||
Command line mode (Last Line Mode or : mode):
|
||||
|
||||
Similar to vi, this mode is entered by typing one of the
|
||||
characters : / ? \ # ! The command is terminated and
|
||||
executed by typing a carriage return; to cancel a
|
||||
partially typed command, type ESC to cancel the current
|
||||
command and return to command mode.
|
||||
|
||||
ENVIRONMENT
|
||||
The editor recognizes the environment variable BVIINIT as
|
||||
a command (or list of commands) to run when it starts
|
||||
up. If this variable is undefined, the editor checks for
|
||||
startup commands in the file ~/.bvirc file, which you
|
||||
must own. However, if there is a .bvirc owned by you in
|
||||
the current directory, the editor takes its startup
|
||||
commands from this file - overriding both the file in your
|
||||
home directory and the environment variable.
|
||||
|
||||
TERMINOLOGY
|
||||
Characters names are abbreviated as follows:
|
||||
Abbr. ASCII name aka
|
||||
CR 010 carriage return
|
||||
^A 001 control-a
|
||||
^H 008 control-h
|
||||
^I 009 control-i aka TAB
|
||||
^U 021 control-u
|
||||
^Z 026 control-z
|
||||
ESC 027 escape aka ESC
|
||||
DEL 127 delete
|
||||
LEFT --- left arrow
|
||||
RIGHT --- right arrow
|
||||
DOWN --- down arrow
|
||||
UP --- up arrow
|
||||
|
||||
COMMAND SUMMARY
|
||||
See the TERMINOLOGY for a summary on key name
|
||||
abbreviations used within the following description of
|
||||
commands.
|
||||
|
||||
Abstract:
|
||||
Arrow keys move the cursor on the screen within the
|
||||
current window.
|
||||
|
||||
Sample commands:
|
||||
:version show version info
|
||||
<- v ^ -> arrow keys move the cursor
|
||||
h j k l same as arrow keys
|
||||
u undo previous change
|
||||
ZZ exit bvi, saving changes
|
||||
:q! quit, discarding changes
|
||||
/text search for text
|
||||
^U ^D scroll up or down
|
||||
|
||||
Counts before bvi commands:
|
||||
Numbers may be typed as a prefix to some commands.
|
||||
They are interpreted in one of these ways.
|
||||
|
||||
screen column |
|
||||
byte of file G
|
||||
scroll amount ^D ^U
|
||||
repeat effect most of the rest
|
||||
|
||||
Interrupting, canceling
|
||||
ESC end insert or incomplete command
|
||||
DEL (delete or rubout) interrupts
|
||||
|
||||
File manipulation:
|
||||
ZZ if file modified, write and exit;
|
||||
otherwise, exit
|
||||
:w write changed buffer to file
|
||||
:w! write changed buffer to file, overriding
|
||||
read-only ("forced" write)
|
||||
:q quit when no changes have been made
|
||||
:q! quit and discard all changes
|
||||
:e file edit file
|
||||
:e! reedit current file, discard all changes
|
||||
:e # edit the alternate file
|
||||
:e! # edit the alternate file, discard changes
|
||||
:w file write current buffer to file
|
||||
:w! file write current buffer to file overriding
|
||||
read-only (this "overwrites" the file)
|
||||
:sh run the command as set with option "shell",
|
||||
then return
|
||||
:!cmd run the command cmd from "shell", then
|
||||
return
|
||||
:n edit next file in the argument list
|
||||
:f show current filename, modified flag,
|
||||
current byte offset, and percentage of
|
||||
current position within buffer
|
||||
^G same as :f
|
||||
|
||||
Additional edit commands
|
||||
You can insert/append/change bytes in
|
||||
ASCII/binary/decimal/ hexadecimal or octal representation.
|
||||
You can enter several (screen) lines of input. A line with
|
||||
only a period (.) in it will terminate the command. You
|
||||
must not type in values greater than a byte value. This
|
||||
causes an abandom of the command. Pressing the CR key
|
||||
does not insert a newline - character into the file. If
|
||||
you use ASCII mode you can use the special characters \n,
|
||||
\r, \t and \0.
|
||||
|
||||
:i aCR insert bytes (ASCII) at cursor position
|
||||
:a bCR append bytes (Binary) at end of file
|
||||
:c hCR change bytes (hexadecimal) at cursor position
|
||||
|
||||
Bit-level operations
|
||||
:and n bitwise 'and' operation with value n
|
||||
:or n bitwise 'or' operation with value n
|
||||
:xor n bitwise 'xor' operation with value n
|
||||
:neg two's complement
|
||||
:not logical negation
|
||||
:sl i shift each byte i bits to the left
|
||||
:sr i shift each byte i bits to the right
|
||||
:rl i rotate each byte i bits to the left
|
||||
:rr i rotate each byte i bits to the right
|
||||
|
||||
Command mode addresses
|
||||
:w foo write current buffer to a file
|
||||
named "foo"
|
||||
:5,10w foo copy byte 5 through 100 into as
|
||||
file named foo
|
||||
:.,.+20w foo copy the current byte and the next
|
||||
20 bytes to foo
|
||||
:^,'aw foo write all bytes from the beginning
|
||||
through marker 'a'
|
||||
:/pat/,$ foo search pattern pat and and copy
|
||||
through end of file
|
||||
|
||||
Positioning within file:
|
||||
^B backward screen
|
||||
^F forward screen
|
||||
^D scroll down half screen
|
||||
^U scroll up half screen
|
||||
nG go to the specified character
|
||||
(end default), where n is a decimal address
|
||||
/pat next line matching pat
|
||||
?pat previous line matching pat
|
||||
\hex jump to next occurrence of hex string hex
|
||||
#hex jump to previous occurrence of hex string hex
|
||||
n repeat last search command
|
||||
N repeat last search command, but in opposite
|
||||
direction
|
||||
|
||||
Adjusting the screen:
|
||||
^L clear and redraw screen
|
||||
zCR redraw screen with current line at top of screen
|
||||
z- redraw screen with current line at bottom of
|
||||
screen
|
||||
z. redraw screen with current line at center of
|
||||
screen
|
||||
/pat/z- search for pattern pat and then move currents
|
||||
line to bottom
|
||||
^E scroll screen down 1 line
|
||||
^Y scroll screen up 1 line
|
||||
|
||||
Marking and returning:
|
||||
mx mark current position with lower-case letter x
|
||||
Note: this command works for all lower-case
|
||||
letters
|
||||
'x move cursor to mark x in ASCII section
|
||||
`x move cursor to mark x in HEX section
|
||||
'' move cursor to previous context in ASCII section
|
||||
`` move cursor to previous context in HEX section
|
||||
|
||||
Line positioning:
|
||||
H jump to first line on screen ("top")
|
||||
L jump to last line on screen ("low")
|
||||
M jump to middle line on screen ("middle")
|
||||
- jump onto previous line on screen
|
||||
+ jump onto next line on screen
|
||||
CR same as +
|
||||
DOWN or j next line, same column
|
||||
UP or k previous line, same column
|
||||
|
||||
Character positioning:
|
||||
^ first byte in HEX window
|
||||
$ end of screen line
|
||||
l or RIGHT jump onto next byte (within current
|
||||
screen line)
|
||||
h or LEFT jump onto previous byte (within current
|
||||
screen line)
|
||||
^H same as LEFT
|
||||
space same as RIGHT
|
||||
fx find next occurrence of character x
|
||||
Fx find previous occurrence of character x
|
||||
n| jump onto nth byte/character within current
|
||||
line
|
||||
|
||||
Strings:
|
||||
(works similar to the strings(1) command)
|
||||
Note: "Words" are defined as strings of "nonprinting
|
||||
characters".
|
||||
e jump to next end of word
|
||||
w jump to next begin of word
|
||||
b jump to previous begin of word
|
||||
W forward to next string delimited with a
|
||||
\0 or \n
|
||||
B back to previous string delimited with a
|
||||
nonprinting char
|
||||
|
||||
Corrections during insert:
|
||||
^H erase last character (backspace)
|
||||
erase your erase character, same as ^H (backspace)
|
||||
ESC ends insertion, back to command mode
|
||||
|
||||
Append and replace:
|
||||
A append at end of file
|
||||
rx replace current bte with char 'x'
|
||||
R enter replace mode; for all subsequent input,
|
||||
the current byte is overwritten with the next
|
||||
input character; leave replace mode with ESC.
|
||||
|
||||
Miscellaneous Operations:
|
||||
TAB toggle between ASCII and HEX section
|
||||
|
||||
Yank and Put:
|
||||
3ySPACE yank 3 characters
|
||||
p insert contents of yank buffer
|
||||
o replace text with content of yank buffer
|
||||
P put back at end of file
|
||||
|
||||
Undo, Redo:
|
||||
u undo last change
|
||||
Note: Only the last change can be undone.
|
||||
Therefore this commands toggles between the
|
||||
last and second-t-last state of the buffer.
|
||||
|
||||
Setting Options:
|
||||
With the :set command you can set options in bvi
|
||||
|
||||
Option Default Description
|
||||
|
||||
autowrite noaw Save current file, if modified, if you
|
||||
give a :n, :r or ! command
|
||||
columns cm=16 on an 80 character wide terminal
|
||||
ignorecase noic Ignores letter case in searching
|
||||
magic nomagic Makes . [ * special in patterns
|
||||
memmove nomm enables insert and delete commands
|
||||
offset of=0 adds an offset to the diplayed addresses
|
||||
readonly noro If set, write fails unless you use ! after command
|
||||
scroll sc=1/2 window
|
||||
Number of lines scrolled by ^U and ^D
|
||||
showmode mo Displays statusline on bottom of the screen
|
||||
terse noterse Let you obtain shorter error messages
|
||||
window window=screensize
|
||||
Lines in window, can be reduced at slow terminals
|
||||
wordlength wl=4 Length of an ASCII-string found by w, W, b or B
|
||||
wrapscan ws Searches wrap around past the end of the file
|
||||
unixstyle nous The representation of ascii characters below
|
||||
32 is displayed in the statusline as shown
|
||||
in ascii(7) if unset rather in DOS-style (^A)
|
||||
|
||||
AUTHOR
|
||||
bvi was developed by Gerhard Buergmann, Vienna, Austria
|
||||
Gerhard.Buergmann@altavista.net
|
||||
|
||||
WWW
|
||||
Bvi Homepage: http://bvi.linuxave.net/
|
||||
Vi Pages: http://www.math.fu-berlin.de/~guckes/vi/
|
||||
(all about Vi and its clones)
|
||||
|
||||
FILES
|
||||
$HOME/.bvirc editor startup file
|
||||
./.bvirc editor startup file
|
||||
|
||||
BUGS
|
||||
Bvi does not update the screen when the terminal changes
|
||||
its size.
|
||||
|
||||
SEE ALSO
|
||||
vi(1), strings(1), ascii(5)
|
||||
|
||||
|
||||
13/Oct/2000 BVI Version 1.3.0 8
|
||||
</xmp>
|
154
html/new120.html
Normal file
154
html/new120.html
Normal file
|
@ -0,0 +1,154 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: CHANGES in bvi 1.2.0</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
<a class="ths" href="new130.html">New in 1.3.0</a><br>
|
||||
<font color="#ffffff" class="ths">New in 1.2.0<br></font>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">CHANGES in bvi 1.2.0</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
<UL>
|
||||
<LI>Configuration with GNU autoconfig
|
||||
<LI>New <B>:set</B> options:
|
||||
<UL>
|
||||
<LI><B>:set columns=n</B><BR>
|
||||
You can set the number of columns on the screen to an
|
||||
arbitrary value. This might be useful if you edit a file
|
||||
with a fixed record length.<BR>
|
||||
Default: max number of columns, divisible by four.<BR>
|
||||
Abbreviation: <B>:set cm=n</B>
|
||||
<LI><B>:set memmove</B>
|
||||
enables the new commands to insert or delete bytes.<BR>
|
||||
Per default this commands are disabled, because e.g. in
|
||||
executable files you must not move bytes.<BR>
|
||||
Default: <B>:set nomemmove</B><BR>
|
||||
Abbreviation: <B>:set mm</B> - <B>:set nomm</B>
|
||||
<LI>The listing for <B>:set all</B> is now in
|
||||
alphabetical order.
|
||||
</UL>
|
||||
<LI>New insert and delete commands:
|
||||
<UL>
|
||||
<LI><B>a</B> inserts after cursor position
|
||||
<LI><B>i</B> inserts on cursor position
|
||||
<LI><B>x</B> deletes byte under cursor
|
||||
<LI><B>X</B> deletes byte before cursor
|
||||
<LI><B>d</B> delete command with modifiers:
|
||||
<UL>
|
||||
<LI><B>d<FONT COLOR=#888888>SPACE</FONT></B> deletes byte under cursor
|
||||
<LI><B>df<FONT COLOR=#FF0000>C</FONT></B> deletes from current position to
|
||||
next character <FONT COLOR=#FF0000>C</FONT>
|
||||
<LI><B>d/<FONT COLOR=#FF0000>xyz</FONT></B> deletes from current position
|
||||
to first matching pattern <FONT COLOR=#FF0000>xyz</FONT>
|
||||
<LI><B>d$</B> deletes from current position to EOF
|
||||
<LI><B>d'<FONT COLOR=#FF0000>a</FONT></B> deletes from current positions
|
||||
to mark <FONT COLOR=#FF0000>a</FONT>
|
||||
<LI><B>d<FONT COLOR=#FF0000>n</FONT>G</B> deletes from current position to
|
||||
byte with (decimal) address <FONT COLOR=#FF0000>n</FONT>
|
||||
</UL>
|
||||
</UL>
|
||||
<LI>New syntax for <B>p</B> (put) command:<BR>
|
||||
In previous versions of <I>bvi</I> the <B>p</B> command did an overwriting
|
||||
"put". Now the bytes are inserted.
|
||||
<LI>New command <B>o</B> (overwrite):<BR>
|
||||
This is an overwriting "put" command. It is the only command in <I>bvi</I>
|
||||
that uses a command key in a complete different way than in <I>vi</I>
|
||||
(<B>o</B> opens a new line in <I>vi</I>).
|
||||
<LI>New syntax for <B>y</B> (yank) command:
|
||||
<UL>
|
||||
<LI><B>y<FONT COLOR=#888888>SPACE</FONT></B> yanks byte under cursor
|
||||
<LI><B>yf<FONT COLOR=#FF0000>C</FONT></B> yanks from current position to next
|
||||
character <FONT COLOR=#FF0000>C</FONT>
|
||||
<LI><B>y/<FONT COLOR=#FF0000>xyz</FONT></B> yanks from current position to
|
||||
first matching pattern <FONT COLOR=#FF0000>xyz</FONT>
|
||||
<LI><B>y$</B> yanks from current position to EOF
|
||||
<LI><B>y'<FONT COLOR=#FF0000>a</FONT></B> yanks from current position to
|
||||
mark <FONT COLOR=#FF0000>a</FONT>
|
||||
<LI><B>y<FONT COLOR=#FF0000>n</FONT>G</B> yanks from current position to
|
||||
byte with (decimal) address <FONT COLOR=#FF0000>n</FONT>
|
||||
</UL>
|
||||
<LI>New ex (colon) commands:
|
||||
<UL>
|
||||
<LI><B>:a(ppend) a(scii)|b(binary)|d(ecimal)|h(exadecimal)|o(ctal)</B>
|
||||
<LI><B>:c(hange) a(scii)|b(binary)|d(ecimal)|h(exadecimal)|o(ctal)</B>
|
||||
<LI><B>:i(nsert) a(scii)|b(binary)|d(ecimal)|h(exadecimal)|o(ctal)</B><BR>
|
||||
The three commands above are used to append or change or insert bytes
|
||||
in the selected representation until you type a line containing only
|
||||
a dot, e.g. insert bytes in binary mode:
|
||||
<PRE>
|
||||
:i b
|
||||
0 010 110 1110010 10 100
|
||||
1 1001 1001 0 0
|
||||
.
|
||||
</PRE>
|
||||
Pressing the <FONT COLOR=#888888>RETURN</FONT> key does <I>not</I> insert
|
||||
a newline - character into the file. If you use <B>:i a</B> (insert
|
||||
ascii) you can use the special characters \n, \r, \t and \0.
|
||||
<LI><B>:d(elete)</B>
|
||||
<LI><B>:g(lobal)</B> does a global search with printing found items
|
||||
<LI><B>:ma(rk)</B>
|
||||
<LI><B>:pu(t)</B> puts yanked bytes into the file
|
||||
<LI><B>:o(verwrite)</B> is an overwriting ":put"
|
||||
<LI><B>:y(ank)</B>
|
||||
</UL>
|
||||
<LI><B>:f newname</B> - bug fixed
|
||||
<LI>new command line option <B><TT>-f script</TT></B>
|
||||
<LI><B>CTRL - C</B> aborts some commands, e.g. search commands
|
||||
<LI>CR moves cursor to 1st column of next screen line
|
||||
<LI>Local settings according to the environment variable LANG
|
||||
will be evaluated (see setlocal(3)).
|
||||
</UL>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
101
html/new130.html
Normal file
101
html/new130.html
Normal file
|
@ -0,0 +1,101 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: CHANGES in bvi 1.3.0</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
<font color="#ffffff" class="ths">New in 1.3.0<br></font>
|
||||
<a class="ths" href="new120.html">New in 1.2.0</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">CHANGES in bvi 1.3.0</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
<UL>
|
||||
<LI>In the <FONT FACE="COURIER">configure</FONT> script you can use <FONT FACE="COURIER">--with-ncurses</FONT>
|
||||
option to configure to specify an alternate
|
||||
search path for Ncurses outside the normal include/lib search path.
|
||||
<P>
|
||||
<li>A <FONT FACE="COURIER">make uninstall</font> option has been added
|
||||
<p>
|
||||
<LI>A <STRONG>bmore</STRONG> program has been added. It acts like the BSD - text - more,
|
||||
but for binary files.<P>
|
||||
Additional command line options:
|
||||
<BLOCKQUOTE>
|
||||
<TT><B>-a</B></TT> ASCII mode
|
||||
</BLOCKQUOTE>
|
||||
Additional (changed) Commands:
|
||||
<BLOCKQUOTE>
|
||||
<TT><B>v</B></TT> does not invoke vi but bvi<BR>
|
||||
<TT><B>w</B></TT> invokes bvi with only that portion of the file
|
||||
which is displayed on the screen.
|
||||
</BLOCKQUOTE>
|
||||
<LI>New in <STRONG>bvi</STRONG>:
|
||||
<UL>
|
||||
<LI>You can edit now Block Special Files too.
|
||||
<LI>You can read - edit - write files partly.
|
||||
<LI>New Command line options:
|
||||
<BLOCKQUOTE>
|
||||
<TT><B>+cmd</B></TT><BR>
|
||||
<TT><B>-b</B> begin \</TT><BR>
|
||||
<TT><B>-e</B> end > </TT>for partial file read<BR>
|
||||
<TT><B>-s</B> size /</TT><P>
|
||||
</BLOCKQUOTE>
|
||||
<I>begin, end</I> or <I>size</I> can be an integer value (decimal or
|
||||
hexadecimal) or an integer value with an appended <B>k</B> (for
|
||||
multiply by 1024) or <B>m</B> (for multiply by 1.048.576).
|
||||
<LI>:e# bug fixed
|
||||
<li>Debian bug #68436 (Buffer overflow in io.c) fixed
|
||||
</UL>
|
||||
</UL>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Oct 12 20:51:06 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
96
html/overview.html
Normal file
96
html/overview.html
Normal file
|
@ -0,0 +1,96 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Command Overview</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<font color="#ffffff" class="thl">Command Overview<br></font>
|
||||
<a class="ths" href="cursor.html">Cursor Movement</a><br>
|
||||
<a class="ths" href="edit.html">Edit Cmds</a><br>
|
||||
<a class="ths" href="yank.html">Yank and Put Cmds</a><br>
|
||||
<a class="ths" href="set.html">Set Options</a><br>
|
||||
<a class="ths" href="colon.html">Colon (ex) Cmds</a><br>
|
||||
<a class="ths" href="man_bvi.html">man - Page</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Command Overview</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
This overview compares bvi commands with the corresponding commands of
|
||||
the standard ascii vi.
|
||||
<P>
|
||||
<CENTER>
|
||||
<TABLE WIDTH=70%>
|
||||
<TR BGCOLOR=#CCCCFF><TD>Commands shown in blue frames are commands which
|
||||
are available in both bvi and vi, but with a slightly different
|
||||
behavior.</TD></TR>
|
||||
<TR BGCOLOR=#CCFFCC><TD>Green frames are used for commands which are
|
||||
equal in both bvi and vi.</TD></TR>
|
||||
<TR BGCOLOR=#FFCCCC><TD>Red frames are used for missing commands</TD></TR>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
<P>
|
||||
Special keys are displayed in a gray font, e.g.
|
||||
<FONT COLOR=#AAAAAA><B>RETURN</B></FONT>,
|
||||
<FONT COLOR=#AAAAAA><B>ARROW_UP</B></FONT> or
|
||||
<FONT COLOR=#AAAAAA><B>CTRL</B></FONT>.
|
||||
|
||||
<H3>Topics:</H3>
|
||||
<P>
|
||||
<UL>
|
||||
<LI><A HREF="cursor.html">Cursor Movements</A>
|
||||
<LI><A HREF="edit.html">Edit Commands</A>
|
||||
<LI><A HREF="yank.html">Yank and Put Commands</A>
|
||||
<LI><A HREF="set.html">Set Options</A>
|
||||
<LI><A HREF="colon.html">Colon (ex) Commands</A>
|
||||
</UL>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
101
html/qt_bit.html
Normal file
101
html/qt_bit.html
Normal file
|
@ -0,0 +1,101 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Bit-wise Operations</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
<a class="ths" href="qt_edit.html">Editing Files</a><br>
|
||||
<a class="ths" href="qt_search.html">Search Commands</a><br>
|
||||
<font color="#ffffff" class="ths">Bit-wise Operations<br></font>
|
||||
<a class="ths" href="qt_find.html">Find and Replace</a><br>
|
||||
<a class="ths" href="qt_yank.html">Yank and Put</a><br>
|
||||
<a class="ths" href="qt_set.html">Settings</a><br>
|
||||
<a class="ths" href="qt_partial.html">Partial File Read</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Quick Tutorial</font>
|
||||
<br><font class="sub">Bit-wise Operations</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
To perform logical operations, bvi has a set of bit-level commands.
|
||||
The following commands are available:
|
||||
<CENTER><TABLE>
|
||||
<TR><TD><B>:rl </B><I>n</I></TD><TD>rotate left</TD><TD ROWSPAN=4>
|
||||
<I>n</I> is a number from 1 through 7</TD></TR>
|
||||
<TR><TD><B>:rr </B><I>n</I></TD><TD>rotate right</TD></TR>
|
||||
<TR><TD><B>:sr </B><I>n</I></TD><TD>shift right</TD></TR>
|
||||
<TR><TD><B>:sl </B><I>n</I></TD><TD>shift left</TD></TR>
|
||||
<TR><TD><B>:and </B><I>i</I></TD><TD>and operation</TD><TD ROWSPAN=4>
|
||||
<I>i</I> is a number from 0 through 255</TD></TR>
|
||||
<TR><TD><B>:or </B><I>i</I></TD><TD>or operation</TD></TR>
|
||||
<TR><TD><B>:xor </B><I>i</I></TD><TD>or operation</TD></TR>
|
||||
<TR><TD><B>:not </B></TD><TD>negates operation</TD></TR>
|
||||
<TR><TD><B>:neg </B></TD><TD>negates operation</TD></TR>
|
||||
</TABLE></CENTER>
|
||||
<P>
|
||||
The <I>i</I> value can be entered as a decimal number (0 - 255),
|
||||
a hexadecimal number with a leading zero (0 - 0ff) or a binary number,
|
||||
either with a leading B (B101) or exactly eight digits long (00000101).
|
||||
<P>
|
||||
On default the whole file is affected, but you can use the usual
|
||||
colon command address forms. In contrast to vi the addresses designate
|
||||
not line numbers but byte numbers. These addresses can be enterd in
|
||||
decimal or hexadecimal notation.<BR>
|
||||
Examples:
|
||||
<BLOCKQUOTE CLASS="examp">
|
||||
<B><TT>:100,500and 01A </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
<B><TT>:03FA,01000or 00001000 </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
<B><TT>:.rr 3 </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
<B><TT>:'a,$sl 1 </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
</BLOCKQUOTE>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
130
html/qt_edit.html
Normal file
130
html/qt_edit.html
Normal file
|
@ -0,0 +1,130 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Editing Files</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
<font color="#ffffff" class="ths">Editing Files<br></font>
|
||||
<a class="ths" href="qt_search.html">Search Commands</a><br>
|
||||
<a class="ths" href="qt_bit.html">Bit-wise Operations</a><br>
|
||||
<a class="ths" href="qt_find.html">Find and Replace</a><br>
|
||||
<a class="ths" href="qt_yank.html">Yank and Put</a><br>
|
||||
<a class="ths" href="qt_set.html">Settings</a><br>
|
||||
<a class="ths" href="qt_partial.html">Partial File Read</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Quick tutorial</font>
|
||||
<br><font class="sub">Editing Files</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
Inserting or deleting bytes can be dangerous on some kind of files,
|
||||
because binary files are mostly executables, database files or maybe
|
||||
graphic files. So you must not shift the remaining bytes to another
|
||||
address.
|
||||
Therefor commands for inserting or deleting bytes are disabled by
|
||||
default.
|
||||
You can use the <B>r</B> command to change a single byte, or
|
||||
the <B>R</B> command to replace multiple characters. You can use a
|
||||
numeric prefix for both commands.
|
||||
<P>
|
||||
You can add characters at the end of the file using the <B>A</B> command.
|
||||
If you start with an empty file, you can create a binary file from
|
||||
scratch. If the cursor is in the ASCII section of the screen and you
|
||||
type <B><TT>100Ax</TT><FONT COLOR=#AAAAAA>ESC</FONT></B>, you create a file
|
||||
which contents 100 x'es.
|
||||
<P>
|
||||
The <B>D</B> command can be used to truncate a file at a certain position.
|
||||
Since there are no lines in a binary file, the <B>D</B> command deletes
|
||||
to end of file.
|
||||
<P>
|
||||
If you have to edit a binary file where it does not matter to move bytes
|
||||
to a different address, you can enable the insert and delete commands by
|
||||
typing <B>:set memmove</B>.
|
||||
Now you are able to use the <B>i</B> command for inserting bytes, the
|
||||
<B>x</B> or <B>X</B> command to delete the byte over or before the cursor
|
||||
and those types of <B>d</B> commands, which does not rely on text lines
|
||||
(e.g. <B>d<FONT COLOR=#AAAAAA>SPACE</FONT></B>, <B>df<TT>C</TT>, d/<TT>xyz</TT>,
|
||||
d$, d'a, d<TT>n</TT>G</B>).
|
||||
|
||||
<P>
|
||||
All edits can be undone by pressing the <B>u</B> key.
|
||||
<H4>Using ex (colon) commands</H4>
|
||||
The edit commands of the <B>ex</B> editor are usually not available in
|
||||
standard <B>vi</B> implementations (<TT>:i[nsert], :a[ppend]</TT>
|
||||
and <TT>:c[hange]</TT>). In <B><FONT COLOR=#FF0000>bvi</B></FONT>
|
||||
they <I>are</I> available with extended options. There are five
|
||||
modifiers <TT>a[scii], b[inary], d[ecimal], h[exadecimal]</TT> and
|
||||
<TT>o[ctal]</TT> (ascii is default). Therefor you can insert, append
|
||||
or change data in all five representations.
|
||||
<P>
|
||||
<B>Example:</B><BR>
|
||||
you would like to append a file with data available in decimal
|
||||
representation:
|
||||
<BLOCKQUOTE><PRE CLASS=examp>
|
||||
:a d
|
||||
0 12 3 128 255 17 0 0 255 255
|
||||
23 24 25 128 6 6 6
|
||||
.
|
||||
</PRE></BLOCKQUOTE>
|
||||
A line with only a period (.) in it will terminate the command.
|
||||
<BR>
|
||||
You must not type values greater than a byte value (255 decimal, FF hex).
|
||||
This causes an abandon of the command.<BR>
|
||||
Pressing the <FONT COLOR=#888888>RETURN</FONT> key does <I>not</I> insert
|
||||
a newline - character into the file. If you use <B>:i a</B> (insert
|
||||
ascii) you can use the special characters \n, \r, \t and \0.
|
||||
<P>
|
||||
An additional advantage is, that all typed bytes are inserted into the
|
||||
file at once. If you insert characters in vi - mode, for every byte typed,
|
||||
the whole remaining file has to be moved one position backwards.
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
113
html/qt_edit.tmp.html
Normal file
113
html/qt_edit.tmp.html
Normal file
|
@ -0,0 +1,113 @@
|
|||
<HTML><HEAD>
|
||||
<TITLE>BVI Editing Files</TITLE>
|
||||
<LINK REL=STYLESHEET TYPE="text/css" HREF="bvi.css">
|
||||
</HEAD><BODY BGCOLOR=#ffffff BACKGROUND="gif/bg2.gif">
|
||||
<A NAME="top"></A>
|
||||
|
||||
<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD WIDTH=1% VALIGN=TOP ALIGN=CENTER><IMG SRC="gif/dot.gif" WIDTH=130 HEIGHT=1>
|
||||
|
||||
<HR NOSHADE WIDTH=60%>
|
||||
<P>
|
||||
<A CLASS="thl" HREF="index.html">Home</A>
|
||||
</P>
|
||||
<P>
|
||||
<A CLASS="thl" HREF="quick.html">Quick Tutorial</A>
|
||||
<FONT COLOR=#FFFFFF CLASS="ths">Editing Files<BR></FONT>
|
||||
<A CLASS="ths" HREF="qt_search.html">Search Commands</A>
|
||||
<A CLASS="ths" HREF="qt_bit.html">Bit-wise Operations</A>
|
||||
<A CLASS="ths" HREF="qt_find.html">Find and Replace</A>
|
||||
<A CLASS="ths" HREF="qt_yank.html">Yank and Put</A>
|
||||
<A CLASS="ths" HREF="qt_set.html">Settings</A>
|
||||
</P>
|
||||
<P>
|
||||
<A CLASS="thl" HREF="download.html">Download</A>
|
||||
</P>
|
||||
<HR NOSHADE WIDTH=60%>
|
||||
|
||||
</TD>
|
||||
<TD WIDTH=1%><IMG SRC="gif/dot.gif" WIDTH=40 HEIGHT=1></TD>
|
||||
<TD WIDTH=99%>
|
||||
|
||||
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>
|
||||
<TR><TD WIDTH=99%>
|
||||
<FONT CLASS=head>Quick Tutorial</FONT><BR>
|
||||
<FONT CLASS=sub>Editing Files</FONT>
|
||||
</TD><TD ALIGN=RIGHT VALIGN=BOTTOM WIDTH=116 ROWSPAN=2>
|
||||
<IMG SRC="gif/bvi_s.gif" ALT="BVI" WIDTH="116" HEIGHT="62">
|
||||
</TD></TR>
|
||||
<TR><TD VALIGN=BOTTOM>
|
||||
<HR NOSHADE>
|
||||
</TD></TR></TABLE>
|
||||
|
||||
<P>
|
||||
Inserting or deleting bytes can be dangerous on some kind of files,
|
||||
because binary files are mostly executables, database files or maybe
|
||||
graphic files. So you must not shift the remaining bytes to another
|
||||
address.
|
||||
Therefor commands for inserting or deleting bytes are disabled by
|
||||
default.
|
||||
You can use the <B>r</B> command to change a single byte, or
|
||||
the <B>R</B> command to replace multiple characters. You can use a
|
||||
numeric prefix for both commands.
|
||||
<P>
|
||||
You can add characters at the end of the file using the <B>A</B> command.
|
||||
If you start with an empty file, you can create a binary file from
|
||||
scratch. If the cursor is in the ASCII section of the screen and you
|
||||
type <B><TT>100Ax</TT><FONT COLOR=#AAAAAA>ESC</FONT></B>, you create a file
|
||||
which contents 100 x'es.
|
||||
<P>
|
||||
The <B>D</B> command can be used to truncate a file at a certain position.
|
||||
Since there are no lines in a binary file, the <B>D</B> command deletes
|
||||
to end of file.
|
||||
<P>
|
||||
If you have to edit a binary file where it does not matter to move bytes
|
||||
to a different address, you can enable the insert and delete commands by
|
||||
typing <B>:set memmove</B>.
|
||||
Now you are able to use the <B>i</B> command for inserting bytes, the
|
||||
<B>x</B> or <B>X</B> command to delete the byte over or before the cursor
|
||||
and those types of <B>d</B> commands, which does not rely on text lines
|
||||
(e.g. <B>d<FONT COLOR=#AAAAAA>SPACE</FONT></B>, <B>df<TT>C</TT>, d/<TT>xyz</TT>,
|
||||
d$, d'a, d<TT>n</TT>G</B>).
|
||||
|
||||
<P>
|
||||
All edits can be undone by pressing the <B>u</B> key.
|
||||
<H4>Using ex (colon) commands</H4>
|
||||
The edit commands of the <B>ex</B> editor are usually not available in
|
||||
standard <B>vi</B> implementations (<TT>:i[nsert], :a[ppend]</TT>
|
||||
and <TT>:c[hange]</TT>). In <B><FONT COLOR=#FF0000>bvi</B></FONT>
|
||||
they <I>are</I> available with extended options. There are five
|
||||
modifiers <TT>a[scii], b[inary], d[ecimal], h[exadecimal]</TT> and
|
||||
<TT>o[ctal]</TT> (ascii is default). Therefor you can insert, append
|
||||
or change data in all five representations.
|
||||
<P>
|
||||
<B>Example:</B><BR>
|
||||
you would like to append a file with data available in decimal
|
||||
representation:
|
||||
<BLOCKQUOTE><PRE>
|
||||
:a d
|
||||
0 12 3 128 255 17 0 0 255 255
|
||||
23 24 25 128 6 6 6
|
||||
.
|
||||
</PRE></BLOCKQUOTE>
|
||||
A line with only a period (.) in it will terminate the command.
|
||||
<BR>
|
||||
You must not type values greater than a byte value (255 decimal, FF hex).
|
||||
This causes an abandon of the command.<BR>
|
||||
Pressing the <FONT COLOR=#888888>RETURN</FONT> key does <I>not</I> insert
|
||||
a newline - character into the file. If you use <B>:i a</B> (insert
|
||||
ascii) you can use the special characters \n, \r, \t and \0.
|
||||
<P>
|
||||
An additional advantage is, that all typed bytes are inserted into the
|
||||
file at once. If you insert characters in vi - mode, for every byte typed,
|
||||
the whole remaining file has to be moved one position backwards.
|
||||
<P>
|
||||
<FONT SIZE=-1>
|
||||
<A CLASS="btop" HREF="#top"><IMG BORDER=0 WIDTH=16 HEIGHT=7 SRC="gif/up.gif"
|
||||
ALT="Back to the top">Back to the top</A>
|
||||
</FONT>
|
||||
<HR NOSHADE>
|
||||
<I>Last update: 17 - 06 - 2000 by Gerhard Bürgmann</I>
|
||||
</TD></TR></TABLE>
|
||||
</BODY>
|
||||
</HTML>
|
98
html/qt_find.html
Normal file
98
html/qt_find.html
Normal file
|
@ -0,0 +1,98 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Find and Replace</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
<a class="ths" href="qt_edit.html">Editing Files</a><br>
|
||||
<a class="ths" href="qt_search.html">Search Commands</a><br>
|
||||
<a class="ths" href="qt_bit.html">Bit-wise Operations</a><br>
|
||||
<font color="#ffffff" class="ths">Find and Replace<br></font>
|
||||
<a class="ths" href="qt_yank.html">Yank and Put</a><br>
|
||||
<a class="ths" href="qt_set.html">Settings</a><br>
|
||||
<a class="ths" href="qt_partial.html">Partial File Read</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Quick Tutorial</font>
|
||||
<br><font class="sub">Find and Replace</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
The <B><TT CLASS="examp">:s</TT></B> (substitute) command behaves a little bit
|
||||
different to that of vi. If you type a command like this in vi <NOBR>
|
||||
<B><TT CLASS="examp">:s/XXXX/UU/</TT></B></NOBR> then the four XXXX's are
|
||||
replaced by
|
||||
two UU's. This means, the file size decreases and all characters after
|
||||
the replacement are moved to another position in the file. Since bvi
|
||||
does not move characters, only two XX's are replaced by two UU's and
|
||||
the third and fourth X still remains in the file.<BR>
|
||||
Another example:
|
||||
<BLOCKQUOTE>
|
||||
<B><TT CLASS="examp">:0,500s/Taste\0/Key\0/</TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
</BLOCKQUOTE>
|
||||
<P>
|
||||
This command replaces within the first 500 bytes of a file the 0 -
|
||||
terminated ASCII string "<TT CLASS="examp">Taste</TT>"
|
||||
with the 0 - terminated
|
||||
string "<TT CLASS="examp">Key</TT>". After the substitution
|
||||
you will find a
|
||||
character sequence "<TT CLASS="examp">Key\0e\0</TT>" in the file.<BR>
|
||||
CAUTION: If the replace
|
||||
string is longer than the find string, additional bytes are overwritten!
|
||||
<BR>
|
||||
This behaviour will not be changed by setting the
|
||||
<TT CLASS="examp">:set memmove</TT> option!
|
||||
<P>
|
||||
Of course you can do also binary substitutions, similar to the search
|
||||
command. The ability of remembering patterns like <B><TT CLASS="examp">\(pattern\)</TT></B>
|
||||
is currently not implemented.
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Fri Jun 30 22:33:20 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
144
html/qt_partial.html
Normal file
144
html/qt_partial.html
Normal file
|
@ -0,0 +1,144 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Partial File Read</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
<a class="ths" href="qt_edit.html">Editing Files</a><br>
|
||||
<a class="ths" href="qt_search.html">Search Commands</a><br>
|
||||
<a class="ths" href="qt_bit.html">Bit-wise Operations</a><br>
|
||||
<a class="ths" href="qt_find.html">Find and Replace</a><br>
|
||||
<a class="ths" href="qt_yank.html">Yank and Put</a><br>
|
||||
<a class="ths" href="qt_set.html">Settings</a><br>
|
||||
<font color="#ffffff" class="ths">Partial File Read<br></font>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Quick Tutorial</font>
|
||||
<br><font class="sub">Partial File Read</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
A new feature of version 1.3.0 is the Partial File Read.
|
||||
If you want to edit a file, you have not to read the file into
|
||||
memory but only the part you want to edit. You can write back this part
|
||||
into the file after editing.
|
||||
<BR>
|
||||
Example:
|
||||
<BR>
|
||||
You have to change only some bytes of the header of a graphic file
|
||||
(e.g. a color). Graphic files can be very large. With the <TT>-s</TT>
|
||||
option you can load only the first kilobyte of the file:
|
||||
<PRE>
|
||||
bvi -s 1000 large.gif
|
||||
</PRE>
|
||||
In this case of course you cannot insert or delete bytes of the file.
|
||||
The editor is set to the <I>no memmove</I> mode. You can write back
|
||||
only as much bytes as you read before. If you add or delete bytes
|
||||
even though, the extra bytes will be ignored or garbage will be
|
||||
written to the file.
|
||||
<P>
|
||||
It is also possible to start not at the begin of the file, but at a
|
||||
certain address. To do this you have to use the option <TT>-b</TT>.
|
||||
You can read the file from this starting point until the end of the file
|
||||
or you can use the <TT>-s</TT> option to specify a size or the
|
||||
<TT>-e</TT> option to specify an end address.
|
||||
<P>
|
||||
If you read the file not from the start an offset will be set to
|
||||
display the correct address at the left side of the screen. If you change this
|
||||
offset with the <TT>:set offset=<I>nnnn</I></TT> command, this has
|
||||
<B>no</B> effect to the write back operation. The edited part of the
|
||||
file will always be written back at the same position, where it was read.
|
||||
<P>
|
||||
In the Linux <TT>/proc</TT> directory there are files which are listed
|
||||
with length 0 in a directory listing. But in reality they have a content.
|
||||
You can read this files, if you use the <TT>-s</TT> option and guess a
|
||||
size. This size should be a little bit larger than the size you expect.
|
||||
<P>
|
||||
The same guidlines can be used, if you load a block device, e.g. a
|
||||
floppy disk.
|
||||
<PRE>
|
||||
bvi -s 1450k /dev/fd0
|
||||
</PRE>
|
||||
After reading the device, you get a message with the value of the
|
||||
real read bytes at the bottom of the screen:
|
||||
<PRE>
|
||||
"/dev/fd0" range 0-1474559
|
||||
</PRE>
|
||||
Note that the <I>size</I> value will be used to allocate memory before
|
||||
reading the file. Therefore do not choose a too large size.<BR>
|
||||
Note further, that <I>1450k</I> in the example above is calculated as
|
||||
<I>1450 * 1024</I> bytes. This gives <I>1484800</I> bytes allocated size.
|
||||
If <STRONG>bvi</STRONG> reads the exact number of bytes you have asked for
|
||||
in the <TT>-s</TT> option, the file may be larger.
|
||||
<P>
|
||||
<B>WARNING:</B>
|
||||
<BLOCKQUOTE>
|
||||
Do not use <STRONG>bvi</STRONG> at mounted disk devices!<BR>
|
||||
Do not edit disk devices, if you don't know exactly what you change!<BR>
|
||||
You may make your disk unreadable by editing it!!
|
||||
</BLOCKQUOTE>
|
||||
<H3>Interaction with <STRONG>bmore</STRONG></H3>
|
||||
You may use <STRONG>bmore</STRONG> to browse through large files or
|
||||
devices. You may use the ASCII - or Hex - search possibilities to
|
||||
locate a certain section of the file.<BR>
|
||||
If you see the desired part of the file on your screen, press <I><B>w</B></I> to
|
||||
read the contents of the file displayed currently on your screen into
|
||||
<STRONG>bvi</STRONG>. You can use a decimal prefix at the <I><B>w</B></I> -
|
||||
command to read more or less bytes than displayed into <STRONG>bvi</STRONG>.
|
||||
<BR>
|
||||
The letter <I><B>w</B></I> is the next letter after <I><B>v</B></I>, which
|
||||
is used in more and bmore to read the whole file into vi or bvi!
|
||||
<P>
|
||||
If you used the <TT>ZZ</TT> or <TT>:w</TT> command, this part of the file will be
|
||||
written back into the original file.
|
||||
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Sun Jul 09 21:57:38 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
115
html/qt_search.html
Normal file
115
html/qt_search.html
Normal file
|
@ -0,0 +1,115 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Search Commands</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
<a class="ths" href="qt_edit.html">Editing Files</a><br>
|
||||
<font color="#ffffff" class="ths">Search Commands<br></font>
|
||||
<a class="ths" href="qt_bit.html">Bit-wise Operations</a><br>
|
||||
<a class="ths" href="qt_find.html">Find and Replace</a><br>
|
||||
<a class="ths" href="qt_yank.html">Yank and Put</a><br>
|
||||
<a class="ths" href="qt_set.html">Settings</a><br>
|
||||
<a class="ths" href="qt_partial.html">Partial File Read</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Quick Tutorial</font>
|
||||
<br><font class="sub">Search Commands</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
Additional to the well known <B>/</B> and <B>?</B> for searching ASCII
|
||||
strings there are two new commands for searching binary strings. These
|
||||
are the keys <B>\</B> and <B>#</B>.
|
||||
<P>
|
||||
In the ASCII search commands <B>/</B> and <B>?</B> you can use \n, \r,
|
||||
\t and \0. You can also use regular expressions. Do <I>not</I> use
|
||||
<B>^</B> and <B>$</B>, because there are no lines in a binary file.
|
||||
Type <B><TT>/foo\0</TT><FONT COLOR=#AAAAAA>RETURN</FONT></B> to
|
||||
search for the null terminated string <I>foo</I> in the file.
|
||||
<P>
|
||||
In the Hex section you can search for a sequence of bytes in hexadecimal
|
||||
notation, e.g. <NOBR><B><TT>\01 AF 12</TT><FONT COLOR=#AAAAAA>RETURN</FONT></B>,
|
||||
</NOBR> which is the same as <NOBR><B><TT>\01AF12</TT><FONT COLOR=#AAAAAA>
|
||||
RETURN</FONT></B></NOBR>.
|
||||
You can also use regular expressions and quoted ASCII strings. Inside of
|
||||
the quotes no character is treated as a special character!<BR>
|
||||
Example:
|
||||
<B><TT>\01 [^AF DE] "foo" 00 </TT><FONT COLOR=#AAAAAA>RETURN</FONT></B>
|
||||
<BR>
|
||||
This means: Search for a string beginning with 01, the second character
|
||||
must not be a hex <TT>AF</TT> or <TT>DE</TT>, followed by the ASCII
|
||||
characters <TT>foo</TT>, terminated with a binary zero.
|
||||
|
||||
<H3>Global Search</H3>
|
||||
There is also a global search option available, but only with the
|
||||
print option.<BR>
|
||||
Example:
|
||||
<BLOCKQUOTE>
|
||||
<B><TT>:g/text_pattern/p</TT><FONT COLOR=#AAAAAA>RETURN</FONT></B>
|
||||
<BR>or<BR>
|
||||
<B><TT>:g\hex_pattern\p</TT><FONT COLOR=#AAAAAA>RETURN</FONT></B>
|
||||
</BLOCKQUOTE>
|
||||
This commands are displaying all found patterns, one per screen line.
|
||||
Of course you can limit the search to a certain part of the file by
|
||||
specifying the starting and ending address.<BR>
|
||||
Other forms of the global search command
|
||||
are line oriented, therefor <B>not</B> useful for binary files and
|
||||
<B>not implemented</B>, e.g.<BR>
|
||||
<BLOCKQUOTE>
|
||||
<TABLE>
|
||||
<TR><TD>:g/pattern/d</TD><TD>Delete all lines containing <I>pattern</I></TD></TR>
|
||||
<TR><TD>:g/pattern/y</TD><TD>Yank all lines containing <I>pattern</I></TD></TR>
|
||||
<TR><TD>:g!/pattern/p</TD><TD>Print all lines <B>not</B> containing <I>pattern</I></TD></TR>
|
||||
</TABLE>
|
||||
</BLOCKQUOTE>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
126
html/qt_set.html
Normal file
126
html/qt_set.html
Normal file
|
@ -0,0 +1,126 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Settings</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
<a class="ths" href="qt_edit.html">Editing Files</a><br>
|
||||
<a class="ths" href="qt_search.html">Search Commands</a><br>
|
||||
<a class="ths" href="qt_bit.html">Bit-wise Operations</a><br>
|
||||
<a class="ths" href="qt_find.html">Find and Replace</a><br>
|
||||
<a class="ths" href="qt_yank.html">Yank and Put</a><br>
|
||||
<font color="#ffffff" class="ths">Settings<br></font>
|
||||
<a class="ths" href="qt_partial.html">Partial File Read</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Quick Tutorial</font>
|
||||
<br><font class="sub">Settings</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
To customize bvi some additional <B>:set</B> options are
|
||||
available. You can add them to your <B><TT CLASS="examp">.bvirc</TT></B>
|
||||
file, if you need them all the time.
|
||||
|
||||
<H4>columns</H4>
|
||||
<BLOCKQUOTE>
|
||||
You can set the number of columns on the screen to an arbitrary value.
|
||||
This might be useful if you edit a file with a fixed record length.<BR>
|
||||
Default value is the max. number of columns, divisible by four.<BR>
|
||||
Example: <B><TT>:set columns=13<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B><BR>
|
||||
Abbreviation: <B><TT>:set cm=9<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H4>memmove</H4>
|
||||
<BLOCKQUOTE>
|
||||
This option enables the commands for inserting and deleting bytes.
|
||||
<BR>
|
||||
Default: <B><TT>:set nomemmove<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B><BR>
|
||||
Abbreviation: <B><TT>:set mm<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H4>offset</H4>
|
||||
<BLOCKQUOTE>
|
||||
You can change the beginning of the displayed byte numbering to a
|
||||
certain number. The default address of the first byte is 0. You can
|
||||
change it to 1 or to any other number by typing:<BR>
|
||||
<B><TT>:set offset=1</TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
You can also use a hexadecimal address, if you type a leading zero:<BR>
|
||||
<B><TT>:set of=01FF</TT><FONT COLOR=#AAAAAA>RETURN</FONT></B><BR>
|
||||
The only commands which are not affected by these numbering is
|
||||
<TT><B>:f</B></TT> or <TT><B><FONT COLOR=#AAAAAA>CTRL</FONT>
|
||||
-G</B></TT>. These commands always
|
||||
designates the first byte in file as 1.
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H4>unixstyle</H4>
|
||||
<BLOCKQUOTE>
|
||||
The rightmost character in the status line displays the ASCII value of
|
||||
the current byte. For values below 32 you can use the notation used on
|
||||
the ascii(7) man page (like NUL, SOH, STX etc.) if you do a<BR>
|
||||
<B><TT>:set unixstyle<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B> or a<BR>
|
||||
<B><TT>:set us<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B>. If you do a<BR>
|
||||
<B><TT>:set nous<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B> you get a
|
||||
DOS style representation (^A, ^B, ^C etc.).
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H4>wordlength</H4>
|
||||
<BLOCKQUOTE>
|
||||
This setting is used to define the minimum length of a "word".
|
||||
A "word" is a sequence of ASCII characters within a binary
|
||||
file. The commands <B>w, b, e, W, B</B> and <B>E</B> are affected by
|
||||
this setting.
|
||||
<P>
|
||||
Default: <B><TT>:set wordlength=4<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B><BR>
|
||||
Abbreviation: <B><TT>:set wl=4<FONT COLOR=#AAAAAA>RETURN</FONT></TT></B>
|
||||
</BLOCKQUOTE>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
132
html/qt_yank.html
Normal file
132
html/qt_yank.html
Normal file
|
@ -0,0 +1,132 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Yank and Put</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
<a class="ths" href="qt_edit.html">Editing Files</a><br>
|
||||
<a class="ths" href="qt_search.html">Search Commands</a><br>
|
||||
<a class="ths" href="qt_bit.html">Bit-wise Operations</a><br>
|
||||
<a class="ths" href="qt_find.html">Find and Replace</a><br>
|
||||
<font color="#ffffff" class="ths">Yank and Put<br></font>
|
||||
<a class="ths" href="qt_set.html">Settings</a><br>
|
||||
<a class="ths" href="qt_partial.html">Partial File Read</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Quick Tutorial</font>
|
||||
<br><font class="sub">Yank and Put</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
Starting with version 1.2.0 there is a new syntax for the yank and put
|
||||
commands! Yank is now more similare to vi.
|
||||
<P>
|
||||
<TABLE>
|
||||
<TR><TD><B>y<FONT COLOR=#888888>SPACE</FONT></B></TD>
|
||||
<TD>yanks byte under cursor</TD></TR>
|
||||
<TR><TD><B><FONT COLOR=#FF0000>n</FONT>y<FONT COLOR=#888888>SPACE</FONT></B>
|
||||
</TD>
|
||||
<TD>yanks <FONT COLOR=#FF0000>n</FONT> bytes, beginning at cursor
|
||||
position</TD></TR>
|
||||
<TR><TD><B>yf<FONT COLOR=#FF0000>C</FONT></B></TD>
|
||||
<TD>yanks from current position to next
|
||||
character <FONT COLOR=#FF0000>C</FONT></TD></TR>
|
||||
<TR><TD><B>y/<FONT COLOR=#FF0000>xyz</FONT></B></TD>
|
||||
<TD>yanks from current position to first matching
|
||||
pattern <FONT COLOR=#FF0000>xyz</FONT></TD></TR>
|
||||
<TR><TD><B>y$</B></TD><TD>yanks from current position to EOF</TD></TR>
|
||||
<TR><TD><B>y'<FONT COLOR=#FF0000>a</FONT></B></TD>
|
||||
<TD>yanks from current position to mark <FONT COLOR=#FF0000>a</FONT></TD></TR>
|
||||
<TR><TD><B>y<FONT COLOR=#FF0000>n</FONT>G</B></TD>
|
||||
<TD>yanks from current position to byte with (decimal)
|
||||
address <FONT COLOR=#FF0000>n</FONT></TD></TR>
|
||||
<TR><TD><B><TT>o</B></TT></TD>
|
||||
<TD>overwrites the bytes after the cursor with the contents of the yank
|
||||
or delete buffer</TD></TR>
|
||||
<TR><TD><B><TT>p</B></TT></TD><TD>puts the contents of the yank or delete
|
||||
buffer after the cursor</TD></TR>
|
||||
<TR><TD><B><TT>P</B></TT></TD><TD>appends the contents of the buffer to end
|
||||
of file</TD></TR>
|
||||
</TABLE>
|
||||
|
||||
<H3>Using ex (colon) Commands</H3>
|
||||
<B>:y</B>(ank)
|
||||
<BLOCKQUOTE>
|
||||
<I>yank</I> can be used with one or two addresses specified. One address
|
||||
with no <I>count</I> specified copies the specified byte into the buffer.
|
||||
Two addresses with no <I>count</I> specified copies multiple bytes
|
||||
starting and ending with the specified bytes. Two addresses and a <I>count</I>
|
||||
value copies <I>count</I> bytes starting at the second specified address (the
|
||||
first address is ignored). If no address is specified, the current address
|
||||
ist used by <I>yank</I>.<BR>
|
||||
Examples:
|
||||
<BLOCKQUOTE>
|
||||
:<I>start_addr,end_addr</I> y <FONT COLOR=#888888>RETURN</FONT><BR>
|
||||
:<I>start_addr</I> y <I>byte_count</I><FONT COLOR=#888888>RETURN</FONT><BR>
|
||||
:y <I>byte_count</I><FONT COLOR=#888888>RETURN</FONT><BR>
|
||||
</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
<P>
|
||||
<B>:pu</B>(t)
|
||||
<BLOCKQUOTE>
|
||||
Restores previously deleted or yanked bytes after the address specified
|
||||
in the <I>put</I> command.
|
||||
</BLOCKQUOTE>
|
||||
<P>
|
||||
<B>:o</B>(verwrite)
|
||||
<BLOCKQUOTE>
|
||||
Overwrites bytes after the specified address with previously deleted or yanked
|
||||
bytes.
|
||||
</BLOCKQUOTE>
|
||||
<P>
|
||||
NOTE: There are currently no namend buffers available.
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
199
html/quick.html
Normal file
199
html/quick.html
Normal file
|
@ -0,0 +1,199 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Quick Tutorial</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<font color="#ffffff" class="thl">Quick Tutorial<br></font>
|
||||
<a class="ths" href="qt_edit.html">Editing Files</a><br>
|
||||
<a class="ths" href="qt_search.html">Search Commands</a><br>
|
||||
<a class="ths" href="qt_bit.html">Bit-wise Operations</a><br>
|
||||
<a class="ths" href="qt_find.html">Find and Replace</a><br>
|
||||
<a class="ths" href="qt_yank.html">Yank and Put</a><br>
|
||||
<a class="ths" href="qt_set.html">Settings</a><br>
|
||||
<a class="ths" href="qt_partial.html">Partial File Read</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Quick Tutorial</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
This tutorial will explain all commands which behaves different to
|
||||
vi. Note that, if you are on a Linux system, you will probably
|
||||
have an 'improved' version of vi. Bvi is more similar to the standard
|
||||
version.
|
||||
|
||||
<H3>The Screen</H3>
|
||||
<CENTER>
|
||||
<TABLE WIDTH=10 CELLSPACING=0 CELLPADDING=0 BORDER=0>
|
||||
<TR><TD BGCOLOR=#ffccff><PRE CLASS="examp">
|
||||
000000
|
||||
00000C
|
||||
000018
|
||||
000024
|
||||
000030
|
||||
00003C
|
||||
000048
|
||||
000054
|
||||
000060
|
||||
00006C
|
||||
000078
|
||||
000084
|
||||
000090
|
||||
00009C</PRE></TD><TD BGCOLOR=#ccffcc><PRE CLASS="examp">
|
||||
7F <tt class="inv">4</tt>5 4C 46 01 01
|
||||
00 00 00 00 01 00
|
||||
00 00 00 00 00 00
|
||||
00 00 00 00 34 00
|
||||
0C 00 09 00 00 00
|
||||
00 00 00 00 55 89
|
||||
53 C7 45 A4 00 00
|
||||
00 00 00 83 7D 08
|
||||
8C 02 00 00 E9 6F
|
||||
00 00 00 00 6A 03
|
||||
45 08 50 E8 FC FF
|
||||
0C 85 D2 75 17 6A
|
||||
E9 43 02 00 00 8D
|
||||
0C 85 D2 75 0D C7</PRE></TD><TD BGCOLOR=#ccffcc><PRE CLASS="examp">
|
||||
01 00 00 00 00 00
|
||||
03 00 01 00 00 00
|
||||
00 00 0C 07 00 00
|
||||
00 00 00 00 28 00
|
||||
00 00 00 00 00 00
|
||||
E5 83 EC 68 57 56
|
||||
00 00 C7 45 A0 01
|
||||
00 75 13 6A 00 E8
|
||||
02 00 00 8D B4 26
|
||||
68 90 00 00 00 8B
|
||||
FF FF 89 C2 83 C4
|
||||
01 E8 60 02 00 00
|
||||
74 26 00 8D BC 27
|
||||
45 A0 00 00 00 00</PRE></TD><TD BGCOLOR=#FFCCCC><PRE CLASS="examp">
|
||||
.ELF........
|
||||
............
|
||||
............
|
||||
....4.....(.
|
||||
............
|
||||
....U....hWV
|
||||
S.E......E..
|
||||
....}..u.j..
|
||||
.....o.....&
|
||||
....j.h.....
|
||||
E.P.........
|
||||
...u.j..`...
|
||||
.C....t&...'
|
||||
...u..E.....</PRE></TD></TR>
|
||||
<TR BGCOLOR=#FFFFCC><TD COLSPAN=2 CLASS="examp">"set.o" 3500 bytes</TD>
|
||||
<TD COLSPAN=2 ALIGN=RIGHT CLASS="examp"><B>000001 \105 0x45 69 'E'</B></TD></TR>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
<P>
|
||||
The screen is divided into four areas, symbolized by four different
|
||||
colors. The magenta area contents the addresses in hexadecimal
|
||||
notation. The green area contents the values of the edited file in
|
||||
hexadecimal notation. The red area contents the same bytes in ASCII
|
||||
representation. The yellow status line displays on the left side the
|
||||
current status messages and on the right site the current position
|
||||
of the cursor and the value of the byte on this address in octal,
|
||||
hexadecimal, decimal and ASCII notation.
|
||||
<BR>
|
||||
You can toggle between the Hex and ASCII value of the same byte by
|
||||
pressing the <FONT COLOR=#AAAAAA><B>TAB</B></FONT> key both in command
|
||||
and input mode.
|
||||
|
||||
<H3>Command Line Options</H3>
|
||||
There are some additional command line options in <B>bvi</B>:<BR>
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<B><TT>-f <I>script</I></TT></B>
|
||||
</BLOCKQUOTE>
|
||||
This command provides a means for collecting a series of <I>ex</I>
|
||||
(colon) commands into a script file, then using this file to edit
|
||||
other files. Since there is no binary stream editor <I>bsed</I>, you
|
||||
can use this option to make several global changes in a binary file.
|
||||
You can do this of course with the <i>source</I> command (<B>:so file</B>)
|
||||
from within bvi too.
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<B><TT>-b <I>begin</I></TT></B>
|
||||
</BLOCKQUOTE>
|
||||
This option causes bvi to load a file not from start but from address
|
||||
<I>begin</I>.
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<B><TT>-e <I>end</I></TT></B>
|
||||
</BLOCKQUOTE>
|
||||
This option causes bvi to load a file not till end but till address
|
||||
<I>end</I>.
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<B><TT>-s <I>size</I></TT></B>
|
||||
</BLOCKQUOTE>
|
||||
This option causes bvi not to load the complete file but only <I>size</I>
|
||||
bytes. This option can also be used to read a file reported with a
|
||||
length 0 like some files in the Linux <TT CLASS="examp">/proc</TT>
|
||||
directory.
|
||||
<P>
|
||||
<I>begin, end</I> or <I>size</I> can be an integer value (decimal or
|
||||
hexadecimal) or an integer value with an appended <B>k</B> (for
|
||||
multiply by 1024) or <B>m</B> (for multiply by 1.048.576).
|
||||
<P>
|
||||
You should use at most two of the three address options to avoid ambiguity!
|
||||
|
||||
|
||||
<H3>Not Implemented Commands</H3>
|
||||
<P>
|
||||
<UL>
|
||||
<LI><B><TT>:map</TT></B> and <B><TT>:unmap</TT></B> (Macros)
|
||||
<LI><B><TT>:abbreviate</TT></B> (<B><TT>:ab</TT></B>) and <B><TT>:una</TT></B>
|
||||
<LI>no named buffers.
|
||||
</UL>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Oct 19 20:58:31 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
6
html/rpm.html
Normal file
6
html/rpm.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<HTML><HEAD>
|
||||
<TITLE>Source RPM</TITLE>
|
||||
<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://sites.inka.de/~mips/unix/index.html">
|
||||
</HEAD><BODY BGCOLOR=#ffffff>
|
||||
Switching to <A HREF="http://sites.inka.de/mips/unix/index.html">http://sites.inka.de/mips/unix/index.html</A> . . .
|
||||
</BODY></HTML>
|
116
html/set.html
Normal file
116
html/set.html
Normal file
|
@ -0,0 +1,116 @@
|
|||
<HTML><HEAD>
|
||||
<TITLE>BVI: Set Commands</TITLE>
|
||||
<LINK REL=STYLESHEET TYPE="text/css" HREF="bvi.css">
|
||||
</HEAD><BODY BGCOLOR="#ffffff">
|
||||
<A NAME="top"></A>
|
||||
|
||||
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>
|
||||
<TR><TD WIDTH=99%>
|
||||
<A CLASS=head HREF="overview.html">Command Overview</A>
|
||||
<BR><FONT CLASS=sub>Set Commands</FONT>
|
||||
</TD><TD ALIGN=RIGHT VALIGN=BOTTOM WIDTH=116 ROWSPAN=2>
|
||||
<A HREF="index.html">
|
||||
<IMG SRC="gif/bvi_s.gif" ALT="BVI" WIDTH="116" HEIGHT="62" BORDER=0></A>
|
||||
</TD></TR>
|
||||
<TR><TD VALIGN=BOTTOM>
|
||||
<HR NOSHADE>
|
||||
</TD></TR></TABLE>
|
||||
<P>
|
||||
|
||||
<CENTER>
|
||||
[ <A CLASS="thl" HREF="cursor.html">Cursor Movements</A>
|
||||
| <A CLASS="thl" HREF="edit.html">Edit Cmds</A>
|
||||
| <A CLASS="thl" HREF="yank.html">Yank and Put Cmds</A>
|
||||
| Set Options
|
||||
| <A CLASS="thl" HREF="colon.html">Colon (ex) Cmds</A>
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
<TABLE WIDTH=100%>
|
||||
<TR BGCOLOR=#CCCCCC><TH WIDTH=20%>Command</TH><TH WIDTH=40%>BVI</TH><TH WIDTH=40%>VI</TH></TR>
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Search<BR>settings</TD><TD BGCOLOR=#CCFFCC COLSPAN=2>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD><B>:set wrapscan</B> or <B>:set ws</B><BR>
|
||||
<B>:set nows</B></TD>
|
||||
<TD>When this option is set, pattern searches resulting from a <B>/,
|
||||
?, n, N</B> (<B>#, \</B>) command automatically wrap around to the opposit end of the file
|
||||
and continue whenever the beginning or end of a file is reached.</TD></TR>
|
||||
<TR><TD><B>:set ignorecase</B> or <B>:set ic</B><BR>
|
||||
<B>:set noic</B></TD>
|
||||
<TD>Uppercase and lowercase characters in text are treated identically
|
||||
in regular expression matching</TD></TR>
|
||||
<TR><TD><B>:set magic</B><BR>
|
||||
<B>:set nomagic</B></TD>
|
||||
<TD>Enables metacharacters for use in regular expressions</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>Display<BR>options</TD><TD BGCOLOR=#CCFFCC COLSPAN=2>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD><B>:set showmode</B><BR>
|
||||
<B>:set noshowmode</B></TD>
|
||||
<TD>Displays a status message in the lowest line on the screen</TD></TR>
|
||||
<TR><TD><B>:set terse</B><BR>
|
||||
<B>:set noterse</B></TD>
|
||||
<TD>The terse option lets you obtain shorter error diagnostics.</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>File<BR>options</TD><TD BGCOLOR=#CCFFCC COLSPAN=2>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD><B>:set readonly</B> or <B> :set ro</B><BR>
|
||||
<B>:set noro</B></TD>
|
||||
<TD>This option sets the read-only flag for the file being editeds,
|
||||
thus preventing accidental overwriting at the end of the session.</TD></TR>
|
||||
<TR><TD><B>:set autowrite</B> or <B>:set aw</B><BR>
|
||||
<B>:set noaw</B></TD>
|
||||
<TD>Causes the contents of the buffer to be written to the current file
|
||||
if you have modified them and given a <B>:next, :rewind</B> or <B>!</B>
|
||||
command.</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER>bvi<BR>options</TD>
|
||||
<TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD><B>:set columns=13<BR>:set cm=5</B></TD>
|
||||
<TD>You can set the number of bytes displayed in on screenline.
|
||||
Default is max. number divisible by four.</TD></TR>
|
||||
<TR><TD><B>:set memmove<BR>:set nomm</B></TD>
|
||||
<TD>If memmove is set, you can use commands to insert or delete bytes.
|
||||
This can be dangerous for e.g. executable programs.
|
||||
Default is nomemmove.</TD></TR>
|
||||
<TR><TD><B>:set offset=1<BR>:set of=5</B></TD>
|
||||
<TD>An offset is added to all addresses and byte counts. Default
|
||||
address of the first byte is 0.</TD></TR>
|
||||
<TR><TD><B>:set wordlength=5<BR>:set wl=8</B></TD>
|
||||
<TD>Length of an ASCII-string found by <B>w, W, b</B> or <B>B</B></TD></TR>
|
||||
<TR><TD><B>:set unixstyle<BR>:set nous</B></TD>
|
||||
<TD>displays ASCII characters below 32 in the status line in
|
||||
Unix-style instead of DOS-style</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFCCCC>
|
||||
Not available.
|
||||
</TD></TR>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
<CENTER>
|
||||
[ <A CLASS="thl" HREF="cursor.html">Cursor Movements</A>
|
||||
| <A CLASS="thl" HREF="edit.html">Edit Cmds</A>
|
||||
| <A CLASS="thl" HREF="yank.html">Yank and Put Cmds</A>
|
||||
| Set Options
|
||||
| <A CLASS="thl" HREF="colon.html">Colon (ex) Cmds</A>
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
<FONT SIZE=-1>
|
||||
<A CLASS="btop" HREF="#top"><IMG BORDER=0 WIDTH=16 HEIGHT=7 SRC="gif/up.gif"
|
||||
ALT="Back to the top">Back to the top</A>
|
||||
</FONT>
|
||||
<HR NOSHADE>
|
||||
<I>Last update: October 30<SUP>th</SUP> 1999 by Gerhard Bürgmann</I>
|
||||
|
||||
|
||||
</BODY></HTML>
|
153
html/sitemap.html
Normal file
153
html/sitemap.html
Normal file
|
@ -0,0 +1,153 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">
|
||||
<html><head>
|
||||
<title>BVI: Sitemap</title>
|
||||
<link rel=stylesheet type="text/css" href="bvi.css">
|
||||
</head><body bgcolor="#ffffff" background="gif/bg2.gif">
|
||||
<a name="top"></a>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="1%" valign="top" align="center">
|
||||
<img src="gif/dot.gif" width="130" height="1">
|
||||
|
||||
<hr noshade width="60%">
|
||||
<p>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</p>
|
||||
<p>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</p>
|
||||
<hr noshade width="60%">
|
||||
|
||||
</td>
|
||||
<td width="1%"><img src="gif/dot.gif" width="40" height="1"></td>
|
||||
<td width="99%">
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr><td width="99%">
|
||||
<font class="head">Sitemap</font>
|
||||
</td>
|
||||
<td align="right" valign="bottom" width="116" rowspan="2">
|
||||
<a href="index.html">
|
||||
<img src="gif/bvi_s.gif" alt="BVI" width="116"
|
||||
height="62" border="0"></a>
|
||||
</td></tr>
|
||||
<tr><td valign="bottom">
|
||||
<hr noshade>
|
||||
</td></tr></table>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="thl" href="index.html">Home</a><br>
|
||||
</li>
|
||||
<ul>
|
||||
</ul>
|
||||
<li>
|
||||
<a class="thl" href="quick.html">Quick Tutorial</a><br>
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="thl" href="qt_edit.html">Editing Files</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="qt_search.html">Search Commands</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="qt_bit.html">Bit-wise Operations</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="qt_find.html">Find and Replace</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="qt_yank.html">Yank and Put</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="qt_set.html">Settings</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="qt_partial.html">Partial File Read</a><br>
|
||||
</li>
|
||||
</ul>
|
||||
<li>
|
||||
<a class="thl" href="download.html">Download</a><br>
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="thl" href="new130.html">New in 1.3.0</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="new120.html">New in 1.2.0</a><br>
|
||||
</li>
|
||||
</ul>
|
||||
<li>
|
||||
<a class="thl" href="install.html">Installation</a><br>
|
||||
</li>
|
||||
<ul>
|
||||
</ul>
|
||||
<li>
|
||||
<a class="thl" href="overview.html">Command Overview</a><br>
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="thl" href="cursor.html">Cursor Movement</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="edit.html">Edit Cmds</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="yank.html">Yank and Put Cmds</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="set.html">Set Options</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="colon.html">Colon (ex) Cmds</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="man_bvi.html">man - Page</a><br>
|
||||
</li>
|
||||
</ul>
|
||||
<li>
|
||||
<a class="thl" href="bmore.html">bmore</a><br>
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="thl" href="bmore_cmd.html">Commands</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="bmore_opt.html">Options</a><br>
|
||||
</li>
|
||||
<li>
|
||||
<a class="thl" href="man_bmore.html">man - Page</a><br>
|
||||
</li>
|
||||
</ul>
|
||||
<li>
|
||||
<a class="thl" href="german.html">Deutsche Beschreibung</a><br>
|
||||
</li>
|
||||
<ul>
|
||||
</ul>
|
||||
</ul><p>
|
||||
<p><font size="-1">
|
||||
<a class="btop" href="#top">
|
||||
<img border="0" width="16" height="7" src="gif/up.gif"
|
||||
alt="Back to the top">Back to the top</a>
|
||||
</font>
|
||||
<hr noshade>
|
||||
<i>Last update: Thu Oct 12 20:42:01 CEST 2000 by Gerhard Bürgmann</i>
|
||||
</td></tr></table>
|
||||
</body></html>
|
141
html/yank.html
Normal file
141
html/yank.html
Normal file
|
@ -0,0 +1,141 @@
|
|||
<HTML><HEAD>
|
||||
<TITLE>BVI: Yank and Put Commands</TITLE>
|
||||
<LINK REL=STYLESHEET TYPE="text/css" HREF="bvi.css">
|
||||
</HEAD><BODY BGCOLOR="#ffffff">
|
||||
<A NAME="top"></A>
|
||||
|
||||
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>
|
||||
<TR><TD WIDTH=99%>
|
||||
<A CLASS=head HREF="overview.html">Command Overview</A>
|
||||
<BR><FONT CLASS=sub>Yank and Put Commands</FONT>
|
||||
</TD><TD ALIGN=RIGHT VALIGN=BOTTOM WIDTH=116 ROWSPAN=2>
|
||||
<A HREF="index.html">
|
||||
<IMG SRC="gif/bvi_s.gif" ALT="BVI" WIDTH="116" HEIGHT="62" BORDER=0></A>
|
||||
</TD></TR>
|
||||
<TR><TD VALIGN=BOTTOM>
|
||||
<HR NOSHADE>
|
||||
</TD></TR></TABLE>
|
||||
<P>
|
||||
|
||||
<CENTER>
|
||||
[ <A CLASS="thl" HREF="cursor.html">Cursor Movements</A>
|
||||
| <A CLASS="thl" HREF="edit.html">Edit Cmds</A>
|
||||
| Yank and Put Cmds
|
||||
| <A CLASS="thl" HREF="set.html">Set Options</A>
|
||||
| <A CLASS="thl" HREF="colon.html">Colon (ex) Cmds</A>
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
NOTE: the <B>o</B> command (<I>overwriting put</I>) is the only command in
|
||||
bvi that uses a key for a complete different purpose than in vi.
|
||||
<P>
|
||||
<TABLE WIDTH=100%>
|
||||
<TR BGCOLOR=#CCCCCC><TH WIDTH=20%>Command</TH><TH WIDTH=40%>BVI</TH><TH WIDTH=40%>VI</TH></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER ROWSPAN=3>Put<BR>bytes</TD>
|
||||
<TD COLSPAN=2 BGCOLOR=#CCFFCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> p </TH>
|
||||
<TD>put the contents of the yank or delete buffer after cursor position</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> P </TH><TD>append the contents of the yank or delete buffer at EOF</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> P </TH><TD>put the contents of the yank or delete buffer
|
||||
before cursor position</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> o </TH><TD>overwrite the following bytes with the contents
|
||||
of the yank or delete buffer</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFCCCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD ROWSPAN=2>not available</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#CCCCCC ALIGN=CENTER ROWSPAN=4>Yank<BR>bytes</TD>
|
||||
<TD COLSPAN=2 BGCOLOR=#CCFFCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>y<FONT COLOR=#888888>SPACE</FONT></TH><TD>yank byte at cursor position</TD></TR>
|
||||
<TR><TH>yf<FONT COLOR=#FF0000>C</FONT></TH>
|
||||
<TD>yank from current position to next character <FONT COLOR=#FF0000>C</FONT></TD></TR>
|
||||
<TR><TH>y/<FONT COLOR=#FF0000>xyz</FONT></TH>
|
||||
<TD>yank from current position to matching pattern <FONT COLOR=#FF0000>xyz</FONT>
|
||||
</TD></TR>
|
||||
<TR><TH>y?<FONT COLOR=#FF0000>xyz</FONT></TH>
|
||||
<TD>yank from current position to matching pattern <FONT COLOR=#FF0000>xyz</FONT> in reverse direction
|
||||
</TD></TR>
|
||||
<TR><TH>y'<FONT COLOR=#FF0000>a</FONT></TH><TD>yank from current position to mark <FONT COLOR=#FF0000>a</FONT></TD></TR>
|
||||
<TR><TH>y<FONT COLOR=#FF0000>n</FONT>G</TH><TD>yank from current position to byte with (decimal) address <FONT COLOR=#FF0000>n</FONT></TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
|
||||
<TR><TD BGCOLOR=#FFCCCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD ROWSPAN=2>not available</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>yy </TH><TD>yank line</TD></TR>
|
||||
<TR><TH>y)</TH><TD>yank from cursor position through first
|
||||
following end of sentence</TD></TR>
|
||||
<TR><TH>y}</TH><TD>yank from cursor position through first
|
||||
following end of paragraph</TD></TR>
|
||||
<TR><TH>y]</TH><TD>yank from cursor position through first
|
||||
following end of section</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#FFFFFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH>y\<FONT COLOR=#FF0000>6a 56 ff</FONT> </TH>
|
||||
<TD>yank from cursor position to first occurance of hex pattern
|
||||
<FONT COLOR=#FF0000>6a 56 ff</FONT></TD></TR>
|
||||
<TR><TH>y#<FONT COLOR=#FF0000>6a 56 ff</FONT> </TH>
|
||||
<TD>yank from cursor position to first occurance of hex pattern
|
||||
<FONT COLOR=#FF0000>6a 56 ff</FONT> in reverse direction</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#FFCCCC>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TD ROWSPAN=2>not available</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> y$ </TH><TD>yank from current position to EOF</TD></TR>
|
||||
</TABLE>
|
||||
</TD><TD BGCOLOR=#CCCCFF>
|
||||
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0>
|
||||
<TR><TH> y$ </TH><TD>yank from current position to end of line</TD></TR>
|
||||
</TABLE>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
<P>
|
||||
Note that most of the commands can be used with a decimal repeat count in front
|
||||
of the command!
|
||||
|
||||
<P>
|
||||
<CENTER>
|
||||
[ <A CLASS="thl" HREF="cursor.html">Cursor Movements</A>
|
||||
| <A CLASS="thl" HREF="edit.html">Edit Cmds</A>
|
||||
| Yank and Put Cmds
|
||||
| <A CLASS="thl" HREF="set.html">Set Options</A>
|
||||
| <A CLASS="thl" HREF="colon.html">Colon (ex) Cmds</A>
|
||||
]
|
||||
</CENTER>
|
||||
<P>
|
||||
<FONT SIZE=-1>
|
||||
<A CLASS="btop" HREF="#top"><IMG BORDER=0 WIDTH=16 HEIGHT=7 SRC="gif/up.gif"
|
||||
ALT="Back to the top">Back to the top</A>
|
||||
</FONT>
|
||||
<HR NOSHADE>
|
||||
<I>Last update: October 30<SUP>th</SUP> 1999 by Gerhard Bürgmann</I>
|
||||
|
||||
|
||||
</BODY></HTML>
|
238
install-sh
Executable file
238
install-sh
Executable file
|
@ -0,0 +1,238 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
tranformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
411
io.c
Normal file
411
io.c
Normal file
|
@ -0,0 +1,411 @@
|
|||
/* IO.C - file in/out and alloc subroutines for BVI
|
||||
*
|
||||
* 1996-02-28 V 1.0.0
|
||||
* 1999-01-20 V 1.1.0
|
||||
* 1999-04-27 V 1.1.1
|
||||
* 1999-07-02 V 1.2.0 beta
|
||||
* 1999-10-15 V 1.2.0 final
|
||||
* 2000-03-23 V 1.3.0 beta
|
||||
* 2000-08-17 V 1.3.0 final
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include "bvi.h"
|
||||
#include "set.h"
|
||||
|
||||
#include <limits.h>
|
||||
#ifndef SIZE_T_MAX
|
||||
# define SIZE_T_MAX ULONG_MAX
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
int filemode;
|
||||
static struct stat buf;
|
||||
static off_t block_read;
|
||||
char *terminal;
|
||||
|
||||
|
||||
/*********** Save the patched file ********************/
|
||||
int
|
||||
save(fname, start, end, flags)
|
||||
char *fname;
|
||||
char *start;
|
||||
char *end;
|
||||
int flags;
|
||||
{
|
||||
int fd;
|
||||
char string[255];
|
||||
char *newstr;
|
||||
off_t filesize;
|
||||
|
||||
if (!fname) {
|
||||
emsg("No file|No current filename");
|
||||
return 0;
|
||||
}
|
||||
if (stat(fname, &buf) == -1) {
|
||||
newstr = "[New file] ";
|
||||
} else {
|
||||
if (S_ISDIR(buf.st_mode)) {
|
||||
sprintf(string, "\"%s\" Is a directory", fname);
|
||||
msg(string);
|
||||
return 0;
|
||||
} else if (S_ISCHR(buf.st_mode)) {
|
||||
sprintf(string, "\"%s\" Character special file", fname);
|
||||
msg(string);
|
||||
return 0;
|
||||
} else if (S_ISBLK(buf.st_mode)) {
|
||||
/*
|
||||
sprintf(string, "\"%s\" Block special file", fname);
|
||||
msg(string);
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
newstr = "";
|
||||
}
|
||||
|
||||
if (filemode == PARTIAL) flags = O_RDWR;
|
||||
if ((fd = open(fname, flags, 0666)) < 0) {
|
||||
sysemsg(fname);
|
||||
return 0;
|
||||
}
|
||||
if (filemode == PARTIAL) {
|
||||
if (block_read) {
|
||||
filesize = block_read;
|
||||
sprintf(string, "\"%s\" range %lu-%lu", fname,
|
||||
(unsigned long)block_begin,
|
||||
(unsigned long)(block_begin - 1 + filesize));
|
||||
if (lseek(fd, block_begin, SEEK_SET) < 0) {
|
||||
sysemsg(fname);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
msg("Null range");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
filesize = end - start + 1L;
|
||||
sprintf(string, "\"%s\" %s%lu bytes", fname, newstr,
|
||||
(unsigned long)filesize);
|
||||
}
|
||||
|
||||
if (write(fd, start, filesize) != filesize) {
|
||||
sysemsg(fname);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
close(fd);
|
||||
edits = 0;
|
||||
msg(string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* loads a file, returns the filesize */
|
||||
off_t
|
||||
load(fname)
|
||||
char *fname;
|
||||
{
|
||||
int fd = -1;
|
||||
char string[MAXCMD];
|
||||
|
||||
buf.st_size = 0L;
|
||||
if (fname != NULL) {
|
||||
sprintf(string, "\"%s\"", fname);
|
||||
msg(string);
|
||||
refresh();
|
||||
if (stat(fname, &buf) == -1) {
|
||||
filemode = NEW;
|
||||
} else if (S_ISDIR(buf.st_mode)) {
|
||||
filemode = DIRECTORY;
|
||||
} else if (S_ISCHR(buf.st_mode)) {
|
||||
filemode = CHARACTER_SPECIAL;
|
||||
} else if (S_ISBLK(buf.st_mode)) {
|
||||
filemode = BLOCK_SPECIAL;
|
||||
if (!block_flag) {
|
||||
block_flag = 1;
|
||||
block_begin = 0;
|
||||
block_size = 1024;
|
||||
block_end = block_begin + block_size - 1;
|
||||
}
|
||||
if ((fd = open(fname, O_RDONLY)) > 0) {
|
||||
P(P_RO) = TRUE;
|
||||
params[P_RO].flags |= P_CHANGED;
|
||||
} else {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
}
|
||||
} else if (S_ISREG(buf.st_mode)) {
|
||||
if ((unsigned long)buf.st_size > (unsigned long)SIZE_T_MAX) {
|
||||
move(maxy, 0);
|
||||
endwin();
|
||||
printf("File too large\n");
|
||||
exit(0);
|
||||
}
|
||||
if ((fd = open(fname, O_RDONLY)) > 0) {
|
||||
filemode = REGULAR;
|
||||
if (access(fname, W_OK)) {
|
||||
P(P_RO) = TRUE;
|
||||
params[P_RO].flags |= P_CHANGED;
|
||||
}
|
||||
} else {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
filemode = NEW;
|
||||
}
|
||||
if (mem != NULL) free(mem);
|
||||
memsize = 1024;
|
||||
if (block_flag) {
|
||||
memsize += block_size;
|
||||
} else if (filemode == REGULAR) {
|
||||
memsize += buf.st_size;
|
||||
}
|
||||
if ((mem = (char *)malloc(memsize)) == NULL) {
|
||||
move(maxy, 0);
|
||||
endwin();
|
||||
printf("Out of memory\n");
|
||||
exit(0);
|
||||
}
|
||||
clear_marks();
|
||||
|
||||
|
||||
if (block_flag && ((filemode == REGULAR) || (filemode == BLOCK_SPECIAL))) {
|
||||
if (lseek(fd, block_begin, SEEK_SET) < 0) {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
} else {
|
||||
if ((filesize = read(fd, mem, block_size)) == 0) {
|
||||
sprintf(string, "\"%s\" Empty file", fname);
|
||||
filemode = ERROR;
|
||||
} else {
|
||||
sprintf(string, "\"%s\" range %lu-%lu", fname,
|
||||
(unsigned long)block_begin,
|
||||
(unsigned long)(block_begin + filesize - 1));
|
||||
filemode = PARTIAL;
|
||||
block_read = filesize;
|
||||
P(P_OF) = block_begin;
|
||||
params[P_OF].flags |= P_CHANGED;
|
||||
}
|
||||
msg(string);
|
||||
refresh();
|
||||
}
|
||||
} else if (filemode == REGULAR) {
|
||||
filesize = buf.st_size;
|
||||
if (read(fd, mem, filesize) != filesize) {
|
||||
sysemsg(fname);
|
||||
filemode = ERROR;
|
||||
}
|
||||
} else {
|
||||
filesize = 0L;
|
||||
}
|
||||
if (fd > 0) close(fd);
|
||||
if (fname != NULL) {
|
||||
switch (filemode) {
|
||||
case NEW:
|
||||
sprintf(string, "\"%s\" [New File]", fname);
|
||||
break;
|
||||
case REGULAR:
|
||||
sprintf(string, "\"%s\" %s%lu bytes", fname,
|
||||
P(P_RO) ? "[Read only] " : "",
|
||||
(unsigned long)filesize);
|
||||
break;
|
||||
case DIRECTORY:
|
||||
sprintf(string, "\"%s\" Directory", fname);
|
||||
break;
|
||||
case CHARACTER_SPECIAL:
|
||||
sprintf(string, "\"%s\" Character special file", fname);
|
||||
break;
|
||||
case BLOCK_SPECIAL:
|
||||
sprintf(string, "\"%s\" Block special file", fname);
|
||||
break;
|
||||
}
|
||||
if (filemode != ERROR) msg(string);
|
||||
}
|
||||
pagepos = mem;
|
||||
maxpos = mem + filesize;
|
||||
loc = HEX;
|
||||
x = AnzAdd; y = 0;
|
||||
repaint();
|
||||
return(filesize);
|
||||
}
|
||||
|
||||
|
||||
/* argument "dir" not used!
|
||||
* Needed for DOS version only
|
||||
*/
|
||||
void
|
||||
bvi_init(dir)
|
||||
char *dir;
|
||||
{
|
||||
char *initstr;
|
||||
char rcpath[MAXCMD];
|
||||
|
||||
terminal = getenv("TERM");
|
||||
shell = getenv("SHELL");
|
||||
if (shell == NULL || *shell == '\0')
|
||||
shell = "/bin/sh";
|
||||
|
||||
if ((initstr = getenv("BVIINIT")) != NULL) {
|
||||
docmdline(initstr);
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(rcpath, getenv("HOME"), MAXCMD - 8);
|
||||
rcpath[MAXCMD - 8] = '\0';
|
||||
strcat(rcpath, "/.bvirc");
|
||||
if (stat(rcpath, &buf) == 0) {
|
||||
if (buf.st_uid == getuid()) read_rc(rcpath);
|
||||
}
|
||||
|
||||
strcpy(rcpath, ".bvirc");
|
||||
if (stat(rcpath, &buf) == 0) {
|
||||
if (buf.st_uid == getuid()) read_rc(rcpath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
enlarge(add)
|
||||
off_t add;
|
||||
{
|
||||
char *newmem;
|
||||
off_t savecur, savepag, savemax, saveundo;
|
||||
|
||||
savecur = curpos - mem;
|
||||
savepag = pagepos - mem;
|
||||
savemax = maxpos - mem;
|
||||
saveundo = undo_start - mem;
|
||||
|
||||
if (mem == NULL) {
|
||||
newmem = malloc(memsize + add);
|
||||
} else {
|
||||
newmem = realloc(mem, memsize + add);
|
||||
}
|
||||
if (newmem == NULL) {
|
||||
emsg("Out of memory");
|
||||
return 1;
|
||||
}
|
||||
|
||||
mem = newmem;
|
||||
memsize += add;
|
||||
curpos = mem + savecur;
|
||||
pagepos = mem + savepag;
|
||||
maxpos = mem + savemax;
|
||||
undo_start = mem + saveundo;
|
||||
current = curpos + 1L;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
do_shell()
|
||||
{
|
||||
addch('\n');
|
||||
savetty();
|
||||
system(shell);
|
||||
resetty();
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *
|
||||
strdup(s)
|
||||
char *s;
|
||||
{
|
||||
char *p;
|
||||
size_t n;
|
||||
|
||||
n = strlen(s) + 1;
|
||||
if ((p = (char *)malloc(n)) != NULL)
|
||||
memcpy(p, s, n);
|
||||
return (p);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
/*
|
||||
* Copy contents of memory (with possible overlapping).
|
||||
*/
|
||||
char *
|
||||
memmove(s1, s2, n)
|
||||
char *s1;
|
||||
char *s2;
|
||||
size_t n;
|
||||
{
|
||||
bcopy(s2, s1, n);
|
||||
return(s1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
off_t
|
||||
alloc_buf(n, buffer)
|
||||
off_t n;
|
||||
char **buffer;
|
||||
{
|
||||
if (*buffer == NULL) {
|
||||
*buffer = (char *)malloc(n);
|
||||
} else {
|
||||
*buffer = (char *)realloc(*buffer, n);
|
||||
}
|
||||
if (*buffer == NULL) {
|
||||
emsg("No buffer space available");
|
||||
return 0L;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
addfile(fname)
|
||||
char *fname;
|
||||
{
|
||||
int fd;
|
||||
off_t oldsize;
|
||||
|
||||
if (stat(fname, &buf)) {
|
||||
sysemsg(fname);
|
||||
return 1;
|
||||
}
|
||||
if ((fd = open(fname, O_RDONLY)) == -1) {
|
||||
sysemsg(fname);
|
||||
return 1;
|
||||
}
|
||||
oldsize = filesize;
|
||||
if (enlarge(buf.st_size)) return 1;
|
||||
if (read(fd, mem + filesize, buf.st_size) == -1) {
|
||||
sysemsg(fname);
|
||||
return 1;
|
||||
}
|
||||
filesize += buf.st_size;
|
||||
maxpos = mem + filesize;
|
||||
close(fd);
|
||||
setpage(mem + oldsize);
|
||||
return 0;
|
||||
}
|
38
mkinstalldirs
Executable file
38
mkinstalldirs
Executable file
|
@ -0,0 +1,38 @@
|
|||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
# $Id: mkinstalldirs,v 1.12.2.1 1998/12/26 17:32:14 bje Exp $
|
||||
|
||||
errstatus=0
|
||||
|
||||
for file
|
||||
do
|
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
||||
shift
|
||||
|
||||
pathcomp=
|
||||
for d
|
||||
do
|
||||
pathcomp="$pathcomp$d"
|
||||
case "$pathcomp" in
|
||||
-* ) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp"
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp="$pathcomp/"
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
1
patchlevel.h
Normal file
1
patchlevel.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define VERSION "1.3.0"
|
640
re.c
Normal file
640
re.c
Normal file
|
@ -0,0 +1,640 @@
|
|||
/* re - regular expression search for bvi
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* 1996-01-06 created;
|
||||
* 1999-01-19 V 1.1.0
|
||||
* 1999-03-17 V 1.1.1
|
||||
* 1999-09-10 V 1.2.0
|
||||
* 2000-04-25 V 1.3.0 beta
|
||||
* 2000-09-29 V 1.3.0 final
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
/* You cannot use a common regexp subroutine, because \0 is a regular
|
||||
* character in a binary string !
|
||||
*/
|
||||
|
||||
#include "bvi.h"
|
||||
#include "set.h"
|
||||
|
||||
static int sbracket();
|
||||
|
||||
char act_pat[MAXCMD]; /* found pattern */
|
||||
char pattern[MAXCMD + 1];
|
||||
char search_pat[BUFFER]; /* / or ? command */
|
||||
char *notfound = "Fail|Pattern not found";
|
||||
char *noprev = "No previous expression";
|
||||
char *emptyclass = "Bad character class|Empty byte class '[]' or '[^]' cannot match";
|
||||
|
||||
|
||||
|
||||
int
|
||||
bregexec(start, scan)
|
||||
PTR start;
|
||||
char *scan;
|
||||
{
|
||||
char *act;
|
||||
int count, test;
|
||||
|
||||
act = act_pat;
|
||||
while (*scan != 0) {
|
||||
switch (*scan++) {
|
||||
case ONE: /* exactly one character */
|
||||
count = *scan++;
|
||||
if (P(P_IC) && smode == ASCII) test = toupper(*start);
|
||||
else test = *start;
|
||||
if (count == 1) {
|
||||
if (test != *scan) return 0;
|
||||
scan++;
|
||||
} else if (count > 1) {
|
||||
if (sbracket(test, scan, count)) return 0;
|
||||
scan += count;
|
||||
}
|
||||
*act++ = *start++;
|
||||
break;
|
||||
case STAR: /* zero or more characters */
|
||||
count = *scan++;
|
||||
if (P(P_IC) && smode == ASCII) test = toupper(*start);
|
||||
else test = *start;
|
||||
if (count == 1) { /* only one character, 0 - n times */
|
||||
while(test == *scan) {
|
||||
*act++ = *start++;
|
||||
if (P(P_IC) && smode == ASCII) test = toupper(*start);
|
||||
else test = *start;
|
||||
}
|
||||
scan++;
|
||||
} else if (count > 1) { /* characters in bracket */
|
||||
if (*scan == '^') {
|
||||
while (start < maxpos) {
|
||||
if (bregexec(start, scan + count)) {
|
||||
*act = '\0';
|
||||
return 1;
|
||||
}
|
||||
if (sbracket(test, scan, count)) return 0;
|
||||
*act++ = *start++;
|
||||
if (P(P_IC) && smode == ASCII) test = toupper(*start);
|
||||
else test = *start;
|
||||
}
|
||||
} else {
|
||||
while(!sbracket(test, scan, count)) {
|
||||
*act++ = *start++;
|
||||
if (P(P_IC) && smode == ASCII) test = toupper(*start);
|
||||
else test = *start;
|
||||
}
|
||||
scan += count;
|
||||
}
|
||||
} else { /* ".*" */
|
||||
while (start < maxpos) {
|
||||
if (bregexec(start, scan)) { *act = '\0'; return 1; }
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*act = '\0';
|
||||
return 1; /* found */
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sbracket(start, scan, count)
|
||||
int start;
|
||||
char *scan;
|
||||
int count;
|
||||
{
|
||||
if (*scan++ == '^') {
|
||||
if (!memchr(scan, start, --count)) return 0;
|
||||
} else {
|
||||
if (memchr(scan, start, --count)) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
PTR
|
||||
end_word(start)
|
||||
PTR start;
|
||||
{
|
||||
PTR pos;
|
||||
|
||||
pos = start;
|
||||
if (!isprint(*pos & 0xff)) return start;
|
||||
while (isprint(*pos & 0xff)) if (pos++ > maxpos) return start;
|
||||
return --pos;
|
||||
}
|
||||
|
||||
|
||||
/* wordsearch serves the 'W' and 'w' - command
|
||||
*/
|
||||
PTR
|
||||
wordsearch(start, mode)
|
||||
PTR start;
|
||||
char mode;
|
||||
{
|
||||
PTR found;
|
||||
PTR pos;
|
||||
int ccount;
|
||||
|
||||
pos = start + 1;
|
||||
do {
|
||||
while (isprint(*pos & 0xff)) if (pos++ > maxpos) return start;
|
||||
while (!isprint(*pos & 0xff)) if (pos++ > maxpos) return start;
|
||||
found = pos;
|
||||
ccount = 0;
|
||||
while (isprint(*pos & 0xff)) {
|
||||
if (pos++ > maxpos) return start;
|
||||
ccount++; }
|
||||
if (ccount < P(P_WL)) continue;
|
||||
|
||||
if (mode == 'W') {
|
||||
if (*pos == '\0' || *pos == '\n') return found;
|
||||
} else {
|
||||
return found;
|
||||
}
|
||||
} while (pos < maxpos);
|
||||
return start;
|
||||
}
|
||||
|
||||
|
||||
/* backsearch serves the 'b' and 'B' command
|
||||
*/
|
||||
PTR
|
||||
backsearch(start, mode)
|
||||
PTR start;
|
||||
char mode;
|
||||
{
|
||||
PTR pos;
|
||||
int ccount;
|
||||
|
||||
pos = start - 1;
|
||||
do {
|
||||
if (mode == 'B') {
|
||||
while (*pos != '\0' && *pos != '\n') if (pos-- < mem) return start;
|
||||
} else {
|
||||
while (!isprint(*pos & 0xff)) if (pos-- < mem) return start;
|
||||
}
|
||||
pos--;
|
||||
ccount = 0;
|
||||
while (isprint(*pos & 0xff)) {
|
||||
if (pos-- < mem) return start;
|
||||
ccount++; }
|
||||
if (ccount >= P(P_WL)) return (pos + 1);
|
||||
|
||||
} while (pos > mem);
|
||||
return start;
|
||||
}
|
||||
|
||||
|
||||
/* used by :s
|
||||
*/
|
||||
int
|
||||
do_substitution(delim, line, startpos, endpos)
|
||||
int delim;
|
||||
char *line;
|
||||
PTR startpos;
|
||||
PTR endpos;
|
||||
{
|
||||
int n;
|
||||
char *found;
|
||||
char *cmd = NULL;
|
||||
int repl_count = 0;
|
||||
int global = 0;
|
||||
int conf = 0;
|
||||
static int direct;
|
||||
static int pat_len = -1;
|
||||
static int ch;
|
||||
static char find_pat[BUFFER];
|
||||
static char repl_pat[MAXCMD];
|
||||
|
||||
ignore_case = P(P_IC);
|
||||
magic = P(P_MA);
|
||||
switch (delim) {
|
||||
case '/':
|
||||
case '?':
|
||||
ch = delim;
|
||||
direct = (ch == '/' ? FORWARD : BACKWARD);
|
||||
cmd = patcpy(pattern, line, ch);
|
||||
if (pattern[0] == '\0') break;
|
||||
if (ascii_comp(find_pat, pattern)) return 0;
|
||||
cmd = patcpy(pattern, cmd, ch); /* Replace Pattern */
|
||||
poi = pattern;
|
||||
pat_len = 0;
|
||||
while (*poi) {
|
||||
if (*poi == '\\') {
|
||||
switch (*(++poi)) {
|
||||
case '0': repl_pat[pat_len++] = '\0'; break;
|
||||
case 'n': repl_pat[pat_len++] = '\n'; break;
|
||||
case 'r': repl_pat[pat_len++] = '\r'; break;
|
||||
case 't': repl_pat[pat_len++] = '\t'; break;
|
||||
case '\\': repl_pat[pat_len++] = '\\'; break;
|
||||
default: sprintf(string,
|
||||
"No such escape sequence \\%c", *poi);
|
||||
emsg(string);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
repl_pat[pat_len++] = *poi;
|
||||
}
|
||||
poi++;
|
||||
}
|
||||
break;
|
||||
case '#':
|
||||
case '\\':
|
||||
ch = delim;
|
||||
direct = (ch == '\\' ? FORWARD : BACKWARD);
|
||||
cmd = patcpy(pattern, line, ch);
|
||||
if (hex_comp(find_pat, pattern)) return 0;
|
||||
cmd = patcpy(pattern, cmd, ch); /* Replace Pattern */
|
||||
poi = pattern;
|
||||
pat_len = 0;
|
||||
while (*poi) {
|
||||
if (*poi == ' ' || *poi == '\t') {
|
||||
poi++;
|
||||
} else {
|
||||
if ((n = hexchar()) < 0) {
|
||||
emsg("Badly formed replacement pattern");
|
||||
return 0; }
|
||||
repl_pat[pat_len] = n;
|
||||
pat_len++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '\0':
|
||||
case 'g':
|
||||
case 'c':
|
||||
break;
|
||||
default:
|
||||
emsg("Extra chars|Extra characters at end of command");
|
||||
return -1;
|
||||
}
|
||||
if (pat_len == -1) {
|
||||
emsg("No previous substitute re|No previous substitute to repeat");
|
||||
return -1;
|
||||
}
|
||||
if (delim != '\0') {
|
||||
if (strchr(cmd, 'g')) global = 1;
|
||||
if (strchr(cmd, 'c')) conf = 1;
|
||||
}
|
||||
if ((strchr("\\#", ch) && loc == ASCII)
|
||||
|| (strchr("/?", ch) && loc == HEX))
|
||||
toggle();
|
||||
|
||||
startpos--;
|
||||
move(maxy, 0);
|
||||
refresh();
|
||||
|
||||
if (global) {
|
||||
if ((undo_count = alloc_buf(endpos - startpos, &undo_buf))) {
|
||||
memcpy(undo_buf, startpos + 1, undo_count);
|
||||
}
|
||||
undo_start = startpos + 1;
|
||||
edits = U_EDIT;
|
||||
}
|
||||
|
||||
AGAIN:
|
||||
if (direct == FORWARD) {
|
||||
found = fsearch(startpos + 1, endpos, find_pat);
|
||||
} else {
|
||||
found = rsearch(startpos - 1, mem, find_pat);
|
||||
}
|
||||
if (!found) {
|
||||
if (!repl_count) {
|
||||
if (P(P_WS)) {
|
||||
emsg(notfound);
|
||||
} else {
|
||||
if (P(P_TE))
|
||||
sprintf(string, "No match to %s", direct == FORWARD ? "BOTTOM" : "TOP");
|
||||
else
|
||||
sprintf(string, "Address search hit %s without matching pattern",
|
||||
direct == FORWARD ? "BOTTOM" : "TOP");
|
||||
emsg(string);
|
||||
}
|
||||
}
|
||||
return repl_count;
|
||||
} else {
|
||||
setpage(found);
|
||||
if (conf) {
|
||||
repaint();
|
||||
msg("Replace?");
|
||||
move(y, x);
|
||||
if (vgetc() != 'y') goto SKIP;
|
||||
}
|
||||
repl_count++;
|
||||
current_start = pagepos + y * Anzahl + xpos();
|
||||
if (!global) {
|
||||
if ((undo_count = alloc_buf(pat_len, &undo_buf))) {
|
||||
memcpy(undo_buf, current_start, undo_count);
|
||||
}
|
||||
undo_start = current_start;
|
||||
edits = U_EDIT;
|
||||
}
|
||||
memcpy(current_start, repl_pat, pat_len);
|
||||
SKIP:
|
||||
if (global) {
|
||||
startpos = found + pat_len - 1;
|
||||
goto AGAIN;
|
||||
}
|
||||
}
|
||||
return repl_count;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Used by /, ?, \, #, n or N command
|
||||
* ch is this command
|
||||
* line are the characters after
|
||||
*
|
||||
* return address found
|
||||
*/
|
||||
PTR
|
||||
searching(ch, line, startpos, endpos, flag)
|
||||
int ch;
|
||||
char *line;
|
||||
PTR startpos;
|
||||
PTR endpos;
|
||||
int flag;
|
||||
{
|
||||
char *cmd = NULL;
|
||||
PTR found;
|
||||
int sdir;
|
||||
static char m[2];
|
||||
static int direct;
|
||||
|
||||
if (line[0] == '\0' && again == 0) {
|
||||
emsg(noprev);
|
||||
return 0L; }
|
||||
|
||||
ignore_case = (P(P_IC));
|
||||
magic = P(P_MA);
|
||||
start_addr--;
|
||||
if ((strchr("\\#", ch) && loc == ASCII)
|
||||
|| (strchr("/?", ch) && loc == HEX))
|
||||
toggle();
|
||||
|
||||
if (!strchr("Nn", ch)) {
|
||||
m[0] = ch;
|
||||
m[1] = '\0';
|
||||
switch (ch) {
|
||||
case '/':
|
||||
case '?':
|
||||
direct = (ch == '/' ? FORWARD : BACKWARD);
|
||||
cmd = patcpy(pattern, line, ch);
|
||||
if (pattern[0] != '\0') {
|
||||
if (ascii_comp(search_pat, pattern)) return 0L;
|
||||
again = 1;
|
||||
}
|
||||
break;
|
||||
case '#':
|
||||
case '\\':
|
||||
direct = (ch == '\\' ? FORWARD : BACKWARD);
|
||||
cmd = patcpy(pattern, line, ch);
|
||||
if (pattern[0] != '\0') {
|
||||
if (hex_comp(search_pat, pattern)) break;
|
||||
again = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!again) return 0L;
|
||||
} else {
|
||||
cmd = "";
|
||||
msg(m);
|
||||
}
|
||||
move(maxy, 0);
|
||||
refresh();
|
||||
sdir = (ch == 'N') ? !direct : direct;
|
||||
|
||||
if (sdir == FORWARD) {
|
||||
found = fsearch(startpos + 1, endpos, search_pat);
|
||||
if (flag & S_GLOBAL) return(found);
|
||||
if (!found)
|
||||
if (flag & 1) {
|
||||
msg("Search wrapped BOTTOM|Search wrapped around BOTTOM of buffer");
|
||||
found = fsearch(mem, startpos, search_pat);
|
||||
}
|
||||
} else {
|
||||
found = rsearch(startpos - 1, mem, search_pat);
|
||||
if (flag & S_GLOBAL) return(found);
|
||||
if (!found)
|
||||
if (flag & 1) {
|
||||
msg("Search wrapped TOP|Search wrapped around TOP of buffer");
|
||||
found = rsearch(endpos, startpos, search_pat);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (flag & 1) {
|
||||
emsg(notfound);
|
||||
} else {
|
||||
if (P(P_TE))
|
||||
sprintf(string, "No match to %s", sdir == FORWARD ? "BOTTOM" : "TOP");
|
||||
else
|
||||
sprintf(string, "Address search hit %s without matching pattern",
|
||||
sdir == FORWARD ? "BOTTOM" : "TOP");
|
||||
emsg(string);
|
||||
}
|
||||
} else {
|
||||
setpage(found);
|
||||
if (cmd) {
|
||||
switch(*cmd) {
|
||||
case 'z': do_z(*++cmd);
|
||||
break;
|
||||
case 's': do_substitution(ch, cmd + 2, found, endpos);
|
||||
repaint();
|
||||
break;
|
||||
case ';': searching(*(cmd + 1), cmd + 2, found, maxpos - 1, flag);
|
||||
case '\0': break;
|
||||
default: beep();
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
/* Copies a string from s2 to s1, up to delim or 0
|
||||
* returns pointer to next character
|
||||
*/
|
||||
char *
|
||||
patcpy(s1, s2, delim)
|
||||
char *s1, *s2;
|
||||
char delim;
|
||||
{
|
||||
while (*s2 != '\0' && *s2 != delim) {
|
||||
if (*s2 == '\\' && *(s2 + 1) == delim) s2++;
|
||||
*s1++ = *s2++;
|
||||
}
|
||||
*s1 = '\0';
|
||||
if (*s2 == delim) s2++;
|
||||
return s2;
|
||||
}
|
||||
|
||||
|
||||
PTR
|
||||
fsearch(start, end, smem)
|
||||
PTR start;
|
||||
PTR end;
|
||||
char *smem;
|
||||
{
|
||||
PTR spos;
|
||||
|
||||
signal(SIGINT, jmpproc);
|
||||
for (spos = start; spos <= end; spos++) {
|
||||
if (bregexec(spos, smem)) {
|
||||
signal(SIGINT, SIG_IGN);
|
||||
return(spos);
|
||||
}
|
||||
}
|
||||
signal(SIGINT, SIG_IGN);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
PTR
|
||||
rsearch(start, end, smem)
|
||||
PTR start;
|
||||
PTR end;
|
||||
char *smem;
|
||||
{
|
||||
PTR spos;
|
||||
|
||||
signal(SIGINT, jmpproc);
|
||||
for (spos = start; spos >= end; spos--) {
|
||||
if (bregexec(spos, smem)) {
|
||||
signal(SIGINT, SIG_IGN);
|
||||
return(spos);
|
||||
}
|
||||
}
|
||||
signal(SIGINT, SIG_IGN);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Calculates an address of a colon command
|
||||
* returns NULL on error or default_address, if nothing found
|
||||
*/
|
||||
PTR
|
||||
calc_addr(pointer, def_addr)
|
||||
char **pointer;
|
||||
PTR def_addr;
|
||||
{
|
||||
PTR addr;
|
||||
int ch, mark;
|
||||
char *cmd;
|
||||
|
||||
cmd = *pointer;
|
||||
addr = def_addr;
|
||||
SKIP_WHITE
|
||||
if (*cmd >= '1' && *cmd <= '9') {
|
||||
addr = mem + strtol(cmd, &cmd, 10) - P(P_OF);
|
||||
} else {
|
||||
ch = *cmd;
|
||||
switch (ch) {
|
||||
case '.': /* Current position */
|
||||
addr = current;
|
||||
cmd++;
|
||||
break;
|
||||
case '^':
|
||||
addr = mem;
|
||||
cmd++;
|
||||
break;
|
||||
case '$':
|
||||
addr = maxpos - 1;
|
||||
cmd++;
|
||||
break;
|
||||
case '\'': /* Mark */
|
||||
mark = (*++cmd);
|
||||
if (mark == '\'') {
|
||||
addr = last_motion;
|
||||
cmd++;
|
||||
break;
|
||||
} else if (mark < 'a' || mark > 'z') {
|
||||
emsg("Marks are ' and a-z");
|
||||
return NULL;
|
||||
}
|
||||
if (markbuf[mark - 'a'] == NULL) {
|
||||
emsg("Mark not defined");
|
||||
return NULL;
|
||||
}
|
||||
addr = markbuf[mark - 'a'];
|
||||
cmd++;
|
||||
break;
|
||||
case '\\':
|
||||
case '/':
|
||||
cmd = patcpy(pattern, cmd + 1, ch);
|
||||
if (pattern[0] == '\0' && again == 0) {
|
||||
emsg(noprev);
|
||||
return NULL;
|
||||
}
|
||||
if (pattern[0] != '\0') {
|
||||
again = 1;
|
||||
if (ch == '/') {
|
||||
if (ascii_comp(search_pat, pattern)) return NULL;
|
||||
} else {
|
||||
if (hex_comp(search_pat, pattern)) return NULL;
|
||||
}
|
||||
}
|
||||
addr = fsearch(mem, maxpos - 1, search_pat);
|
||||
break;
|
||||
case '#':
|
||||
case '?':
|
||||
cmd = patcpy(pattern, cmd + 1, ch);
|
||||
if (pattern[0] == '\0' && again == 0) {
|
||||
emsg(noprev);
|
||||
return NULL;
|
||||
}
|
||||
if (pattern[0] != '\0') {
|
||||
again = 1;
|
||||
if (ch == '?') {
|
||||
if (ascii_comp(search_pat, pattern)) return NULL;
|
||||
} else {
|
||||
if (hex_comp(search_pat, pattern)) return NULL;
|
||||
}
|
||||
}
|
||||
addr = rsearch(maxpos - 1, mem, search_pat);
|
||||
break;
|
||||
case '0':
|
||||
addr = mem + strtol(cmd, &cmd, 16) - P(P_OF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
SKIP_WHITE
|
||||
while (*cmd == '+' || *cmd == '-') {
|
||||
if (*cmd == '+') {
|
||||
cmd++;
|
||||
SKIP_WHITE
|
||||
if (*cmd >= '1' && *cmd <= '9') {
|
||||
addr += strtol(cmd, &cmd, 10);
|
||||
} else if (*cmd == '0') {
|
||||
addr += strtol(cmd, &cmd, 16);
|
||||
}
|
||||
} else {
|
||||
cmd++;
|
||||
SKIP_WHITE
|
||||
if (*cmd >= '1' && *cmd <= '9') {
|
||||
addr -= strtol(cmd, &cmd, 10);
|
||||
} else if (*cmd == '0') {
|
||||
addr -= strtol(cmd, &cmd, 16);
|
||||
}
|
||||
}
|
||||
SKIP_WHITE
|
||||
}
|
||||
if (*pointer != cmd) {
|
||||
*pointer = cmd;
|
||||
addr_flag++;
|
||||
}
|
||||
return addr;
|
||||
}
|
279
recomp.c
Normal file
279
recomp.c
Normal file
|
@ -0,0 +1,279 @@
|
|||
/* recomp - regular expression compiler
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* 1996-01-06 created;
|
||||
* 2000-04-25 V 1.3.0 beta
|
||||
* 2000-07-12 V 1.3.0 final
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
/* You cannot use a common regexp subroutine, because \0 is a regular
|
||||
* character in a binary string !
|
||||
*/
|
||||
|
||||
|
||||
#include "bvi.h"
|
||||
#include "set.h"
|
||||
|
||||
|
||||
char *poi;
|
||||
int smode;
|
||||
int again = 0;
|
||||
int magic = 1;
|
||||
int ignore_case = 0;
|
||||
|
||||
extern long bytepos;
|
||||
extern int ignore_case;
|
||||
extern char *emptyclass;
|
||||
|
||||
/*
|
||||
* Compiling an ASCII sequence to a regex string
|
||||
*/
|
||||
int
|
||||
ascii_comp(smem, pattern)
|
||||
char *smem;
|
||||
char *pattern;
|
||||
{
|
||||
char *end;
|
||||
char *comp;
|
||||
char cc, cc1;
|
||||
char *counter;
|
||||
int count;
|
||||
int bracket, dot;
|
||||
|
||||
comp = smem;
|
||||
poi = pattern;
|
||||
while (*poi != END) {
|
||||
bracket = FALSE;
|
||||
if (magic) {
|
||||
if (*poi == '[') bracket = TRUE;
|
||||
} else {
|
||||
if (*poi == '\\' && *(poi + 1) == '[') {
|
||||
bracket = TRUE;
|
||||
poi++;
|
||||
}
|
||||
}
|
||||
if (bracket) {
|
||||
if (!(end = strchr(poi, ']'))) {
|
||||
emsg("Missing ]");
|
||||
return 1; }
|
||||
poi++;
|
||||
if (*poi == ']' || (*poi == '^' && *(poi + 1) == ']')) {
|
||||
emsg(emptyclass);
|
||||
return 1; }
|
||||
if (magic) {
|
||||
if (*(end + 1) == '*') *comp++ = STAR;
|
||||
else *comp++ = ONE;
|
||||
} else {
|
||||
if (*(end + 1) == '\\' && *(end + 2) == '*') *comp++ = STAR;
|
||||
else *comp++ = ONE;
|
||||
}
|
||||
count = 0;
|
||||
counter = comp;
|
||||
comp++;
|
||||
if (*poi != '^') {
|
||||
*comp++ = '\0';
|
||||
count++; }
|
||||
|
||||
while (end > poi) {
|
||||
if (*poi == '-') {
|
||||
if (ignore_case) {
|
||||
cc = toupper(*(poi - 1));
|
||||
cc1 = toupper(*(poi + 1));
|
||||
} else {
|
||||
cc = *(poi - 1);
|
||||
cc1 = *(poi + 1);
|
||||
}
|
||||
while (cc <= cc1) {
|
||||
*comp++ = cc++;
|
||||
count++;
|
||||
}
|
||||
poi++; poi++;
|
||||
} else {
|
||||
count++;
|
||||
if (ignore_case)
|
||||
*comp++ = toupper(*poi++);
|
||||
else
|
||||
*comp++ = *poi++;
|
||||
}
|
||||
}
|
||||
poi++;
|
||||
*counter = count;
|
||||
} else {
|
||||
dot = FALSE;
|
||||
if (magic) {
|
||||
if (*poi == '.') dot = TRUE;
|
||||
} else {
|
||||
if (*poi == '\\' && *(poi + 1) == '.') {
|
||||
dot = TRUE; poi++; }
|
||||
}
|
||||
|
||||
if (*poi == '\\') {
|
||||
switch (*(poi + 1)) {
|
||||
case 'n': *++poi = '\n'; break;
|
||||
case 'r': *++poi = '\r'; break;
|
||||
case 't': *++poi = '\t'; break;
|
||||
case '0': *++poi = '\0'; break;
|
||||
default : ++poi;
|
||||
}
|
||||
}
|
||||
if (magic)
|
||||
if (*(poi + 1) == '*') *comp++ = STAR;
|
||||
else *comp++ = ONE;
|
||||
else
|
||||
if (*(poi + 1) == '\\' && *(poi + 2) == '*') *comp++ = STAR;
|
||||
else *comp++ = ONE;
|
||||
|
||||
if (dot) {
|
||||
*comp++ = 0;
|
||||
poi++;
|
||||
} else {
|
||||
*comp++ = 1;
|
||||
if (ignore_case)
|
||||
*comp++ = toupper(*poi++);
|
||||
else
|
||||
*comp++ = *poi++;
|
||||
}
|
||||
}
|
||||
if (magic) {
|
||||
if (*poi == '*') poi++;
|
||||
} else {
|
||||
if (*poi == '\\' && *(poi + 1) == '*') { poi++; poi++; }
|
||||
}
|
||||
}
|
||||
*comp = END;
|
||||
smode = ASCII;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Compiling a hex expression to a regex string
|
||||
*/
|
||||
int
|
||||
hex_comp(smem, pattern)
|
||||
char *smem;
|
||||
char *pattern;
|
||||
{
|
||||
char *end;
|
||||
char *comp;
|
||||
int cc, ccm;
|
||||
char *counter;
|
||||
int count, nr;
|
||||
|
||||
comp = smem;
|
||||
poi = pattern;
|
||||
while (*poi != END) {
|
||||
while (*poi == ' ' || *poi == '\t') poi++;
|
||||
if (*poi == '[') {
|
||||
if (!(end = strchr(poi, ']'))) {
|
||||
emsg("Missing ]");
|
||||
return 1; }
|
||||
poi++;
|
||||
while (*poi == ' ' || *poi == '\t') poi++;
|
||||
|
||||
if (*poi == ']' || (*poi == '^' && *(poi + 1) == ']')) {
|
||||
emsg(emptyclass);
|
||||
return 1; }
|
||||
if (*(end + 1) == '*') *comp++ = STAR;
|
||||
else *comp++ = ONE;
|
||||
count = 1;
|
||||
counter = comp;
|
||||
comp++;
|
||||
if (*poi == '^')
|
||||
*comp++ = *poi++;
|
||||
else
|
||||
*comp++ = '\0';
|
||||
while (end > poi) {
|
||||
if (*poi == ' ' || *poi == '\t') poi++;
|
||||
else if (*poi == '-') {
|
||||
cc = *(comp - 1);
|
||||
poi++;
|
||||
if ((ccm = hexchar()) < 0) return 1;
|
||||
while (cc <= ccm) {
|
||||
*comp++ = cc++;
|
||||
count++;
|
||||
}
|
||||
poi++; poi++;
|
||||
} else {
|
||||
if ((nr = hexchar()) < 0) return 1;
|
||||
count++;
|
||||
*comp++ = nr;
|
||||
}
|
||||
}
|
||||
poi++;
|
||||
*counter = count;
|
||||
if (*poi == '*') poi++;
|
||||
} else if (*poi == '"') {
|
||||
poi++;
|
||||
if (!(end = strchr(poi, '"'))) {
|
||||
/*
|
||||
emsg("Missing '\"'");
|
||||
return 1;
|
||||
*/
|
||||
end = poi + strlen(poi);
|
||||
}
|
||||
while (end > poi) {
|
||||
*comp++ = 1;
|
||||
*comp++ = 1;
|
||||
if (ignore_case)
|
||||
*comp++ = toupper(*poi++);
|
||||
else
|
||||
*comp++ = *poi++;
|
||||
}
|
||||
poi++;
|
||||
} else {
|
||||
if (*poi == '.') {
|
||||
if (*(poi + 1) == '*') { *comp++ = STAR; poi++; }
|
||||
else *comp++ = ONE;
|
||||
*comp++ = 0;
|
||||
poi++;
|
||||
} else {
|
||||
if ((nr = hexchar()) < 0) return 1;
|
||||
if (*poi == '*') { poi++; *comp++ = STAR; }
|
||||
else *comp++ = ONE;
|
||||
*comp++ = 1;
|
||||
*comp++ = nr;
|
||||
}
|
||||
}
|
||||
}
|
||||
*comp = END;
|
||||
smode = HEX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
hexchar()
|
||||
{
|
||||
int nr;
|
||||
char tmpbuf[3];
|
||||
|
||||
if (isxdigit(*poi)) {
|
||||
tmpbuf[0] = *poi++;
|
||||
tmpbuf[1] = '\0';
|
||||
if (isxdigit(*poi)) tmpbuf[1] = *poi++;
|
||||
tmpbuf[2] = '\0';
|
||||
sscanf(tmpbuf, "%2x", &nr);
|
||||
while (*poi == ' ' || *poi == '\t') poi++;
|
||||
return nr;
|
||||
} else {
|
||||
emsg("Bad hex character@in expression");
|
||||
return -1;
|
||||
}
|
||||
}
|
373
set.c
Normal file
373
set.c
Normal file
|
@ -0,0 +1,373 @@
|
|||
/* SET.C - performing :set - command
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* 1996-02-29 created;
|
||||
* 1998-03-14 V 1.0.1
|
||||
* 1999-01-14 V 1.1.0
|
||||
* 1999-03-17 V 1.1.1
|
||||
* 1999-07-02 V 1.2.0 beta
|
||||
* 1999-08-14 V 1.2.0 final
|
||||
* 2000-07-15 V 1.3.0 final
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
#include "bvi.h"
|
||||
#include "set.h"
|
||||
|
||||
static int from_file = 0;
|
||||
static FILE *ffp;
|
||||
static char fbuf[256];
|
||||
static char buf[64];
|
||||
|
||||
struct param params[] = {
|
||||
{ "autowrite", "aw", FALSE, "", P_BOOL },
|
||||
{ "columns", "cm", 16, "", P_NUM },
|
||||
{ "errorbells", "eb", FALSE, "", P_BOOL },
|
||||
{ "ignorecase", "ic", FALSE, "", P_BOOL },
|
||||
{ "magic", "ma", TRUE, "", P_BOOL },
|
||||
{ "memmove", "mm", FALSE, "", P_BOOL },
|
||||
{ "offset", "of", 0, "", P_NUM },
|
||||
{ "readonly", "ro", FALSE, "", P_BOOL },
|
||||
{ "scroll", "scroll", 12, "", P_NUM },
|
||||
{ "showmode", "mo", TRUE, "", P_BOOL },
|
||||
{ "term", "term", 0, "", P_TEXT },
|
||||
{ "terse", "terse", FALSE, "", P_BOOL },
|
||||
{ "unixstyle", "us", FALSE, "", P_BOOL },
|
||||
{ "window", "window", 25, "", P_NUM },
|
||||
{ "wordlength", "wl", 4, "", P_NUM },
|
||||
{ "wrapscan", "ws", TRUE, "", P_BOOL },
|
||||
#ifdef __MSDOS__
|
||||
{ "color", "co", 7, "", P_NUM },
|
||||
#endif
|
||||
{ "", "", 0, "", 0, } /* end marker */
|
||||
|
||||
};
|
||||
|
||||
int
|
||||
doset(arg)
|
||||
char *arg; /* parameter string */
|
||||
{
|
||||
int i;
|
||||
char *s;
|
||||
int did_window = FALSE;
|
||||
int state = TRUE; /* new state of boolean parms. */
|
||||
char string[80];
|
||||
|
||||
if (arg == NULL) {
|
||||
showparms(FALSE);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(arg, "all")) {
|
||||
showparms(TRUE);
|
||||
return 0; }
|
||||
if (!strncmp(arg, "no", 2)) {
|
||||
state = FALSE;
|
||||
arg += 2; }
|
||||
|
||||
for (i = 0; params[i].fullname[0] != '\0'; i++) {
|
||||
s = params[i].fullname;
|
||||
if (strncmp(arg, s, strlen(s)) == 0) /* matched full name */
|
||||
break;
|
||||
s = params[i].shortname;
|
||||
if (strncmp(arg, s, strlen(s)) == 0) /* matched short name */
|
||||
break;
|
||||
}
|
||||
|
||||
if (params[i].fullname[0] != '\0') { /* found a match */
|
||||
if (arg[strlen(s)] == '?') {
|
||||
if (params[i].flags & P_BOOL)
|
||||
sprintf(buf, " %s%s",
|
||||
(params[i].nvalue ? " " : "no"), params[i].fullname);
|
||||
else if (params[i].flags & P_TEXT)
|
||||
sprintf(buf, " %s=%s", params[i].fullname,
|
||||
params[i].svalue);
|
||||
else
|
||||
sprintf(buf, " %s=%ld", params[i].fullname,
|
||||
params[i].nvalue);
|
||||
msg(buf);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(params[i].fullname, "term")) {
|
||||
emsg("Can't change type of terminal from within bvi");
|
||||
return 1;
|
||||
}
|
||||
if (params[i].flags & P_NUM) {
|
||||
if ((i == P_LI) || (i == P_OF)) did_window++;
|
||||
if (arg[strlen(s)] != '=' || state == FALSE) {
|
||||
sprintf(string, "Option %s is not a toggle",
|
||||
params[i].fullname);
|
||||
emsg(string);
|
||||
return 1;
|
||||
} else {
|
||||
s = arg + strlen(s) + 1;
|
||||
if (*s == '0') {
|
||||
params[i].nvalue = strtol(s, &s, 16);
|
||||
} else {
|
||||
params[i].nvalue = strtol(s, &s, 10);
|
||||
}
|
||||
params[i].flags |= P_CHANGED;
|
||||
#ifdef __MSDOS__
|
||||
if (i == P_CO) {
|
||||
textcolor(P(P_CO) & 0x07);
|
||||
textbackground((P(P_CO) & 0xf0) >> 4);
|
||||
clrscr();
|
||||
repaint();
|
||||
}
|
||||
#endif
|
||||
if (i == P_CM) {
|
||||
if (((COLS - AnzAdd - 1) / 4) >= P(P_CM)) {
|
||||
Anzahl = P(P_CM);
|
||||
} else {
|
||||
Anzahl = P(P_CM) = ((COLS - AnzAdd - 1) / 4);
|
||||
}
|
||||
maxx = Anzahl * 4 + AnzAdd + 1;
|
||||
Anzahl3 = Anzahl * 3;
|
||||
status = Anzahl3 + Anzahl - 17;
|
||||
screen = Anzahl * (maxy - 1);
|
||||
did_window++;
|
||||
stuffin("H"); /* set cursor at HOME */
|
||||
}
|
||||
}
|
||||
} else { /* boolean */
|
||||
if (arg[strlen(s)] == '=') {
|
||||
emsg("Invalid set of boolean parameter");
|
||||
return 1;
|
||||
} else {
|
||||
params[i].nvalue = state;
|
||||
params[i].flags |= P_CHANGED;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
emsg("No such option@- `set all' gives all option values");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (did_window) {
|
||||
maxy = P(P_LI) - 1;
|
||||
new_screen();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* show ALL parameters */
|
||||
void
|
||||
showparms(all)
|
||||
int all;
|
||||
{
|
||||
struct param *p;
|
||||
int n;
|
||||
|
||||
n = 2;
|
||||
msg("Parameters:\n");
|
||||
for (p = ¶ms[0]; p->fullname[0] != '\0' ;p++) {
|
||||
if (!all && ((p->flags & P_CHANGED) == 0))
|
||||
continue;
|
||||
if (p->flags & P_BOOL)
|
||||
sprintf(buf, " %s%s\n",
|
||||
(p->nvalue ? " " : "no"), p->fullname);
|
||||
else if (p->flags & P_TEXT)
|
||||
sprintf(buf, " %s=%s\n", p->fullname, p->svalue);
|
||||
else
|
||||
sprintf(buf, " %s=%ld\n", p->fullname, p->nvalue);
|
||||
|
||||
msg(buf);
|
||||
n++;
|
||||
if (n == params[P_LI].nvalue) {
|
||||
if (wait_return(FALSE)) return;
|
||||
n = 1;
|
||||
}
|
||||
}
|
||||
wait_return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* reads the init file (.bvirc) */
|
||||
int
|
||||
read_rc(fn)
|
||||
char *fn;
|
||||
{
|
||||
if((ffp = fopen(fn, "r")) == NULL) return -1;
|
||||
from_file = 1;
|
||||
while(fgets(fbuf, 255, ffp) != NULL) {
|
||||
strtok(fbuf, "\n\r");
|
||||
docmdline(fbuf);
|
||||
}
|
||||
fclose(ffp);
|
||||
from_file = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
do_logic(mode, str)
|
||||
int mode;
|
||||
char *str;
|
||||
{
|
||||
int a, b;
|
||||
int value;
|
||||
size_t n;
|
||||
char *err_str ="Invalid value@for bit manipulation";
|
||||
|
||||
if (mode==LSHIFT || mode==RSHIFT || mode==LROTATE || mode==RROTATE) {
|
||||
value = atoi(str);
|
||||
if (value < 1 || value > 8) {
|
||||
emsg(err_str);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (strlen(str) == 8) {
|
||||
value = strtol(str, NULL, 2);
|
||||
for (n = 0; n < 8; n++) {
|
||||
if (str[n] != '0' && str[n] != '1') {
|
||||
value = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (str[0] == 'b' || str[0] == 'B') {
|
||||
value = strtol(str + 1, NULL, 2);
|
||||
} else if (str[0] == '0') {
|
||||
value = strtol(str, NULL, 16);
|
||||
for (n = 0; n < strlen(str); n++) {
|
||||
if (!isxdigit(str[n])) {
|
||||
value = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
value = atoi(str);
|
||||
}
|
||||
if (value < 0 || value > 255) {
|
||||
emsg(err_str);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if ((undo_count = alloc_buf(end_addr - start_addr + 1, &undo_buf))) {
|
||||
memcpy(undo_buf, start_addr, undo_count);
|
||||
}
|
||||
undo_start = start_addr;
|
||||
edits = U_EDIT;
|
||||
while(start_addr <= end_addr) {
|
||||
a = *start_addr;
|
||||
a &= 0xff;
|
||||
switch(mode) {
|
||||
case LSHIFT: a <<= value;
|
||||
break;
|
||||
case RSHIFT: a >>= value;
|
||||
break;
|
||||
case LROTATE: a <<= value;
|
||||
b = a >> 8;
|
||||
a |= b;
|
||||
break;
|
||||
case RROTATE:
|
||||
b = a << 8;
|
||||
a |= b;
|
||||
a >>= value;
|
||||
/*
|
||||
b = a << (8 - value);
|
||||
a >>= value;
|
||||
a |= b;
|
||||
*/
|
||||
break;
|
||||
case AND: a &= value;
|
||||
break;
|
||||
case OR: a |= value;
|
||||
break;
|
||||
case XOR:
|
||||
case NOT: a ^= value;
|
||||
break;
|
||||
case NEG: a ^= value;
|
||||
a++; /* Is this true */
|
||||
break;
|
||||
}
|
||||
*start_addr++ = (char)(a & 0xff);
|
||||
}
|
||||
repaint();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
getcmdstr(p, x)
|
||||
char *p;
|
||||
int x;
|
||||
{
|
||||
int c;
|
||||
int n;
|
||||
char *buff, *q;
|
||||
|
||||
if (from_file) {
|
||||
if(fgets(p, 255, ffp) != NULL) {
|
||||
strtok(p, "\n\r");
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
signal(SIGINT, jmpproc);
|
||||
buff = p;
|
||||
move(maxy, x);
|
||||
do {
|
||||
switch (c = vgetc()) {
|
||||
case CTRL('H'):
|
||||
case KEY_BACKSPACE:
|
||||
case KEY_LEFT:
|
||||
if (p > buff) {
|
||||
p--;
|
||||
move(maxy, x);
|
||||
n = x;
|
||||
for (q = buff; q < p ;q++) {
|
||||
addch(*q);
|
||||
n++;
|
||||
}
|
||||
addch(' ');
|
||||
move(maxy, n);
|
||||
} else {
|
||||
*buff = '\0';
|
||||
msg("");
|
||||
signal(SIGINT, SIG_IGN);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case ESC: /* abandon command */
|
||||
*buff = '\0';
|
||||
msg("");
|
||||
signal(SIGINT, SIG_IGN);
|
||||
return 1;
|
||||
#if NL != KEY_ENTER
|
||||
case NL:
|
||||
#endif
|
||||
#if CR != KEY_ENTER
|
||||
case CR:
|
||||
#endif
|
||||
case KEY_ENTER:
|
||||
break;
|
||||
default: /* a normal character */
|
||||
addch(c);
|
||||
*p++ = c;
|
||||
break;
|
||||
}
|
||||
refresh();
|
||||
} while (c != NL && c != CR && c != KEY_ENTER);
|
||||
|
||||
*p = '\0';
|
||||
signal(SIGINT, SIG_IGN);
|
||||
return 0;
|
||||
}
|
72
set.h
Normal file
72
set.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/* SET.H
|
||||
*
|
||||
* NOTE: Edit this file with tabstop=4 !
|
||||
*
|
||||
* Copyright 1996-2000 by Gerhard Buergmann
|
||||
* Gerhard.Buergmann@altavista.net
|
||||
*
|
||||
* 1998-03-14 V 1.0.0
|
||||
* 1999-01-14 V 1.1.0
|
||||
* 1999-03-23 V 1.1.1
|
||||
* 1999-07-02 V 1.2.0 beta
|
||||
* 1999-08-14 V 1.2.0 final
|
||||
* 2000-08-21 V 1.3.0 final
|
||||
*
|
||||
* 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, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See file COPYING for information on distribution conditions.
|
||||
*/
|
||||
|
||||
|
||||
struct param {
|
||||
char *fullname; /* full parameter name */
|
||||
char *shortname; /* permissible abbreviation */
|
||||
long nvalue;
|
||||
char *svalue;
|
||||
int flags;
|
||||
};
|
||||
|
||||
extern struct param params[];
|
||||
|
||||
#define P_BOOL 0x01 /* the parameter is boolean */
|
||||
#define P_NUM 0x02 /* the parameter is numeric */
|
||||
#define P_TEXT 0x04 /* the paameter is text */
|
||||
#define P_CHANGED 0x08 /* the parameter has been changed */
|
||||
|
||||
/*
|
||||
* The following are the indices in the params array for each parameter
|
||||
*/
|
||||
|
||||
/*
|
||||
* parameters
|
||||
*/
|
||||
#define P_AW 0 /* Autowrite */
|
||||
#define P_CM 1 /* Columns */
|
||||
#define P_EB 2 /* error bells */
|
||||
#define P_IC 3 /* ignore case in searches */
|
||||
#define P_MA 4 /* Magic characters in reg expr */
|
||||
#define P_MM 5 /* move bytes in file */
|
||||
#define P_OF 6 /* address offset */
|
||||
#define P_RO 7 /* Readonly */
|
||||
#define P_SS 8 /* scroll size */
|
||||
#define P_MO 9 /* show mode */
|
||||
#define P_TT 10 /* Terminal type */
|
||||
#define P_TE 11 /* Terse (short messages) */
|
||||
#define P_US 12 /* Unix-Style of ASCII representation */
|
||||
#define P_LI 13 /* lines */
|
||||
#define P_WL 14 /* Wordlength for w, W, b, B command */
|
||||
#define P_WS 15 /* wrapscan */
|
||||
#define P_CO 16 /* color/attribute setting */
|
||||
|
||||
/*
|
||||
* Macro to get the value of a parameter
|
||||
*/
|
||||
#define P(n) (params[n].nvalue)
|
Loading…
Reference in a new issue