o __P has been reoved

o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
  they already are.
o gc some #ifdef sun ... #endif code

Approved by: arch@, new style(9)
This commit is contained in:
Warner Losh 2002-02-02 06:36:49 +00:00
parent f9bcb0beb5
commit 7669d0fc4f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=90109
11 changed files with 207 additions and 348 deletions

View File

@ -49,12 +49,8 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
int main __P((int, char *[]));
int
main(argc, argv)
int argc __unused;
char *argv[];
main(int argc __unused, char *argv[])
{
int nflag;

View File

@ -45,8 +45,7 @@ line_t buffer_head; /* incore buffer */
/* get_sbuf_line: get a line of text from the scratch file; return pointer
to the text */
char *
get_sbuf_line(lp)
line_t *lp;
get_sbuf_line(line_t *lp)
{
static char *sfbuf = NULL; /* buffer */
static int sfbufsz = 0; /* buffer size */
@ -81,8 +80,7 @@ get_sbuf_line(lp)
/* put_sbuf_line: write a line of text to the scratch file and add a line node
to the editor buffer; return a pointer to the end of the text */
const char *
put_sbuf_line(cs)
const char *cs;
put_sbuf_line(const char *cs)
{
line_t *lp;
int len, ct;
@ -128,8 +126,7 @@ put_sbuf_line(cs)
/* add_line_node: add a line node in the editor buffer after the current line */
void
add_line_node(lp)
line_t *lp;
add_line_node(line_t *lp)
{
line_t *cp;
@ -142,8 +139,7 @@ add_line_node(lp)
/* get_line_node_addr: return line number of pointer */
long
get_line_node_addr(lp)
line_t *lp;
get_line_node_addr(line_t *lp)
{
line_t *cp = &buffer_head;
long n = 0;
@ -160,8 +156,7 @@ get_line_node_addr(lp)
/* get_addressed_line_node: return pointer to a line node in the editor buffer */
line_t *
get_addressed_line_node(n)
long n;
get_addressed_line_node(long n)
{
static line_t *lp = &buffer_head;
static long on = 0;
@ -196,7 +191,7 @@ char sfn[15] = ""; /* scratch file name */
/* open_sbuf: open scratch file */
int
open_sbuf()
open_sbuf(void)
{
int fd = -1;
int u;
@ -220,7 +215,7 @@ open_sbuf()
/* close_sbuf: close scratch file */
int
close_sbuf()
close_sbuf(void)
{
if (sfp) {
if (fclose(sfp) < 0) {
@ -238,8 +233,7 @@ close_sbuf()
/* quit: remove_lines scratch file and exit */
void
quit(n)
int n;
quit(int n)
{
if (sfp) {
fclose(sfp);
@ -253,7 +247,7 @@ unsigned char ctab[256]; /* character translation table */
/* init_buffers: open scratch buffer; initialize line queue */
void
init_buffers()
init_buffers(void)
{
int i = 0;
@ -278,11 +272,7 @@ init_buffers()
/* translit_text: translate characters in a string */
char *
translit_text(s, len, from, to)
char *s;
int len;
int from;
int to;
translit_text(char *s, int len, int from, int to)
{
static int i = 0;

View File

@ -102,7 +102,7 @@ int des_n = 0; /* index for put_des_char/get_des_char */
/* init_des_cipher: initialize DES */
void
init_des_cipher()
init_des_cipher(void)
{
#ifdef DES
int i;
@ -121,8 +121,7 @@ init_des_cipher()
/* get_des_char: return next char in an encrypted file */
int
get_des_char(fp)
FILE *fp;
get_des_char(FILE *fp)
{
#ifdef DES
if (des_n >= des_ct) {
@ -138,9 +137,7 @@ get_des_char(fp)
/* put_des_char: write a char to an encrypted file; return char written */
int
put_des_char(c, fp)
int c;
FILE *fp;
put_des_char(int c, FILE *fp)
{
#ifdef DES
if (des_n == sizeof des_buf) {
@ -156,8 +153,7 @@ put_des_char(c, fp)
/* flush_des_file: flush an encrypted file's output; return status */
int
flush_des_file(fp)
FILE *fp;
flush_des_file(FILE *fp)
{
#ifdef DES
if (des_n == sizeof des_buf) {
@ -175,7 +171,7 @@ flush_des_file(fp)
* get keyword from tty or stdin
*/
int
get_keyword()
get_keyword(void)
{
char *p; /* used to obtain the key */
Desbuf msgbuf; /* I/O buffer */
@ -202,8 +198,7 @@ get_keyword()
* print a warning message and, possibly, terminate
*/
void
des_error(s)
const char *s; /* the message */
des_error(const char *s)
{
errmsg = s ? s : strerror(errno);
}
@ -212,9 +207,7 @@ des_error(s)
* map a hex character to an integer
*/
int
hex_to_binary(c, radix)
int c; /* char to be converted */
int radix; /* base (2 to 16) */
hex_to_binary(int c, int radix)
{
switch(c) {
case '0': return(0x0);
@ -242,11 +235,11 @@ hex_to_binary(c, radix)
/*
* convert the key to a bit pattern
* obuf bit pattern
* kbuf the key itself
*/
void
expand_des_key(obuf, kbuf)
char *obuf; /* bit pattern */
char *kbuf; /* the key itself */
expand_des_key(char *obuf, char *kbuf)
{
int i, j; /* counter in a for loop */
int nbuf[64]; /* used for hex/key translation */
@ -312,8 +305,7 @@ expand_des_key(obuf, kbuf)
* DES ignores the low order bit of each character.
*/
void
set_des_key(buf)
Desbuf buf; /* key block */
set_des_key(Desbuf buf) /* key block */
{
int i, j; /* counter in a for loop */
int par; /* parity counter */
@ -342,10 +334,7 @@ set_des_key(buf)
* This encrypts using the Cipher Block Chaining mode of DES
*/
int
cbc_encode(msgbuf, n, fp)
char *msgbuf;
int n;
FILE *fp;
cbc_encode(char *msgbuf, int n, FILE *fp)
{
int inverse = 0; /* 0 to encrypt, 1 to decrypt */
@ -379,11 +368,11 @@ cbc_encode(msgbuf, n, fp)
/*
* This decrypts using the Cipher Block Chaining mode of DES
* msgbuf I/O buffer
* fp input file descriptor
*/
int
cbc_decode(msgbuf, fp)
char *msgbuf; /* I/O buffer */
FILE *fp; /* input file descriptor */
cbc_decode(char *msgbuf, FILE *fp)
{
Desbuf tbuf; /* temp buffer for initialization vector */
int n; /* number of bytes actually read */

View File

@ -175,92 +175,80 @@ if ((i) > (n)) { \
/* NEWLINE_TO_NUL: overwrite newlines with ASCII NULs */
#define NEWLINE_TO_NUL(s, l) translit_text(s, l, '\n', '\0')
#ifdef sun
# define strerror(n) sys_errlist[n]
#endif
#ifndef __P
# ifndef __STDC__
# define __P(proto) ()
# else
# define __P(proto) proto
# endif
#endif
/* Local Function Declarations */
void add_line_node __P((line_t *));
int append_lines __P((long));
int apply_subst_template __P((const char *, regmatch_t *, int, int));
int build_active_list __P((int));
int cbc_decode __P((char *, FILE *));
int cbc_encode __P((char *, int, FILE *));
int check_addr_range __P((long, long));
void clear_active_list __P((void));
void clear_undo_stack __P((void));
int close_sbuf __P((void));
int copy_lines __P((long));
int delete_lines __P((long, long));
void des_error __P((const char *));
int display_lines __P((long, long, int));
line_t *dup_line_node __P((line_t *));
int exec_command __P((void));
long exec_global __P((int, int));
void expand_des_key __P((char *, char *));
int extract_addr_range __P((void));
char *extract_pattern __P((int));
int extract_subst_tail __P((int *, long *));
char *extract_subst_template __P((void));
int filter_lines __P((long, long, char *));
int flush_des_file __P((FILE *));
line_t *get_addressed_line_node __P((long));
pattern_t *get_compiled_pattern __P((void));
int get_des_char __P((FILE *));
char *get_extended_line __P((int *, int));
char *get_filename __P((void));
int get_keyword __P((void));
long get_line_node_addr __P((line_t *));
long get_matching_node_addr __P((pattern_t *, int));
long get_marked_node_addr __P((int));
char *get_sbuf_line __P((line_t *));
int get_shell_command __P((void));
int get_stream_line __P((FILE *));
int get_tty_line __P((void));
void handle_hup __P((int));
void handle_int __P((int));
void handle_winch __P((int));
int has_trailing_escape __P((char *, char *));
int hex_to_binary __P((int, int));
void init_buffers __P((void));
void init_des_cipher __P((void));
int is_legal_filename __P((char *));
int join_lines __P((long, long));
int mark_line_node __P((line_t *, int));
int move_lines __P((long));
line_t *next_active_node __P((void));
long next_addr __P((void));
int open_sbuf __P((void));
char *parse_char_class __P((char *));
int pop_undo_stack __P((void));
undo_t *push_undo_stack __P((int, long, long));
int put_des_char __P((int, FILE *));
const char *put_sbuf_line __P((const char *));
int put_stream_line __P((FILE *, const char *, int));
int put_tty_line __P((const char *, int, long, int));
void quit __P((int));
long read_file __P((char *, long));
long read_stream __P((FILE *, long));
int search_and_replace __P((pattern_t *, int, int));
int set_active_node __P((line_t *));
void set_des_key __P((char *));
void signal_hup __P((int));
void signal_int __P((int));
char *strip_escapes __P((char *));
int substitute_matching_text __P((pattern_t *, line_t *, int, int));
char *translit_text __P((char *, int, int, int));
void unmark_line_node __P((line_t *));
void unset_active_nodes __P((line_t *, line_t *));
long write_file __P((char *, const char *, long, long));
long write_stream __P((FILE *, long, long));
void add_line_node(line_t *);
int append_lines(long);
int apply_subst_template(const char *, regmatch_t *, int, int);
int build_active_list(int);
int cbc_decode(char *, FILE *);
int cbc_encode(char *, int, FILE *);
int check_addr_range(long, long);
void clear_active_list(void);
void clear_undo_stack(void);
int close_sbuf(void);
int copy_lines(long);
int delete_lines(long, long);
void des_error(const char *);
int display_lines(long, long, int);
line_t *dup_line_node(line_t *);
int exec_command(void);
long exec_global(int, int);
void expand_des_key(char *, char *);
int extract_addr_range(void);
char *extract_pattern(int);
int extract_subst_tail(int *, long *);
char *extract_subst_template(void);
int filter_lines(long, long, char *);
int flush_des_file(FILE *);
line_t *get_addressed_line_node(long);
pattern_t *get_compiled_pattern(void);
int get_des_char(FILE *);
char *get_extended_line(int *, int);
char *get_filename(void);
int get_keyword(void);
long get_line_node_addr(line_t *);
long get_matching_node_addr(pattern_t *, int);
long get_marked_node_addr(int);
char *get_sbuf_line(line_t *);
int get_shell_command(void);
int get_stream_line(FILE *);
int get_tty_line(void);
void handle_hup(int);
void handle_int(int);
void handle_winch(int);
int has_trailing_escape(char *, char *);
int hex_to_binary(int, int);
void init_buffers(void);
void init_des_cipher(void);
int is_legal_filename(char *);
int join_lines(long, long);
int mark_line_node(line_t *, int);
int move_lines(long);
line_t *next_active_node(void);
long next_addr(void);
int open_sbuf(void);
char *parse_char_class(char *);
int pop_undo_stack(void);
undo_t *push_undo_stack(int, long, long);
int put_des_char(int, FILE *);
const char *put_sbuf_line(const char *);
int put_stream_line(FILE *, const char *, int);
int put_tty_line(const char *, int, long, int);
void quit(int);
long read_file(char *, long);
long read_stream(FILE *, long);
int search_and_replace(pattern_t *, int, int);
int set_active_node(line_t *);
void set_des_key(char *);
void signal_hup(int);
void signal_int(int);
char *strip_escapes(char *);
int substitute_matching_text(pattern_t *, line_t *, int, int);
char *translit_text(char *, int, int, int);
void unmark_line_node(line_t *);
void unset_active_nodes(line_t *, line_t *);
long write_file(char *, const char *, long, long);
long write_stream(FILE *, long, long);
/* global buffers */
extern char stdinbuf[];
@ -282,6 +270,3 @@ extern const char *errmsg;
extern long first_addr;
extern int lineno;
extern long second_addr;
#ifdef sun
extern char *sys_errlist[];
#endif

View File

@ -41,8 +41,7 @@ static const char rcsid[] =
/* build_active_list: add line matching a pattern to the global-active list */
int
build_active_list(isgcmd)
int isgcmd;
build_active_list(int isgcmd)
{
pattern_t *pat;
line_t *lp;
@ -75,9 +74,7 @@ build_active_list(isgcmd)
/* exec_global: apply command list in the command buffer to the active
lines in a range; return command status */
long
exec_global(interact, gflag)
int interact;
int gflag;
exec_global(int interact, int gflag)
{
static char *ocmd = NULL;
static int ocmdsz = 0;
@ -149,8 +146,7 @@ long active_ndx; /* active_list index (modulo active_last) */
/* set_active_node: add a line node to the global-active list */
int
set_active_node(lp)
line_t *lp;
set_active_node(line_t *lp)
{
if (active_last + 1 > active_size) {
int ti = active_size;
@ -188,8 +184,7 @@ set_active_node(lp)
/* unset_active_nodes: remove a range of lines from the global-active list */
void
unset_active_nodes(np, mp)
line_t *np, *mp;
unset_active_nodes(line_t *np, line_t *mp)
{
line_t *lp;
long i;
@ -206,7 +201,7 @@ unset_active_nodes(np, mp)
/* next_active_node: return the next global-active line node */
line_t *
next_active_node()
next_active_node(void)
{
while (active_ptr < active_last && active_list[active_ptr] == NULL)
active_ptr++;
@ -216,7 +211,7 @@ next_active_node()
/* clear_active_list: clear the global-active list */
void
clear_active_list()
clear_active_list(void)
{
SPL1();
active_size = active_last = active_ptr = active_ndx = 0;

View File

@ -37,9 +37,7 @@ extern int scripted;
/* read_file: read a named file/pipe into the buffer; return line count */
long
read_file(fn, n)
char *fn;
long n;
read_file(char *fn, long n)
{
FILE *fp;
long size;
@ -70,9 +68,7 @@ int newline_added; /* if set, newline appended to input file */
/* read_stream: read a stream into the editor buffer; return status */
long
read_stream(fp, n)
FILE *fp;
long n;
read_stream(FILE *fp, long n)
{
line_t *lp = get_addressed_line_node(n);
undo_t *up = NULL;
@ -121,8 +117,7 @@ read_stream(fp, n)
/* get_stream_line: read a line of text from a stream; return line length */
int
get_stream_line(fp)
FILE *fp;
get_stream_line(FILE *fp)
{
int c;
int i = 0;
@ -151,11 +146,7 @@ get_stream_line(fp)
/* write_file: write a range of lines to a named file/pipe; return line count */
long
write_file(fn, mode, n, m)
char *fn;
const char *mode;
long n;
long m;
write_file(char *fn, const char *mode, long n, long m)
{
FILE *fp;
long size;
@ -179,10 +170,7 @@ write_file(fn, mode, n, m)
/* write_stream: write a range of lines to a stream; return status */
long
write_stream(fp, n, m)
FILE *fp;
long n;
long m;
write_stream(FILE *fp, long n, long m)
{
line_t *lp = get_addressed_line_node(n);
unsigned long size = 0;
@ -211,10 +199,7 @@ write_stream(fp, n, m)
/* put_stream_line: write a line of text to a stream; return status */
int
put_stream_line(fp, s, len)
FILE *fp;
const char *s;
int len;
put_stream_line(FILE *fp, const char *s, int len)
{
while (len--)
if ((des ? put_des_char(*s++, fp) : fputc(*s++, fp)) < 0) {
@ -227,9 +212,7 @@ put_stream_line(fp, s, len)
/* get_extended_line: get a an extended line from stdin */
char *
get_extended_line(sizep, nonl)
int *sizep;
int nonl;
get_extended_line(int *sizep, int nonl)
{
static char *cvbuf = NULL; /* buffer */
static int cvbufsz = 0; /* buffer size */
@ -272,7 +255,7 @@ get_extended_line(sizep, nonl)
/* get_tty_line: read a line of text from stdin; return line length */
int
get_tty_line()
get_tty_line(void)
{
int oi = 0;
int i = 0;
@ -320,11 +303,7 @@ extern int cols;
/* put_tty_line: print text to stdout */
int
put_tty_line(s, l, n, gflag)
const char *s;
int l;
long n;
int gflag;
put_tty_line(const char *s, int l, long n, int gflag)
{
int col = 0;
int lc = 0;

View File

@ -103,9 +103,7 @@ const char usage[] = "usage: %s [-] [-sx] [-p string] [name]\n";
/* ed: line editor */
int
main(argc, argv)
int argc;
char **argv;
main(int argc, char *argv[])
{
int c, n;
long status = 0;
@ -266,7 +264,7 @@ long first_addr, second_addr, addr_cnt;
/* extract_addr_range: get line addresses from the command buffer until an
illegal address is seen; return status */
int
extract_addr_range()
extract_addr_range(void)
{
long addr;
@ -298,7 +296,7 @@ extract_addr_range()
/* next_addr: return the next line address in the command buffer */
long
next_addr()
next_addr(void)
{
const char *hd;
long addr = current_addr;
@ -449,7 +447,7 @@ long rows = 22; /* scroll length: ws_row - 2 */
/* exec_command: execute the next command in command buffer; return print
request, if any */
int
exec_command()
exec_command(void)
{
extern long u_current_addr;
extern long u_addr_last;
@ -883,8 +881,7 @@ exec_command()
/* check_addr_range: return status of address range check */
int
check_addr_range(n, m)
long n, m;
check_addr_range(long n, long m)
{
if (addr_cnt == 0) {
first_addr = n;
@ -903,9 +900,7 @@ check_addr_range(n, m)
pattern in a given direction. wrap around begin/end of editor buffer if
necessary */
long
get_matching_node_addr(pat, dir)
pattern_t *pat;
int dir;
get_matching_node_addr(pattern_t *pat, int dir)
{
char *s;
long n = current_addr;
@ -930,7 +925,7 @@ get_matching_node_addr(pat, dir)
/* get_filename: return pointer to copy of filename in the command buffer */
char *
get_filename()
get_filename(void)
{
static char *file = NULL;
static int filesz = 0;
@ -973,7 +968,7 @@ get_filename()
/* get_shell_command: read a shell command from stdin; return substitution
status */
int
get_shell_command()
get_shell_command(void)
{
static char *buf = NULL;
static int n = 0;
@ -1039,8 +1034,7 @@ get_shell_command()
/* append_lines: insert text from stdin to after line n; stop when either a
single period is read or EOF; return status */
int
append_lines(n)
long n;
append_lines(long n)
{
int l;
const char *lp = ibuf;
@ -1089,9 +1083,7 @@ append_lines(n)
/* join_lines: replace a range of lines with the joined text of those lines */
int
join_lines(from, to)
long from;
long to;
join_lines(long from, long to)
{
static char *buf = NULL;
static int n;
@ -1128,8 +1120,7 @@ join_lines(from, to)
/* move_lines: move a range of lines */
int
move_lines(addr)
long addr;
move_lines(long addr)
{
line_t *b1, *a1, *b2, *a2;
long n = INC_MOD(second_addr, addr_last);
@ -1173,8 +1164,7 @@ move_lines(addr)
/* copy_lines: copy a range of lines; return status */
int
copy_lines(addr)
long addr;
copy_lines(long addr)
{
line_t *lp, *np = get_addressed_line_node(first_addr);
undo_t *up = NULL;
@ -1210,8 +1200,7 @@ copy_lines(addr)
/* delete_lines: delete a range of lines */
int
delete_lines(from, to)
long from, to;
delete_lines(long from, long to)
{
line_t *n, *p;
@ -1236,10 +1225,7 @@ delete_lines(from, to)
/* display_lines: print a range of lines to stdout */
int
display_lines(from, to, gflag)
long from;
long to;
int gflag;
display_lines(long from, long to, int gflag)
{
line_t *bp;
line_t *ep;
@ -1268,9 +1254,7 @@ int markno; /* line marker count */
/* mark_line_node: set a line node mark */
int
mark_line_node(lp, n)
line_t *lp;
int n;
mark_line_node(line_t *lp, int n)
{
if (!islower((unsigned char)n)) {
errmsg = "invalid mark character";
@ -1284,8 +1268,7 @@ mark_line_node(lp, n)
/* get_marked_node_addr: return address of a marked line */
long
get_marked_node_addr(n)
int n;
get_marked_node_addr(int n)
{
if (!islower((unsigned char)n)) {
errmsg = "invalid mark character";
@ -1297,8 +1280,7 @@ get_marked_node_addr(n)
/* unmark_line_node: clear line node mark */
void
unmark_line_node(lp)
line_t *lp;
unmark_line_node(line_t *lp)
{
int i;
@ -1312,8 +1294,7 @@ unmark_line_node(lp)
/* dup_line_node: return a pointer to a copy of a line node */
line_t *
dup_line_node(lp)
line_t *lp;
dup_line_node(line_t *lp)
{
line_t *np;
@ -1331,9 +1312,7 @@ dup_line_node(lp)
/* has_trailing_escape: return the parity of escapes preceding a character
in a string */
int
has_trailing_escape(s, t)
char *s;
char *t;
has_trailing_escape(char *s, char *t)
{
return (s == t || *(t - 1) != '\\') ? 0 : !has_trailing_escape(s, t - 1);
}
@ -1341,8 +1320,7 @@ has_trailing_escape(s, t)
/* strip_escapes: return copy of escaped string of at most length PATH_MAX */
char *
strip_escapes(s)
char *s;
strip_escapes(char *s)
{
static char *file = NULL;
static int filesz = 0;
@ -1358,8 +1336,7 @@ strip_escapes(s)
void
signal_hup(signo)
int signo;
signal_hup(int signo)
{
if (mutex)
sigflags |= (1 << (signo - 1));
@ -1369,8 +1346,7 @@ signal_hup(signo)
void
signal_int(signo)
int signo;
signal_int(int signo)
{
if (mutex)
sigflags |= (1 << (signo - 1));
@ -1380,8 +1356,7 @@ signal_int(signo)
void
handle_hup(signo)
int signo;
handle_hup(int signo)
{
char *hup = NULL; /* hup filename */
char *s;
@ -1406,8 +1381,7 @@ handle_hup(signo)
void
handle_int(signo)
int signo;
handle_int(int signo)
{
if (!sigactive)
quit(1);
@ -1423,8 +1397,7 @@ handle_int(signo)
int cols = 72; /* wrap column */
void
handle_winch(signo)
int signo;
handle_winch(int signo)
{
int save_errno = errno;
@ -1441,8 +1414,7 @@ handle_winch(signo)
/* is_legal_filename: return a legal filename */
int
is_legal_filename(s)
char *s;
is_legal_filename(char *s)
{
if (red && (*s == '!' || !strcmp(s, "..") || strchr(s, '/'))) {
errmsg = "shell access restricted";

View File

@ -41,7 +41,7 @@ const char *errmsg = "";
/* get_compiled_pattern: return pointer to compiled pattern from command
buffer */
pattern_t *
get_compiled_pattern()
get_compiled_pattern(void)
{
static pattern_t *exp = NULL;
static char error[1024];
@ -81,8 +81,7 @@ get_compiled_pattern()
/* extract_pattern: copy a pattern string from the command buffer; return
pointer to the copy */
char *
extract_pattern(delimiter)
int delimiter;
extract_pattern(int delimiter)
{
static char *lhbuf = NULL; /* buffer */
static int lhbufsz = 0; /* buffer size */
@ -118,8 +117,7 @@ extract_pattern(delimiter)
/* parse_char_class: expand a POSIX character class */
char *
parse_char_class(s)
char *s;
parse_char_class(char *s)
{
int c, d;

View File

@ -40,9 +40,7 @@ int rhbufi; /* rhs substitution buffer index */
/* extract_subst_tail: extract substitution tail from the command buffer */
int
extract_subst_tail(flagp, np)
int *flagp;
long *np;
extract_subst_tail(int *flagp, long *np)
{
char delimiter;
@ -73,7 +71,7 @@ extract_subst_tail(flagp, np)
/* extract_subst_template: return pointer to copy of substitution template
in the command buffer */
char *
extract_subst_template()
extract_subst_template(void)
{
int n = 0;
int i = 0;
@ -115,10 +113,7 @@ int rbufsz; /* substitute_matching_text buffer size */
/* search_and_replace: for each line in a range, change text matching a pattern
according to a substitution template; return status */
int
search_and_replace(pat, gflag, kth)
pattern_t *pat;
int gflag;
int kth;
search_and_replace(pattern_t *pat, int gflag, int kth)
{
undo_t *up;
const char *txt;
@ -172,11 +167,7 @@ search_and_replace(pat, gflag, kth)
/* substitute_matching_text: replace text matched by a pattern according to
a substitution template; return pointer to the modified text */
int
substitute_matching_text(pat, lp, gflag, kth)
pattern_t *pat;
line_t *lp;
int gflag;
int kth;
substitute_matching_text(pattern_t *pat, line_t *lp, int gflag, int kth)
{
int off = 0;
int changed = 0;
@ -234,11 +225,7 @@ substitute_matching_text(pat, lp, gflag, kth)
/* apply_subst_template: modify text according to a substitution template;
return offset to end of modified text */
int
apply_subst_template(boln, rm, off, re_nsub)
const char *boln;
regmatch_t *rm;
int off;
int re_nsub;
apply_subst_template(const char *boln, regmatch_t *rm, int off, int re_nsub)
{
int j = 0;
int k = 0;

View File

@ -40,10 +40,7 @@ long u_p = 0; /* undo stack pointer */
/* push_undo_stack: return pointer to initialized undo node */
undo_t *
push_undo_stack(type, from, to)
int type;
long from;
long to;
push_undo_stack(int type, long from, long to)
{
undo_t *t;
@ -87,7 +84,7 @@ long u_addr_last = -1; /* if >= 0, undo enabled */
/* pop_undo_stack: undo last change to the editor buffer */
int
pop_undo_stack()
pop_undo_stack(void)
{
long n;
long o_current_addr = current_addr;
@ -136,7 +133,7 @@ pop_undo_stack()
/* clear_undo_stack: clear the undo stack */
void
clear_undo_stack()
clear_undo_stack(void)
{
line_t *lp, *ep, *tl;

View File

@ -32,35 +32,34 @@ struct val {
struct val *result;
int chk_div __P((quad_t, quad_t));
int chk_minus __P((quad_t, quad_t, quad_t));
int chk_plus __P((quad_t, quad_t, quad_t));
int chk_times __P((quad_t, quad_t, quad_t));
void free_value __P((struct val *));
int is_zero_or_null __P((struct val *));
int isstring __P((struct val *));
int main __P((int, char **));
struct val *make_integer __P((quad_t));
struct val *make_str __P((const char *));
struct val *op_and __P((struct val *, struct val *));
struct val *op_colon __P((struct val *, struct val *));
struct val *op_div __P((struct val *, struct val *));
struct val *op_eq __P((struct val *, struct val *));
struct val *op_ge __P((struct val *, struct val *));
struct val *op_gt __P((struct val *, struct val *));
struct val *op_le __P((struct val *, struct val *));
struct val *op_lt __P((struct val *, struct val *));
struct val *op_minus __P((struct val *, struct val *));
struct val *op_ne __P((struct val *, struct val *));
struct val *op_or __P((struct val *, struct val *));
struct val *op_plus __P((struct val *, struct val *));
struct val *op_rem __P((struct val *, struct val *));
struct val *op_times __P((struct val *, struct val *));
quad_t to_integer __P((struct val *));
void to_string __P((struct val *));
int yyerror __P((const char *));
int yylex __P((void));
int yyparse __P((void));
int chk_div(quad_t, quad_t);
int chk_minus(quad_t, quad_t, quad_t);
int chk_plus(quad_t, quad_t, quad_t);
int chk_times(quad_t, quad_t, quad_t);
void free_value(struct val *);
int is_zero_or_null(struct val *);
int isstring(struct val *);
struct val *make_integer(quad_t);
struct val *make_str(const char *);
struct val *op_and(struct val *, struct val *);
struct val *op_colon(struct val *, struct val *);
struct val *op_div(struct val *, struct val *);
struct val *op_eq(struct val *, struct val *);
struct val *op_ge(struct val *, struct val *);
struct val *op_gt(struct val *, struct val *);
struct val *op_le(struct val *, struct val *);
struct val *op_lt(struct val *, struct val *);
struct val *op_minus(struct val *, struct val *);
struct val *op_ne(struct val *, struct val *);
struct val *op_or(struct val *, struct val *);
struct val *op_plus(struct val *, struct val *);
struct val *op_rem(struct val *, struct val *);
struct val *op_times(struct val *, struct val *);
quad_t to_integer(struct val *);
void to_string(struct val *);
int yyerror(const char *);
int yylex(void);
int yyparse(void);
char **av;
%}
@ -106,8 +105,7 @@ expr: TOKEN
%%
struct val *
make_integer (i)
quad_t i;
make_integer(quad_t i)
{
struct val *vp;
@ -122,8 +120,7 @@ quad_t i;
}
struct val *
make_str (s)
const char *s;
make_str(const char *s)
{
struct val *vp;
size_t i;
@ -152,8 +149,7 @@ const char *s;
void
free_value (vp)
struct val *vp;
free_value(struct val *vp)
{
if (vp->type == string || vp->type == numeric_string)
free (vp->u.s);
@ -161,8 +157,7 @@ struct val *vp;
quad_t
to_integer (vp)
struct val *vp;
to_integer(struct val *vp)
{
quad_t i;
@ -185,8 +180,7 @@ struct val *vp;
}
void
to_string (vp)
struct val *vp;
to_string(struct val *vp)
{
char *tmp;
@ -205,8 +199,7 @@ struct val *vp;
int
isstring (vp)
struct val *vp;
isstring(struct val *vp)
{
/* only TRUE if this string is not a valid integer */
return (vp->type == string);
@ -214,7 +207,7 @@ struct val *vp;
int
yylex ()
yylex(void)
{
char *p;
@ -239,8 +232,7 @@ yylex ()
}
int
is_zero_or_null (vp)
struct val *vp;
is_zero_or_null(struct val *vp)
{
if (vp->type == integer) {
return (vp->u.i == 0);
@ -251,9 +243,7 @@ struct val *vp;
}
int
main (argc, argv)
int argc __unused;
char **argv;
main(int argc __unused, char *argv[])
{
setlocale (LC_ALL, "");
@ -270,16 +260,14 @@ char **argv;
}
int
yyerror (s)
const char *s __unused;
yyerror(const char *s __unused)
{
errx (2, "syntax error");
}
struct val *
op_or (a, b)
struct val *a, *b;
op_or(struct val *a, struct val *b)
{
if (is_zero_or_null (a)) {
free_value (a);
@ -291,8 +279,7 @@ struct val *a, *b;
}
struct val *
op_and (a, b)
struct val *a, *b;
op_and(struct val *a, struct val *b)
{
if (is_zero_or_null (a) || is_zero_or_null (b)) {
free_value (a);
@ -305,8 +292,7 @@ struct val *a, *b;
}
struct val *
op_eq (a, b)
struct val *a, *b;
op_eq(struct val *a, struct val *b)
{
struct val *r;
@ -326,8 +312,7 @@ struct val *a, *b;
}
struct val *
op_gt (a, b)
struct val *a, *b;
op_gt(struct val *a, struct val *b)
{
struct val *r;
@ -347,8 +332,7 @@ struct val *a, *b;
}
struct val *
op_lt (a, b)
struct val *a, *b;
op_lt(struct val *a, struct val *b)
{
struct val *r;
@ -368,8 +352,7 @@ struct val *a, *b;
}
struct val *
op_ge (a, b)
struct val *a, *b;
op_ge(struct val *a, struct val *b)
{
struct val *r;
@ -389,8 +372,7 @@ struct val *a, *b;
}
struct val *
op_le (a, b)
struct val *a, *b;
op_le(struct val *a, struct val *b)
{
struct val *r;
@ -410,8 +392,7 @@ struct val *a, *b;
}
struct val *
op_ne (a, b)
struct val *a, *b;
op_ne(struct val *a, struct val *b)
{
struct val *r;
@ -431,8 +412,7 @@ struct val *a, *b;
}
int
chk_plus (a, b, r)
quad_t a, b, r;
chk_plus(quad_t a, quad_t b, quad_t r)
{
/* sum of two positive numbers must be positive */
if (a > 0 && b > 0 && r <= 0)
@ -445,8 +425,7 @@ quad_t a, b, r;
}
struct val *
op_plus (a, b)
struct val *a, *b;
op_plus(struct val *a, struct val *b)
{
struct val *r;
@ -464,8 +443,7 @@ struct val *a, *b;
}
int
chk_minus (a, b, r)
quad_t a, b, r;
chk_minus(quad_t a, quad_t b, quad_t r)
{
/* special case subtraction of QUAD_MIN */
if (b == QUAD_MIN) {
@ -479,8 +457,7 @@ quad_t a, b, r;
}
struct val *
op_minus (a, b)
struct val *a, *b;
op_minus(struct val *a, struct val *b)
{
struct val *r;
@ -498,8 +475,7 @@ struct val *a, *b;
}
int
chk_times (a, b, r)
quad_t a, b, r;
chk_times(quad_t a, quad_t b, quad_t r)
{
/* special case: first operand is 0, no overflow possible */
if (a == 0)
@ -511,8 +487,7 @@ quad_t a, b, r;
}
struct val *
op_times (a, b)
struct val *a, *b;
op_times(struct val *a, struct val *b)
{
struct val *r;
@ -530,8 +505,7 @@ struct val *a, *b;
}
int
chk_div (a, b)
quad_t a, b;
chk_div(quad_t a, quad_t b)
{
/* div by zero has been taken care of before */
/* only QUAD_MIN / -1 causes overflow */
@ -542,8 +516,7 @@ quad_t a, b;
}
struct val *
op_div (a, b)
struct val *a, *b;
op_div(struct val *a, struct val *b)
{
struct val *r;
@ -565,8 +538,7 @@ struct val *a, *b;
}
struct val *
op_rem (a, b)
struct val *a, *b;
op_rem(struct val *a, struct val *b)
{
struct val *r;
@ -586,8 +558,7 @@ struct val *a, *b;
}
struct val *
op_colon (a, b)
struct val *a, *b;
op_colon(struct val *a, struct val *b)
{
regex_t rp;
regmatch_t rm[2];