* Switch from old 4.3BSD tty ioctls to termios.

* Use the latest Debian version (1.40-18) as upstream.
* Improved description, from Debian.
* Miscellaneous clean-up.

input and ok jca@
This commit is contained in:
naddy 2013-12-12 21:59:57 +00:00
parent f23e3e75b6
commit a3cbc8ab0c
11 changed files with 250 additions and 116 deletions

View File

@ -1,24 +1,38 @@
# $OpenBSD: Makefile,v 1.26 2013/03/11 11:02:49 espie Exp $
# $OpenBSD: Makefile,v 1.27 2013/12/12 21:59:57 naddy Exp $
COMMENT= binary editor and viewer
DISTNAME= beav_1.40-15
PKGNAME= beav-1.40.15
VERSION= 1.40
# Debian
REV= 18
DISTNAME= beav-140
PKGNAME= beav-${VERSION}.${REV}
CATEGORIES= editors
MAINTAINER= Kevin Lo <kevlo@openbsd.org>
# GPLv2+
PERMIT_PACKAGE_CDROM= Yes
WANTLIB= c curses
WANTLIB= c ncurses
MASTER_SITES= ${MASTER_SITE_DEBIAN:=main/b/beav/}
WRKDIST= ${WRKDIR}/beav-1.40
DISTFILES= beav_${VERSION}.orig.tar.gz
PATCHFILES= beav_${VERSION}-${REV}.diff.gz
PATCH_DIST_STRIP= -p1
ALL_TARGET= beav
MAKE_FLAGS= CC="${CC}" CFLAGS="${CFLAGS} -DUNIX -DBSD"
USE_GROFF = Yes
NO_TEST= Yes
post-install:
do-install:
${INSTALL_PROGRAM} ${WRKBUILD}/beav ${PREFIX}/bin
${INSTALL_MAN} ${WRKSRC}/beav.1 ${PREFIX}/man/man1
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/beav
${INSTALL_DATA} ${WRKSRC}/beav140.txt ${PREFIX}/share/doc/beav/beav.txt
@perl -i -pe 's:%%PREFIX%%:${TRUEPREFIX}:' ${PREFIX}/man/man1/beav.1
.include <bsd.port.mk>

View File

@ -1,5 +1,4 @@
MD5 (beav_1.40-15.tar.gz) = smFBn67WFcUAwwr0ZPzgHQ==
RMD160 (beav_1.40-15.tar.gz) = m/QcFl1y7HYmFAQrIe6FirDzqmM=
SHA1 (beav_1.40-15.tar.gz) = ig6SLfKVUEOrKYJEsUmL2viaLhs=
SHA256 (beav_1.40-15.tar.gz) = 3ANhHD0dn8KN6VVr2j+tAADWys5/9EAbeRv8ToUMfBE=
SIZE (beav_1.40-15.tar.gz) = 131476
SHA256 (beav_1.40-18.diff.gz) = eQRiTnHK1MOtybAgAnjoQXLxNog9bi/Mytl3+Q0XY6M=
SHA256 (beav_1.40.orig.tar.gz) = etkF5BJL8QXKDiE9ghK+0jFVmCWsEViHlLm+epE5ndw=
SIZE (beav_1.40-18.diff.gz) = 14218
SIZE (beav_1.40.orig.tar.gz) = 128103

View File

@ -1,32 +0,0 @@
$OpenBSD: patch-Makefile,v 1.4 2010/05/22 15:05:29 espie Exp $
--- Makefile.orig Sat Dec 13 09:34:59 1997
+++ Makefile Sat May 22 16:56:49 2010
@@ -1,7 +1,6 @@
# This is the makefile for BSD UNIX
#CFLAGS= -g -DUNIX
-CFLAGS= -O2 -DUNIX
-CC=gcc
+CFLAGS+= -DUNIX -DBSD
OFILES= basic.o ebcdic.o fileio.o region.o text.o wangpc.o \
buffer.o echo.o language.o main.o search.o tty.o window.o \
@@ -16,10 +15,16 @@ CFILES= basic.c ebcdic.c fileio.c region.c text.c
HFILES= def.h prototyp.h
-beav: $(OFILES)
- $(CC) $(CFLAGS) $(OFILES) -lncurses -o beav
+all beav: $(OFILES)
+ $(CC) $(CFLAGS) $(OFILES) -lcurses -o beav
+install: beav
+ $(BSD_INSTALL_PROGRAM) beav $(PREFIX)/bin
+ mkdir -p $(PREFIX)/share/doc/beav
+ $(BSD_INSTALL_DATA) beav140.txt $(PREFIX)/share/doc/beav/beav.txt
+ $(BSD_INSTALL_MAN) beav.1 $(PREFIX)/man/man1
+
clean:
rm -f *.o beav
-(OFILES): $(HFILES)
+$(OFILES): $(HFILES)

