mirror of
https://git.FreeBSD.org/ports.git
synced 2024-10-29 21:39:24 +00:00
ac8929da86
FreeBSD/Alpha to fail.
208 lines
4.8 KiB
Plaintext
208 lines
4.8 KiB
Plaintext
--- bpatch.c.orig Wed Jan 17 08:33:33 1990
|
|
+++ bpatch.c Sat Sep 18 18:08:04 1999
|
|
@@ -90,10 +90,15 @@
|
|
/*E*/
|
|
/*S includes, globals, and defines */
|
|
/*Page Eject*/
|
|
-#include <curses.h>
|
|
+#include <ncurses.h>
|
|
#include <fcntl.h>
|
|
#include <signal.h>
|
|
#include <ctype.h>
|
|
+#include <stdlib.h>
|
|
+#include <string.h>
|
|
+#include <unistd.h>
|
|
+#include <stdio.h>
|
|
+#include <termios.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
|
|
@@ -103,14 +108,8 @@
|
|
void icc ();
|
|
void copyrec ();
|
|
void schwapp ();
|
|
-
|
|
-/* added declarations, mostly for cleanliness */
|
|
-extern long lseek();
|
|
-extern long atol();
|
|
-extern char *strncpy();
|
|
-extern void exit();
|
|
-extern unsigned sleep(); /* signal problems ??? if sleep called */
|
|
-extern void perror();
|
|
+void breakp ();
|
|
+void reset ();
|
|
|
|
/* set up for calls to outstr and errmsg, etc, */
|
|
/* by use of sprintf to fill outbuf */
|
|
@@ -190,7 +189,7 @@
|
|
#ifdef MOD_HAX
|
|
#else /* use original code... */
|
|
/* plus some more for restoring terminal function */
|
|
- struct termio asis, aswas;
|
|
+ struct termios asis, aswas;
|
|
#endif /* MOD_HAX */
|
|
|
|
/*S main - control all the work from here */
|
|
@@ -210,12 +209,10 @@
|
|
extern WINDOW *newwin ();
|
|
|
|
register char *cp; /* general purpose char ptr */
|
|
- extern char *gets (); /* get string from stdin */
|
|
char m = '\017'; /* mask for hex edit */
|
|
char response[512]; /* general purpose buffer */
|
|
int z; /* character read in */
|
|
|
|
- int breakp (); /* signal trapping function */
|
|
int c; /* current screen column */
|
|
int change = 0; /* true if cmd line option toggled */
|
|
int fid; /* file descriptor */
|
|
@@ -234,8 +231,7 @@
|
|
extern char *optarg; /* getopt pointer to opt arg */
|
|
|
|
extern long getnum ();
|
|
- extern char *instr (); /* get a string from the cmd line */
|
|
- extern int reset (); /* exit function - reset terminal */
|
|
+ extern char *myinstr (); /* get a string from the cmd line */
|
|
|
|
/* ------------------------------------------------------------ */
|
|
/* set up signal handling */
|
|
@@ -333,19 +329,27 @@
|
|
alphawin = subwin (stdscr, 16, 16, 4, 57);
|
|
keypad (alphawin, TRUE);
|
|
errwin = subwin (stdscr, 1, 80, 23, 0);
|
|
+ if (errwin == NULL)
|
|
+ errwin = stdscr;
|
|
+ if (hexwin == NULL || alphawin == NULL)
|
|
+ {
|
|
+ fprintf(stderr, "Can't create all necessary curses windows.\n");
|
|
+ reset (0);
|
|
+ exit (2);
|
|
+ }
|
|
|
|
#ifdef MOD_HAX
|
|
/* This is not exactly what the original code does,
|
|
but it's good enough. -r$ */
|
|
raw();
|
|
#else /* use original code... */
|
|
- ioctl (0, TCGETA, &asis);
|
|
+ tcgetattr (0, &asis);
|
|
aswas = asis; /* save termio stuff for later restore */
|
|
asis.c_cc[VINTR] = '\0';
|
|
asis.c_iflag &= ~IXON;
|
|
asis.c_iflag &= ~IXOFF;
|
|
asis.c_iflag &= ~IXANY;
|
|
- ioctl (0, TCSETA, &asis);
|
|
+ tcsetattr (0, TCSANOW, &asis);
|
|
#endif /* MOD_HAX */
|
|
}
|
|
|
|
@@ -478,7 +482,9 @@
|
|
}
|
|
pbrk = 0;
|
|
fprintf (stderr, "\007");
|
|
- gets (response);
|
|
+ fgets (response, 512, stdin);
|
|
+ if ((cp = strchr (response, '\n')))
|
|
+ *cp = 0;
|
|
|
|
if (pbrk) status = EOF;
|
|
}
|
|
@@ -617,7 +623,7 @@
|
|
|
|
case '\006': /* new file (^F) */
|
|
close (fid);
|
|
- fid = ckfile (cp = instr (), &size);
|
|
+ fid = ckfile (cp = myinstr (), &size);
|
|
if (fid < 0)
|
|
{
|
|
fid = ckfile (filename, &size);
|
|
@@ -832,7 +838,8 @@
|
|
touchwin (alphawin);
|
|
wrefresh (alphawin);
|
|
|
|
- while ((z = wgetch (alphawin)) != DEL)
|
|
+ while ((z = wgetch (alphawin)) != KEY_DC &&
|
|
+ z != KEY_BACKSPACE)
|
|
{
|
|
if (!arrow (z, &r, &c))
|
|
{
|
|
@@ -902,7 +909,8 @@
|
|
touchwin (hexwin);
|
|
wrefresh (hexwin);
|
|
|
|
- while ((z = wgetch (hexwin)) != DEL)
|
|
+ while ((z = wgetch (hexwin)) != KEY_DC
|
|
+ && z != KEY_BACKSPACE)
|
|
{
|
|
if (!arrow (z, &r, &c))
|
|
{
|
|
@@ -1281,7 +1289,7 @@
|
|
/*S breakp - set pbrk on interrupt */
|
|
/*H breakp */
|
|
/*E*/
|
|
-int breakp (i)
|
|
+void breakp (i)
|
|
int i;
|
|
{
|
|
int s;
|
|
@@ -1592,6 +1600,7 @@
|
|
/*S reset - reset terminal to original state */
|
|
/*H reset */
|
|
/*E*/
|
|
+void
|
|
reset (sig)
|
|
int sig;
|
|
{
|
|
@@ -1600,7 +1609,7 @@
|
|
move (23, 0);
|
|
refresh ();
|
|
#ifndef MOD_HAX
|
|
- ioctl (0, TCSETA, &aswas);
|
|
+ tcsetattr (0, TCSANOW, &aswas);
|
|
#endif
|
|
endwin ();
|
|
}
|
|
@@ -1610,7 +1619,6 @@
|
|
fprintf (stderr, "killed with signal %d\n", sig);
|
|
exit (sig);
|
|
}
|
|
- return (0);
|
|
}
|
|
/*S arrow - determine if current character is a cursor control key */
|
|
/*H arrow */
|
|
@@ -1683,11 +1691,11 @@
|
|
|
|
return;
|
|
}
|
|
-/*S instr - get a character string from the terminal */
|
|
-/*H instr */
|
|
+/*S myinstr - get a character string from the terminal */
|
|
+/*H myinstr */
|
|
/*E*/
|
|
char *
|
|
-instr ()
|
|
+myinstr ()
|
|
{
|
|
static char buf[512];
|
|
|
|
@@ -1827,7 +1835,7 @@
|
|
register int matched = 0;
|
|
register int srch_len;
|
|
|
|
- register char *cp = instr ();
|
|
+ register char *cp = myinstr ();
|
|
register char *rp;
|
|
|
|
int row, col;
|
|
@@ -1924,8 +1932,8 @@
|
|
outstr (fmt)
|
|
char *fmt;
|
|
{
|
|
- if (dump) printf (fmt);
|
|
- else printw (fmt);
|
|
+ if (dump) printf ("%s", fmt);
|
|
+ else printw ("%s", fmt);
|
|
|
|
return;
|
|
}
|