1
0
Fork 0
mirror of https://github.com/vbatts/bvi.git synced 2025-08-02 15:40:28 +00:00

Compare commits

..

No commits in common. "master" and "v1.4.2" have entirely different histories.

28 changed files with 1473 additions and 1936 deletions

23
CHANGES
View file

@ -1,20 +1,9 @@
New in release 1.5.0
====================
* Terminal window resizeable
* fix build fails with gcc-15/C23
* fix statusline for small windows
* various issues caught by lintian solved
* fix old-style-definition warnings
* Minor fixes
New in release 1.4.2 New in release 1.4.2
==================== ====================
This release is dedicated to Sven Guckes (*1967-04-06 +2022-02-20). This release is dedicated to Sven Guckes (*1967-04-06 +2022-02-20).
Sven was an enthusiastic Linux explainer, his particular passion was the console tools. Sven was an enthusiastic Linux explainer, his particular passion was the console tools.
I met Sven a couple of times. He always showed interest in the further development of I met Sven a couple of times. He always showed interest in the further development of
the bvi and liked to discuss new ideas. the bvi and liked to discuss new ideas.
R.I.P. Sven R.I.P. Sven
* :wq bug fixed * :wq bug fixed
@ -40,7 +29,7 @@ New in release 1.4.1rc
* Compile warning: implicit declaration of function save_chk fixed (SF bug #9) * Compile warning: implicit declaration of function save_chk fixed (SF bug #9)
* bmore seg fault on file not found fixed * bmore seg fault on file not found fixed
* set columns prevents filename display on the commandline fixed (SF bug #8) * set columns prevents filename display on the commandline fixed (SF bug #8)
* bmore new option -r * bmore new option -r
bvi new setting: set reverse bvi new setting: set reverse
Characters between 160 - 254 are displayed as "reverse video text" as used in Characters between 160 - 254 are displayed as "reverse video text" as used in
some legacy systems (Atari, Commodore, Apple II, etc). some legacy systems (Atari, Commodore, Apple II, etc).
@ -139,9 +128,9 @@ New in release 1.3.0
* Reading of Block Special Files * Reading of Block Special Files
* New Command line options: * New Command line options:
+cmd +cmd
-b begin \ -b begin \
-e end > for partial file read -e end > for partial file read
-s size / -s size /
* :e# bug fixed * :e# bug fixed
* Debian bug #68436 (Buffer overflow in io.c) fixed * Debian bug #68436 (Buffer overflow in io.c) fixed

View file

@ -1,7 +1,7 @@
Patches: Patches:
Etienne Mollier <emollier@debian.org> gcc-15/C23 issues Guido <guido@bearix.oche.de> sys_errlist
Matthias Klose <doko@debian.org> GCC-15 issues Christian "naddy" Weisgerber <naddy@mips.rhein-neckar.de> {Free,Open}BSD
Vincent Batts <vbatts@hashbangbash.com> nit cleanup Gunnar Larisch <la@softing.com> ^ZZ bug
Peter J. Holzer <hjp@wsr.ac.at> setlocale Peter J. Holzer <hjp@wsr.ac.at> setlocale
Albert Chin-A-Young <china@thewrittenword.com> Makefile.in Albert Chin-A-Young <china@thewrittenword.com> Makefile.in
Ralf <rks@ffm.tc.iot.dtag.de> AIX fixes Ralf <rks@ffm.tc.iot.dtag.de> AIX fixes

View file

@ -8,7 +8,7 @@
# #
# Copyright (c) 1996-2022 by Gerhard Buergmann # Copyright (c) 1996-2022 by Gerhard Buergmann
# gerhard@puon.at # gerhard@puon.at
# #
# 1996-01-18 V 1.0.0 # 1996-01-18 V 1.0.0
# 1999-01-15 V 1.1.0 # 1999-01-15 V 1.1.0
# 1999-03-03 V 1.1.1 # 1999-03-03 V 1.1.1

14
README
View file

@ -9,12 +9,12 @@ and is distributed under the GPL (GNU Public License).
How to compile How to compile
============== ==============
You need the curses (ncurses) library for cursor movement on your system. You need the curses (ncurses) library for cursor movement on your system.
https://www.cyberciti.biz/faq/linux-install-ncurses-library-headers-on-debian-ubuntu-centos-fedora/ https://www.cyberciti.biz/faq/linux-install-ncurses-library-headers-on-debian-ubuntu-centos-fedora/
gunzip -c bvi-1.5.0.src.tar.gz | tar xvf - gunzip -c bvi-1.4.2.src.tar.gz | tar xvf -
cd bvi-1.5.0 cd bvi-1.4.2
./configure ./configure
make make
make install make install
@ -32,6 +32,14 @@ To avoid this behaviour use:
stty dsusp undef stty dsusp undef
---------------------------------------------------------------------------
Subscribe to the bvi mailing for support, updates and other news:
Send a blank email to bvi-subscribe@yahoogroups.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, PLEASE send any bug reports (and fixes), code for new features,
comments, questions, etc. (even flames) to: comments, questions, etc. (even flames) to:

View file

@ -10,4 +10,4 @@
#undef NEED_PUTC_CHAR #undef NEED_PUTC_CHAR
#undef HAVE_NCURSES_TERM_H #undef HAVE_NCURSES_TERM_H

View file

@ -126,7 +126,7 @@ cleartoeol()
int int
vgetc() vgetc()
{ {
return ((char)bioskey(0)); return ((char)bioskey(0));
} }

View file

@ -7,11 +7,10 @@
* 2010-06-02 V 1.3.4 * 2010-06-02 V 1.3.4
* 2013-08-22 V 1.4.0 * 2013-08-22 V 1.4.0
* 2019-10-09 V 1.4.1 * 2019-10-09 V 1.4.1
* 2025-07-19 V 1.5.0
* *
* NOTE: Edit this file with tabstop=4 ! * NOTE: Edit this file with tabstop=4 !
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2019 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -65,7 +64,8 @@ putchr(char ch)
#else #else
int int
putchr(int ch) putchr(ch)
int ch;
{return putchar(ch);} {return putchar(ch);}
#endif #endif
@ -116,7 +116,7 @@ initterm()
no_intty = tcgetattr(fileno(stdin), &ostate); no_intty = tcgetattr(fileno(stdin), &ostate);
tcgetattr(fileno(stderr), &ostate); tcgetattr(fileno(stderr), &ostate);
nstate = ostate; nstate = ostate;
if (!no_tty) { if (!no_tty) {
ostate.c_lflag &= ~(ICANON|ECHO); ostate.c_lflag &= ~(ICANON|ECHO);
@ -143,7 +143,8 @@ reset_tty()
void void
sig(int sig) sig(sig)
int sig;
{ {
reset_tty(); reset_tty();
printf("\r\n"); printf("\r\n");
@ -155,15 +156,12 @@ sig(int sig)
* doshell() - run a command or an interactive shell * doshell() - run a command or an interactive shell
*/ */
void void
doshell(char *cmd) doshell(cmd)
char *cmd;
{ {
int ret; int ret;
#ifndef DJGPP #ifndef DJGPP
#ifdef __STDC__
char *getenv(const char *);
#else
char *getenv(); char *getenv();
#endif
char *shell; char *shell;
char cline[128]; char cline[128];
#endif #endif
@ -279,7 +277,10 @@ vgetc()
* Copy contents of memory (with possible overlapping). * Copy contents of memory (with possible overlapping).
*/ */
char * char *
memmove(char *s1, char *s2, size_t n) memmove(s1, s2, n)
char *s1;
char *s2;
size_t n;
{ {
bcopy(s2, s1, n); bcopy(s2, s1, n);
return(s1); return(s1);

View file

@ -1,4 +1,4 @@
.TH BMORE 1 "24 May 2025" .TH BMORE 1 "8 Feb 2022"
.SH NAME .SH NAME
bmore \- browse through a binary file bmore \- browse through a binary file
.SH SYNOPSIS .SH SYNOPSIS
@ -77,7 +77,7 @@ except that a header is printed before each file in a series.
.SH OPTIONS .SH OPTIONS
.TP .TP
.B \-a .B \-a
ASCII mode: no hex representation of the contents. Non printable ASCII mode: no hex representation of the contents. Non printable
characters are displayed as a dot (.) characters are displayed as a dot (.)
.TP .TP
.B \-c .B \-c
@ -232,7 +232,7 @@ in the file remains unchanged. Regular expressions can be
edited using erase and kill characters. edited using erase and kill characters.
Erasing back past the first column cancels the search command. Erasing back past the first column cancels the search command.
.TP .TP
.B ' .B \'
Single quote. Go to the point from which the last search started. Single quote. Go to the point from which the last search started.
If no search has been performed in the current file, If no search has been performed in the current file,
go to the beginning of the file. go to the beginning of the file.

80
bmore.c
View file

@ -9,9 +9,8 @@
* 2013-08-23 V 1.4.0 * 2013-08-23 V 1.4.0
* 2019-01-22 V 1.4.1 * 2019-01-22 V 1.4.1
* 2023-03-06 V 1.4.2 * 2023-03-06 V 1.4.2
* 2025-07-19 V 1.5.0
* *
* Copyright 1990-2025 by Gerhard Buergmann * Copyright 1990-2023 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* NOTE: Edit this file with tabstop=4 ! * NOTE: Edit this file with tabstop=4 !
@ -114,7 +113,9 @@ usage()
int int
main(int argc, char *argv[]) main(argc, argv)
int argc;
char *argv[];
{ {
int ch, ch1; int ch, ch1;
int colon = 0, last_ch = 0; int colon = 0, last_ch = 0;
@ -140,7 +141,7 @@ main(int argc, char *argv[])
#endif #endif
poi = strrchr(argv[0], DELIM); poi = strrchr(argv[0], DELIM);
if (poi) strncpy(progname, ++poi, 9); if (poi) strncpy(progname, ++poi, 9);
else strncpy(progname, argv[0], 9); else strncpy(progname, argv[0], 9);
strtok(progname, "."); strtok(progname, ".");
@ -176,7 +177,7 @@ main(int argc, char *argv[])
break; break;
case 'r': r_flag++; case 'r': r_flag++;
break; break;
default: default:
usage(); usage();
} }
i++; i++;
@ -339,7 +340,7 @@ main(int argc, char *argv[])
fclose(curr_file); fclose(curr_file);
reset_tty(); reset_tty();
exit(exval); exit(exval);
case ':' : case ':' :
switch (colon) { switch (colon) {
case 'f': case 'f':
prompt = 0; prompt = 0;
@ -448,7 +449,7 @@ main(int argc, char *argv[])
bytepos = screen_home; bytepos = screen_home;
to_print = maxy; to_print = maxy;
break; break;
case '\\': case '\\':
if (ascii_flag) { if (ascii_flag) {
bmbeep(); bmbeep();
break; break;
@ -459,13 +460,13 @@ main(int argc, char *argv[])
if (rdline(ch, sstring)) break; if (rdline(ch, sstring)) break;
} }
case 'n': /**** Search Next ****/ case 'n': /**** Search Next ****/
case 'N': case 'N':
bmsearch(ch); bmsearch(ch);
/* /*
to_print--; to_print--;
*/ */
break; break;
case '\'': case '\'':
if (no_intty) { if (no_intty) {
bmbeep(); bmbeep();
} else { } else {
@ -492,7 +493,7 @@ main(int argc, char *argv[])
break; break;
} }
while ((ch1 = getc(help_file)) != EOF) while ((ch1 = getc(help_file)) != EOF)
putchar(ch1); putchar(ch1);
fclose(help_file); fclose(help_file);
to_print = 0; to_print = 0;
break; break;
@ -501,13 +502,13 @@ main(int argc, char *argv[])
if (!no_intty) { if (!no_intty) {
cleartoeol(); cleartoeol();
if (ch == 'v') { if (ch == 'v') {
sprintf(string, "bvi +%lu %s", sprintf(string, "bvi +%lu %s",
(unsigned long)(screen_home + (unsigned long)(screen_home +
(maxy + 1) / 2 * out_len), name); (maxy + 1) / 2 * out_len), name);
} else { } else {
if (precount < 1) precount = bytepos - screen_home; if (precount < 1) precount = bytepos - screen_home;
sprintf(string, "bvi -b %lu -s %lu %s", sprintf(string, "bvi -b %lu -s %lu %s",
(unsigned long)screen_home, (unsigned long)screen_home,
(unsigned long)precount, name); (unsigned long)precount, name);
} }
doshell(string); doshell(string);
@ -532,7 +533,9 @@ main(int argc, char *argv[])
int int
rdline(int ch, char *sstring) rdline(ch, sstring)
int ch;
char *sstring;
{ {
int i = 0; int i = 0;
int ch1 = 0; int ch1 = 0;
@ -584,7 +587,8 @@ rdline(int ch, char *sstring)
void void
do_next(int n) do_next(n)
int n;
{ {
if (numfiles) { if (numfiles) {
if (n == 1 && file_nr == numfiles) { if (n == 1 && file_nr == numfiles) {
@ -610,7 +614,8 @@ do_next(int n)
int int
open_file(char *name) open_file(name)
char *name;
{ {
struct stat buf; struct stat buf;
@ -631,7 +636,9 @@ open_file(char *name)
void void
putline(char *buf, int num) putline(buf, num)
char *buf;
int num;
{ {
int print_pos; int print_pos;
unsigned char ch; unsigned char ch;
@ -642,31 +649,31 @@ putline(char *buf, int num)
if (!ascii_flag) { if (!ascii_flag) {
for (print_pos = 0; print_pos < num; print_pos++) { for (print_pos = 0; print_pos < num; print_pos++) {
ch = buf[print_pos]; ch = buf[print_pos];
PRINTF("%02X ", ch); PRINTF("%02X ", ch);
} }
for (; print_pos < out_len; print_pos++) { for (; print_pos < out_len; print_pos++) {
PRINTF(" "); PRINTF(" ");
} }
PRINTF(" "); PRINTF(" ");
} }
// ASCII section // ASCII section
for (print_pos = 0; print_pos < num; print_pos++) { for (print_pos = 0; print_pos < num; print_pos++) {
++bytepos; ++bytepos;
ch = buf[print_pos]; ch = buf[print_pos];
if ((ch > 31) && (ch < 127)) { if ((ch > 31) && (ch < 127)) {
PRINTF("%c", ch); PRINTF("%c", ch);
} else { } else {
if (r_flag) { if (r_flag) {
if ((ch & 128) && ((ch > 159) && (ch < 255))) { if ((ch & 128) && ((ch > 159) && (ch < 255))) {
if (!no_tty) highlight(); if (!no_tty) highlight();
PRINTF("%c", ch & 127); PRINTF("%c", ch & 127);
if (!no_tty) normal(); if (!no_tty) normal();
} else { } else {
PRINTF("."); PRINTF(".");
} }
} else { } else {
PRINTF("."); PRINTF(".");
} }
} }
} }
@ -682,12 +689,13 @@ putline(char *buf, int num)
int int
printout(int lns) printout(lns)
int lns;
{ {
int c, num; int c, num;
int doub = 0; int doub = 0;
static int flag; static int flag;
if (c_flag) { if (c_flag) {
clearscreen(); clearscreen();
} }
@ -747,7 +755,9 @@ nextchar()
void void
pushback(int n, char *where) pushback(n, where)
int n;
char *where;
{ {
if (cnt) memmove(cmdbuf + n, cmdbuf, n); if (cnt) memmove(cmdbuf + n, cmdbuf, n);
memcpy(cmdbuf, where, n); memcpy(cmdbuf, where, n);
@ -764,7 +774,8 @@ pushback(int n, char *where)
* 1 found * 1 found
*/ */
int int
bmregexec(char *scan) bmregexec(scan)
char *scan;
{ {
char *act; char *act;
int count, test; int count, test;
@ -858,7 +869,7 @@ bmregexec(char *scan)
pushback(1, --act); pushback(1, --act);
l--; l--;
} }
} else { /* ".*" */ } else { /* ".*" */
do { do {
if ((test = nextchar()) == -1) return -5; if ((test = nextchar()) == -1) return -5;
*act++ = test; *act++ = test;
@ -882,7 +893,10 @@ bmregexec(char *scan)
int int
sbracket(int start, char *scan, int count) sbracket(start, scan, count)
int start;
char *scan;
int count;
{ {
if (*scan++ == '^') { if (*scan++ == '^') {
if (!memchr(scan, start, --count)) return 0; if (!memchr(scan, start, --count)) return 0;
@ -894,7 +908,8 @@ sbracket(int start, char *scan, int count)
void void
bmsearch(int ch) bmsearch(ch)
int ch;
{ {
int i; int i;
@ -946,7 +961,8 @@ emsg(string);
void void
emsg(char *s) emsg(s)
char *s;
{ {
putchar('\r'); putchar('\r');
cleartoeol(); cleartoeol();

22
bmore.h
View file

@ -7,7 +7,7 @@
* 1999-08-21 V 1.2.0 final * 1999-08-21 V 1.2.0 final
* 2000-05-31 V 1.3.0 beta * 2000-05-31 V 1.3.0 beta
* 2000-10-04 V 1.3.0 final * 2000-10-04 V 1.3.0 final
* 2002-01-16 V 1.3.1 * 2002-01-16 V 1.3.1
* 2003-02-20 V 1.3.2 * 2003-02-20 V 1.3.2
* 2010-03-28 V 1.3.4 * 2010-03-28 V 1.3.4
* 2019-01-22 V 1.4.1 * 2019-01-22 V 1.4.1
@ -43,7 +43,7 @@
#if defined(__MSDOS__) && !defined(DJGPP) #if defined(__MSDOS__) && !defined(DJGPP)
# include "patchlev.h" # include "patchlev.h"
# include "dosconf.h" # include "dosconf.h"
# include <alloc.h> # include <alloc.h>
# include <conio.h> # include <conio.h>
# include <bios.h> # include <bios.h>
#else #else
@ -51,21 +51,21 @@
# include "config.h" # include "config.h"
# include <unistd.h> # include <unistd.h>
# if defined HAVE_NCURSESW_CURSES_H # if defined HAVE_NCURSESW_CURSES_H
# include <ncursesw/curses.h> # include <ncursesw/curses.h>
# include <ncursesw/term.h> # include <ncursesw/term.h>
# elif defined HAVE_NCURSESW_H # elif defined HAVE_NCURSESW_H
# include <ncursesw.h> # include <ncursesw.h>
# elif defined HAVE_NCURSES_CURSES_H # elif defined HAVE_NCURSES_CURSES_H
# include <ncurses/curses.h> # include <ncurses/curses.h>
# elif defined HAVE_NCURSES_H # elif defined HAVE_NCURSES_H
# include <ncurses.h> # include <ncurses.h>
# elif defined HAVE_CURSES_H # elif defined HAVE_CURSES_H
# include <curses.h> # include <curses.h>
# else # else
# error "SysV or X/Open-compatible Curses header file required" # error "SysV or X/Open-compatible Curses header file required"
# endif # endif
# if HAVE_TERM_H # if HAVE_TERM_H
# include <term.h> # include <term.h>
# endif # endif
#endif #endif
@ -136,7 +136,7 @@ extern int no_tty, no_intty;
#if defined(ANSI) || defined(__STDC__) #ifdef ANSI
void initterm(void), set_tty(void), reset_tty(void); void initterm(void), set_tty(void), reset_tty(void);
void cleartoeol(void), clearscreen(void), highlight(void); void cleartoeol(void), clearscreen(void), highlight(void);
void normal(void), bmbeep(void), home(void), sig(int); void normal(void), bmbeep(void), home(void), sig(int);

77
bvi.1
View file

@ -1,8 +1,8 @@
.rn '' }` .rn '' }`
.\" $RCSfile$$Revision$$Date$ ''' $RCSfile$$Revision$$Date$
.\" '''
.\" $Log$ ''' $Log$
.\" '''
.de Sh .de Sh
.br .br
.if t .Sp .if t .Sp
@ -31,12 +31,12 @@
.fi .fi
.. ..
.\" '''
.\" '''
.\" Set up \*(-- to give an unbreakable dash; ''' Set up \*(-- to give an unbreakable dash;
.\" string Tr holds user defined translation string. ''' string Tr holds user defined translation string.
.\" Bell System Logo is used as a dummy character. ''' Bell System Logo is used as a dummy character.
.\" '''
.tr \(*W-|\(bv\*(Tr .tr \(*W-|\(bv\*(Tr
.ie n \{\ .ie n \{\
.ds -- \(*W- .ds -- \(*W-
@ -45,10 +45,10 @@
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
.ds L" "" .ds L" ""
.ds R" "" .ds R" ""
.\" \*(M", \*(S", \*(N" and \*(T" are the equivalent of ''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of
.\" \*(L" and \*(R", except that they are used on ".xx" lines, ''' \*(L" and \*(R", except that they are used on ".xx" lines,
.\" such as .IP and .SH, which do another additional levels of ''' such as .IP and .SH, which do another additional levels of
.\" double-quote interpretation ''' double-quote interpretation
.ds M" """ .ds M" """
.ds S" """ .ds S" """
.ds N" """"" .ds N" """""
@ -79,9 +79,9 @@
'br\} 'br\}
.\" If the F register is turned on, we'll generate .\" If the F register is turned on, we'll generate
.\" index entries out stderr for the following things: .\" index entries out stderr for the following things:
.\" TH Title .\" TH Title
.\" SH Header .\" SH Header
.\" Sh Subsection .\" Sh Subsection
.\" Ip Item .\" Ip Item
.\" X<> Xref (embedded .\" X<> Xref (embedded
.\" Of course, you have to process the output yourself .\" Of course, you have to process the output yourself
@ -93,7 +93,7 @@
.nr % 0 .nr % 0
.rr F .rr F
.\} .\}
.TH BVI 1 "BVI Version 1.5.0" "31/May/2025" "User Commands" .TH BVI 1 "BVI Version 1.4.2" "8/Feb/2022" "User Commands"
.IX Title "BVI 1" .IX Title "BVI 1"
.UC .UC
.IX Name "bvi, bview - visual display editor for binary files" .IX Name "bvi, bview - visual display editor for binary files"
@ -194,7 +194,7 @@
bvi, bview \- visual editor for binary files bvi, bview \- visual editor for binary files
.SH "VERSION" .SH "VERSION"
.IX Header "VERSION" .IX Header "VERSION"
bvi-1.5.0 bvi-1.4.1
.SH "SYNOPSIS" .SH "SYNOPSIS"
.IX Header "SYNOPSIS" .IX Header "SYNOPSIS"
\fBbvi\fR\ \ \ [\fB\-R\fR]\ [\fB\-c\fR\ \fIcmd\fR]\ [\fB\-f\fR\ \fIscript\fR]\ [\fB\-s\fR\ \fIskip\fR]\ [\fB\-e\fR\ \fIend\fR]\ [\fB\-n\fR\ \fIlength\fR]\ \fIfile\fR... \fBbvi\fR\ \ \ [\fB\-R\fR]\ [\fB\-c\fR\ \fIcmd\fR]\ [\fB\-f\fR\ \fIscript\fR]\ [\fB\-s\fR\ \fIskip\fR]\ [\fB\-e\fR\ \fIend\fR]\ [\fB\-n\fR\ \fIlength\fR]\ \fIfile\fR...
@ -203,10 +203,10 @@ bvi-1.5.0
.IX Header "OPTIONS" .IX Header "OPTIONS"
.Ip "\fIfile\fR..." 4 .Ip "\fIfile\fR..." 4
.IX Item "\fIfile\fR..." .IX Item "\fIfile\fR..."
A list of filenames. The first one will be the current file and A list of filenames. The first one will be the current file and
will be read will be read
into the buffer. The cursor will be positioned on the first line of 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. the buffer. You can get to the other files with the ":next" command.
.Ip "\fB\-R\fR" 4 .Ip "\fB\-R\fR" 4
.IX Item "\fB\-R\fR" .IX Item "\fB\-R\fR"
\*(L"Readonly": The readonly flag is set for all the files, \*(L"Readonly": The readonly flag is set for all the files,
@ -261,7 +261,7 @@ The byte offset (extreme left), the hex pane (middle),
and an ascii pane (right) which shows as printable characters and an ascii pane (right) which shows as printable characters
those bytes in the hex pane. those bytes in the hex pane.
On an 80 column terminal there will be sixteen hex values On an 80 column terminal there will be sixteen hex values
and their ASCII values on each screen line. and their ASCII values on each screen line.
Note that (as one would expect) the first byte has the offset \*(L'0\*(R' (zero). Note that (as one would expect) the first byte has the offset \*(L'0\*(R' (zero).
.PP .PP
You can toggle between the hex and ascii windows with the tab key (TAB). You can toggle between the hex and ascii windows with the tab key (TAB).
@ -270,10 +270,10 @@ position (offset) within the file.
.PP .PP
No \*(L"lines\*(R" concept: No \*(L"lines\*(R" concept:
Files are treated as one long stream of bytes. The characters 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 \*(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 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 represent lines in the usual way. Data is broken across screen lines
arbitrarily. arbitarily.
As a consequence there are no commands in bvi from ex or vi 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'. 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 This also changes the meaning of \*(L"range\*(R" before the \*(L":write\*(R" command
@ -313,13 +313,13 @@ using these meta sequences:
.Ve .Ve
Additional search commands: Additional search commands:
Similar to the text search commands there are additional hex-search Similar to the text search commands there are additional hex-search
functions \*(L'\e\*(R' and \*(L'#\*(R' which allow one to search for any byte value. 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". Example: \*(L"\e62 76 69\*(R" will search for the string \*(L"bvi\*(R".
Spaces between hex value are optional, so searching Spaces between hex value are optional, so searching
for \*(L"6775636B6573\*(R" will find \*(L"guckes\*(R". for \*(L"6775636B6573\*(R" will find \*(L"guckes\*(R".
.PP .PP
Changing the length of data (insertion, deletion) moves the data to other addresses; 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 this is bad for many cases (eg. databases, program files) and is
thus disabled by default. You can enable this commands by typing thus disabled by default. You can enable this commands by typing
.PP .PP
\f(CW :set memmove\fR \f(CW :set memmove\fR
@ -334,11 +334,11 @@ Use ESC (escape) to cancel a partial (uncompleted) command.
.PP .PP
Input Mode: Input Mode:
.PP .PP
Input is treated as replacement of current characters or Input is treated as replacement of current characters or
(after the end of the file) is appended (after the end of the file) is appended
to the current file. This mode is entered from command mode by 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'. 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 You can enter the characters from the keyboard (in the ASCII window) or
hexadecimal values (in the HEX window). hexadecimal values (in the HEX window).
Type TAB to switch between these two windows. Type TAB to switch between these two windows.
Type ESC to finish the current input and return to command mode. Type ESC to finish the current input and return to command mode.
@ -346,8 +346,8 @@ Type CTRL\-C to cancel current command abnormally.
.PP .PP
Command line mode (Last Line Mode or : mode): Command line mode (Last Line Mode or : mode):
.PP .PP
Similar to vi, this mode is entered by typing one of the Similar to vi, this mode is entered by typing one of the
characters characters
: / ? \e # ! : / ? \e # !
The command is terminated and executed by typing a carriage The command is terminated and executed by typing a carriage
return; to cancel a partially typed command, type return; to cancel a partially typed command, type
@ -439,10 +439,10 @@ used within the following description of commands.
You can insert/append/change bytes in ASCII/binary/decimal/ You can insert/append/change bytes in ASCII/binary/decimal/
hexadecimal or octal representation. You can enter several hexadecimal or octal representation. You can enter several
(screen) lines of input. A line with only a period (.) in it (screen) lines of input. A line with only a period (.) in it
will terminate the command. You must not type in values greater will terminate the command. You must not type in values greater
than a byte value. This causes an abandonment of the command. than a byte value. This causes an abandonment of the command.
Pressing the CR key does not insert a newline \- character into Pressing the CR key does not insert a newline \- character into
the file. If you use ASCII mode you can use the special characters the file. If you use ASCII mode you can use the special characters
\en, \er, \et and \e0. \en, \er, \et and \e0.
.PP .PP
.Vb 3 .Vb 3
@ -507,7 +507,7 @@ the file. If you use ASCII mode you can use the special characters
`\fIx\fR move cursor to mark \fIx\fR in HEX section `\fIx\fR move cursor to mark \fIx\fR in HEX section
\*(L'\*(R' move cursor to previous context in ASCII section \*(L'\*(R' move cursor to previous context in ASCII section
`` move cursor to previous context in HEX section `` move cursor to previous context in HEX section
\fBLine positioning:\fR \fBLine positioning:\fR
H jump to first line on screen ("top") H jump to first line on screen ("top")
L jump to last line on screen ("low") L jump to last line on screen ("low")
@ -554,7 +554,7 @@ the file. If you use ASCII mode you can use the special characters
rx replace current bte with char \*(L'x\*(R' rx replace current bte with char \*(L'x\*(R'
R enter replace mode; for all subsequent input, R enter replace mode; for all subsequent input,
the current byte is overwritten with the next the current byte is overwritten with the next
input character; leave replace mode with ESC. input character; leave replace mode with ESC.
.PP .PP
\fBMiscellaneous Operations:\fR \fBMiscellaneous Operations:\fR
TAB toggle between ASCII and HEX section TAB toggle between ASCII and HEX section
@ -583,8 +583,8 @@ the file. If you use ASCII mode you can use the special characters
\& columns cm=16 on an 80 character wide terminal \& columns cm=16 on an 80 character wide terminal
\& ignorecase noic Ignores letter case in searching \& ignorecase noic Ignores letter case in searching
\& magic nomagic Makes . [ * special in patterns \& magic nomagic Makes . [ * special in patterns
\& memmove nomm enables insert and delete commands \& memmove nomm enables insert and delete commands
\& offset of=0 adds an offset to the displayed addresses \& offset of=0 adds an offset to the diplayed addresses
\& readonly noro If set, write fails unless you use ! after command \& readonly noro If set, write fails unless you use ! after command
\& reverse nore display otherwise-printable characters with their \& reverse nore display otherwise-printable characters with their
\& high bit set as reverse video \& high bit set as reverse video
@ -606,7 +606,7 @@ bvi was developed by Gerhard Buergmann, Vienna, Austria
\fIgerhard@puon.at\fR \fIgerhard@puon.at\fR
.SH "WWW" .SH "WWW"
.IX Header "WWW" .IX Header "WWW"
Bvi\ Homepage:\ \ https://bvi.sourceforge.net/ Bvi\ Homepage:\ \ http://bvi.sourceforge.net/
Vi\ Pages:\ \ \ \ \ \ http://www.guckes.net/vi/clones.php3 Vi\ Pages:\ \ \ \ \ \ http://www.guckes.net/vi/clones.php3
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (all\ about\ Vi\ and\ its\ clones) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (all\ about\ Vi\ and\ its\ clones)
.SH "FILES" .SH "FILES"
@ -614,6 +614,9 @@ Vi\ Pages:\ \ \ \ \ \ http://www.guckes.net/vi/clones.php3
\fI\ $HOME/.bvirc\fR\ \ \ \ \ \ \ \ \ \ editor\ startup\ file \fI\ $HOME/.bvirc\fR\ \ \ \ \ \ \ \ \ \ editor\ startup\ file
.BR .BR
\fI\ ./.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" .SH "SEE ALSO"
.IX Header "SEE ALSO" .IX Header "SEE ALSO"
\fIbmore\fR\|(1), \fIvi\fR\|(1), \fIstrings\fR\|(1), \fIascii\fR\|(5) \fIbmore\fR\|(1), \fIvi\fR\|(1), \fIstrings\fR\|(1), \fIascii\fR\|(5)

156
bvi.c
View file

@ -2,7 +2,7 @@
* *
* 1996-02-28 V 1.0.0 * 1996-02-28 V 1.0.0
* 1999-01-27 V 1.1.0 * 1999-01-27 V 1.1.0
* 1999-04-22 V 1.1.1 * 1999-04-22 V 1.1.1
* 1999-07-01 V 1.2.0 beta * 1999-07-01 V 1.2.0 beta
* 1999-10-22 V 1.2.0 final * 1999-10-22 V 1.2.0 final
* 2000-05-10 V 1.3.0 alpha * 2000-05-10 V 1.3.0 alpha
@ -14,11 +14,10 @@
* 2014-10-07 V 1.4.0 * 2014-10-07 V 1.4.0
* 2019-10-12 V 1.4.1 * 2019-10-12 V 1.4.1
* 2023-03-06 V 1.4.2 * 2023-03-06 V 1.4.2
* 2025-07-19 V 1.5.0
* *
* NOTE: Edit this file with tabstop=4 ! * NOTE: Edit this file with tabstop=4 !
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2023 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -45,56 +44,55 @@
#endif #endif
char *copyright = "(C) GPL 1996-2025 by Gerhard Buergmann"; char *copyright = "(C) GPL 1996-2023 by Gerhard Buergmann";
jmp_buf env; /* context for `longjmp' function */ jmp_buf env; /* context for `longjmp' function */
int loc; int loc;
int maxx, maxy, x, xx, y; int maxx, maxy, x, xx, y;
int screen, status, statsize; int screen, status, statsize;
off_t size; off_t size;
PTR mem = NULL; PTR mem = NULL;
PTR curpos; PTR curpos;
PTR maxpos; PTR maxpos;
PTR pagepos; PTR pagepos;
PTR spos; PTR spos;
char *name = NULL; char *name = NULL;
char *shell; char *shell;
char string[MAXCMD+1]; char string[MAXCMD+1];
char cmdstr[MAXCMD+1] = ""; char cmdstr[MAXCMD+1] = "";
FILE *Ausgabe_Datei; FILE *Ausgabe_Datei;
int edits = 0; int edits = 0;
int AnzAdd, Anzahl, Anzahl3; int AnzAdd, Anzahl, Anzahl3;
off_t filesize, memsize, undosize; off_t filesize, memsize, undosize;
int statusflag = 1;
int space = 2;
long precount = -1; long precount = -1;
int block_flag = 0; int block_flag = 0;
off_t block_begin, block_end, block_size; off_t block_begin, block_end, block_size;
char **files; /* list of input files */ char **files; /* list of input files */
int numfiles; /* number of input files */ int numfiles; /* number of input files */
int curfile; /* number of the current file */ int curfile; /* number of the current file */
int arrnum = 0; int arrnum = 0;
char numarr[MAXCMD+1]; /* string for collecting number */ char numarr[MAXCMD+1]; /* string for collecting number */
char rep_buf[BUFFER]; char rep_buf[BUFFER];
PTR current; PTR current;
PTR last_motion; PTR last_motion;
PTR current_start; PTR current_start;
PTR undo_start; PTR undo_start;
off_t undo_count; off_t undo_count;
off_t yanked = 0L; off_t yanked = 0L;
char *yank_buf = NULL; char *yank_buf = NULL;
char *undo_buf = NULL; char *undo_buf = NULL;
char *fname_buf = NULL; char *fname_buf = NULL;
PTR markbuf[26]; PTR markbuf[26];
char addr_form[15]; char addr_form[15];
@ -102,8 +100,8 @@ char *nobytes = "No bytes@in the buffer";
static char progname[8]; static char progname[8];
static char line[MAXCMD+1]; static char line[MAXCMD+1];
static int mark; static int mark;
static int wrstat = 1; static int wrstat = 1;
void void
@ -119,7 +117,9 @@ usage()
int int
main(int argc, char *argv[]) main(argc, argv)
int argc;
char *argv[];
{ {
int ch; int ch;
int lflag; int lflag;
@ -248,7 +248,7 @@ main(int argc, char *argv[])
break; break;
case BLOCK_BEGIN|BLOCK_END|BLOCK_LEN: case BLOCK_BEGIN|BLOCK_END|BLOCK_LEN:
if (block_end - block_begin != block_size + 1) { if (block_end - block_begin != block_size + 1) {
fprintf(stderr, "Ambiguous block data\n"); fprintf(stderr, "Ambigous block data\n");
exit(1); exit(1);
} }
break; break;
@ -267,9 +267,7 @@ main(int argc, char *argv[])
maxy = LINES; maxy = LINES;
if (params[P_LI].flags & P_CHANGED) maxy = P(P_LI); if (params[P_LI].flags & P_CHANGED) maxy = P(P_LI);
P(P_SS) = maxy / 2; P(P_SS) = maxy / 2;
/* We do not set P(P_LI) and P(P_CM) anymore, because 0 means "auto"
P(P_LI) = maxy; P(P_LI) = maxy;
*/
maxy--; maxy--;
keypad(stdscr, TRUE); keypad(stdscr, TRUE);
scrollok(stdscr, TRUE); scrollok(stdscr, TRUE);
@ -277,21 +275,21 @@ main(int argc, char *argv[])
cbreak(); cbreak();
noecho(); noecho();
/* address column width */ /* address column width */
/* default is 8 + 2 blanks */ /* default is 8 + 2 blanks */
/* if block_begin has 8 hex digits or more */ /* if block_begin has 8 hex digits or more */
/* reserve 1 hex digit more than required */ /* reserve 1 hex digit more than required */
char tmp[sizeof(block_begin) * 2 + 3]; char tmp[sizeof(block_begin) * 2 + 3];
AnzAdd = sprintf(tmp, "%llX", (long long unsigned)block_begin) + 1; AnzAdd = sprintf(tmp, "%llX", (long long unsigned)block_begin) + 1;
if (AnzAdd < 8) AnzAdd = 8; if (AnzAdd < 8)
if (AnzAdd > sizeof(block_begin) * 2) AnzAdd = sizeof(block_begin) * 2; AnzAdd = 8;
sprintf(addr_form, "%%0%dllX ", AnzAdd); if (AnzAdd > sizeof(block_begin) * 2)
AnzAdd = sprintf(tmp, addr_form, block_begin); AnzAdd = sizeof(block_begin) * 2;
sprintf(addr_form, "%%0%dllX ", AnzAdd);
AnzAdd = sprintf(tmp, addr_form, block_begin);
Anzahl = ((COLS - AnzAdd - space) / 16) * 4; Anzahl = ((COLS - AnzAdd - 1) / 16) * 4;
/*
P(P_CM) = Anzahl; P(P_CM) = Anzahl;
*/
maxx = Anzahl * 4 + AnzAdd + 1; maxx = Anzahl * 4 + AnzAdd + 1;
Anzahl3 = Anzahl * 3; Anzahl3 = Anzahl * 3;
statsize = 35; statsize = 35;
@ -312,7 +310,7 @@ main(int argc, char *argv[])
if (*cmdstr != '\0') if (*cmdstr != '\0')
docmdline(cmdstr); docmdline(cmdstr);
msg(fname_buf); msg(fname_buf);
/* main loop */ /* main loop */
do { do {
setjmp(env); setjmp(env);
@ -330,10 +328,6 @@ main(int argc, char *argv[])
else precount = -1; else precount = -1;
lflag = arrnum = 0; lflag = arrnum = 0;
if (statusflag == 0) {
statusflag = 1;
clearstr();
}
switch (ch) { switch (ch) {
case '^': x = AnzAdd; case '^': x = AnzAdd;
loc = HEX; loc = HEX;
@ -432,7 +426,7 @@ main(int argc, char *argv[])
x = AnzAdd - 1 + Anzahl3 + Anzahl; x = AnzAdd - 1 + Anzahl3 + Anzahl;
loc = ASCII; } loc = ASCII; }
break; break;
case ':' : clearstr(); case ':' : clearstr();
addch(ch); addch(ch);
refresh(); refresh();
getcmdstr(cmdstr, 1); getcmdstr(cmdstr, 1);
@ -473,18 +467,6 @@ main(int argc, char *argv[])
fileinfo(name); fileinfo(name);
wrstat = 0; wrstat = 0;
break; break;
case KEY_RESIZE:
if (P(P_CM) == 0) {
Anzahl = ((COLS - AnzAdd - space) / 4);
maxx = Anzahl * 4 + AnzAdd + 1;
Anzahl3 = Anzahl * 3;
status = Anzahl3 + Anzahl - statsize;
}
if (P(P_LI) == 0) {
screen = Anzahl * (maxy - 1);
maxy = LINES - 1;
P(P_SS) = maxy / 2;
}
case BVICTRL('L'): /*** REDRAW SCREEN ***/ case BVICTRL('L'): /*** REDRAW SCREEN ***/
new_screen(); new_screen();
break; break;
@ -509,9 +491,9 @@ main(int argc, char *argv[])
break; break;
case ';': do_ft(0, 0); case ';': do_ft(0, 0);
break; break;
case 'F': case 'F':
case 'f': case 'f':
case 't': case 't':
case 'T': do_ft(ch, 0); case 'T': do_ft(ch, 0);
break; break;
case 'G': last_motion = current; case 'G': last_motion = current;
@ -519,10 +501,10 @@ main(int argc, char *argv[])
if ((precount < P(P_OF)) || if ((precount < P(P_OF)) ||
(precount - P(P_OF)) > (filesize - 1L)) { (precount - P(P_OF)) > (filesize - 1L)) {
beep(); beep();
} else { } else {
setpage((PTR)(mem + precount - P(P_OF))); setpage((PTR)(mem + precount - P(P_OF)));
} }
} else { } else {
setpage((PTR)(mem + filesize - 1L)); setpage((PTR)(mem + filesize - 1L));
} }
break; break;
@ -753,7 +735,8 @@ main(int argc, char *argv[])
off_t off_t
calc_size(char *arg) calc_size(arg)
char *arg;
{ {
off_t val; off_t val;
extern int errno; extern int errno;
@ -773,13 +756,13 @@ calc_size(char *arg)
switch (*poi) { switch (*poi) {
case 'k': case 'k':
case 'K': val *= 1024; case 'K': val *= 1024;
break; break;
case 'm': case 'm':
case 'M': val *= 1048576; case 'M': val *= 1048576;
break; break;
case 'g': case 'g':
case 'G': val *= 1024*1024*1024LL; case 'G': val *= 1024*1024*1024LL;
break; break;
case '\0': break; case '\0': break;
default: usage(); default: usage();
} }
@ -804,7 +787,9 @@ trunc_cur()
int int
do_append(off_t count, char *buf) do_append(count, buf)
off_t count;
char *buf;
{ {
if (filesize + count > memsize) { if (filesize + count > memsize) {
if (enlarge(count + 100L)) return 1; if (enlarge(count + 100L)) return 1;
@ -821,7 +806,8 @@ do_append(off_t count, char *buf)
void void
do_tilde(off_t count) do_tilde(count)
off_t count;
{ {
if (filesize == 0L) return; if (filesize == 0L) return;
undo_start = current; undo_start = current;
@ -907,7 +893,10 @@ do_undo()
void void
do_over(PTR loc, off_t n, PTR buf) do_over(loc, n, buf)
PTR loc;
off_t n;
PTR buf;
{ {
if (n < 1L) { if (n < 1L) {
emsg(nobytes); emsg(nobytes);
@ -929,7 +918,10 @@ do_over(PTR loc, off_t n, PTR buf)
void void
do_put(PTR loc, off_t n, PTR buf) do_put(loc, n, buf)
PTR loc;
off_t n;
PTR buf;
{ {
if (n < 1L) { if (n < 1L) {
emsg(nobytes); emsg(nobytes);
@ -957,7 +949,8 @@ do_put(PTR loc, off_t n, PTR buf)
/* argument sig not used, because only SIGINT will be catched */ /* argument sig not used, because only SIGINT will be catched */
void void
jmpproc(int sig) jmpproc(sig)
int sig;
{ {
if (P(P_EB)) beep(); if (P(P_EB)) beep();
repaint(); repaint();
@ -968,7 +961,8 @@ jmpproc(int sig)
off_t off_t
range(int ch) range(ch)
int ch;
{ {
int ch1; int ch1;
long count; long count;
@ -1039,7 +1033,7 @@ range(int ch)
- (off_t)P(P_OF)) > (filesize - 1L)) { - (off_t)P(P_OF)) > (filesize - 1L)) {
beep(); beep();
return 0; return 0;
} else { } else {
if (mem + count < current) { if (mem + count < current) {
return(mem + count - current); return(mem + count - current);
} else { } else {
@ -1057,9 +1051,9 @@ range(int ch)
} }
end_addr = markbuf[mark - 'a']; end_addr = markbuf[mark - 'a'];
if (end_addr == NULL) { if (end_addr == NULL) {
beep(); beep();
return 0; return 0;
} }
if (end_addr < current) { if (end_addr < current) {
return(end_addr - current); return(end_addr - current);
} else { } else {

165
bvi.h
View file

@ -13,11 +13,10 @@
* 2014-10-01 V 1.4.0 * 2014-10-01 V 1.4.0
* 2019-01-28 V 1.4.1 * 2019-01-28 V 1.4.1
* 2023-03-07 V 1.4.2 * 2023-03-07 V 1.4.2
* 2025-05-24 V 1.5.0
* *
* NOTE: Edit this file with tabstop=4 ! * NOTE: Edit this file with tabstop=4 !
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2023 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -47,8 +46,8 @@
#if defined(__MSDOS__) && !defined(DJGPP) #if defined(__MSDOS__) && !defined(DJGPP)
# include "patchlev.h" # include "patchlev.h"
# include "dosconf.h" # include "dosconf.h"
# include "doscur.h" # include "doscur.h"
# include <alloc.h> # include <alloc.h>
#else #else
# include "patchlevel.h" # include "patchlevel.h"
# include "config.h" # include "config.h"
@ -130,14 +129,14 @@
# define ANSI # define ANSI
# define PTR char huge * # define PTR char huge *
# define off_t long # define off_t long
# define DELIM '\\' # define DELIM '\\'
# define strncasecmp strnicmp # define strncasecmp strnicmp
# define strcasecmp stricmp # define strcasecmp stricmp
# define memcpy d_memcpy # define memcpy d_memcpy
# define memmove d_memmove # define memmove d_memmove
#else #else
# define PTR char * # define PTR char *
# define DELIM '/' # define DELIM '/'
#endif #endif
#define MAXCMD 255 #define MAXCMD 255
@ -165,27 +164,27 @@ extern char search_pat[];
extern long hl_spat; extern long hl_spat;
extern char pattern[]; extern char pattern[];
extern char rep_buf[]; extern char rep_buf[];
extern int maxx, maxy, x, y; extern int maxx, maxy, x, y;
extern int filemode, loc; extern int filemode, loc;
extern int edits, new; extern int edits, new;
extern int AnzAdd; extern int AnzAdd;
extern int Anzahl, Anzahl3; extern int Anzahl, Anzahl3;
extern int addr_flag; extern int addr_flag;
extern int ignore_case, magic; extern int ignore_case, magic;
extern int screen, status, statsize; extern int screen, status, statsize;
extern PTR mem; extern PTR mem;
extern PTR maxpos; extern PTR maxpos;
extern PTR pagepos; extern PTR pagepos;
extern PTR undo_start; extern PTR undo_start;
extern PTR current_start; extern PTR current_start;
extern PTR curpos; extern PTR curpos;
extern PTR current; extern PTR current;
extern PTR start_addr; extern PTR start_addr;
extern PTR end_addr; extern PTR end_addr;
extern char *name, cmdstr[]; extern char *name, cmdstr[];
extern off_t filesize, memsize; extern off_t filesize, memsize;
extern PTR markbuf[]; extern PTR markbuf[];
extern PTR last_motion; extern PTR last_motion;
extern off_t undo_count; extern off_t undo_count;
extern off_t yanked; extern off_t yanked;
extern off_t undosize; extern off_t undosize;
@ -193,16 +192,14 @@ extern char *copyright, *notfound;
extern char *terminal; extern char *terminal;
extern char *undo_buf; extern char *undo_buf;
extern char *yank_buf; extern char *yank_buf;
extern int repl_count; extern int repl_count;
extern char string[]; extern char string[];
extern char *shell; extern char *shell;
extern char *poi; extern char *poi;
extern int smode; extern int smode;
extern int again; extern int again;
extern int block_flag; extern int block_flag;
extern off_t block_begin, block_end, block_size; extern off_t block_begin, block_end, block_size;
extern int statusflag;
extern int space;
#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ #ifndef S_ISDIR /* POSIX 1003.1 file type tests. */
#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ #define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */
@ -217,7 +214,7 @@ extern int space;
void d_memmove(PTR, PTR, off_t); void d_memmove(PTR, PTR, off_t);
#endif #endif
#if defined(ANSI) || defined(__STDC__) #ifdef ANSI
off_t alloc_buf(off_t, char **), yd_addr(void); off_t alloc_buf(off_t, char **), yd_addr(void);
off_t range(int); off_t range(int);
void do_dot(void), do_exit(void), do_shell(void), do_undo(void); void do_dot(void), do_exit(void), do_shell(void), do_undo(void);
@ -226,26 +223,26 @@ extern int space;
void do_mark(int, PTR), badcmd(char *), movebyte(void); 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 docmdline(char *), do_over(PTR, off_t, PTR), do_put(PTR, off_t, PTR);
void jmpproc(int), printline(PTR, int); void jmpproc(int), printline(PTR, int);
int addfile(char *); int addfile(char *);
PTR bregexec(PTR, char *); PTR bregexec(PTR, char *);
int chk_comm(int); int chk_comm(int);
int doecmd(char *, int); int doecmd(char *, int);
int do_append(off_t, char *), do_logic(int, char *); int do_append(off_t, char *), do_logic(int, char *);
int do_delete(off_t, PTR); int do_delete(off_t, PTR);
int doset(char *); int doset(char *);
int do_substitution(int, char *, PTR, PTR); int do_substitution(int, char *, PTR, PTR);
int hexchar(void); int hexchar(void);
int outmsg(char *); int outmsg(char *);
int save_chk(char *, char *, char *, int); int save_chk(char *, char *, char *, int);
PTR searching(int, char *, PTR, PTR, int); PTR searching(int, char *, PTR, PTR, int);
PTR wordsearch(PTR, char); PTR wordsearch(PTR, char);
PTR backsearch(PTR, char); PTR backsearch(PTR, char);
PTR fsearch(PTR, PTR, char *); PTR fsearch(PTR, PTR, char *);
PTR fsearch_end(PTR, PTR, char *, PTR *); PTR fsearch_end(PTR, PTR, char *, PTR *);
PTR rsearch(PTR, PTR, char *); PTR rsearch(PTR, PTR, char *);
PTR end_word(PTR); PTR end_word(PTR);
PTR calc_addr(char **, PTR); PTR calc_addr(char **, PTR);
PTR do_ft(int, int); PTR do_ft(int, int);
char *patcpy(char *, char *, char); char *patcpy(char *, char *, char);
void setpage(PTR), msg(char *), emsg(char *), smsg(char *); void setpage(PTR), msg(char *), emsg(char *), smsg(char *);
void usage(void), bvi_init(char *), statpos(void), setcur(void); void usage(void), bvi_init(char *), statpos(void), setcur(void);
@ -256,43 +253,43 @@ extern int space;
off_t edit(int), load(char *); off_t edit(int), load(char *);
off_t calc_size(char *); off_t calc_size(char *);
int ascii_comp(char *, char *), hex_comp(char *, char *); int ascii_comp(char *, char *), hex_comp(char *, char *);
int cur_forw(int), cur_back(void); int cur_forw(int), cur_back(void);
int lineout(void), save(char *, PTR, PTR, int); int lineout(void), save(char *, PTR, PTR, int);
int at_least(char *, char *, int); int at_least(char *, char *, int);
int vgetc(void), xpos(void), enlarge(off_t); int vgetc(void), xpos(void), enlarge(off_t);
int getcmdstr(char *, int), read_rc(char *); int getcmdstr(char *, int), read_rc(char *);
int wait_return(int); int wait_return(int);
#else #else
int addfile(); int addfile();
off_t alloc_buf(), yd_addr(); off_t alloc_buf(), yd_addr();
off_t range(); off_t range();
off_t calc_size(); off_t calc_size();
void do_mark(), badcmd(), movebyte(); void do_mark(), badcmd(), movebyte();
void do_back(), do_ins_chg(); void do_back(), do_ins_chg();
void jmpproc(), printline(); void jmpproc(), printline();
int chk_comm(); int chk_comm();
void docmdline(), do_over(), do_put(); void docmdline(), do_over(), do_put();
int doecmd(); int doecmd();
void do_dot(), do_exit(), do_shell(), do_undo(); void do_dot(), do_exit(), do_shell(), do_undo();
void do_tilde(), trunc_cur(); void do_tilde(), trunc_cur();
int do_append(), do_logic(); int do_append(), do_logic();
int do_delete(); int do_delete();
int doset(); int doset();
int do_substitution(); int do_substitution();
int hexchar(); int hexchar();
int outmsg(); int outmsg();
int save_chk(); int save_chk();
PTR searching(); PTR searching();
PTR wordsearch(); PTR wordsearch();
PTR backsearch(); PTR backsearch();
/* int bregexec(); */ /* int bregexec(); */
PTR bregexec(); PTR bregexec();
PTR fsearch(); PTR fsearch();
PTR fsearch_end(); PTR fsearch_end();
PTR rsearch(); PTR rsearch();
PTR end_word(); PTR end_word();
PTR calc_addr(); PTR calc_addr();
PTR do_ft(); PTR do_ft();
char *patcpy(); char *patcpy();
void setpage(), msg(), emsg(), smsg(); void setpage(), msg(), emsg(), smsg();
void usage(), bvi_init(), statpos(), setcur(); void usage(), bvi_init(), statpos(), setcur();
@ -302,9 +299,9 @@ extern int space;
void quit(), sysemsg(), do_z(), stuffin(); void quit(), sysemsg(), do_z(), stuffin();
off_t edit(), load(); off_t edit(), load();
int ascii_comp(), hex_comp(); int ascii_comp(), hex_comp();
int cur_forw(), cur_back(); int cur_forw(), cur_back();
int lineout(), save(), at_least(), read_rc(); int lineout(), save(), at_least(), read_rc();
int getcmdstr(), enlarge(); int getcmdstr(), enlarge();
int vgetc(), xpos(); int vgetc(), xpos();
int wait_return(); int wait_return();
#endif #endif

94
comm.c
View file

@ -8,18 +8,17 @@
* 1999-09-10 V 1.2.0 final * 1999-09-10 V 1.2.0 final
* 2000-03-03 V 1.3.0 beta * 2000-03-03 V 1.3.0 beta
* 2000-07-15 V 1.3.0 final * 2000-07-15 V 1.3.0 final
* 2001-10-10 V 1.3.1 * 2001-10-10 V 1.3.1
* 2003-07-04 V 1.3.2 * 2003-07-04 V 1.3.2
* 2005-08-17 V 1.3.3 * 2005-08-17 V 1.3.3
* 2010-06-02 V 1.3.4 * 2010-06-02 V 1.3.4
* 2014-01-28 V 1.4.0 * 2014-01-28 V 1.4.0
* 2019-01-27 V 1.4.1 * 2019-01-27 V 1.4.1
* 2023-03-06 V 1.4.2 * 2023-03-06 V 1.4.2
* 2025-07-19 V 1.5.0
* *
* NOTE: Edit this file with tabstop=4 ! * NOTE: Edit this file with tabstop=4 !
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2023 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -73,8 +72,8 @@ static char *c_argv[9];
char *nowrtmsg = "No write@since last change (:%s! overrides)"; char *nowrtmsg = "No write@since last change (:%s! overrides)";
char *morefiles = "more files@to edit"; char *morefiles = "more files@to edit";
char *ambigous = "Ambiguous|Too many file names"; char *ambigous = "Ambigous|Too many file names";
char *ambvalue = "Ambiguous|Too many values"; char *ambvalue = "Ambigous|Too many values";
char *extra = "Extra chars|Extra characters at end of command"; char *extra = "Extra chars|Extra characters at end of command";
char *noaddr = "No address allowed@on this command"; char *noaddr = "No address allowed@on this command";
char *noval = "No value@for binary operation"; char *noval = "No value@for binary operation";
@ -99,7 +98,8 @@ static char oldbuf[CMDSZ + 3]; /** for :!! command **/
* the environment variable "BVIINIT" (or eventually .bvirc). * the environment variable "BVIINIT" (or eventually .bvirc).
*/ */
void void
docmdline(char *cmdline) docmdline(cmdline)
char *cmdline;
{ {
char buff[CMDSZ]; char buff[CMDSZ];
char cmdbuf[CMDSZ]; char cmdbuf[CMDSZ];
@ -286,22 +286,22 @@ docmdline(char *cmdline)
if ((c_argv[c_argc] = strtok(cmd, " \t")) != NULL) c_argc++; if ((c_argv[c_argc] = strtok(cmd, " \t")) != NULL) c_argc++;
while ((c_argv[c_argc] = strtok(NULL, " \t")) != NULL) c_argc++; while ((c_argv[c_argc] = strtok(NULL, " \t")) != NULL) c_argc++;
if (c_argc > 1) { if (c_argc > 1) {
emsg(ambigous); emsg(ambigous);
return; } return; }
if (c_argc == 1) { if (c_argc == 1) {
/* change '%' to Filename */ /* change '%' to Filename */
while ((p = strchr(c_argv[0], '%')) != NULL && *(p-1) != '\\') { while ((p = strchr(c_argv[0], '%')) != NULL && *(p-1) != '\\') {
if (name == NULL) { if (name == NULL) {
emsg("No filename@to substitute for %"); emsg("No filename@to substitute for %");
return; return;
} }
*p = '\0'; *p = '\0';
strcpy (oldbuf, c_argv[0]); strcpy (oldbuf, c_argv[0]);
strcat (oldbuf, name); strcat (oldbuf, name);
strcat (oldbuf, p + 1); strcat (oldbuf, p + 1);
c_argv[0] = oldbuf; c_argv[0] = oldbuf;
} }
} }
if (name == NULL && c_argc != 0) name = strdup(c_argv[0]); if (name == NULL && c_argc != 0) name = strdup(c_argv[0]);
if (force) { if (force) {
@ -629,7 +629,11 @@ yd_addr()
/*********** Save file if not read only ********************/ /*********** Save file if not read only ********************/
int int
save_chk(char *fname, char *start, char *end, int flags) save_chk(fname, start, end, flags)
char *fname;
char *start;
char *end;
int flags;
{ {
if (P(P_RO)) { if (P(P_RO)) {
sprintf(string, "\"%s\" File is read only", name); sprintf(string, "\"%s\" File is read only", name);
@ -653,7 +657,9 @@ do_exit()
int int
doecmd(char *arg, int force) doecmd(arg, force)
char *arg;
int force;
{ {
char *tmp; char *tmp;
@ -716,34 +722,33 @@ clearstr()
/**** displays an error message *****/ /**** displays an error message *****/
void void
emsg(char *s) emsg(s)
char *s;
{ {
int cnt; int cnt;
/* int stchar;
int stchar;
if (P(P_EB)) beep();
if (P(P_MO)) { if (P(P_MO)) {
stchar = statsize; stchar = statsize;
} else { } else {
stchar = 0; stchar = 0;
} }
*/
if (P(P_EB)) beep();
statusflag = 0;
clearstr(); clearstr();
attrset(A_REVERSE); attrset(A_REVERSE);
cnt = outmsg(s); cnt = outmsg(s);
attrset(A_NORMAL); attrset(A_NORMAL);
if (cnt >= (maxx)) { if (cnt >= (maxx - stchar)) {
// addch('\n'); addch('\n');
wait_return(TRUE); wait_return(TRUE); }
}
} }
/*** System error message *****/ /*** System error message *****/
void void
sysemsg(char *s) sysemsg(s)
char *s;
{ {
char string[256]; char string[256];
@ -759,7 +764,8 @@ sysemsg(char *s)
/*** displays mode if showmode set *****/ /*** displays mode if showmode set *****/
void void
smsg(char *s) smsg(s)
char *s;
{ {
if (P(P_MO)) { if (P(P_MO)) {
msg(s); msg(s);
@ -770,30 +776,30 @@ smsg(char *s)
/************* displays s on status line *****************/ /************* displays s on status line *****************/
void void
msg(char *s) msg(s)
char *s;
{ {
/*
int stchar; int stchar;
if (P(P_MO)) { if (P(P_MO)) {
stchar = statsize; stchar = statsize;
} else { } else {
stchar = 0; stchar = 0;
}o*/ }
statusflag = 0;
clearstr(); clearstr();
if (outmsg(s) >= maxx) { if (outmsg(s) >= (maxx - stchar)) {
// addch('\n'); addch('\n');
wait_return(TRUE); wait_return(TRUE);
} }
} }
int int
outmsg(char *s) outmsg(s)
char *s;
{ {
char *poi; char *poi;
int cnt = 0; int cnt = 0;
move(maxy, 0); move(maxy, 0);
poi = strchr(s, '|'); poi = strchr(s, '|');
@ -805,7 +811,7 @@ outmsg(char *s)
cnt++; cnt++;
} }
} else { } else {
if (poi) poi++; if (poi) poi++;
else poi = s; else poi = s;
while (*poi) { while (*poi) {
if (*poi == '@') addch(' '); if (*poi == '@') addch(' ');
@ -822,7 +828,8 @@ outmsg(char *s)
* *
*/ */
int int
wait_return(int flag) wait_return(flag)
int flag;
{ {
int c; int c;
@ -845,7 +852,8 @@ wait_return(int flag)
int int
chk_comm(int flag) chk_comm(flag)
int flag;
{ {
if ((flag & NO_ADDR) && (addr_flag > 0)) { if ((flag & NO_ADDR) && (addr_flag > 0)) {
emsg(noaddr); return 1; } emsg(noaddr); return 1; }

71
config.guess vendored
View file

@ -1,10 +1,10 @@
#! /bin/sh #! /bin/sh
# Attempt to guess a canonical system name. # Attempt to guess a canonical system name.
# Copyright 1992-2024 Free Software Foundation, Inc. # Copyright 1992-2023 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale # shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2024-07-27' timestamp='2023-01-01'
# This file is free software; you can redistribute it and/or modify it # 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 # under the terms of the GNU General Public License as published by
@ -47,7 +47,7 @@ me=`echo "$0" | sed -e 's,.*/,,'`
usage="\ usage="\
Usage: $0 [OPTION] Usage: $0 [OPTION]
Output the configuration name of the system '$me' is run on. Output the configuration name of the system \`$me' is run on.
Options: Options:
-h, --help print this help, then exit -h, --help print this help, then exit
@ -60,13 +60,13 @@ version="\
GNU config.guess ($timestamp) GNU config.guess ($timestamp)
Originally written by Per Bothner. Originally written by Per Bothner.
Copyright 1992-2024 Free Software Foundation, Inc. Copyright 1992-2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help=" help="
Try '$me --help' for more information." Try \`$me --help' for more information."
# Parse command line # Parse command line
while test $# -gt 0 ; do while test $# -gt 0 ; do
@ -102,8 +102,8 @@ GUESS=
# temporary files to be created and, as you can see below, it is a # temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion. # headache to deal with in a portable fashion.
# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use 'HOST_CC' if defined, but it is deprecated. # use `HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team. # Portable tmp directory creation inspired by the Autoconf team.
@ -123,7 +123,7 @@ set_cc_for_build() {
dummy=$tmp/dummy dummy=$tmp/dummy
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
,,) echo "int x;" > "$dummy.c" ,,) echo "int x;" > "$dummy.c"
for driver in cc gcc c17 c99 c89 ; do for driver in cc gcc c89 c99 ; do
if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
CC_FOR_BUILD=$driver CC_FOR_BUILD=$driver
break break
@ -155,9 +155,6 @@ Linux|GNU|GNU/*)
set_cc_for_build set_cc_for_build
cat <<-EOF > "$dummy.c" cat <<-EOF > "$dummy.c"
#if defined(__ANDROID__)
LIBC=android
#else
#include <features.h> #include <features.h>
#if defined(__UCLIBC__) #if defined(__UCLIBC__)
LIBC=uclibc LIBC=uclibc
@ -165,8 +162,6 @@ Linux|GNU|GNU/*)
LIBC=dietlibc LIBC=dietlibc
#elif defined(__GLIBC__) #elif defined(__GLIBC__)
LIBC=gnu LIBC=gnu
#elif defined(__LLVM_LIBC__)
LIBC=llvm
#else #else
#include <stdarg.h> #include <stdarg.h>
/* First heuristic to detect musl libc. */ /* First heuristic to detect musl libc. */
@ -174,7 +169,6 @@ Linux|GNU|GNU/*)
LIBC=musl LIBC=musl
#endif #endif
#endif #endif
#endif
EOF EOF
cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
eval "$cc_set_libc" eval "$cc_set_libc"
@ -465,7 +459,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
UNAME_RELEASE=`uname -v` UNAME_RELEASE=`uname -v`
;; ;;
esac esac
# Japanese Language versions have a version number like '4.1.3-JL'. # Japanese Language versions have a version number like `4.1.3-JL'.
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
GUESS=sparc-sun-sunos$SUN_REL GUESS=sparc-sun-sunos$SUN_REL
;; ;;
@ -634,8 +628,7 @@ EOF
sed 's/^ //' << EOF > "$dummy.c" sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h> #include <sys/systemcfg.h>
int main()
main ()
{ {
if (!__power_pc()) if (!__power_pc())
exit(1); exit(1);
@ -719,8 +712,7 @@ EOF
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
int int main ()
main ()
{ {
#if defined(_SC_KERNEL_BITS) #if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS); long bits = sysconf(_SC_KERNEL_BITS);
@ -912,7 +904,7 @@ EOF
fi fi
;; ;;
*:FreeBSD:*:*) *:FreeBSD:*:*)
UNAME_PROCESSOR=`uname -p` UNAME_PROCESSOR=`/usr/bin/uname -p`
case $UNAME_PROCESSOR in case $UNAME_PROCESSOR in
amd64) amd64)
UNAME_PROCESSOR=x86_64 ;; UNAME_PROCESSOR=x86_64 ;;
@ -984,27 +976,7 @@ EOF
GUESS=$UNAME_MACHINE-unknown-minix GUESS=$UNAME_MACHINE-unknown-minix
;; ;;
aarch64:Linux:*:*) aarch64:Linux:*:*)
set_cc_for_build GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
CPU=$UNAME_MACHINE
LIBCABI=$LIBC
if test "$CC_FOR_BUILD" != no_compiler_found; then
ABI=64
sed 's/^ //' << EOF > "$dummy.c"
#ifdef __ARM_EABI__
#ifdef __ARM_PCS_VFP
ABI=eabihf
#else
ABI=eabi
#endif
#endif
EOF
cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
eval "$cc_set_abi"
case $ABI in
eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
esac
fi
GUESS=$CPU-unknown-linux-$LIBCABI
;; ;;
aarch64_be:Linux:*:*) aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be UNAME_MACHINE=aarch64_be
@ -1070,15 +1042,6 @@ EOF
k1om:Linux:*:*) k1om:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;; ;;
kvx:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
kvx:cos:*:*)
GUESS=$UNAME_MACHINE-unknown-cos
;;
kvx:mbr:*:*)
GUESS=$UNAME_MACHINE-unknown-mbr
;;
loongarch32:Linux:*:* | loongarch64:Linux:*:*) loongarch32:Linux:*:* | loongarch64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;; ;;
@ -1234,7 +1197,7 @@ EOF
GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
;; ;;
i*86:OS/2:*:*) i*86:OS/2:*:*)
# If we were able to find 'uname', then EMX Unix compatibility # If we were able to find `uname', then EMX Unix compatibility
# is probably installed. # is probably installed.
GUESS=$UNAME_MACHINE-pc-os2-emx GUESS=$UNAME_MACHINE-pc-os2-emx
;; ;;
@ -1375,7 +1338,7 @@ EOF
GUESS=ns32k-sni-sysv GUESS=ns32k-sni-sysv
fi fi
;; ;;
PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV> # says <Richard.M.Bartel@ccMail.Census.GOV>
GUESS=i586-unisys-sysv4 GUESS=i586-unisys-sysv4
;; ;;
@ -1597,9 +1560,6 @@ EOF
*:Unleashed:*:*) *:Unleashed:*:*)
GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
;; ;;
*:Ironclad:*:*)
GUESS=$UNAME_MACHINE-unknown-ironclad
;;
esac esac
# Do we have a guess based on uname results? # Do we have a guess based on uname results?
@ -1623,7 +1583,6 @@ cat > "$dummy.c" <<EOF
#endif #endif
#endif #endif
#endif #endif
int
main () main ()
{ {
#if defined (sony) #if defined (sony)

View file

@ -11,7 +11,7 @@
#undef NEED_PUTC_CHAR #undef NEED_PUTC_CHAR
#undef HAVE_NCURSES_TERM_H #undef HAVE_NCURSES_TERM_H
/* Define to 1 if you have the <fcntl.h> header file. */ /* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H #undef HAVE_FCNTL_H

935
config.sub vendored

File diff suppressed because it is too large Load diff

View file

@ -12,13 +12,13 @@ dnl On SunOS4 systems you have to use the /usr/5bin/cc compiler
dnl to get the SYSV curses library: dnl to get the SYSV curses library:
case "$host_os" in case "$host_os" in
sunos4*) sunos4*)
AC_MSG_RESULT("using /usr/5bin/cc") AC_MSG_RESULT("using /usr/5bin/cc")
CC="/usr/5bin/cc" CC="/usr/5bin/cc"
ac_objext="o" ac_objext="o"
;; ;;
*) *)
AC_PROG_CC AC_PROG_CC
;; ;;
esac esac
@ -26,11 +26,11 @@ dnl Some curses specials
dnl Solaris needs for tputs 'putc(char)' instead of 'putc(int)' dnl Solaris needs for tputs 'putc(char)' instead of 'putc(int)'
case "$host_os" in case "$host_os" in
solaris*) solaris*)
CPPFLAGS="${CPPFLAGS} -D_MSE_INT_H" CPPFLAGS="${CPPFLAGS} -D_MSE_INT_H"
AC_DEFINE(NEED_PUTC_CHAR) AC_DEFINE(NEED_PUTC_CHAR)
;; ;;
hpux9*) DEFS=${DEFS-"-DMINICURSES"} hpux9*) DEFS=${DEFS-"-DMINICURSES"}
;; ;;
esac esac
@ -65,21 +65,21 @@ AC_ARG_WITH(ncurses,
AC_CHECK_HEADER([ncurses.h],[ AC_CHECK_HEADER([ncurses.h],[
AC_SEARCH_LIBS([initscr], [ncurses], [ AC_SEARCH_LIBS([initscr], [ncurses], [
AC_DEFINE(HAVE_NCURSES_H) AC_DEFINE(HAVE_NCURSES_H)
AC_SEARCH_LIBS([tputs], [tinfo])],[ AC_SEARCH_LIBS([tputs], [tinfo])],[
AC_SEARCH_LIBS([initscr], [curses],[ AC_SEARCH_LIBS([initscr], [curses],[
AC_DEFINE(HAVE_CURSES_H) AC_DEFINE(HAVE_CURSES_H)
AC_SEARCH_LIBS([tputs], [tinfo])],[ AC_SEARCH_LIBS([tputs], [tinfo])],[
AC_MSG_ERROR([bvi requires a curses library])])]) AC_MSG_ERROR([bvi requires a curses library])])])
],[ ],[
AC_CHECK_HEADER([curses.h],[ AC_CHECK_HEADER([curses.h],[
AC_SEARCH_LIBS([initscr], [curses], [ AC_SEARCH_LIBS([initscr], [curses], [
AC_DEFINE(HAVE_CURSES_H)],[ AC_DEFINE(HAVE_CURSES_H)],[
AC_MSG_ERROR([bvi requires a curses library])])],[ AC_MSG_ERROR([bvi requires a curses library])])],[
AC_CHECK_HEADER([ncursesw/curses.h], [ AC_CHECK_HEADER([ncursesw/curses.h], [
AC_SEARCH_LIBS([initscr], [ncursesw], [ AC_SEARCH_LIBS([initscr], [ncursesw], [
AC_DEFINE(HAVE_NCURSESW_CURSES_H)],[ AC_DEFINE(HAVE_NCURSESW_CURSES_H)],[
AC_MSG_ERROR([bvi requires a curses library])])],[ AC_MSG_ERROR([bvi requires a curses library])])],[
AC_MSG_ERROR([bvi requires a curses library])])])]) AC_MSG_ERROR([bvi requires a curses library])])])])
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
dnl AC_TYPE_SIZE_T dnl AC_TYPE_SIZE_T

66
dosio.c
View file

@ -141,14 +141,14 @@ save(char *fname, PTR start, PTR end, int flags)
if (!fname) { if (!fname) {
emsg("No file|No current filename"); emsg("No file|No current filename");
return 0; return 0;
} }
if (stat(fname, &buf) == -1) { if (stat(fname, &buf) == -1) {
newstr = "[New file] "; newstr = "[New file] ";
} else { } else {
if (S_ISDIR(buf.st_mode)) { if (S_ISDIR(buf.st_mode)) {
sprintf(string, "\"%s\" Is a directory", fname); sprintf(string, "\"%s\" Is a directory", fname);
msg(string); msg(string);
return 0; return 0;
} }
newstr = ""; newstr = "";
} }
@ -159,20 +159,20 @@ save(char *fname, PTR start, PTR end, int flags)
return 0; return 0;
} }
if (filemode == PARTIAL) { if (filemode == PARTIAL) {
if (block_read) { if (block_read) {
filesize = block_read; filesize = block_read;
sprintf(string, "\"%s\" range %lu-%lu", fname, sprintf(string, "\"%s\" range %lu-%lu", fname,
(unsigned long)block_begin, (unsigned long)block_begin,
(unsigned long)(block_begin - 1 + filesize)); (unsigned long)(block_begin - 1 + filesize));
if (lseek(fd, block_begin, SEEK_SET) < 0) { if (lseek(fd, block_begin, SEEK_SET) < 0) {
sysemsg(fname); sysemsg(fname);
return 0; return 0;
} }
} else { } else {
msg("Null range"); msg("Null range");
return 0; return 0;
} }
} else { } else {
filesize = end - start + 1L; filesize = end - start + 1L;
sprintf(string, "\"%s\" %s%lu@bytes", fname, newstr, (long)filesize); sprintf(string, "\"%s\" %s%lu@bytes", fname, newstr, (long)filesize);
} }
@ -228,7 +228,7 @@ load(char *fname)
} else if (filemode == REGULAR) { } else if (filemode == REGULAR) {
memsize = buf.st_size + 100; memsize = buf.st_size + 100;
} else { } else {
memsize = 1000; memsize = 1000;
} }
if (farcoreleft() < memsize) { if (farcoreleft() < memsize) {
@ -255,18 +255,18 @@ load(char *fname)
filesize += (off_t)n; filesize += (off_t)n;
} while (filesize < buf.st_size); } while (filesize < buf.st_size);
if ((filesize == 0) { if ((filesize == 0) {
sprintf(string, "\"%s\" No such range: %lu-%lu", fname, sprintf(string, "\"%s\" No such range: %lu-%lu", fname,
(unsigned long)block_begin, (unsigned long)(block_end)); (unsigned long)block_begin, (unsigned long)(block_end));
} else { } else {
sprintf(string, "\"%s\" range %lu-%lu", fname, sprintf(string, "\"%s\" range %lu-%lu", fname,
(unsigned long)block_begin, (unsigned long)block_begin,
(unsigned long)(block_begin + filesize - 1)); (unsigned long)(block_begin + filesize - 1));
} }
filemode = PARTIAL; filemode = PARTIAL;
block_read = filesize; block_read = filesize;
msg(string); msg(string);
P(P_OF) = block_begin; P(P_OF) = block_begin;
params[P_OF].flags |= P_CHANGED; params[P_OF].flags |= P_CHANGED;
} }
} else if (filemode == REGULAR) { } else if (filemode == REGULAR) {
chunk = buf.st_size > 0xfffe ? 0xfffe : buf.st_size; chunk = buf.st_size > 0xfffe ? 0xfffe : buf.st_size;

177
edit.c
View file

@ -12,9 +12,8 @@
* 2006-04-05 V 1.3.3 alpha - binary representation * 2006-04-05 V 1.3.3 alpha - binary representation
* 2014-09-30 V 1.4.0 * 2014-09-30 V 1.4.0
* 2019-10-12 V 1.4.1 * 2019-10-12 V 1.4.1
* 2025-07-19 V 1.5.0
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2019 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -64,7 +63,8 @@ static char *getcnext = NULL;
* characters (for "." command) * characters (for "." command)
*/ */
off_t off_t
edit(int mode) edit(mode)
int mode;
{ {
int ch, ch1; int ch, ch1;
size_t len; size_t len;
@ -117,7 +117,7 @@ edit(int mode)
setcur(); setcur();
continue; continue;
} }
if (ch == KEY_BACKSPACE if (ch == KEY_BACKSPACE
|| ch == ASCII_DEL || ch == ASCII_DEL
|| ch == BVICTRL('H')) { || ch == BVICTRL('H')) {
if (count > 0) { if (count > 0) {
@ -286,7 +286,8 @@ escape:
* else setpage() * else setpage()
*/ */
PTR PTR
do_ft(int ch, int flag) do_ft(ch, flag)
int ch, flag;
{ {
static int chi; static int chi;
static int chp = 1; static int chp = 1;
@ -297,7 +298,7 @@ do_ft(int ch, int flag)
switch (ch) { switch (ch) {
/* /*
case 1: beep(); case 1: beep();
return NULL; no previous command return NULL; no previous command
case -1: if (chp == 'f' || chp == 't') dir = BACKWARD; case -1: if (chp == 'f' || chp == 't') dir = BACKWARD;
else dir = FORWARD; else dir = FORWARD;
break; break;
@ -363,7 +364,8 @@ do_ft(int ch, int flag)
void void
do_z(int mode) do_z(mode)
int mode;
{ {
switch (mode) { switch (mode) {
case '.': while (y != maxy / 2) { case '.': while (y != maxy / 2) {
@ -399,7 +401,8 @@ do_z(int mode)
void void
scrolldown(int lns) scrolldown(lns)
int lns;
{ {
while (lns--) { while (lns--) {
if (maxpos >= (pagepos + Anzahl)) pagepos += Anzahl; if (maxpos >= (pagepos + Anzahl)) pagepos += Anzahl;
@ -411,7 +414,8 @@ scrolldown(int lns)
void void
scrollup(int lns) scrollup(lns)
int lns;
{ {
while (lns--) { while (lns--) {
if (mem <= (PTR)(pagepos - Anzahl)) pagepos -= Anzahl; if (mem <= (PTR)(pagepos - Anzahl)) pagepos -= Anzahl;
@ -455,14 +459,13 @@ setcur()
void void
statpos() statpos()
{ {
char bin_val [9]; char bin_val [9];
unsigned char Char1; unsigned char Char1;
int i; int i;
off_t bytepos; off_t bytepos;
char string[MAXCMD+1], str[6]; char string[MAXCMD+1], str[6];
// if (!P(P_MO)) return; if (!P(P_MO)) return;
if (!statusflag) return;
bytepos = current - mem; bytepos = current - mem;
if (bytepos >= filesize) { if (bytepos >= filesize) {
// mvaddstr(maxy, status, " "); // mvaddstr(maxy, status, " ");
@ -480,19 +483,11 @@ statpos()
} }
} }
bin_val[8] = '\0'; bin_val[8] = '\0';
sprintf(string, "%08llX %s \\%03o 0x%02X %3d ",
(long long)(bytepos + P(P_OF)), bin_val, Char1, Char1, Char1);
attrset(A_BOLD); attrset(A_BOLD);
status = maxx - 1 - statsize; status = maxx - 1 - statsize;
if (status > 0) {
sprintf(string, "%08llX %s \\%03o 0x%02X %3d ",
(long long)(bytepos + P(P_OF)), bin_val, Char1, Char1, Char1);
} else {
sprintf(string, "%08llX %3d ",
(long long)(bytepos + P(P_OF)), Char1);
mvaddstr(maxy, 0, string);
attrset(A_NORMAL);
return;
}
mvaddstr(maxy, status, string); mvaddstr(maxy, status, string);
if (isprint(Char1)) { if (isprint(Char1)) {
@ -526,9 +521,10 @@ statpos()
} }
void void
printline(PTR mempos, int scpos) printline(mempos, scpos)
PTR mempos;
int scpos;
{ {
PTR hl_start = 0; PTR hl_start = 0;
PTR hl_end = 0; PTR hl_end = 0;
@ -548,44 +544,44 @@ printline(PTR mempos, int scpos)
mv_pos = AnzAdd; mv_pos = AnzAdd;
*linbuf = '\0'; *linbuf = '\0';
if (hl_spat) { if (hl_spat) {
f_start = (mempos - Anzahl) < mem ? mem : (mempos - Anzahl); f_start = (mempos - Anzahl) < mem ? mem : (mempos - Anzahl);
f_end = mempos + (2 * Anzahl); f_end = mempos + (2 * Anzahl);
hl_start = fsearch_end(f_start, f_end, search_pat, &hl_end); hl_start = fsearch_end(f_start, f_end, search_pat, &hl_end);
} }
for (print_pos = 0; print_pos < Anzahl; print_pos++) { for (print_pos = 0; print_pos < Anzahl; print_pos++) {
if (hl_spat) { if (hl_spat) {
while (hl_start != NULL) { while (hl_start != NULL) {
if (hl_start < mempos) { if (hl_start < mempos) {
if (hl_end < mempos) { if (hl_end < mempos) {
f_start = hl_start + 1; f_start = hl_start + 1;
hl_start = fsearch_end(f_start, f_end, search_pat, &hl_end); hl_start = fsearch_end(f_start, f_end, search_pat, &hl_end);
} else { } else {
attrset(A_STANDOUT); /* start out highlighted */ attrset(A_STANDOUT); /* start out highlighted */
break; break;
} }
} else if (hl_start >= mempos) { } else if (hl_start >= mempos) {
break; break;
} }
} }
if (hl_start != NULL) { if (hl_start != NULL) {
if ((hl_start - mempos) == print_pos) { if ((hl_start - mempos) == print_pos) {
mvaddstr(scpos, mv_pos, linbuf); mvaddstr(scpos, mv_pos, linbuf);
mv_pos = AnzAdd + (3 * print_pos); mv_pos = AnzAdd + (3 * print_pos);
*linbuf = '\0'; *linbuf = '\0';
attrset(A_STANDOUT); attrset(A_STANDOUT);
} }
if ((hl_end - mempos) == print_pos) { if ((hl_end - mempos) == print_pos) {
mvaddstr(scpos, mv_pos, linbuf); mvaddstr(scpos, mv_pos, linbuf);
*linbuf = '\0'; *linbuf = '\0';
mv_pos = AnzAdd + (3 * print_pos); mv_pos = AnzAdd + (3 * print_pos);
f_start = hl_end; f_start = hl_end;
hl_start = fsearch_end(f_start, f_end, search_pat, &hl_end); hl_start = fsearch_end(f_start, f_end, search_pat, &hl_end);
if (f_start != hl_start) { if (f_start != hl_start) {
attrset(A_NORMAL); attrset(A_NORMAL);
} }
} }
} }
} }
if (mempos + print_pos >= maxpos) { if (mempos + print_pos >= maxpos) {
sprintf(tmpbuf, " "); sprintf(tmpbuf, " ");
@ -613,10 +609,10 @@ printline(PTR mempos, int scpos)
addstr(string); addstr(string);
attrset(A_NORMAL); attrset(A_NORMAL);
} else { } else {
addstr("."); addstr(".");
} }
} else { } else {
addstr("."); addstr(".");
} }
} }
} else { } else {
@ -664,7 +660,8 @@ repaint() /***** redraw screen *********************/
/******* display an arbitrary address on screen *******/ /******* display an arbitrary address on screen *******/
void void
setpage(PTR addr) setpage(addr)
PTR addr;
{ {
if ((addr >= pagepos) && ((addr - pagepos) < screen)) { if ((addr >= pagepos) && ((addr - pagepos) < screen)) {
y = (addr - pagepos) / Anzahl; y = (addr - pagepos) / Anzahl;
@ -687,7 +684,8 @@ setpage(PTR addr)
int int
cur_forw(int check) cur_forw(check)
int check;
{ {
if (check) { if (check) {
if (current - mem >= filesize) { if (current - mem >= filesize) {
@ -762,7 +760,8 @@ cur_back()
void void
fileinfo(char *fname) fileinfo(fname)
char *fname;
{ {
off_t bytepos; off_t bytepos;
char fstatus[MAXCMD]; char fstatus[MAXCMD];
@ -789,8 +788,8 @@ fileinfo(char *fname)
if (edits) strcat(string, "[Modified] "); if (edits) strcat(string, "[Modified] ");
if (filesize) { if (filesize) {
bytepos = (pagepos + y * Anzahl + xpos()) - mem + 1L; bytepos = (pagepos + y * Anzahl + xpos()) - mem + 1L;
sprintf(fstatus, "byte %llu of %llu --%llu%%--", sprintf(fstatus, "byte %llu of %llu --%llu%%--",
(unsigned long long)bytepos, (unsigned long long)bytepos,
(unsigned long long)filesize, (unsigned long long)filesize,
(unsigned long long)(bytepos * 100L / filesize)); (unsigned long long)(bytepos * 100L / filesize));
strcat(string, fstatus); strcat(string, fstatus);
@ -831,7 +830,8 @@ vgetc()
void void
stuffin(char *s) stuffin(s)
char *s;
{ {
if (s == NULL) { /* clear the stuff buffer */ if (s == NULL) { /* clear the stuff buffer */
getcnext = NULL; getcnext = NULL;
@ -846,7 +846,9 @@ stuffin(char *s)
void void
do_back(off_t n, PTR start) do_back(n, start)
off_t n;
PTR start;
{ {
if (start - n < mem) { if (start - n < mem) {
beep(); beep();
@ -868,7 +870,9 @@ do_back(off_t n, PTR start)
int int
do_delete(off_t n, PTR start) do_delete(n, start)
off_t n;
PTR start;
{ {
if (n + start > maxpos) { if (n + start > maxpos) {
beep(); beep();
@ -898,7 +902,10 @@ do_delete(off_t n, PTR start)
* The :insert, :append and :change command * The :insert, :append and :change command
*/ */
void void
do_ins_chg(PTR start, char *arg, int mode) do_ins_chg(start, arg, mode)
PTR start;
char *arg;
int mode;
{ {
int base; int base;
off_t buffer = BUFFER; off_t buffer = BUFFER;
@ -938,22 +945,22 @@ do_ins_chg(PTR start, char *arg, int mode)
if (base == 1) { /* ASCII */ if (base == 1) { /* ASCII */
while (*poi != '\0') { while (*poi != '\0') {
if (*poi == '\\') { if (*poi == '\\') {
switch (*(++poi)) { switch (*(++poi)) {
case 'n': val = '\n'; break; case 'n': val = '\n'; break;
case 'r': val = '\r'; break; case 'r': val = '\r'; break;
case 't': val = '\t'; break; case 't': val = '\t'; break;
case '0': val = '\0'; break; case '0': val = '\0'; break;
case '\\': val = '\\'; break; case '\\': val = '\\'; break;
default : val = '\\'; poi--; default : val = '\\'; poi--;
} }
poi++; poi++;
} else { } else {
val = *poi++; val = *poi++;
} }
*(tempbuf + count++) = val; *(tempbuf + count++) = val;
} }
} else { } else {
while (isspace(cmdstr[strlen(cmdstr) - 1])) while (isspace(cmdstr[strlen(cmdstr) - 1]))
cmdstr[strlen(cmdstr) - 1] = '\0'; cmdstr[strlen(cmdstr) - 1] = '\0';
while (*poi != '\0') { while (*poi != '\0') {
val = strtol(poi, &epoi, base); val = strtol(poi, &epoi, base);
@ -986,7 +993,7 @@ do_ins_chg(PTR start, char *arg, int mode)
case U_APPEND: case U_APPEND:
if ((undo_count = alloc_buf(count, &undo_buf)) == 0L) { if ((undo_count = alloc_buf(count, &undo_buf)) == 0L) {
repaint(); repaint();
goto mfree; goto mfree;
} }
do_append((off_t)count, tempbuf); do_append((off_t)count, tempbuf);
memcpy(undo_buf, tempbuf, count); memcpy(undo_buf, tempbuf, count);
@ -1014,9 +1021,11 @@ clear_marks()
void void
do_mark(int mark, PTR addr) do_mark(mark, addr)
int mark;
PTR addr;
{ {
if (mark < 'a' || mark > 'z' || current >= maxpos) if (mark < 'a' || mark > 'z' || current >= maxpos)
return; return;
markbuf[mark - 'a'] = addr; markbuf[mark - 'a'] = addr;
} }

41
io.c
View file

@ -12,11 +12,10 @@
* 2014-05-03 V 1.4.0 * 2014-05-03 V 1.4.0
* 2019-01-27 V 1.4.1 * 2019-01-27 V 1.4.1
* 2022-03-09 V 1.4.2 * 2022-03-09 V 1.4.2
* 2025-07-19 V 1.5.0
* *
* NOTE: Edit this file with tabstop=4 ! * NOTE: Edit this file with tabstop=4 !
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2022 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -80,7 +79,11 @@ extern char *fname_buf;
/*********** Save the patched file ********************/ /*********** Save the patched file ********************/
int int
save(char *fname, char *start, char *end, int flags) save(fname, start, end, flags)
char *fname;
char *start;
char *end;
int flags;
{ {
int fd; int fd;
char *string; char *string;
@ -164,7 +167,8 @@ save(char *fname, char *start, char *end, int flags)
/* loads a file, returns the filesize */ /* loads a file, returns the filesize */
off_t off_t
load(char *fname) load(fname)
char *fname;
{ {
int fd = -1; int fd = -1;
//char *string; //char *string;
@ -231,7 +235,7 @@ load(char *fname)
params[P_RO].flags |= P_CHANGED; params[P_RO].flags |= P_CHANGED;
} }
} else { } else {
sysemsg(fname); sysemsg(fname);
filemode = ERROR; filemode = ERROR;
} }
} }
@ -329,11 +333,12 @@ load(char *fname)
} }
/* argument "dir" not used! /* argument "dir" not used!
* Needed for DOS version only * Needed for DOS version only
*/ */
void void
bvi_init(char *dir) bvi_init(dir)
char *dir;
{ {
char *initstr; char *initstr;
char rcpath[MAXCMD]; char rcpath[MAXCMD];
@ -347,7 +352,7 @@ bvi_init(char *dir)
docmdline(initstr); docmdline(initstr);
return; return;
} }
#ifdef DJGPP #ifdef DJGPP
strcpy(rcpath, "c:"); strcpy(rcpath, "c:");
strcpy(rcpath, dir); strcpy(rcpath, dir);
@ -373,7 +378,8 @@ bvi_init(char *dir)
int int
enlarge(off_t add) enlarge(add)
off_t add;
{ {
char *newmem; char *newmem;
off_t savecur, savepag, savemax, saveundo; off_t savecur, savepag, savemax, saveundo;
@ -422,10 +428,11 @@ do_shell()
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
char * char *
strdup(char *s) strdup(s)
char *s;
{ {
char *p; char *p;
size_t n; size_t n;
n = strlen(s) + 1; n = strlen(s) + 1;
if ((p = (char *)malloc(n)) != NULL) if ((p = (char *)malloc(n)) != NULL)
@ -440,7 +447,10 @@ strdup(char *s)
* Copy contents of memory (with possible overlapping). * Copy contents of memory (with possible overlapping).
*/ */
char * char *
memmove(char *s1, char *s2, size_t n) memmove(s1, s2, n)
char *s1;
char *s2;
size_t n;
{ {
bcopy(s2, s1, n); bcopy(s2, s1, n);
return(s1); return(s1);
@ -449,7 +459,9 @@ memmove(char *s1, char *s2, size_t n)
off_t off_t
alloc_buf(off_t n, char **buffer) alloc_buf(n, buffer)
off_t n;
char **buffer;
{ {
if (*buffer == NULL) { if (*buffer == NULL) {
*buffer = (char *)malloc(n); *buffer = (char *)malloc(n);
@ -465,7 +477,8 @@ alloc_buf(off_t n, char **buffer)
int int
addfile(char *fname) addfile(fname)
char *fname;
{ {
int fd; int fd;
off_t oldsize; off_t oldsize;

View file

@ -1,59 +1,59 @@
AC_CHECK_HEADER AC_CHECK_HEADER
( (
[ncurses.h], [ncurses.h],
[ [
AC_SEARCH_LIBS AC_SEARCH_LIBS
([initscr], [ncurses], ([initscr], [ncurses],
[ [
AC_DEFINE(HAVE_NCURSES_H) AC_DEFINE(HAVE_NCURSES_H)
AC_SEARCH_LIBS([tputs], [tinfo]) AC_SEARCH_LIBS([tputs], [tinfo])
],[ ],[
AC_SEARCH_LIBS AC_SEARCH_LIBS
( (
[initscr], [curses], [initscr], [curses],
[ [
AC_DEFINE(HAVE_CURSES_H) AC_DEFINE(HAVE_CURSES_H)
AC_SEARCH_LIBS([tputs], [tinfo]) AC_SEARCH_LIBS([tputs], [tinfo])
],[ ],[
AC_MSG_ERROR([bvi requires a curses library]) AC_MSG_ERROR([bvi requires a curses library])
] ]
) )
] ]
) )
],[ ],[
AC_CHECK_HEADER AC_CHECK_HEADER
( (
[curses.h], [curses.h],
[ [
AC_SEARCH_LIBS AC_SEARCH_LIBS
(
[initscr], [curses],
[
AC_DEFINE(HAVE_CURSES_H)
],[
AC_MSG_ERROR([bvi requires a curses library])
]
)
],[
# statt: AC_MSG_ERROR([bvi requires a curses library])
AC_CHECK_HEADER
( (
[ncursesw/curses.h], [initscr], [curses],
[ [
AC_SEARCH_LIBS AC_DEFINE(HAVE_CURSES_H)
(
[initscr], [curses],
[
AC_DEFINE(HAVE_NCURSESW_CURSES_H)
],[
AC_MSG_ERROR([bvi requires a curses library])
]
)
],[ ],[
AC_MSG_ERROR([bvi requires a curses library]) AC_MSG_ERROR([bvi requires a curses library])
] ]
) )
] ],[
) # statt: AC_MSG_ERROR([bvi requires a curses library])
] AC_CHECK_HEADER
(
[ncursesw/curses.h],
[
AC_SEARCH_LIBS
(
[initscr], [curses],
[
AC_DEFINE(HAVE_NCURSESW_CURSES_H)
],[
AC_MSG_ERROR([bvi requires a curses library])
]
)
],[
AC_MSG_ERROR([bvi requires a curses library])
]
)
]
)
]
) )

View file

@ -1 +1 @@
#define VERSION "1.5.0" #define VERSION "1.4.2"

74
re.c
View file

@ -12,9 +12,8 @@
* 2013-08-24 V 1.4.0 * 2013-08-24 V 1.4.0
* 2019-01-28 V 1.4.1 * 2019-01-28 V 1.4.1
* 2023-03-07 V 1.4.2 * 2023-03-07 V 1.4.2
* 2025-07-19 V 1.5.0
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2023 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -33,15 +32,11 @@
/* You cannot use a common regexp subroutine, because \0 is a regular /* You cannot use a common regexp subroutine, because \0 is a regular
* character in a binary string ! * character in a binary string !
*/ */
#include "bvi.h" #include "bvi.h"
#include "set.h" #include "set.h"
#ifdef __STDC__
static int sbracket(int, char *, int);
#else
static int sbracket(); static int sbracket();
#endif
char act_pat[MAXCMD]; /* found pattern */ char act_pat[MAXCMD]; /* found pattern */
char pattern[MAXCMD + 1]; char pattern[MAXCMD + 1];
@ -53,7 +48,9 @@ char *emptyclass = "Bad character class|Empty byte class '[]' or '[^]' cannot ma
PTR PTR
bregexec(PTR start, char *scan) bregexec(start, scan)
PTR start;
char *scan;
{ {
char *act; char *act;
int count, test; int count, test;
@ -128,7 +125,10 @@ bregexec(PTR start, char *scan)
static int static int
sbracket(int start, char *scan, int count) sbracket(start, scan, count)
int start;
char *scan;
int count;
{ {
if (*scan++ == '^') { if (*scan++ == '^') {
if (!memchr(scan, start, --count)) return 0; if (!memchr(scan, start, --count)) return 0;
@ -140,7 +140,8 @@ sbracket(int start, char *scan, int count)
PTR PTR
end_word(PTR start) end_word(start)
PTR start;
{ {
PTR pos; PTR pos;
@ -154,7 +155,9 @@ end_word(PTR start)
/* wordsearch serves the 'W' and 'w' - command /* wordsearch serves the 'W' and 'w' - command
*/ */
PTR PTR
wordsearch(PTR start, char mode) wordsearch(start, mode)
PTR start;
char mode;
{ {
PTR found; PTR found;
PTR pos; PTR pos;
@ -184,7 +187,9 @@ wordsearch(PTR start, char mode)
/* backsearch serves the 'b' and 'B' command /* backsearch serves the 'b' and 'B' command
*/ */
PTR PTR
backsearch(PTR start, char mode) backsearch(start, mode)
PTR start;
char mode;
{ {
PTR pos; PTR pos;
int ccount; int ccount;
@ -211,7 +216,11 @@ backsearch(PTR start, char mode)
/* used by :s /* used by :s
*/ */
int int
do_substitution(int delim, char *line, PTR startpos, PTR endpos) do_substitution(delim, line, startpos, endpos)
int delim;
char *line;
PTR startpos;
PTR endpos;
{ {
int n; int n;
char *found; char *found;
@ -323,9 +332,9 @@ AGAIN:
emsg(notfound); emsg(notfound);
} else { } else {
if (P(P_TE)) if (P(P_TE))
sprintf(string, "No match to %s", direct == FORWARD ? "BOTTOM" : "TOP"); sprintf(string, "No match to %s", direct == FORWARD ? "BOTTOM" : "TOP");
else else
sprintf(string, "Address search hit %s without matching pattern", sprintf(string, "Address search hit %s without matching pattern",
direct == FORWARD ? "BOTTOM" : "TOP"); direct == FORWARD ? "BOTTOM" : "TOP");
emsg(string); emsg(string);
} }
@ -367,7 +376,12 @@ SKIP:
* return address found * return address found
*/ */
PTR PTR
searching(int ch, char *line, PTR startpos, PTR endpos, int flag) searching(ch, line, startpos, endpos, flag)
int ch;
char *line;
PTR startpos;
PTR endpos;
int flag;
{ {
char *cmd = NULL; char *cmd = NULL;
PTR found; PTR found;
@ -441,9 +455,9 @@ searching(int ch, char *line, PTR startpos, PTR endpos, int flag)
emsg(notfound); emsg(notfound);
} else { } else {
if (P(P_TE)) { if (P(P_TE)) {
sprintf(string, "No match to %s", sdir == FORWARD ? "BOTTOM" : "TOP"); sprintf(string, "No match to %s", sdir == FORWARD ? "BOTTOM" : "TOP");
} else { } else {
sprintf(string, "Address search hit %s without matching pattern", sprintf(string, "Address search hit %s without matching pattern",
sdir == FORWARD ? "BOTTOM" : "TOP"); sdir == FORWARD ? "BOTTOM" : "TOP");
} }
emsg(string); emsg(string);
@ -471,7 +485,9 @@ searching(int ch, char *line, PTR startpos, PTR endpos, int flag)
* returns pointer to next character * returns pointer to next character
*/ */
char * char *
patcpy(char *s1, char *s2, char delim) patcpy(s1, s2, delim)
char *s1, *s2;
char delim;
{ {
while (*s2 != '\0' && *s2 != delim) { while (*s2 != '\0' && *s2 != delim) {
if (*s2 == '\\' && *(s2 + 1) == delim) s2++; if (*s2 == '\\' && *(s2 + 1) == delim) s2++;
@ -484,10 +500,14 @@ patcpy(char *s1, char *s2, char delim)
PTR PTR
fsearch_end(PTR start, PTR end, char *smem, PTR *s_end) fsearch_end(start, end, smem, s_end)
/* /*
fsearch(start, end, smem) fsearch(start, end, smem)
*/ */
PTR start;
PTR end;
char *smem;
PTR *s_end;
{ {
PTR spos; PTR spos;
@ -506,7 +526,10 @@ fsearch(start, end, smem)
PTR PTR
fsearch(PTR start, PTR end, char *smem) fsearch(start, end, smem)
PTR start;
PTR end;
char *smem;
{ {
PTR s_end; PTR s_end;
return fsearch_end(start, end, smem, &s_end); return fsearch_end(start, end, smem, &s_end);
@ -514,7 +537,10 @@ fsearch(PTR start, PTR end, char *smem)
PTR PTR
rsearch(PTR start, PTR end, char *smem) rsearch(start, end, smem)
PTR start;
PTR end;
char *smem;
{ {
PTR spos; PTR spos;
@ -534,7 +560,9 @@ rsearch(PTR start, PTR end, char *smem)
* returns NULL on error or default_address, if nothing found * returns NULL on error or default_address, if nothing found
*/ */
PTR PTR
calc_addr(char **pointer, PTR def_addr) calc_addr(pointer, def_addr)
char **pointer;
PTR def_addr;
{ {
PTR addr; PTR addr;
int ch, mark; int ch, mark;

View file

@ -6,9 +6,8 @@
* 2000-04-25 V 1.3.0 beta * 2000-04-25 V 1.3.0 beta
* 2000-07-12 V 1.3.0 final * 2000-07-12 V 1.3.0 final
* 2019-01-28 V 1.4.1 * 2019-01-28 V 1.4.1
* 2025-07-19 V 1.5.0
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2019 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -27,7 +26,7 @@
/* You cannot use a common regexp subroutine, because \0 is a regular /* You cannot use a common regexp subroutine, because \0 is a regular
* character in a binary string ! * character in a binary string !
*/ */
#include "bvi.h" #include "bvi.h"
#include "set.h" #include "set.h"
@ -47,7 +46,9 @@ extern char *emptyclass;
* Compiling an ASCII sequence to a regex string * Compiling an ASCII sequence to a regex string
*/ */
int int
ascii_comp(char *smem, char *pattern) ascii_comp(smem, pattern)
char *smem;
char *pattern;
{ {
char *end; char *end;
char *comp; char *comp;
@ -166,7 +167,9 @@ ascii_comp(char *smem, char *pattern)
* Compiling a hex expression to a regex string * Compiling a hex expression to a regex string
*/ */
int int
hex_comp(char *smem, char *pattern) hex_comp(smem, pattern)
char *smem;
char *pattern;
{ {
char *end; char *end;
char *comp; char *comp;

134
set.c
View file

@ -9,14 +9,13 @@
* 1999-07-02 V 1.2.0 beta * 1999-07-02 V 1.2.0 beta
* 1999-08-14 V 1.2.0 final * 1999-08-14 V 1.2.0 final
* 2000-07-15 V 1.3.0 final * 2000-07-15 V 1.3.0 final
* 2001-10-10 V 1.3.1 * 2001-10-10 V 1.3.1
* 2003-07-03 V 1.3.2 * 2003-07-03 V 1.3.2
* 2010-06-02 V 1.2.4 * 2010-06-02 V 1.2.4
* 2014-09-30 V 1.4.0 * 2014-09-30 V 1.4.0
* 2019-01-22 V 1.4.1 * 2019-01-22 V 1.4.1
* 2025-07-19 V 1.5.0
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2019 by Gerhard Buergmann
* gerhard@puon.at * gerhard@puon.at
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -35,47 +34,46 @@
#include "bvi.h" #include "bvi.h"
#include "set.h" #include "set.h"
static int from_file = 0; static int from_file = 0;
static FILE *ffp; static FILE *ffp;
static char fbuf[MAXCMD+1]; static char fbuf[MAXCMD+1];
static char buf[MAXCMD+1]; static char buf[MAXCMD+1];
struct param params[] = { struct param params[] = {
{ "autowrite", "aw", FALSE, "", P_BOOL }, { "autowrite", "aw", FALSE, "", P_BOOL },
{ "columns", "cm", 0, "", P_NUM }, { "columns", "cm", 16, "", P_NUM },
{ "errorbells", "eb", FALSE, "", P_BOOL }, { "errorbells", "eb", FALSE, "", P_BOOL },
{ "ignorecase", "ic", FALSE, "", P_BOOL }, { "ignorecase", "ic", FALSE, "", P_BOOL },
{ "magic", "ma", TRUE, "", P_BOOL }, { "magic", "ma", TRUE, "", P_BOOL },
{ "memmove", "mm", FALSE, "", P_BOOL }, { "memmove", "mm", FALSE, "", P_BOOL },
{ "offset", "of", 0, "", P_NUM }, { "offset", "of", 0, "", P_NUM },
{ "readonly", "ro", FALSE, "", P_BOOL }, { "readonly", "ro", FALSE, "", P_BOOL },
{ "scroll", "scroll", 12, "", P_NUM }, { "scroll", "scroll", 12, "", P_NUM },
{ "showmode", "mo", TRUE, "", P_BOOL }, { "showmode", "mo", TRUE, "", P_BOOL },
{ "term", "term", 0, "", P_TEXT }, { "term", "term", 0, "", P_TEXT },
{ "terse", "terse", FALSE, "", P_BOOL }, { "terse", "terse", FALSE, "", P_BOOL },
{ "unixstyle", "us", FALSE, "", P_BOOL }, { "unixstyle", "us", FALSE, "", P_BOOL },
{ "window", "window", 0, "", P_NUM }, { "window", "window", 25, "", P_NUM },
{ "wordlength", "wl", 4, "", P_NUM }, { "wordlength", "wl", 4, "", P_NUM },
{ "wrapscan", "ws", TRUE, "", P_BOOL }, { "wrapscan", "ws", TRUE, "", P_BOOL },
{ "highlight", "hl", TRUE, "", P_BOOL }, { "highlight", "hl", TRUE, "", P_BOOL },
{ "reverse", "re", FALSE, "", P_BOOL }, { "reverse", "re", FALSE, "", P_BOOL },
#if defined(__MSDOS__) && !defined(DJGPP) #if defined(__MSDOS__) && !defined(DJGPP)
{ "color", "co", 7, "", P_NUM }, { "color", "co", 7, "", P_NUM },
#endif #endif
{ "", "", 0, "", 0, } /* end marker */ { "", "", 0, "", 0, } /* end marker */
}; };
int int
doset(char *arg) doset(arg)
char *arg; /* parameter string */
{ {
int i; int i;
char *s; char *s;
int did_window = FALSE; int did_window = FALSE;
int state = TRUE; /* new state of boolean parms. */ int state = TRUE; /* new state of boolean parms. */
char string[80]; char string[80];
off_t val;
if (arg == NULL) { if (arg == NULL) {
showparms(FALSE); showparms(FALSE);
@ -113,38 +111,20 @@ doset(char *arg)
return 0; return 0;
} }
if (!strcmp(params[i].fullname, "term")) { if (!strcmp(params[i].fullname, "term")) {
emsg("Can't change@type of terminal from within bvi"); emsg("Can't change type of terminal from within bvi");
return 1; return 1;
} }
if (params[i].flags & P_NUM) { if (params[i].flags & P_NUM) {
if ((i == P_LI) || (i == P_OF) || (i == P_CM)) did_window++; if ((i == P_LI) || (i == P_OF)) did_window++;
if (arg[strlen(s)] != '=' || state == FALSE) { if (arg[strlen(s)] != '=' || state == FALSE) {
sprintf(string, "Option %s is not a toggle", params[i].fullname); sprintf(string, "Option %s is not a toggle",
params[i].fullname);
emsg(string); emsg(string);
return 1; return 1;
} else { } else {
s = arg + strlen(s) + 1; s = arg + strlen(s) + 1;
val = strtoll(s, &s, 0); params[i].nvalue = strtoll(s, &s, 0);
if ((i == P_CM || i == P_LI) && (!strcmp("auto", s) || (val == 0))) {
if (i == P_CM) {
params[i].nvalue = 0;
Anzahl = ((COLS - AnzAdd - space) / 4);
} else {
params[i].nvalue = 0;
maxy = LINES - 1;
}
} else {
params[i].nvalue = val;
if (i == P_CM) {
Anzahl = val;
} else {
maxy = val;
}
}
params[i].flags |= P_CHANGED; params[i].flags |= P_CHANGED;
if (i == P_LI) params[P_SS].nvalue = val / 2;
#if defined(__MSDOS__) && !defined(DJGPP) #if defined(__MSDOS__) && !defined(DJGPP)
if (i == P_CO) { if (i == P_CO) {
textcolor(P(P_CO) & 0x07); textcolor(P(P_CO) & 0x07);
@ -154,23 +134,22 @@ doset(char *arg)
} }
#endif #endif
if (i == P_CM) { if (i == P_CM) {
/*
if (((COLS - AnzAdd - 1) / 4) >= P(P_CM)) { if (((COLS - AnzAdd - 1) / 4) >= P(P_CM)) {
Anzahl = P(P_CM); Anzahl = P(P_CM);
} else { } else {
Anzahl = ((COLS - AnzAdd - 1) / 4); Anzahl = P(P_CM) = ((COLS - AnzAdd - 1) / 4);
} }
*/ maxx = Anzahl * 4 + AnzAdd + 1;
maxx = Anzahl * 4 + AnzAdd + 1; Anzahl3 = Anzahl * 3;
Anzahl3 = Anzahl * 3; status = Anzahl3 + Anzahl - 17;
status = Anzahl3 + Anzahl - statsize; screen = Anzahl * (maxy - 1);
screen = Anzahl * (maxy - 1); did_window++;
stuffin("H"); /* set cursor at HOME */ stuffin("H"); /* set cursor at HOME */
} }
} }
} else { /* boolean */ } else { /* boolean */
if (arg[strlen(s)] == '=') { if (arg[strlen(s)] == '=') {
emsg("Invalid set@of boolean parameter"); emsg("Invalid set of boolean parameter");
return 1; return 1;
} else { } else {
params[i].nvalue = state; params[i].nvalue = state;
@ -190,10 +169,7 @@ doset(char *arg)
} }
if (did_window) { if (did_window) {
/*
maxy = P(P_LI) - 1; maxy = P(P_LI) - 1;
maxy = LINES - 1;
*/
new_screen(); new_screen();
} }
@ -203,33 +179,28 @@ doset(char *arg)
/* show ALL parameters */ /* show ALL parameters */
void void
showparms(int all) showparms(all)
int all;
{ {
struct param *p; struct param *p;
int n, i; int n;
statusflag = 0;
n = 2; n = 2;
i = -1;
msg("Parameters:\n"); msg("Parameters:\n");
for (p = &params[0]; p->fullname[0] != '\0' ;p++) { for (p = &params[0]; p->fullname[0] != '\0' ;p++) {
i++;
if (!all && ((p->flags & P_CHANGED) == 0)) if (!all && ((p->flags & P_CHANGED) == 0))
continue; continue;
if (p->flags & P_BOOL) { if (p->flags & P_BOOL)
sprintf(buf, " %s%s\n", (p->nvalue ? " " : "no"), p->fullname); sprintf(buf, " %s%s\n",
} else if (p->flags & P_TEXT) { (p->nvalue ? " " : "no"), p->fullname);
else if (p->flags & P_TEXT)
sprintf(buf, " %s=%s\n", p->fullname, p->svalue); sprintf(buf, " %s=%s\n", p->fullname, p->svalue);
} else { else
if ((p->nvalue == 0) && (i == P_CM || i == P_LI)) { sprintf(buf, " %s=%lld\n", p->fullname, (long long)p->nvalue);
sprintf(buf, " %s=auto\n", p->fullname);
} else {
sprintf(buf, " %s=%lld\n", p->fullname, (long long)p->nvalue);
}
}
msg(buf); msg(buf);
n++; n++;
if (n == maxy) { if (n == params[P_LI].nvalue) {
if (wait_return(FALSE)) return; if (wait_return(FALSE)) return;
n = 1; n = 1;
} }
@ -240,7 +211,8 @@ showparms(int all)
/* reads the init file (.bvirc) */ /* reads the init file (.bvirc) */
int int
read_rc(char *fn) read_rc(fn)
char *fn;
{ {
int i; int i;
@ -258,7 +230,9 @@ read_rc(char *fn)
int int
do_logic(int mode, char *str) do_logic(mode, str)
int mode;
char *str;
{ {
int a, b; int a, b;
int value; int value;
@ -315,13 +289,13 @@ do_logic(int mode, char *str)
b = a >> 8; b = a >> 8;
a |= b; a |= b;
break; break;
case RROTATE: case RROTATE:
b = a << 8; b = a << 8;
a |= b; a |= b;
a >>= value; a >>= value;
/* /*
b = a << (8 - value); b = a << (8 - value);
a >>= value; a >>= value;
a |= b; a |= b;
*/ */
break; break;
@ -329,7 +303,7 @@ do_logic(int mode, char *str)
break; break;
case OR: a |= value; case OR: a |= value;
break; break;
case XOR: case XOR:
case NOT: a ^= value; case NOT: a ^= value;
break; break;
case NEG: a ^= value; case NEG: a ^= value;
@ -344,7 +318,9 @@ do_logic(int mode, char *str)
int int
getcmdstr(char *p, int x) getcmdstr(p, x)
char *p;
int x;
{ {
int c; int c;
int i, n; int i, n;

7
set.h
View file

@ -2,8 +2,8 @@
* *
* NOTE: Edit this file with tabstop=4 ! * NOTE: Edit this file with tabstop=4 !
* *
* Copyright 1996-2025 by Gerhard Buergmann * Copyright 1996-2019 by Gerhard Buergmann
* gerhard@puon.at * Gerhard.Buergmann@puon.at
* *
* 1998-03-14 V 1.0.0 * 1998-03-14 V 1.0.0
* 1999-01-14 V 1.1.0 * 1999-01-14 V 1.1.0
@ -14,7 +14,6 @@
* 2010-06-02 V 1.3.4 * 2010-06-02 V 1.3.4
* 2013-08-23 V 1.4.0 * 2013-08-23 V 1.4.0
* 2019-01-22 V 1.4.1 * 2019-01-22 V 1.4.1
* 2025-05-24 V 1.5.0
* *
* This program is free software; you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -35,7 +34,7 @@ struct param {
char *shortname; /* permissible abbreviation */ char *shortname; /* permissible abbreviation */
off_t nvalue; off_t nvalue;
char *svalue; char *svalue;
int flags; int flags;
}; };
extern struct param params[]; extern struct param params[];

1091
tags

File diff suppressed because it is too large Load diff