View File

@ -1,10 +1,28 @@
$OpenBSD: patch-beav_1,v 1.3 2010/05/22 15:05:29 espie Exp $
--- beav.1.orig Sun Aug 20 20:05:22 1995
+++ beav.1 Sat May 22 16:56:49 2010
$OpenBSD: patch-beav_1,v 1.4 2013/12/12 21:59:57 naddy Exp $
--- beav.1.orig Thu Dec 12 22:54:27 2013
+++ beav.1 Thu Dec 12 22:56:12 2013
@@ -9,7 +9,7 @@ This is a brief description of the minimal set of comm
that are necessary to start using
.IR beav
effectively.
-For more information, review the file /usr/share/doc/beav/beav140.txt.gz.
+For more information, review the file %%PREFIX%%/share/doc/beav/beav.txt.
.PP
The \fIfile-visit\fR command,\fB Ctl-X Ctl-V\fR, can be used to read a
file in for editing. The file can also be read in from the
@@ -23,7 +23,7 @@ These commands can be used to navigate around the wind
.br
\fImove-back-line\fB Ctl-P\fB moves up\fR
.br
-\fImove-forw-char\fb Ctl-F\fB moves right\fR
+\fImove-forw-char\fB Ctl-F\fB moves right\fR
.br
\fImove-forw-line\fB Ctl-N\fB moves down\fR
.br
@@ -59,5 +59,5 @@ The \fIquit-no-save\fR command,\fB Ctl-X Ctl-C\fR, wil
If there is any data that has not been saved you will be warned.
.PP
.SH FILES
-/usr/doc/beav/beav.txt
-/usr/share/doc/beav/beav140.txt.gz
+%%PREFIX%%/share/doc/beav/beav.txt

View File

@ -1,32 +1,12 @@
$OpenBSD: patch-def_h,v 1.2 2010/05/22 15:05:29 espie Exp $
--- def.h.orig Sat Dec 13 09:34:59 1997
+++ def.h Sat May 22 16:59:41 2010
@@ -12,10 +12,12 @@
#ifndef DEF_DEF
$OpenBSD: patch-def_h,v 1.3 2013/12/12 21:59:57 naddy Exp $
--- def.h.orig Wed Dec 11 17:22:35 2013
+++ def.h Wed Dec 11 17:23:14 2013
@@ -13,6 +13,8 @@
#define DEF_DEF
#define LINT_ARGS 1 /* enable lint type checking */
-#include "stdio.h"
+#include <stdio.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdlib.h>
#ifdef UNIX
-#include "sys/types.h"
+#include <sys/types.h>
#endif /* UNIX */
#define BACKUP 1 /* Make backup file. */
@@ -562,13 +564,6 @@ extern int auto_update;
extern int flush_count;
extern int rowb;
extern char file_off_bad;
-
-/*
- * Standard I/O.
- */
-extern char *malloc ();
-extern char *strcpy ();
-extern char *strcat ();
#ifndef NOPROTO
#include "prototyp.h"
#include <sys/types.h>

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-file_c,v 1.1 2010/05/22 15:05:29 espie Exp $
--- file.c.orig Sat May 22 17:01:04 2010
+++ file.c Sat May 22 17:01:12 2010
@@ -9,7 +9,6 @@
$OpenBSD: patch-file_c,v 1.2 2013/12/12 21:59:57 naddy Exp $
--- file.c.orig Wed Dec 11 20:07:15 2013
+++ file.c Wed Dec 11 20:07:15 2013
@@ -10,7 +10,6 @@
char load_file ();
char readin ();
void makename ();

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-random_c,v 1.1 2010/05/22 15:05:29 espie Exp $
--- random.c.orig Sat May 22 17:01:30 2010
+++ random.c Sat May 22 17:01:47 2010
@@ -72,7 +72,6 @@ extern bool read_pat_mode;
$OpenBSD: patch-random_c,v 1.2 2013/12/12 21:59:57 naddy Exp $
--- random.c.orig Wed Dec 11 20:07:15 2013
+++ random.c Wed Dec 11 20:07:15 2013
@@ -73,7 +73,6 @@ extern bool read_pat_mode;
extern bool dont_repeat;
extern BUFFER sav_buf;

View File

