1
0
Fork 0
mirror of https://github.com/vbatts/bvi.git synced 2025-08-01 23:20:28 +00:00

cleanup mixed use of tabs and spaces

still isn't 100%, but is progress

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2025-03-02 11:42:21 -05:00
parent 92a88a4b4b
commit f62d2aa929
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED
14 changed files with 176 additions and 176 deletions

View file

@ -128,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

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

16
bmore.c
View file

@ -493,7 +493,7 @@ main(argc, 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;
@ -649,10 +649,10 @@ putline(buf, 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(" ");
} }
@ -662,18 +662,18 @@ putline(buf, num)
++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(".");
} }
} }
} }
@ -869,7 +869,7 @@ bmregexec(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;

18
bmore.h
View file

@ -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

2
bvi.1
View file

@ -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

12
bvi.c
View file

@ -756,13 +756,13 @@ calc_size(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();
} }
@ -1051,9 +1051,9 @@ range(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 {

22
comm.c
View file

@ -290,18 +290,18 @@ docmdline(cmdline)
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) {

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

36
dosio.c
View file

@ -144,11 +144,11 @@ save(char *fname, PTR start, PTR end, int flags)
} }
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 = "";
} }
@ -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;

94
edit.c
View file

@ -298,7 +298,7 @@ do_ft(ch, 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;
@ -544,44 +544,44 @@ printline(mempos, 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, " ");
@ -609,10 +609,10 @@ printline(mempos, scpos)
addstr(string); addstr(string);
attrset(A_NORMAL); attrset(A_NORMAL);
} else { } else {
addstr("."); addstr(".");
} }
} else { } else {
addstr("."); addstr(".");
} }
} }
} else { } else {
@ -945,15 +945,15 @@ do_ins_chg(start, arg, 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++;
} }
@ -993,7 +993,7 @@ do_ins_chg(start, arg, 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);

4
io.c
View file

@ -235,7 +235,7 @@ load(fname)
params[P_RO].flags |= P_CHANGED; params[P_RO].flags |= P_CHANGED;
} }
} else { } else {
sysemsg(fname); sysemsg(fname);
filemode = ERROR; filemode = ERROR;
} }
} }
@ -432,7 +432,7 @@ strdup(s)
char *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)

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
( (
[initscr], [curses], [ncursesw/curses.h],
[ [
AC_DEFINE(HAVE_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]) 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])
]
)
]
)
]
) )

8
re.c
View file

@ -332,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);
} }
@ -455,9 +455,9 @@ searching(ch, line, startpos, endpos, 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);

8
set.c
View file

@ -139,10 +139,10 @@ doset(arg)
} else { } else {
Anzahl = P(P_CM) = ((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 - 17;
screen = Anzahl * (maxy - 1); screen = Anzahl * (maxy - 1);
did_window++; did_window++;
stuffin("H"); /* set cursor at HOME */ stuffin("H"); /* set cursor at HOME */
} }