mined: K&R to ANSI, fix function sigs & warnings

- Re-write function declarations from K&R style to ANSI style.
 - Change declaration of write_char(), S(), in_list() to match ptotos.
 - Resolve clang warnings about assignments in conditionals.

Change-Id: I61624b18afbefe1ff29941233d274bd6c0f12520
This commit is contained in:
Thomas Cort 2013-08-09 20:41:13 +00:00 committed by Gerrit Code Review
parent 228e84ad2a
commit d06d9df7af
2 changed files with 123 additions and 229 deletions

View file

@ -425,7 +425,7 @@ int screenmax = SCREENMAX;
/* /*
* Print file status. * Print file status.
*/ */
void FS() void FS(void)
{ {
fstatus(file_name[0] ? "" : "[buffer]", -1L); fstatus(file_name[0] ? "" : "[buffer]", -1L);
} }
@ -434,7 +434,7 @@ void FS()
* Visit (edit) another file. If the file has been modified, ask the user if * Visit (edit) another file. If the file has been modified, ask the user if
* he wants to save it. * he wants to save it.
*/ */
void VI() void VI(void)
{ {
char new_file[LINE_LEN]; /* Buffer to hold new file name */ char new_file[LINE_LEN]; /* Buffer to hold new file name */
@ -458,7 +458,7 @@ void VI()
/* /*
* Write file in core to disc. * Write file in core to disc.
*/ */
int WT() int WT(void)
{ {
register LINE *line; register LINE *line;
register long count = 0L; /* Nr of chars written */ register long count = 0L; /* Nr of chars written */
@ -516,7 +516,7 @@ int WT()
} }
/* Call WT and discard value returned. */ /* Call WT and discard value returned. */
void XWT() void XWT(void)
{ {
(void) WT(); (void) WT();
} }
@ -526,7 +526,7 @@ void XWT()
/* /*
* Call an interactive shell. * Call an interactive shell.
*/ */
void SH() void SH(void)
{ {
register int w; register int w;
int pid, status; int pid, status;
@ -572,9 +572,7 @@ void SH()
* it returns the count'th line before `line'. When the next (previous) * it returns the count'th line before `line'. When the next (previous)
* line is the tail (header) indicating EOF (tof) it stops. * line is the tail (header) indicating EOF (tof) it stops.
*/ */
LINE *proceed(line, count) LINE *proceed(register LINE *line, register int count)
register LINE *line;
register int count;
{ {
if (count < 0) if (count < 0)
while (count++ < 0 && line != header) while (count++ < 0 && line != header)
@ -590,11 +588,7 @@ register int count;
* If revfl is TRUE, turn on reverse video on both strings. Set stat_visible * If revfl is TRUE, turn on reverse video on both strings. Set stat_visible
* only if bottom_line is visible. * only if bottom_line is visible.
*/ */
int bottom_line(revfl, s1, s2, inbuf, statfl) int bottom_line(FLAG revfl, char *s1, char *s2, char *inbuf, FLAG statfl)
FLAG revfl;
char *s1, *s2;
char *inbuf;
FLAG statfl;
{ {
int ret = FINE; int ret = FINE;
char buf[LINE_LEN]; char buf[LINE_LEN];
@ -602,10 +596,10 @@ FLAG statfl;
*p++ = ' '; *p++ = ' ';
if (s1 != NULL) if (s1 != NULL)
while (*p = *s1++) while ((*p = *s1++))
p++; p++;
if (s2 != NULL) if (s2 != NULL)
while (*p = *s2++) while ((*p = *s2++))
p++; p++;
*p++ = ' '; *p++ = ' ';
*p++ = 0; *p++ = 0;
@ -651,8 +645,7 @@ FLAG statfl;
* Count_chars() count the number of chars that the line would occupy on the * Count_chars() count the number of chars that the line would occupy on the
* screen. Counting starts at the real x-coordinate of the line. * screen. Counting starts at the real x-coordinate of the line.
*/ */
int count_chars(line) int count_chars(LINE *line)
LINE *line;
{ {
register int cnt = get_shift(line->shift_count) * -SHIFT_SIZE; register int cnt = get_shift(line->shift_count) * -SHIFT_SIZE;
register char *textp = line->text; register char *textp = line->text;
@ -686,10 +679,7 @@ LINE *line;
* If we're moving to the same x coordinate, try to move the the x-coordinate * If we're moving to the same x coordinate, try to move the the x-coordinate
* used on the other previous call. * used on the other previous call.
*/ */
void move(new_x, new_address, new_y) void move(register int new_x, char *new_address, int new_y)
register int new_x;
int new_y;
char *new_address;
{ {
register LINE *line = cur_line; /* For building new cur_line */ register LINE *line = cur_line; /* For building new cur_line */
int shift = 0; /* How many shifts to make */ int shift = 0; /* How many shifts to make */
@ -752,9 +742,7 @@ char *new_address;
* Find_x() returns the x coordinate belonging to address. * Find_x() returns the x coordinate belonging to address.
* (Tabs are expanded). * (Tabs are expanded).
*/ */
int find_x(line, address) int find_x(LINE *line, char *address)
LINE *line;
char *address;
{ {
register char *textp = line->text; register char *textp = line->text;
register int nx = get_shift(line->shift_count) * -SHIFT_SIZE; register int nx = get_shift(line->shift_count) * -SHIFT_SIZE;
@ -772,10 +760,7 @@ char *address;
* Find_address() returns the pointer in the line with offset x_coord. * Find_address() returns the pointer in the line with offset x_coord.
* (Tabs are expanded). * (Tabs are expanded).
*/ */
char *find_address(line, x_coord, old_x) char *find_address(LINE *line, int x_coord, int *old_x)
LINE *line;
int x_coord;
int *old_x;
{ {
register char *textp = line->text; register char *textp = line->text;
register int tx = get_shift(line->shift_count) * -SHIFT_SIZE; register int tx = get_shift(line->shift_count) * -SHIFT_SIZE;
@ -800,8 +785,7 @@ int *old_x;
* Length_of() returns the number of characters int the string `string' * Length_of() returns the number of characters int the string `string'
* excluding the '\0'. * excluding the '\0'.
*/ */
int length_of(string) int length_of(register char *string)
register char *string;
{ {
register int count = 0; register int count = 0;
@ -816,11 +800,9 @@ register char *string;
* Copy_string() copies the string `from' into the string `to'. `To' must be * Copy_string() copies the string `from' into the string `to'. `To' must be
* long enough to hold `from'. * long enough to hold `from'.
*/ */
void copy_string(to, from) void copy_string(register char *to, register char *from)
register char *to;
register char *from;
{ {
while (*to++ = *from++) while ((*to++ = *from++))
; ;
} }
@ -829,9 +811,7 @@ register char *from;
* which must be the first line of the screen, and an y-coordinate, * which must be the first line of the screen, and an y-coordinate,
* which will be the current y-coordinate (if it isn't larger than last_y) * which will be the current y-coordinate (if it isn't larger than last_y)
*/ */
void reset(head_line, screen_y) void reset(LINE *head_line, int screen_y)
LINE *head_line;
int screen_y;
{ {
register LINE *line; register LINE *line;
@ -852,8 +832,7 @@ int screen_y;
/* /*
* Set cursor at coordinates x, y. * Set cursor at coordinates x, y.
*/ */
void set_cursor(nx, ny) void set_cursor(int nx, int ny)
int nx, ny;
{ {
#ifdef UNIX #ifdef UNIX
extern char *tgoto(); extern char *tgoto();
@ -870,7 +849,7 @@ int nx, ny;
/* /*
* Routine to open terminal when mined is used in a pipeline. * Routine to open terminal when mined is used in a pipeline.
*/ */
void open_device() void open_device(void)
{ {
if ((input_fd = open("/dev/tty", 0)) < 0) if ((input_fd = open("/dev/tty", 0)) < 0)
panic("Cannot open /dev/tty for read"); panic("Cannot open /dev/tty for read");
@ -880,7 +859,7 @@ void open_device()
* Getchar() reads one character from the terminal. The character must be * Getchar() reads one character from the terminal. The character must be
* masked with 0377 to avoid sign extension. * masked with 0377 to avoid sign extension.
*/ */
int getchar() int getchar(void)
{ {
#ifdef UNIX #ifdef UNIX
return (_getchar() & 0377); return (_getchar() & 0377);
@ -900,10 +879,7 @@ int getchar()
* rest of the screen with blank_line's. * rest of the screen with blank_line's.
* When count is negative, a backwards print from `line' will be done. * When count is negative, a backwards print from `line' will be done.
*/ */
void display(x_coord, y_coord, line, count) void display(int x_coord, int y_coord, register LINE *line, register int count)
int x_coord, y_coord;
register LINE *line;
register int count;
{ {
set_cursor(x_coord, y_coord); set_cursor(x_coord, y_coord);
@ -935,9 +911,7 @@ register int count;
/* /*
* Write_char does a buffered output. * Write_char does a buffered output.
*/ */
int write_char(fd, c) int write_char(int fd, int c)
int fd;
char c;
{ {
screen [out_count++] = c; screen [out_count++] = c;
if (out_count == SCREEN_SIZE) /* Flush on SCREEN_SIZE chars */ if (out_count == SCREEN_SIZE) /* Flush on SCREEN_SIZE chars */
@ -948,9 +922,7 @@ char c;
/* /*
* Writeline writes the given string on the given filedescriptor. * Writeline writes the given string on the given filedescriptor.
*/ */
int writeline(fd, text) int writeline(register int fd, register char *text)
register int fd;
register char *text;
{ {
while(*text) while(*text)
if (write_char(fd, *text++) == ERRORS) if (write_char(fd, *text++) == ERRORS)
@ -964,10 +936,7 @@ register char *text;
* then (screen) line will be cleared when the end of the line has been * then (screen) line will be cleared when the end of the line has been
* reached. * reached.
*/ */
void put_line(line, offset, clear_line) void put_line(LINE *line, int offset, FLAG clear_line)
LINE *line; /* Line to print */
int offset; /* Offset to start */
FLAG clear_line; /* Clear to eoln if TRUE */
{ {
register char *textp = line->text; register char *textp = line->text;
register int count = get_shift(line->shift_count) * -SHIFT_SIZE; register int count = get_shift(line->shift_count) * -SHIFT_SIZE;
@ -1028,8 +997,7 @@ FLAG clear_line; /* Clear to eoln if TRUE */
/* /*
* Flush the I/O buffer on filedescriptor fd. * Flush the I/O buffer on filedescriptor fd.
*/ */
int flush_buffer(fd) int flush_buffer(int fd)
int fd;
{ {
if (out_count <= 0) /* There is nothing to flush */ if (out_count <= 0) /* There is nothing to flush */
return FINE; return FINE;
@ -1051,8 +1019,7 @@ int fd;
/* /*
* Bad_write() is called when a write failed. Notify the user. * Bad_write() is called when a write failed. Notify the user.
*/ */
void bad_write(fd) void bad_write(int fd)
int fd;
{ {
if (fd == STD_OUT) /* Cannot write to terminal? */ if (fd == STD_OUT) /* Cannot write to terminal? */
exit(1); exit(1);
@ -1067,8 +1034,7 @@ int fd;
/* /*
* Catch the SIGQUIT signal (^\) send to mined. It turns on the quitflag. * Catch the SIGQUIT signal (^\) send to mined. It turns on the quitflag.
*/ */
void catch(sig) void catch(int sig)
int sig;
{ {
/* Reset the signal */ /* Reset the signal */
signal(SIGQUIT, catch); signal(SIGQUIT, catch);
@ -1078,7 +1044,7 @@ int sig;
/* /*
* Abort_mined() will leave mined. Confirmation is asked first. * Abort_mined() will leave mined. Confirmation is asked first.
*/ */
void abort_mined() void abort_mined(void)
{ {
quit = FALSE; quit = FALSE;
@ -1107,8 +1073,7 @@ void abort_mined()
* Set and reset tty into CBREAK or old mode according to argument `state'. It * Set and reset tty into CBREAK or old mode according to argument `state'. It
* also sets all signal characters (except for ^\) to UNDEF. ^\ is caught. * also sets all signal characters (except for ^\) to UNDEF. ^\ is caught.
*/ */
void raw_mode(state) void raw_mode(FLAG state)
FLAG state;
{ {
static struct termios old_tty; static struct termios old_tty;
static struct termios new_tty; static struct termios new_tty;
@ -1140,8 +1105,7 @@ FLAG state;
* It writes the message to the terminal, resets the tty and exits. * It writes the message to the terminal, resets the tty and exits.
* Ask the user if he wants to save his file. * Ask the user if he wants to save his file.
*/ */
void panic(message) void panic(register char *message)
register char *message;
{ {
extern char yank_file[]; extern char yank_file[];
@ -1166,8 +1130,7 @@ register char *message;
#endif /* UNIX */ #endif /* UNIX */
} }
char *alloc(bytes) char *alloc(int bytes)
int bytes;
{ {
char *p; char *p;
@ -1180,8 +1143,7 @@ int bytes;
return(p); return(p);
} }
void free_space(p) void free_space(char *p)
char *p;
{ {
free(p); free(p);
} }
@ -1257,7 +1219,7 @@ long chars_saved; /* Nr of chars in buffer */
* Initialize is called when a another file is edited. It free's the allocated * Initialize is called when a another file is edited. It free's the allocated
* space and sets modified back to FALSE and fixes the header/tail pointer. * space and sets modified back to FALSE and fixes the header/tail pointer.
*/ */
void initialize() void initialize(void)
{ {
register LINE *line, *next_line; register LINE *line, *next_line;
@ -1277,8 +1239,7 @@ void initialize()
/* /*
* Basename() finds the absolute name of the file out of a given path_name. * Basename() finds the absolute name of the file out of a given path_name.
*/ */
char *basename(path) char *basename(char *path)
char *path;
{ {
register char *ptr = path; register char *ptr = path;
register char *last = NULL; register char *last = NULL;
@ -1302,8 +1263,7 @@ char *path;
* couldn't be opened, just some initializations are done, and a line consisting * couldn't be opened, just some initializations are done, and a line consisting
* of a `\n' is installed. * of a `\n' is installed.
*/ */
void load_file(file) void load_file(char *file)
char *file;
{ {
register LINE *line = header; register LINE *line = header;
register int len; register int len;
@ -1366,9 +1326,7 @@ char *file;
* Get_line reads one line from filedescriptor fd. If EOF is reached on fd, * Get_line reads one line from filedescriptor fd. If EOF is reached on fd,
* get_line() returns ERRORS, else it returns the length of the string. * get_line() returns ERRORS, else it returns the length of the string.
*/ */
int get_line(fd, buffer) int get_line(int fd, register char *buffer)
int fd;
register char *buffer;
{ {
static char *last = NULL; static char *last = NULL;
static char *current = NULL; static char *current = NULL;
@ -1408,9 +1366,7 @@ register char *buffer;
* Install_line installs the buffer into a LINE structure It returns a pointer * Install_line installs the buffer into a LINE structure It returns a pointer
* to the allocated structure. * to the allocated structure.
*/ */
LINE *install_line(buffer, length) LINE *install_line(char *buffer, int length)
char *buffer;
int length;
{ {
register LINE *new_line = (LINE *) alloc(sizeof(LINE)); register LINE *new_line = (LINE *) alloc(sizeof(LINE));
@ -1421,9 +1377,7 @@ int length;
return new_line; return new_line;
} }
int main(argc, argv) int main(int argc, char *argv[])
int argc;
char *argv[];
{ {
/* mined is the Minix editor. */ /* mined is the Minix editor. */
@ -1490,7 +1444,7 @@ char *argv[];
/* /*
* Redraw the screen * Redraw the screen
*/ */
void RD() void RD(void)
{ {
/* Clear screen */ /* Clear screen */
#ifdef UNIX #ifdef UNIX
@ -1516,14 +1470,14 @@ void RD()
/* /*
* Ignore this keystroke. * Ignore this keystroke.
*/ */
void I() void I(void)
{ {
} }
/* /*
* Leave editor. If the file has changed, ask if the user wants to save it. * Leave editor. If the file has changed, ask if the user wants to save it.
*/ */
void XT() void XT(void)
{ {
if (modified == TRUE && ask_save() == ERRORS) if (modified == TRUE && ask_save() == ERRORS)
return; return;
@ -1536,8 +1490,7 @@ void XT()
exit(0); exit(0);
} }
void (*escfunc(c))() void (*escfunc(int c))(void)
int c;
{ {
if (c == '[') { if (c == '[') {
/* Start of ASCII escape sequence. */ /* Start of ASCII escape sequence. */
@ -1568,7 +1521,7 @@ int c;
* command count times. If a ^\ is given during repeating, stop looping and * command count times. If a ^\ is given during repeating, stop looping and
* return to main loop. * return to main loop.
*/ */
void ESC() void ESC(void)
{ {
register int count = 0; register int count = 0;
register void (*func)(); register void (*func)();
@ -1608,7 +1561,7 @@ void ESC()
/* /*
* Ask the user if he wants to save his file or not. * Ask the user if he wants to save his file or not.
*/ */
int ask_save() int ask_save(void)
{ {
register int c; register int c;
@ -1635,7 +1588,7 @@ int ask_save()
/* /*
* Line_number() finds the line number we're on. * Line_number() finds the line number we're on.
*/ */
int line_number() int line_number(void)
{ {
register LINE *line = header->next; register LINE *line = header->next;
register int count = 1; register int count = 1;
@ -1652,12 +1605,8 @@ int line_number()
* Display a line telling how many chars and lines the file contains. Also tell * Display a line telling how many chars and lines the file contains. Also tell
* whether the file is readonly and/or modified. * whether the file is readonly and/or modified.
*/ */
void file_status(message, count, file, lines, writefl, changed) void file_status(char *message, register long count, char *file, int lines,
char *message; FLAG writefl, FLAG changed)
register long count; /* Contains number of characters in file */
char *file;
int lines;
FLAG writefl, changed;
{ {
register LINE *line; register LINE *line;
char msg[LINE_LEN + 40];/* Buffer to hold line */ char msg[LINE_LEN + 40];/* Buffer to hold line */
@ -1696,9 +1645,7 @@ FLAG writefl, changed;
void build_string(char *buf, char *fmt, ...) void build_string(char *buf, char *fmt, ...)
{ {
#else #else
void build_string(buf, fmt, va_alist) void build_string(char *buf, char *fmt, va_dcl va_alist)
char *buf, *fmt;
va_dcl
{ {
#endif #endif
va_list argptr; va_list argptr;
@ -1726,7 +1673,7 @@ va_dcl
default : default :
scanp = ""; scanp = "";
} }
while (*buf++ = *scanp++) while ((*buf++ = *scanp++))
; ;
buf--; buf--;
} }
@ -1741,8 +1688,7 @@ va_dcl
* Output an (unsigned) long in a 10 digit field without leading zeros. * Output an (unsigned) long in a 10 digit field without leading zeros.
* It returns a pointer to the first digit in the buffer. * It returns a pointer to the first digit in the buffer.
*/ */
char *num_out(number) char *num_out(long number)
long number;
{ {
static char num_buf[11]; /* Buffer to build number */ static char num_buf[11]; /* Buffer to build number */
register long digit; /* Next digit of number */ register long digit; /* Next digit of number */
@ -1771,9 +1717,7 @@ long number;
* returned. ERRORS is returned on a bad number. The resulting number is put * returned. ERRORS is returned on a bad number. The resulting number is put
* into the integer the arguments points to. * into the integer the arguments points to.
*/ */
int get_number(message, result) int get_number(char *message, int *result)
char *message;
int *result;
{ {
register int index; register int index;
register int count = 0; register int count = 0;
@ -1806,9 +1750,7 @@ int *result;
* Input() reads a string from the terminal. When the KILL character is typed, * Input() reads a string from the terminal. When the KILL character is typed,
* it returns ERRORS. * it returns ERRORS.
*/ */
int input(inbuf, clearfl) int input(char *inbuf, FLAG clearfl)
char *inbuf;
FLAG clearfl;
{ {
register char *ptr; register char *ptr;
register char c; /* Character read */ register char c; /* Character read */
@ -1867,8 +1809,7 @@ FLAG clearfl;
* Get_file() reads a filename from the terminal. Filenames longer than * Get_file() reads a filename from the terminal. Filenames longer than
* FILE_LENGHT chars are truncated. * FILE_LENGHT chars are truncated.
*/ */
int get_file(message, file) int get_file(char *message, char *file)
char *message, *file;
{ {
char *ptr; char *ptr;
int ret; int ret;
@ -1887,7 +1828,7 @@ char *message, *file;
#ifdef UNIX #ifdef UNIX
#undef putchar #undef putchar
int _getchar() int _getchar(void)
{ {
char c; char c;
@ -1896,18 +1837,17 @@ int _getchar()
return c & 0377; return c & 0377;
} }
void _flush() void _flush(void)
{ {
(void) fflush(stdout); (void) fflush(stdout);
} }
void _putchar(c) void _putchar(char c)
char c;
{ {
(void) write_char(STD_OUT, c); (void) write_char(STD_OUT, c);
} }
void get_term() void get_term(void)
{ {
static char termbuf[50]; static char termbuf[50];
extern char *tgetstr(), *getenv(); extern char *tgetstr(), *getenv();

View file

@ -12,7 +12,7 @@
/* /*
* Move one line up. * Move one line up.
*/ */
void UP() void UP(void)
{ {
if (y == 0) { /* Top line of screen. Scroll one line */ if (y == 0) { /* Top line of screen. Scroll one line */
(void) reverse_scroll(); (void) reverse_scroll();
@ -25,7 +25,7 @@ void UP()
/* /*
* Move one line down. * Move one line down.
*/ */
void DN() void DN(void)
{ {
if (y == last_y) { /* Last line of screen. Scroll one line */ if (y == last_y) { /* Last line of screen. Scroll one line */
if (bot_line->next == tail && bot_line->text[0] != '\n') { if (bot_line->next == tail && bot_line->text[0] != '\n') {
@ -45,7 +45,7 @@ void DN()
/* /*
* Move left one position. * Move left one position.
*/ */
void LF() void LF(void)
{ {
if (x == 0 && get_shift(cur_line->shift_count) == 0) {/* Begin of line */ if (x == 0 && get_shift(cur_line->shift_count) == 0) {/* Begin of line */
if (cur_line->prev != header) { if (cur_line->prev != header) {
@ -60,7 +60,7 @@ void LF()
/* /*
* Move right one position. * Move right one position.
*/ */
void RT() void RT(void)
{ {
if (*cur_text == '\n') { if (*cur_text == '\n') {
if (cur_line->next != tail) { /* Last char of file */ if (cur_line->next != tail) { /* Last char of file */
@ -75,7 +75,7 @@ void RT()
/* /*
* Move to coordinates [0, 0] on screen. * Move to coordinates [0, 0] on screen.
*/ */
void HIGH() void HIGH(void)
{ {
move_to(0, 0); move_to(0, 0);
} }
@ -83,7 +83,7 @@ void HIGH()
/* /*
* Move to coordinates [0, YMAX] on screen. * Move to coordinates [0, YMAX] on screen.
*/ */
void LOW() void LOW(void)
{ {
move_to(0, last_y); move_to(0, last_y);
} }
@ -91,7 +91,7 @@ void LOW()
/* /*
* Move to begin of line. * Move to begin of line.
*/ */
void BL() void BL(void)
{ {
move_to(LINE_START, y); move_to(LINE_START, y);
} }
@ -99,7 +99,7 @@ void BL()
/* /*
* Move to end of line. * Move to end of line.
*/ */
void EL() void EL(void)
{ {
move_to(LINE_END, y); move_to(LINE_END, y);
} }
@ -107,7 +107,7 @@ void EL()
/* /*
* GOTO() prompts for a linenumber and moves to that line. * GOTO() prompts for a linenumber and moves to that line.
*/ */
void GOTO() void GOTO(void)
{ {
int number; int number;
LINE *line; LINE *line;
@ -126,7 +126,7 @@ void GOTO()
* top_line of display.) Try to leave the cursor on the same line. If this is * top_line of display.) Try to leave the cursor on the same line. If this is
* not possible, leave cursor on the line halfway the page. * not possible, leave cursor on the line halfway the page.
*/ */
void PD() void PD(void)
{ {
register int i; register int i;
@ -146,7 +146,7 @@ void PD()
* Try to leave the cursor on the same line. If this is not possible, leave * Try to leave the cursor on the same line. If this is not possible, leave
* cursor on the line halfway the page. * cursor on the line halfway the page.
*/ */
void PU() void PU(void)
{ {
register int i; register int i;
@ -168,7 +168,7 @@ void PU()
/* /*
* Go to top of file, scrolling if possible, else redrawing screen. * Go to top of file, scrolling if possible, else redrawing screen.
*/ */
void HO() void HO(void)
{ {
if (proceed(top_line, -screenmax) == header) if (proceed(top_line, -screenmax) == header)
PU(); /* It fits. Let PU do it */ PU(); /* It fits. Let PU do it */
@ -182,7 +182,7 @@ void HO()
/* /*
* Go to last line of file, scrolling if possible, else redrawing screen * Go to last line of file, scrolling if possible, else redrawing screen
*/ */
void EF() void EF(void)
{ {
if (tail->prev->text[0] != '\n') if (tail->prev->text[0] != '\n')
dummy_line(); dummy_line();
@ -198,7 +198,7 @@ void EF()
/* /*
* Scroll one line up. Leave the cursor on the same line (if possible). * Scroll one line up. Leave the cursor on the same line (if possible).
*/ */
void SU() void SU(void)
{ {
if (top_line->prev == header) /* Top of file. Can't scroll */ if (top_line->prev == header) /* Top of file. Can't scroll */
return; return;
@ -216,7 +216,7 @@ void SU()
/* /*
* Scroll one line down. Leave the cursor on the same line (if possible). * Scroll one line down. Leave the cursor on the same line (if possible).
*/ */
void SD() void SD(void)
{ {
if (forward_scroll() != ERRORS) if (forward_scroll() != ERRORS)
move_to(x, (y == 0) ? 0 : y - 1); move_to(x, (y == 0) ? 0 : y - 1);
@ -228,7 +228,7 @@ void SD()
* Perform a forward scroll. It returns ERRORS if we're at the last line of the * Perform a forward scroll. It returns ERRORS if we're at the last line of the
* file. * file.
*/ */
int forward_scroll() int forward_scroll(void)
{ {
if (bot_line->next == tail) /* Last line of file. No dice */ if (bot_line->next == tail) /* Last line of file. No dice */
return ERRORS; return ERRORS;
@ -245,7 +245,7 @@ int forward_scroll()
* Perform a backwards scroll. It returns ERRORS if we're at the first line * Perform a backwards scroll. It returns ERRORS if we're at the first line
* of the file. * of the file.
*/ */
int reverse_scroll() int reverse_scroll(void)
{ {
if (top_line->prev == header) if (top_line->prev == header)
return ERRORS; /* Top of file. Can't scroll */ return ERRORS; /* Top of file. Can't scroll */
@ -279,13 +279,12 @@ int reverse_scroll()
* MP() moves to the start of the previous word. A word is defined as a * MP() moves to the start of the previous word. A word is defined as a
* number of non-blank characters separated by tabs spaces or linefeeds. * number of non-blank characters separated by tabs spaces or linefeeds.
*/ */
void MP() void MP(void)
{ {
move_previous_word(NO_DELETE); move_previous_word(NO_DELETE);
} }
void move_previous_word(remove) void move_previous_word(FLAG remove)
FLAG remove;
{ {
register char *begin_line; register char *begin_line;
register char *textp; register char *textp;
@ -329,13 +328,12 @@ FLAG remove;
* non-blank characters separated by tabs spaces or linefeeds. Always keep in * non-blank characters separated by tabs spaces or linefeeds. Always keep in
* mind that the pointer shouldn't pass the '\n'. * mind that the pointer shouldn't pass the '\n'.
*/ */
void MN() void MN(void)
{ {
move_next_word(NO_DELETE); move_next_word(NO_DELETE);
} }
void move_next_word(remove) void move_next_word(FLAG remove)
FLAG remove;
{ {
register char *textp = cur_text; register char *textp = cur_text;
@ -373,7 +371,7 @@ FLAG remove;
* If this character is the only character of the line, the current line will * If this character is the only character of the line, the current line will
* be deleted. * be deleted.
*/ */
void DCC() void DCC(void)
{ {
if (*cur_text == '\n') if (*cur_text == '\n')
delete(cur_line,cur_text, cur_line->next,cur_line->next->text); delete(cur_line,cur_text, cur_line->next,cur_line->next->text);
@ -386,7 +384,7 @@ void DCC()
* at the beginning of the line, the last character if the previous line is * at the beginning of the line, the last character if the previous line is
* deleted. * deleted.
*/ */
void DPC() void DPC(void)
{ {
if (x == 0 && cur_line->prev == header) if (x == 0 && cur_line->prev == header)
return; /* Top of file */ return; /* Top of file */
@ -399,7 +397,7 @@ void DPC()
* DLN deletes all characters until the end of the line. If the current * DLN deletes all characters until the end of the line. If the current
* character is a '\n', then delete that char. * character is a '\n', then delete that char.
*/ */
void DLN() void DLN(void)
{ {
if (*cur_text == '\n') if (*cur_text == '\n')
DCC(); DCC();
@ -410,7 +408,7 @@ void DLN()
/* /*
* DNW() deletes the next word (as described in MN()) * DNW() deletes the next word (as described in MN())
*/ */
void DNW() void DNW(void)
{ {
if (*cur_text == '\n') if (*cur_text == '\n')
DCC(); DCC();
@ -421,7 +419,7 @@ void DNW()
/* /*
* DPW() deletes the next word (as described in MP()) * DPW() deletes the next word (as described in MP())
*/ */
void DPW() void DPW(void)
{ {
if (cur_text == cur_line->text) if (cur_text == cur_line->text)
DPC(); DPC();
@ -432,8 +430,7 @@ void DPW()
/* /*
* Insert character `character' at current location. * Insert character `character' at current location.
*/ */
void S(character) void S(int character)
register char character;
{ {
static char buffer[2]; static char buffer[2];
@ -467,7 +464,7 @@ register char character;
* CTL inserts a control-char at the current location. A message that this * CTL inserts a control-char at the current location. A message that this
* function is called is displayed at the status line. * function is called is displayed at the status line.
*/ */
void CTL() void CTL(void)
{ {
register char ctrl; register char ctrl;
@ -484,7 +481,7 @@ void CTL()
* LIB insert a line at the current position and moves back to the end of * LIB insert a line at the current position and moves back to the end of
* the previous line. * the previous line.
*/ */
void LIB() void LIB(void)
{ {
S('\n'); /* Insert the line */ S('\n'); /* Insert the line */
UP(); /* Move one line up */ UP(); /* Move one line up */
@ -495,10 +492,7 @@ void LIB()
* Line_insert() inserts a new line with text pointed to by `string'. * Line_insert() inserts a new line with text pointed to by `string'.
* It returns the address of the new line. * It returns the address of the new line.
*/ */
LINE *line_insert(line, string, len) LINE *line_insert(register LINE *line, char *string, int len)
register LINE *line;
char *string;
int len;
{ {
register LINE *new_line; register LINE *new_line;
@ -520,9 +514,7 @@ int len;
/* /*
* Insert() insert the string `string' at the given line and location. * Insert() insert the string `string' at the given line and location.
*/ */
int insert(line, location, string) int insert(register LINE *line, char *location, char *string)
register LINE *line;
char *location, *string;
{ {
register char *bufp = text_buffer; /* Buffer for building line */ register char *bufp = text_buffer; /* Buffer for building line */
register char *textp = line->text; register char *textp = line->text;
@ -560,8 +552,7 @@ char *location, *string;
* Line_delete() deletes the argument line out of the line list. The pointer to * Line_delete() deletes the argument line out of the line list. The pointer to
* the next line is returned. * the next line is returned.
*/ */
LINE *line_delete(line) LINE *line_delete(register LINE *line)
register LINE *line;
{ {
register LINE *next_line = line->next; register LINE *next_line = line->next;
@ -584,10 +575,8 @@ register LINE *line;
* startposition and endposition and fixes the screen accordingly. It * startposition and endposition and fixes the screen accordingly. It
* returns the number of lines deleted. * returns the number of lines deleted.
*/ */
void delete(start_line, start_textp, end_line, end_textp) void delete(register LINE *start_line, char *start_textp, LINE *end_line,
register LINE *start_line; char *end_textp)
LINE *end_line;
char *start_textp, *end_textp;
{ {
register char *textp = start_line->text; register char *textp = start_line->text;
register char *bufp = text_buffer; /* Storage for new line->text */ register char *bufp = text_buffer; /* Storage for new line->text */
@ -676,7 +665,7 @@ int lines_saved; /* Nr of lines in buffer */
/* /*
* PT() inserts the buffer at the current location. * PT() inserts the buffer at the current location.
*/ */
void PT() void PT(void)
{ {
register int fd; /* File descriptor for buffer */ register int fd; /* File descriptor for buffer */
@ -692,7 +681,7 @@ void PT()
* IF() prompt for a filename and inserts the file at the current location * IF() prompt for a filename and inserts the file at the current location
* in the file. * in the file.
*/ */
void IF() void IF(void)
{ {
register int fd; /* File descriptor of file */ register int fd; /* File descriptor of file */
char name[LINE_LEN]; /* Buffer for file name */ char name[LINE_LEN]; /* Buffer for file name */
@ -713,9 +702,7 @@ void IF()
* File_insert() inserts a an opened file (as given by filedescriptor fd) * File_insert() inserts a an opened file (as given by filedescriptor fd)
* at the current location. * at the current location.
*/ */
void file_insert(fd, old_pos) void file_insert(int fd, FLAG old_pos)
int fd;
FLAG old_pos;
{ {
char line_buffer[MAX_CHARS]; /* Buffer for next line */ char line_buffer[MAX_CHARS]; /* Buffer for next line */
register LINE *line = cur_line; register LINE *line = cur_line;
@ -772,7 +759,7 @@ FLAG old_pos;
* WB() writes the buffer (yank_file) into another file, which * WB() writes the buffer (yank_file) into another file, which
* is prompted for. * is prompted for.
*/ */
void WB() void WB(void)
{ {
register int new_fd; /* Filedescriptor to copy file */ register int new_fd; /* Filedescriptor to copy file */
int yank_fd; /* Filedescriptor to buffer */ int yank_fd; /* Filedescriptor to buffer */
@ -817,7 +804,7 @@ void WB()
/* /*
* MA sets mark_line (mark_text) to the current line (text pointer). * MA sets mark_line (mark_text) to the current line (text pointer).
*/ */
void MA() void MA(void)
{ {
mark_line = cur_line; mark_line = cur_line;
mark_text = cur_text; mark_text = cur_text;
@ -828,7 +815,7 @@ void MA()
* YA() puts the text between the marked position and the current * YA() puts the text between the marked position and the current
* in the buffer. * in the buffer.
*/ */
void YA() void YA(void)
{ {
set_up(NO_DELETE); set_up(NO_DELETE);
} }
@ -836,7 +823,7 @@ void YA()
/* /*
* DT() is essentially the same as YA(), but in DT() the text is deleted. * DT() is essentially the same as YA(), but in DT() the text is deleted.
*/ */
void DT() void DT(void)
{ {
set_up(DELETE); set_up(DELETE);
} }
@ -846,8 +833,7 @@ void DT()
* if the marked position is still valid. If it is, yank is called with the * if the marked position is still valid. If it is, yank is called with the
* arguments in the right order. * arguments in the right order.
*/ */
void set_up(remove) void set_up(FLAG remove)
FLAG remove; /* DELETE if text should be deleted */
{ {
switch (checkmark()) { switch (checkmark()) {
case NOT_VALID : case NOT_VALID :
@ -874,7 +860,7 @@ FLAG remove; /* DELETE if text should be deleted */
* NOT_VALID is returned when mark_line and/or mark_text are no longer valid. * NOT_VALID is returned when mark_line and/or mark_text are no longer valid.
* Legal() checks if mark_text is valid on the mark_line. * Legal() checks if mark_text is valid on the mark_line.
*/ */
FLAG checkmark() FLAG checkmark(void)
{ {
register LINE *line; register LINE *line;
FLAG cur_seen = FALSE; FLAG cur_seen = FALSE;
@ -907,7 +893,7 @@ FLAG checkmark()
/* /*
* Legal() checks if mark_text is still a valid pointer. * Legal() checks if mark_text is still a valid pointer.
*/ */
int legal() int legal(void)
{ {
register char *textp = mark_line->text; register char *textp = mark_line->text;
@ -923,10 +909,8 @@ int legal()
* The caller must check that the arguments to yank() are valid. (E.g. in * The caller must check that the arguments to yank() are valid. (E.g. in
* the right order) * the right order)
*/ */
void yank(start_line, start_textp, end_line, end_textp, remove) void yank(LINE *start_line, char *start_textp, LINE *end_line, char *end_textp,
LINE *start_line, *end_line; FLAG remove)
char *start_textp, *end_textp;
FLAG remove; /* DELETE if text should be deleted */
{ {
register LINE *line = start_line; register LINE *line = start_line;
register char *textp = start_textp; register char *textp = start_textp;
@ -986,8 +970,7 @@ FLAG remove; /* DELETE if text should be deleted */
#define MAXTRAILS 26 #define MAXTRAILS 26
int scratch_file(mode) int scratch_file(FLAG mode)
FLAG mode; /* Can be READ or WRITE permission */
{ {
static int trials = 0; /* Keep track of trails */ static int trials = 0; /* Keep track of trails */
register char *y_ptr, *n_ptr; register char *y_ptr, *n_ptr;
@ -1049,7 +1032,7 @@ char typed_expression[LINE_LEN]; /* Holds previous expr. */
/* /*
* SF searches forward for an expression. * SF searches forward for an expression.
*/ */
void SF() void SF(void)
{ {
search("Search forward:", FORWARD); search("Search forward:", FORWARD);
} }
@ -1057,7 +1040,7 @@ void SF()
/* /*
* SF searches backwards for an expression. * SF searches backwards for an expression.
*/ */
void SR() void SR(void)
{ {
search("Search reverse:", REVERSE); search("Search reverse:", REVERSE);
} }
@ -1069,8 +1052,7 @@ void SR()
* The save flag indicates whether the expression should be appended at the * The save flag indicates whether the expression should be appended at the
* message pointer. * message pointer.
*/ */
REGEX *get_expression(message) REGEX *get_expression(char *message)
char *message;
{ {
static REGEX program; /* Program of expression */ static REGEX program; /* Program of expression */
char exp_buf[LINE_LEN]; /* Buffer for new expr. */ char exp_buf[LINE_LEN]; /* Buffer for new expr. */
@ -1099,7 +1081,7 @@ char *message;
* GR() a replaces all matches from the current position until the end * GR() a replaces all matches from the current position until the end
* of the file. * of the file.
*/ */
void GR() void GR(void)
{ {
change("Global replace:", VALID); change("Global replace:", VALID);
} }
@ -1107,7 +1089,7 @@ void GR()
/* /*
* LR() replaces all matches on the current line. * LR() replaces all matches on the current line.
*/ */
void LR() void LR(void)
{ {
change("Line replace:", NOT_VALID); change("Line replace:", NOT_VALID);
} }
@ -1118,9 +1100,7 @@ void LR()
* for expressions at the current line and continues until the end of the file * for expressions at the current line and continues until the end of the file
* if the FLAG file is VALID. * if the FLAG file is VALID.
*/ */
void change(message, file) void change(char *message, FLAG file)
char *message; /* Message to prompt for expression */
FLAG file;
{ {
char mess_buf[LINE_LEN]; /* Buffer to hold message */ char mess_buf[LINE_LEN]; /* Buffer to hold message */
char replacement[LINE_LEN]; /* Buffer to hold subst. pattern */ char replacement[LINE_LEN]; /* Buffer to hold subst. pattern */
@ -1188,10 +1168,7 @@ FLAG file;
* as indicated by the program. Every '&' in the replacement is replaced by * as indicated by the program. Every '&' in the replacement is replaced by
* the original match. A \ in the replacement escapes the next character. * the original match. A \ in the replacement escapes the next character.
*/ */
char *substitute(line, program, replacement) char *substitute(LINE *line, REGEX *program, char *replacement)
LINE *line;
REGEX *program;
char *replacement; /* Contains replacement pattern */
{ {
register char *textp = text_buffer; register char *textp = text_buffer;
register char *subp = replacement; register char *subp = replacement;
@ -1246,9 +1223,7 @@ char *replacement; /* Contains replacement pattern */
* Find_x() and find_y() display the right page on the screen, and return * Find_x() and find_y() display the right page on the screen, and return
* the right coordinates for x and y. These coordinates are passed to move_to() * the right coordinates for x and y. These coordinates are passed to move_to()
*/ */
void search(message, method) void search(char *message, FLAG method)
char *message;
FLAG method;
{ {
register REGEX *program; register REGEX *program;
register LINE *match_line; register LINE *match_line;
@ -1277,8 +1252,7 @@ FLAG method;
* returns the new y coordinate, else it displays the correct page with the * returns the new y coordinate, else it displays the correct page with the
* matched line in the middle and returns the new y value; * matched line in the middle and returns the new y value;
*/ */
int find_y(match_line) int find_y(LINE *match_line)
LINE *match_line;
{ {
register LINE *line; register LINE *line;
register int count = 0; register int count = 0;
@ -1341,9 +1315,7 @@ char *too_long = "Regular expression too long";
* allocates space for the expression, and copies the expression buffer into * allocates space for the expression, and copies the expression buffer into
* this field. * this field.
*/ */
void finished(program, last_exp) void finished(register REGEX *program, int *last_exp)
register REGEX *program;
int *last_exp;
{ {
register int length = (last_exp - exp_buffer) * sizeof(int); register int length = (last_exp - exp_buffer) * sizeof(int);
@ -1360,9 +1332,7 @@ int *last_exp;
* the union. If all went well the expression is saved and the expression * the union. If all went well the expression is saved and the expression
* pointer is set to the saved (and compiled) expression. * pointer is set to the saved (and compiled) expression.
*/ */
void compile(pattern, program) void compile(register char *pattern, REGEX *program)
register char *pattern; /* Pointer to pattern */
REGEX *program;
{ {
register int *expression = exp_buffer; register int *expression = exp_buffer;
int *prev_char; /* Pointer to previous compiled atom */ int *prev_char; /* Pointer to previous compiled atom */
@ -1501,10 +1471,7 @@ REGEX *program;
* Match() will look through the whole file until a match is found. * Match() will look through the whole file until a match is found.
* NULL is returned if no match could be found. * NULL is returned if no match could be found.
*/ */
LINE *match(program, string, method) LINE *match(REGEX *program, char *string, register FLAG method)
REGEX *program;
char *string;
register FLAG method;
{ {
register LINE *line = cur_line; register LINE *line = cur_line;
char old_char; /* For saving chars */ char old_char; /* For saving chars */
@ -1548,10 +1515,7 @@ register FLAG method;
* indicates FORWARD or REVERSE search. It scans through the whole string * indicates FORWARD or REVERSE search. It scans through the whole string
* until a match is found, or the end of the string is reached. * until a match is found, or the end of the string is reached.
*/ */
int line_check(program, string, method) int line_check(register REGEX *program, char *string, FLAG method)
register REGEX *program;
char *string;
FLAG method;
{ {
register char *textp = string; register char *textp = string;
@ -1596,10 +1560,7 @@ FLAG method;
* (and expression). Check() return MATCH for a match, NO_MATCH is the string * (and expression). Check() return MATCH for a match, NO_MATCH is the string
* couldn't be matched or REG_ERROR for an illegal opcode in expression. * couldn't be matched or REG_ERROR for an illegal opcode in expression.
*/ */
int check_string(program, string, expression) int check_string(REGEX *program, register char *string, int *expression)
REGEX *program;
register char *string;
int *expression;
{ {
register int opcode; /* Holds opcode of next expr. atom */ register int opcode; /* Holds opcode of next expr. atom */
char c; /* Char that must be matched */ char c; /* Char that must be matched */
@ -1614,7 +1575,7 @@ int *expression;
*string != '\0' && *string != '\n') { *string != '\0' && *string != '\n') {
c = *expression & LOW_BYTE; /* Extract match char */ c = *expression & LOW_BYTE; /* Extract match char */
opcode = *expression & HIGH_BYTE; /* Extract opcode */ opcode = *expression & HIGH_BYTE; /* Extract opcode */
if (star_fl = (opcode & STAR)) { /* Check star occurrence */ if ((star_fl = (opcode & STAR))) { /* Check star occurrence */
opcode &= ~STAR; /* Strip opcode */ opcode &= ~STAR; /* Strip opcode */
mark = string; /* Mark current position */ mark = string; /* Mark current position */
} }
@ -1672,11 +1633,8 @@ int *expression;
* It searches backwards until the (in check_string()) marked position * It searches backwards until the (in check_string()) marked position
* is reached, or a match is found. * is reached, or a match is found.
*/ */
int star(program, end_position, string, expression) int star(REGEX *program, register char *end_position, register char *string,
REGEX *program; int *expression)
register char *end_position;
register char *string;
int *expression;
{ {
do { do {
string--; string--;
@ -1692,11 +1650,7 @@ int *expression;
* it returns MATCH. if it isn't it returns NO_MATCH. These returns values * it returns MATCH. if it isn't it returns NO_MATCH. These returns values
* are reversed when the NEGATE field in the opcode is present. * are reversed when the NEGATE field in the opcode is present.
*/ */
int in_list(list, c, list_length, opcode) int in_list(int *list, int c, register int list_length, int opcode)
register int *list;
char c;
register int list_length;
int opcode;
{ {
if (c == '\0' || c == '\n') /* End of string, never matches */ if (c == '\0' || c == '\n') /* End of string, never matches */
return NO_MATCH; return NO_MATCH;
@ -1713,7 +1667,7 @@ int opcode;
* useful in combination with the EF and DN command in combination with the * useful in combination with the EF and DN command in combination with the
* Yank command set. * Yank command set.
*/ */
void dummy_line() void dummy_line(void)
{ {
(void) line_insert(tail->prev, "\n", 1); (void) line_insert(tail->prev, "\n", 1);
tail->prev->shift_count = DUMMY; tail->prev->shift_count = DUMMY;