@ -1,15 +1,15 @@
$OpenBSD: patch-symbol_c,v 1.2 2010/05/22 15:05:29 espie Exp $
--- symbol.c.orig Sat Dec 13 09:34:59 1997
+++ symbol.c Sat May 22 17:02:25 2010
@@ -6,7 +6,6 @@
*/
$OpenBSD: patch-symbol_c,v 1.3 2013/12/12 21:59:57 naddy Exp $
--- symbol.c.orig Wed Dec 11 20:07:15 2013
+++ symbol.c Wed Dec 11 20:07:15 2013
@@ -8,7 +8,6 @@
#include <string.h>
#include "def.h"
-void keyadd ();
void keydup ();
@@ -219,7 +218,6 @@ extern char save_region (); /* Save region in named bu
@@ -221,7 +220,6 @@ extern char save_region (); /* Save region in named bu
* Defined by "spawn.c".
*/
extern char spawncli (); /* Run CLI in a subjob. */

View File

@ -1,12 +1,47 @@
$OpenBSD: patch-tcap_c,v 1.2 2010/05/22 15:05:29 espie Exp $
--- tcap.c.orig Sat Dec 13 09:34:59 1997
+++ tcap.c Sat May 22 16:56:49 2010
@@ -39,7 +39,7 @@ char *UP, PC, *CM, *CE, *CL, *SO, *SE, *TI, *TE; /* DR
$OpenBSD: patch-tcap_c,v 1.3 2013/12/12 21:59:57 naddy Exp $
--- tcap.c.orig Thu Dec 12 17:12:17 2013
+++ tcap.c Thu Dec 12 17:14:22 2013
@@ -41,11 +41,12 @@ char *UP, PC, *CM, *CE, *CL, *SO, *SE, *TI, *TE; /* DR
#ifdef BSD
#include <sys/ioctl.h>
-struct winsize ttysize;
+struct ttysize ttysize;
#endif /* BSD */
#ifdef ULTRIX
+#ifdef TIOCGWINSZ
struct winsize ttysize;
-#endif /* BSD */
-#ifdef ULTRIX
-struct winsize ttysize;
+#else
+struct ttysize ttysize;
#endif
+#endif /* BSD */
void
putpad (str)
@@ -62,9 +63,6 @@ tcapopen ()
char tcbuf[1024];
char *tv_stype;
char err_str[NCOL];
-#ifdef ULTRIX
- struct winsize ttysize;
-#endif
nrow = NROW;
@@ -89,7 +87,7 @@ tcapopen ()
#ifdef BSD
-#ifdef ULTRIX
+#ifdef TIOCGWINSZ
if (ioctl (0, TIOCGWINSZ, &ttysize) == 0
&& ttysize.ws_row > 0)
{
@@ -103,7 +101,7 @@ tcapopen ()
nrow = ttysize.ts_lines;
}
else
-#endif /* ULTRIX */
+#endif /* TIOCGWINSZ */
#endif /* BSD */
#ifndef OS2

View File

@ -1,13 +1,131 @@
$OpenBSD: patch-termio_c,v 1.1 2002/08/02 03:45:19 kevlo Exp $
--- termio.c.orig Sat Jul 21 13:35:05 2001
+++ termio.c Thu Aug 1 15:26:10 2002
@@ -12,6 +12,9 @@
#include <signal.h>
#ifdef BSD
#include <sys/ioctl.h>
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#include <sys/ioctl_compat.h>
$OpenBSD: patch-termio_c,v 1.2 2013/12/12 21:59:57 naddy Exp $
--- termio.c.orig Thu Dec 12 17:11:56 2013
+++ termio.c Thu Dec 12 17:14:58 2013
@@ -8,11 +8,16 @@
#ifdef UNIX /* System V */
+#if defined(__GLIBC__) || \
+ defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#define TERMIOS 1
+#endif
+
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
-#ifdef BSD
+#if defined(BSD) && !defined(TERMIOS)
#include <sys/ioctl.h>
#else
#ifdef OS2
#ifndef __EMX__
@@ -28,7 +33,8 @@
#include <sgtty.h>
#define O_NDELAY O_NONBLOCK
#else
-#ifdef __GLIBC__
+#ifdef TERMIOS
+#include <sys/ioctl.h>
#include <termios.h>
#else
#include <termio.h>
@@ -44,7 +50,7 @@ int kbdpoll; /* in O_NDELAY mode */
int kbdqp; /* there is a char in kbdq */
char kbdq; /* char we've already read */
-#ifdef BSD
+#if defined(BSD) && !defined(TERMIOS)
struct sgttyb otermb;
struct sgttyb ntermb;
#else
@@ -58,7 +64,7 @@ struct sgttyb otermio; /* original terminal character
struct sgttyb ntermio; /* charactoristics to use inside */
struct tchars tchars, tcharsorig;
#else
-#ifdef __GLIBC__
+#ifdef TERMIOS
#include <sys/ioctl.h>
struct termios otermio;
struct termios ntermio;
@@ -86,8 +92,8 @@ int ncol; /* Terminal size, columns. */
void
ttopen ()
{
-#ifdef BSD
-#ifdef ULTRIX
+#if defined(BSD) && !defined(TERMIOS)
+#ifdef TIOCGWINSZ
struct winsize ttysize;
#else
struct ttysize ttysize;
@@ -104,7 +110,7 @@ ttopen ()
of the cursor */
ttrow = 999;
ttcol = 999;
-#ifdef ULTRIX
+#ifdef TIOCGWINSZ
if (ioctl (0, TIOCGWINSZ, &ttysize) == 0)
{
nrow = ttysize.ws_row;
@@ -137,8 +143,13 @@ ttopen ()
tchars.t_stopc = tchars.t_eofc = tchars.t_brkc = -1;
ioctl (0, TIOCSETC, &tchars);
#else
-#ifdef __GLIBC__
+#ifdef TERMIOS
+#ifdef TIOCGWINSZ
+ struct winsize ttysize;
+#endif
tcgetattr(0,&otermio);
+ ntermio.c_ispeed = otermio.c_ispeed;
+ ntermio.c_ospeed = otermio.c_ospeed;
#else
ioctl (0, TCGETA, &otermio);/* save old settings */
ntermio.c_line = otermio.c_line;
@@ -149,7 +160,7 @@ ttopen ()
ntermio.c_lflag = 0;
ntermio.c_cc[VMIN] = 1;
ntermio.c_cc[VTIME] = 0;
-#ifdef __GLIBC__
+#ifdef TERMIOS
tcsetattr(0,TCSANOW,&ntermio);
#else
ioctl (0, TCSETAW, &ntermio); /* and activate them */
@@ -161,8 +172,17 @@ ttopen ()
/* on all screens we are not sure of the initial position of the cursor */
ttrow = 999;
ttcol = 999;
- nrow = NROW;
- ncol = NCOL;
+#if defined(TERMIOS) && defined(TIOCGWINSZ)
+ if (ioctl (0, TIOCGWINSZ, &ttysize) == 0)
+ {
+ nrow = ttysize.ws_row;
+ ncol = ttysize.ws_col;
+ } else
+#endif
+ {
+ nrow = NROW;
+ ncol = NCOL;
+ }
#endif /* BSD */
}
@@ -174,7 +194,7 @@ ttopen ()
void
ttclose ()
{
-#ifdef BSD
+#if defined(BSD) && !defined(TERMIOS)
if (ioctl (0, TIOCSETP, &otermb) == -1) /* restore terminal settings */
printf ("closing ioctl on dev 0 failure, error = %d\n", errno);
#else
@@ -186,7 +206,7 @@ ttclose ()
ioctl (0, TIOCSETC, &tcharsorig) == -1)
printf ("closing ioctl on dev 0 failure, error = %d\n", errno);
#else
-#ifdef __GLIBC__
+#ifdef TERMIOS
if( tcsetattr(0,TCSANOW,&otermio) == -1)
#else
if (ioctl (0, TCSETAW, &otermio) == -1) /* restore terminal settings */

View File

@ -1,9 +1,11 @@
BEAV (Binary Editor And Viewer), is a full featured binary file
editor. Just about any operation that you could want to do to a binary
file is possible with BEAV. You can insert or delete in the middle of
a file thereby changing it's size. You can edit multiple files in
multiple windows and cut and paste between them. You can display and
edit data in hex, octal, decimal, binary, ascii, or ebcdic formats. You
can display data in byte, word, or long word formats in either Intel or
Motorola byte ordering. You can send the formatted display mode to a
file or printer.
beav (Binary Editor And Viewer) is an editor for binary files
containing arbitrary data. With beav, you can edit a file in HEX,
ASCII, EBCDIC, OCTAL, DECIMAL, and BINARY. You can display but not
edit data in FLOAT mode. You can search or search and replace in
any of these modes. Data can be displayed in BYTE, WORD, or DOUBLE
WORD formats. While displaying WORDS or DOUBLE WORDS the data can
be displayed in INTEL's or MOTOROLA's byte ordering. Data of any
length can be inserted at any point in the file. The source of this
data can be the keyboard, another buffer, or a file. Any data that
is being displayed can be sent to a printer in the displayed format.
Files that are bigger than memory can be handled.