bin/mined cleanup stage1

Sepherosa Ziehau sepherosa at gmail.com
Tue Apr 26 05:33:01 PDT 2005


1) remove register keyword
2) remove (void) before function call
3) ANSIfy
4) initialize stack variable properly
5) WARNS 3

please review it

-- 
Live Free or Die
Index: Makefile
===================================================================
RCS file: /opt/df_cvs/src/bin/mined/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- Makefile	15 Mar 2005 01:56:24 -0000	1.1
+++ Makefile	26 Apr 2005 12:19:16 -0000
@@ -3,6 +3,6 @@
 
 PROG=	mined
 SRCS=	mined1.c mined2.c
-WARNS=0
+WARNS=	3
 
 .include <bsd.prog.mk>
Index: mined.h
===================================================================
RCS file: /opt/df_cvs/src/bin/mined/mined.h,v
retrieving revision 1.4
diff -u -r1.4 mined.h
--- mined.h	15 Mar 2005 02:32:57 -0000	1.4
+++ mined.h	26 Apr 2005 12:19:16 -0000
@@ -285,11 +285,11 @@
 
 /* mined1.c */
 
-_PROTOTYPE(void FS, (void));
-_PROTOTYPE(void VI, (void));
+_PROTOTYPE(void FS, (int));
+_PROTOTYPE(void VI, (int));
 _PROTOTYPE(int WT, (void));
-_PROTOTYPE(void XWT, (void));
-_PROTOTYPE(void SH, (void));
+_PROTOTYPE(void XWT, (int));
+_PROTOTYPE(void SH, (int));
 _PROTOTYPE(LINE *proceed, (LINE *line, int count ));
 _PROTOTYPE(int bottom_line, (FLAG revfl, char *s1, char *s2, char *inbuf, FLAG statfl ));
 _PROTOTYPE(int count_chars, (LINE *line ));
@@ -303,7 +303,7 @@
 _PROTOTYPE(void open_device, (void));
 _PROTOTYPE(int getchar, (void));
 _PROTOTYPE(void display, (int x_coord, int y_coord, LINE *line, int count ));
-_PROTOTYPE(int write_char, (int fd, int c ));
+_PROTOTYPE(int write_char, (int fd, char c ));
 _PROTOTYPE(int writeline, (int fd, char *text ));
 _PROTOTYPE(void put_line, (LINE *line, int offset, FLAG clear_line ));
 _PROTOTYPE(int flush_buffer, (int fd ));
@@ -327,10 +327,10 @@
 _PROTOTYPE(int get_line, (int fd, char *buffer ));
 _PROTOTYPE(LINE *install_line, (char *buffer, int length ));
 _PROTOTYPE(int main, (int argc, char *argv []));
-_PROTOTYPE(void RD, (void));
-_PROTOTYPE(void I, (void));
-_PROTOTYPE(void XT, (void));
-_PROTOTYPE(void ESC, (void));
+_PROTOTYPE(void RD, (int));
+_PROTOTYPE(void I, (int));
+_PROTOTYPE(void XT, (int));
+_PROTOTYPE(void ESC, (int));
 _PROTOTYPE(int ask_save, (void));
 _PROTOTYPE(int line_number, (void));
 _PROTOTYPE(void file_status, (char *message, long count, char *file, int lines,
@@ -351,58 +351,58 @@
 
 /* mined2.c */
 
-_PROTOTYPE(void UP, (void));
-_PROTOTYPE(void DN, (void));
-_PROTOTYPE(void LF, (void));
-_PROTOTYPE(void RT, (void));
-_PROTOTYPE(void HIGH, (void));
-_PROTOTYPE(void LOW, (void));
-_PROTOTYPE(void BL, (void));
-_PROTOTYPE(void EL, (void));
-_PROTOTYPE(void GOTO, (void));
-_PROTOTYPE(void HLP, (void));
-_PROTOTYPE(void ST, (void));
-_PROTOTYPE(void PD, (void));
-_PROTOTYPE(void PU, (void));
-_PROTOTYPE(void HO, (void));
-_PROTOTYPE(void EF, (void));
-_PROTOTYPE(void SU, (void));
-_PROTOTYPE(void SD, (void));
+_PROTOTYPE(void UP, (int));
+_PROTOTYPE(void DN, (int));
+_PROTOTYPE(void LF, (int));
+_PROTOTYPE(void RT, (int));
+_PROTOTYPE(void HIGH, (int));
+_PROTOTYPE(void LOW, (int));
+_PROTOTYPE(void BL, (int));
+_PROTOTYPE(void EL, (int));
+_PROTOTYPE(void GOTO, (int));
+_PROTOTYPE(void HLP, (int));
+_PROTOTYPE(void ST, (int));
+_PROTOTYPE(void PD, (int));
+_PROTOTYPE(void PU, (int));
+_PROTOTYPE(void HO, (int));
+_PROTOTYPE(void EF, (int));
+_PROTOTYPE(void SU, (int));
+_PROTOTYPE(void SD, (int));
 _PROTOTYPE(int forward_scroll, (void));
 _PROTOTYPE(int reverse_scroll, (void));
-_PROTOTYPE(void MP, (void));
+_PROTOTYPE(void MP, (int));
 _PROTOTYPE(void move_previous_word, (FLAG remove ));
-_PROTOTYPE(void MN, (void));
+_PROTOTYPE(void MN, (int));
 _PROTOTYPE(void move_next_word, (FLAG remove ));
-_PROTOTYPE(void DCC, (void));
-_PROTOTYPE(void DPC, (void));
-_PROTOTYPE(void DLN, (void));
-_PROTOTYPE(void DNW, (void));
-_PROTOTYPE(void DPW, (void));
+_PROTOTYPE(void DCC, (int));
+_PROTOTYPE(void DPC, (int));
+_PROTOTYPE(void DLN, (int));
+_PROTOTYPE(void DNW, (int));
+_PROTOTYPE(void DPW, (int));
 _PROTOTYPE(void S, (int character ));
-_PROTOTYPE(void CTL, (void));
-_PROTOTYPE(void LIB, (void));
+_PROTOTYPE(void CTL, (int));
+_PROTOTYPE(void LIB, (int));
 _PROTOTYPE(LINE *line_insert, (LINE *line, char *string, int len ));
 _PROTOTYPE(int insert, (LINE *line, char *location, char *string ));
 _PROTOTYPE(LINE *line_delete, (LINE *line ));
 _PROTOTYPE(void delete, (LINE *start_line, char *start_textp, LINE *end_line, char *end_textp ));
-_PROTOTYPE(void PT, (void));
-_PROTOTYPE(void IF, (void));
+_PROTOTYPE(void PT, (int));
+_PROTOTYPE(void IF, (int));
 _PROTOTYPE(void file_insert, (int fd, FLAG old_pos ));
-_PROTOTYPE(void WB, (void));
-_PROTOTYPE(void MA, (void));
-_PROTOTYPE(void YA, (void));
-_PROTOTYPE(void DT, (void));
+_PROTOTYPE(void WB, (int));
+_PROTOTYPE(void MA, (int));
+_PROTOTYPE(void YA, (int));
+_PROTOTYPE(void DT, (int));
 _PROTOTYPE(void set_up, (FLAG remove ));
 _PROTOTYPE(FLAG checkmark, (void));
 _PROTOTYPE(int legal, (void));
 _PROTOTYPE(void yank, (LINE *start_line, char *start_textp, LINE *end_line, char *end_textp, FLAG remove ));
 _PROTOTYPE(int scratch_file, (FLAG mode ));
-_PROTOTYPE(void SF, (void));
-_PROTOTYPE(void SR, (void));
+_PROTOTYPE(void SF, (int));
+_PROTOTYPE(void SR, (int));
 _PROTOTYPE(REGEX *get_expression, (char *message ));
-_PROTOTYPE(void GR, (void));
-_PROTOTYPE(void LR, (void));
+_PROTOTYPE(void GR, (int));
+_PROTOTYPE(void LR, (int));
 _PROTOTYPE(void change, (char *message, FLAG file ));
 _PROTOTYPE(char *substitute, (LINE *line, REGEX *program, char *replacement ));
 _PROTOTYPE(void search, (char *message, FLAG method ));
@@ -413,5 +413,5 @@
 _PROTOTYPE(int line_check, (REGEX *program, char *string, FLAG method ));
 _PROTOTYPE(int check_string, (REGEX *program, char *string, int *expression ));
 _PROTOTYPE(int star, (REGEX *program, char *end_position, char *string, int *expression ));
-_PROTOTYPE(int in_list, (int *list, int c, int list_length, int opcode ));
+_PROTOTYPE(int in_list, (int *list, char c, int list_length, int opcode ));
 _PROTOTYPE(void dummy_line, (void));
Index: mined1.c
===================================================================
RCS file: /opt/df_cvs/src/bin/mined/mined1.c,v
retrieving revision 1.5
diff -u -r1.5 mined1.c
--- mined1.c	17 Mar 2005 21:41:16 -0000	1.5
+++ mined1.c	26 Apr 2005 12:19:16 -0000
@@ -454,13 +454,9 @@
 #include <errno.h>
 #include <sys/wait.h>
 #include <sys/ioctl.h>
-#if __STDC__
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
+#include <stdlib.h>
 
-extern int errno;
 int ymax = YMAX;
 int screenmax = SCREENMAX;
 
@@ -468,7 +464,7 @@
 /*
  * Print file status.
  */
-void FS()
+void FS(int u __unused)
 {
   fstatus(file_name[0] ? "" : "[buffer]", -1L);
 }
@@ -477,7 +473,7 @@
  * Visit (edit) another file. If the file has been modified, ask the user if
  * he wants to save it.
  */
-void VI()
+void VI(int u __unused)
 {
   char new_file[LINE_LEN];	/* Buffer to hold new file name */
 
@@ -501,10 +497,10 @@
 /*
  * Write file in core to disc.
  */
-int WT()
+int WT(void)
 {
-  register LINE *line;
-  register long count = 0L;	/* Nr of chars written */
+  LINE *line;
+  long count = 0L;	/* Nr of chars written */
   char file[LINE_LEN];		/* Buffer for new file name */
   int fd;				/* Filedescriptor of file */
 
@@ -559,9 +555,9 @@
 }
 
 /* Call WT and discard value returned. */
-void XWT()
+void XWT(int u __unused)
 {
-  (void) WT();
+  WT();
 }
 
 
@@ -569,9 +565,9 @@
 /*
  * Call an interactive shell.
  */
-void SH()
+void SH(int u __unused)
 {
-  register int w;
+  int w;
   int pid, status;
   char *shell;
 
@@ -602,7 +598,7 @@
   }
 
   raw_mode(ON);
-  RD();
+  RD(0);
 
   if ((status >> 8) == 127)		/* Child died with 127 */
   	error("Cannot exec ", shell);
@@ -615,9 +611,7 @@
  * it returns the count'th line before `line'. When the next (previous)
  * line is the tail (header) indicating EOF (tof) it stops.
  */
-LINE *proceed(line, count)
-register LINE *line;
-register int count;
+LINE *proceed(LINE *line, int count)
 {
   if (count < 0)
   	while (count++ < 0 && line != header)
@@ -633,22 +627,18 @@
  * If revfl is TRUE, turn on reverse video on both strings. Set stat_visible
  * only if bottom_line is visible.
  */
-int bottom_line(revfl, s1, s2, inbuf, statfl)
-FLAG revfl;
-char *s1, *s2;
-char *inbuf;
-FLAG statfl;
+int bottom_line(FLAG revfl, char *s1, char *s2, char *inbuf, FLAG statfl)
 {
   int ret = FINE;
   char buf[LINE_LEN];
-  register char *p = buf;
+  char *p = buf;
 
   *p++ = ' ';
   if (s1 != NIL_PTR)
-	while (*p = *s1++)
+	while ((*p = *s1++) != NULL)
 		p++;
   if (s2 != NIL_PTR)
-	while (*p = *s2++)
+	while ((*p = *s2++) != NULL)
 		p++;
   *p++ = ' ';
   *p++ = 0;
@@ -694,11 +684,10 @@
  * 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.
  */
-int count_chars(line)
-LINE *line;
+int count_chars(LINE *line)
 {
-  register int cnt = get_shift(line->shift_count) * -SHIFT_SIZE;
-  register char *textp = line->text;
+  int cnt = get_shift(line->shift_count) * -SHIFT_SIZE;
+  char *textp = line->text;
 
 /* Find begin of line on screen */
   while (cnt < 0) {
@@ -729,12 +718,9 @@
  * If we're moving to the same x coordinate, try to move the the x-coordinate
  * used on the other previous call.
  */
-void move(new_x, new_address, new_y)
-register int new_x;
-int new_y;
-char *new_address;
+void move(int new_x, char *new_address, int new_y)
 {
-  register LINE *line = cur_line;	/* For building new cur_line */
+  LINE *line = cur_line;	/* For building new cur_line */
   int shift = 0;			/* How many shifts to make */
   static int rel_x = 0;		/* Remember relative x position */
   int tx = x;
@@ -808,12 +794,10 @@
  * Find_x() returns the x coordinate belonging to address.
  * (Tabs are expanded).
  */
-int find_x(line, address)
-LINE *line;
-char *address;
+int find_x(LINE *line, char *address)
 {
-  register char *textp = line->text;
-  register int nx = get_shift(line->shift_count) * -SHIFT_SIZE;
+  char *textp = line->text;
+  int nx = get_shift(line->shift_count) * -SHIFT_SIZE;
 
   while (textp != address && *textp != '\0') {
   	if (is_tab(*textp++)) 	/* Expand tabs */
@@ -828,13 +812,10 @@
  * Find_address() returns the pointer in the line with offset x_coord.
  * (Tabs are expanded).
  */
-char *find_address(line, x_coord, old_x)
-LINE *line;
-int x_coord;
-int *old_x;
+char *find_address(LINE *line, int x_coord, int *old_x)
 {
-  register char *textp = line->text;
-  register int tx = get_shift(line->shift_count) * -SHIFT_SIZE;
+  char *textp = line->text;
+  int tx = get_shift(line->shift_count) * -SHIFT_SIZE;
 
   while (tx < x_coord && *textp != '\n') {
   	if (is_tab(*textp)) {
@@ -856,10 +837,9 @@
  * Length_of() returns the number of characters int the string `string'
  * excluding the '\0'.
  */
-int length_of(string)
-register char *string;
+int length_of(char *string)
 {
-  register int count = 0;
+  int count = 0;
 
   if (string != NIL_PTR) {
   	while (*string++ != '\0')
@@ -872,11 +852,9 @@
  * Copy_string() copies the string `from' into the string `to'. `To' must be
  * long enough to hold `from'.
  */
-void copy_string(to, from)
-register char *to;
-register char *from;
+void copy_string(char *to, char *from)
 {
-  while (*to++ = *from++)
+  while ((*to++ = *from++) != NULL)
   	;
 }
 
@@ -885,11 +863,9 @@
  * 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)
  */
-void reset(head_line, screen_y)
-LINE *head_line;
-int screen_y;
+void reset(LINE *head_line, int screen_y)
 {
-  register LINE *line;
+  LINE *line;
 
   top_line = line = head_line;
 
@@ -908,12 +884,9 @@
 /*
  * Set cursor at coordinates x, y.
  */
-void set_cursor(nx, ny)
-int nx, ny;
+void set_cursor(int nx, int ny)
 {
 #ifdef UNIX
-  extern char *tgoto();
-
   tputs(tgoto(CM, nx, ny), 0, _putchar);
 #else
   char text_buffer[10];
@@ -926,7 +899,7 @@
 /*
  * 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)
 	panic("Cannot open /dev/tty for read");
@@ -936,7 +909,7 @@
  * Getchar() reads one character from the terminal. The character must be
  * masked with 0377 to avoid sign extension.
  */
-int getchar()
+int getchar(void)
 {
 #ifdef UNIX
   return (_getchar() & 0377);
@@ -956,10 +929,7 @@
  * rest of the screen with blank_line's.
  * When count is negative, a backwards print from `line' will be done.
  */
-void display(x_coord, y_coord, line, count)
-int x_coord, y_coord;
-register LINE *line;
-register int count;
+void display(int x_coord, int y_coord, LINE *line, int count)
 {
   set_cursor(x_coord, y_coord);
 
@@ -992,9 +962,7 @@
 /*
  * Write_char does a buffered output. 
  */
-int write_char(fd, c)
-int fd;
-char c;
+int write_char(int fd, char c)
 {
   screen [out_count++] = c;
   if (out_count == SCREEN_SIZE)		/* Flush on SCREEN_SIZE chars */
@@ -1005,9 +973,7 @@
 /*
  * Writeline writes the given string on the given filedescriptor.
  */
-int writeline(fd, text)
-register int fd;
-register char *text;
+int writeline(int fd, char *text)
 {
   while(*text)
   	 if (write_char(fd, *text++) == ERRORS)
@@ -1020,14 +986,16 @@
  * printing will start at that x-coordinate. If the FLAG clear_line is TRUE,
  * then (screen) line will be cleared when the end of the line has been
  * reached.
+ *
+ * parameter
+ * line:	Line to print
+ * offset:	Offset to start
+ * clear_line:	Clear to eoln if TRUE
  */
-void put_line(line, offset, clear_line)
-LINE *line;				/* Line to print */
-int offset;				/* Offset to start */
-FLAG clear_line;			/* Clear to eoln if TRUE */
+void put_line(LINE *line, int offset, FLAG clear_line)
 {
-  register char *textp = line->text;
-  register int count = get_shift(line->shift_count) * -SHIFT_SIZE;
+  char *textp = line->text;
+  int count = get_shift(line->shift_count) * -SHIFT_SIZE;
   int tab_count;			/* Used in tab expansion */
 
 /* Skip all chars as indicated by the offset and the shift_count field */
@@ -1085,8 +1053,7 @@
 /*
  * Flush the I/O buffer on filedescriptor fd.
  */
-int flush_buffer(fd)
-int fd;
+int flush_buffer(int fd)
 {
   if (out_count <= 0)		/* There is nothing to flush */
   	return FINE;
@@ -1108,8 +1075,7 @@
 /*
  * Bad_write() is called when a write failed. Notify the user.
  */
-void bad_write(fd)
-int fd;
+void bad_write(int fd)
 {
   if (fd == STD_OUT)		/* Cannot write to terminal? */
   	exit(1);
@@ -1124,8 +1090,7 @@
 /*
  * Catch the SIGQUIT signal (^\) send to mined. It turns on the quitflag.
  */
-void catch(sig)
-int sig;
+void catch(int sig __unused)
 {
 /* Reset the signal */
   signal(SIGQUIT, catch);
@@ -1135,7 +1100,7 @@
 /*
  * Abort_mined() will leave mined. Confirmation is asked first.
  */
-void abort_mined()
+void abort_mined(void)
 {
   quit = FALSE;
 
@@ -1164,8 +1129,7 @@
  * 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.
  */
-void raw_mode(state)
-FLAG state;
+void raw_mode(FLAG state)
 {
   static struct termios old_tty;
   static struct termios new_tty;
@@ -1197,23 +1161,20 @@
  * It writes the message to the terminal, resets the tty and exits.
  * Ask the user if he wants to save his file.
  */
-void panic(message)
-register char *message;
+void panic(char *message)
 {
-  extern char yank_file[];
-
 #ifdef UNIX
   tputs(CL, 0, _putchar);
   build_string(text_buffer, "%s\nError code %d\n", message, errno);
 #else
   build_string(text_buffer, "%s%s\nError code %d\n", enter_string, message, errno);
 #endif /* UNIX */
-  (void) write(STD_OUT, text_buffer, length_of(text_buffer));
+  write(STD_OUT, text_buffer, length_of(text_buffer));
 
   if (loading == FALSE)
-  	XT();			/* Check if file can be saved */
+  	XT(0);			/* Check if file can be saved */
   else
-  	(void) unlink(yank_file);
+  	unlink(yank_file);
   raw_mode(OFF);
 
 #ifdef UNIX
@@ -1223,8 +1184,7 @@
 #endif /* UNIX */
 }
 
-char *alloc(bytes)
-int bytes;
+char *alloc(int bytes)
 {
   char *p;
 
@@ -1237,8 +1197,7 @@
   return(p);
 }
 
-void free_space(p)
-char *p;
+void free_space(char *p)
 {
   free(p);
 }
@@ -1249,7 +1208,7 @@
 
 /* The mapping between input codes and functions. */
 
-void (*key_map[256])() = {       /* map ASCII characters to functions */
+void (*key_map[256])(int) = {       /* map ASCII characters to functions */
    /* 000-017 */ MA, BL, MP, YA, SD, EL, MN, IF, DPC, S, S, DT, RD, S, DNW,LIB,
    /* 020-037 */ DPW, WB, GR, SH, DLN, SU, VI, XWT, XT, PT, ST, ESC, I, GOTO,
 		 HIGH, LOW,
@@ -1314,9 +1273,9 @@
  * 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.
  */
-void initialize()
+void initialize(void)
 {
-  register LINE *line, *next_line;
+  LINE *line, *next_line;
 
 /* Delete the whole list */
   for (line = header->next; line != tail; line = next_line) {
@@ -1334,11 +1293,10 @@
 /*
  * Basename() finds the absolute name of the file out of a given path_name.
  */
-char *basename(path)
-char *path;
+char *basename(char *path)
 {
-  register char *ptr = path;
-  register char *last = NIL_PTR;
+  char *ptr = path;
+  char *last = NIL_PTR;
 
   while (*ptr != '\0') {
   	if (*ptr == '/')
@@ -1359,11 +1317,10 @@
  * couldn't be opened, just some initializations are done, and a line consisting
  * of a `\n' is installed.
  */
-void load_file(file)
-char *file;
+void load_file(char *file)
 {
-  register LINE *line = header;
-  register int len;
+  LINE *line = header;
+  int len;
   long nr_of_chars = 0L;
   int fd = -1;			/* Filedescriptor for file */
 
@@ -1404,10 +1361,10 @@
   	clear_buffer();		/* Clear output buffer */
   	cur_line = header->next;
   	fstatus("Read", nr_of_chars);
-  	(void) close(fd);		/* Close file */
+  	close(fd);		/* Close file */
   }
   else					/* Just install a "\n" */
-  	(void) line_insert(line, "\n", 1);
+  	line_insert(line, "\n", 1);
 
   reset(header->next, 0);		/* Initialize pointers */
 
@@ -1423,14 +1380,12 @@
  * 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.
  */
-int get_line(fd, buffer)
-int fd;
-register char *buffer;
+int get_line(int fd, char *buffer)
 {
   static char *last = NIL_PTR;
   static char *current = NIL_PTR;
   static int read_chars;
-  register char *cur_pos = current;
+  char *cur_pos = current;
   char *begin = buffer;
 
   do {
@@ -1448,13 +1403,14 @@
   if (read_chars <= 0) {
   	if (buffer == begin)
   		return ERRORS;
-  	if (*(buffer - 1) != '\n')
+  	if (*(buffer - 1) != '\n') {
   		if (loading == TRUE) /* Add '\n' to last line of file */
   			*buffer++ = '\n';
   		else {
   			*buffer = '\0';
   			return NO_LINE;
   		}
+	}
   }
 
   *buffer = '\0';
@@ -1465,11 +1421,9 @@
  * Install_line installs the buffer into a LINE structure It returns a pointer
  * to the allocated structure.
  */
-LINE *install_line(buffer, length)
-char *buffer;
-int length;
+LINE *install_line(char *buffer, int length)
 {
-  register LINE *new_line = (LINE *) alloc(sizeof(LINE));
+  LINE *new_line = (LINE *) alloc(sizeof(LINE));
 
   new_line->text = alloc(length + 1);
   new_line->shift_count = 0;
@@ -1479,13 +1433,11 @@
 }
 
 int 
-main(argc, argv)
-int argc;
-char *argv[];
+main(int argc, char *argv[])
 {
 /* mined is the Minix editor. */
 
-  register int index;		/* Index in key table */
+  int index;		/* Index in key table */
   struct winsize winsize;
 
 #ifdef UNIX
@@ -1520,7 +1472,7 @@
   if (argc < 2)
   	load_file(NIL_PTR);
   else {
-  	(void) get_file(NIL_PTR, argv[1]);	/* Truncate filename */
+  	get_file(NIL_PTR, argv[1]);	/* Truncate filename */
   	load_file(argv[1]);
   }
 
@@ -1548,7 +1500,7 @@
 /*
  * Redraw the screen
  */
-void RD()
+void RD(int u __unused)
 {
 /* Clear screen */
 #ifdef UNIX
@@ -1574,14 +1526,14 @@
 /*
  * Ignore this keystroke.
  */
-void I()
+void I(int u __unused)
 {
 }
 
 /*
  * Leave editor. If the file has changed, ask if the user wants to save it.
  */
-void XT()
+void XT(int u __unused)
 {
   if (modified == TRUE && ask_save() == ERRORS)
   	return;
@@ -1590,12 +1542,12 @@
   set_cursor(0, ymax);
   putchar('\n');
   flush();
-  (void) unlink(yank_file);		/* Might not be necessary */
+  unlink(yank_file);		/* Might not be necessary */
   exit(0);
 }
 
-void (*escfunc(c))()
-int c;
+static void
+(*escfunc(int c))(int)
 {
 #if (CHIP == M68000)
 #ifndef COMPAT
@@ -1630,8 +1582,8 @@
 	case '1': 
 	 	  switch (ch) {
 		  case '~': return(SF);
-		  case '7': (void) getchar(); return(MA);
-		  case '8': (void) getchar(); return(CTL);
+		  case '7': getchar(); return(MA);
+		  case '8': getchar(); return(CTL);
                   }
 	case '2': return(SR);
 	case '3': return(PD);
@@ -1710,10 +1662,10 @@
  * command count times. If a ^\ is given during repeating, stop looping and
  * return to main loop.
  */
-void ESC()
+void ESC(int u __unused)
 {
-  register int count = 0;
-  register void (*func)();
+  int count = 0;
+  void (*func)(int);
   int index;
 
   index = getchar();
@@ -1750,9 +1702,9 @@
 /*
  * Ask the user if he wants to save his file or not.
  */
-int ask_save()
+int ask_save(void)
 {
-  register int c;
+  int c;
 
   status_line(file_name[0] ? basename(file_name) : "[buffer]" ,
 					     " has been modified. Save? (y/n)");
@@ -1777,10 +1729,10 @@
 /*
  * Line_number() finds the line number we're on.
  */
-int line_number()
+int line_number(void)
 {
-  register LINE *line = header->next;
-  register int count = 1;
+  LINE *line = header->next;
+  int count = 1;
 
   while (line != cur_line) {
   	count++;
@@ -1793,15 +1745,14 @@
 /*
  * Display a line telling how many chars and lines the file contains. Also tell
  * whether the file is readonly and/or modified.
+ *
+ * parameter
+ * count:	Contains number of characters in file
  */
-void file_status(message, count, file, lines, writefl, changed)
-char *message;
-register long count;		/* Contains number of characters in file */
-char *file;
-int lines;
-FLAG writefl, changed;
+void file_status(char *message, long count, char *file, int lines,
+		 FLAG writefl, FLAG changed)
 {
-  register LINE *line;
+  LINE *line;
   char msg[LINE_LEN + 40];/* Buffer to hold line */
   char yank_msg[LINE_LEN];/* Buffer for msg of yank_file */
 
@@ -1834,23 +1785,12 @@
  * Build_string() prints the arguments as described in fmt, into the buffer.
  * %s indicates an argument string, %d indicated an argument number.
  */
-#if __STDC__
 void build_string(char *buf, char *fmt, ...)
 {
-#else
-void build_string(buf, fmt, va_alist)
-char *buf, *fmt;
-va_dcl
-{
-#endif
   va_list argptr;
   char *scanp;
 
-#if __STDC__
   va_start(argptr, fmt);
-#else
-  va_start(argptr);
-#endif
 
   while (*fmt) {
   	if (*fmt == '%') {
@@ -1868,7 +1808,7 @@
   		default :
   			scanp = "";
   		}
-  		while (*buf++ = *scanp++)
+  		while ((*buf++ = *scanp++) != NULL)
   			;
   		buf--;
   	}
@@ -1883,12 +1823,11 @@
  * Output an (unsigned) long in a 10 digit field without leading zeros.
  * It returns a pointer to the first digit in the buffer.
  */
-char *num_out(number)
-long number;
+char *num_out(long number)
 {
   static char num_buf[11];		/* Buffer to build number */
-  register long digit;			/* Next digit of number */
-  register long pow = 1000000000L;	/* Highest ten power of long */
+  long digit;			/* Next digit of number */
+  long pow = 1000000000L;	/* Highest ten power of long */
   FLAG digit_seen = FALSE;
   int i;
 
@@ -1913,12 +1852,10 @@
  * returned.  ERRORS is returned on a bad number. The resulting number is put
  * into the integer the arguments points to.
  */
-int get_number(message, result)
-char *message;
-int *result;
+int get_number(char *message, int *result)
 {
-  register int index;
-  register int count = 0;
+  int index;
+  int count = 0;
 
   status_line(message, NIL_PTR);
 
@@ -1948,12 +1885,10 @@
  * Input() reads a string from the terminal.  When the KILL character is typed,
  * it returns ERRORS.
  */
-int input(inbuf, clearfl)
-char *inbuf;
-FLAG clearfl;
+int input(char *inbuf, FLAG clearfl)
 {
-  register char *ptr;
-  register char c;			/* Character read */
+  char *ptr;
+  char c;			/* Character read */
 
   ptr = inbuf;
 
@@ -2009,11 +1944,10 @@
  * Get_file() reads a filename from the terminal. Filenames longer than 
  * FILE_LENGHT chars are truncated.
  */
-int get_file(message, file)
-char *message, *file;
+int get_file(char *message, char *file)
 {
   char *ptr;
-  int ret;
+  int ret = FINE;
 
   if (message == NIL_PTR || (ret = get_string(message, file, TRUE)) == FINE) {
   	if (length_of((ptr = basename(file))) > NAME_MAX)
@@ -2029,7 +1963,7 @@
 #ifdef UNIX
 #undef putchar
 
-int _getchar()
+int _getchar(void)
 {
   char c;
 
@@ -2038,21 +1972,19 @@
   return c & 0377;
 }
 
-void _flush()
+void _flush(void)
 {
-  (void) fflush(stdout);
+  fflush(stdout);
 }
 
-void _putchar(c)
-char c;
+void _putchar(char c)
 {
-  (void) write_char(STD_OUT, c);
+  write_char(STD_OUT, c);
 }
 
-void get_term()
+void get_term(void)
 {
   static char termbuf[50];
-  extern char *tgetstr(), *getenv();
   char *loc = termbuf;
   char entry[1024];
 
Index: mined2.c
===================================================================
RCS file: /opt/df_cvs/src/bin/mined/mined2.c,v
retrieving revision 1.3
diff -u -r1.3 mined2.c
--- mined2.c	15 Mar 2005 02:25:25 -0000	1.3
+++ mined2.c	26 Apr 2005 12:19:16 -0000
@@ -50,10 +50,10 @@
 /*
  * Move one line up.
  */
-void UP()
+void UP(int u __unused)
 {
   if (y == 0) {		/* Top line of screen. Scroll one line */
-  	(void) reverse_scroll();
+  	reverse_scroll();
   	move_to(x, y);
   }
   else			/* Move to previous line */
@@ -88,7 +88,7 @@
 /*
  * Help
  */
-void HLP()
+void HLP(int u __unused)
 {
 	char c;
 
@@ -96,31 +96,31 @@
 	string_print(help_string);
 	flush();
 	c=getchar();
-	RD();
+	RD(0);
 	return;
 }
 
-void ST()
+void ST(int u __unused)
 {
 	raw_mode(OFF);
 	kill(getpid(), SIGTSTP);
 	raw_mode(ON);
-	RD();
+	RD(0);
 }
 
 /*
  * Move one line down.
  */
-void DN()
+void DN(int u __unused)
 {
   if (y == last_y) {	/* Last line of screen. Scroll one line */
 	if (bot_line->next == tail && bot_line->text[0] != '\n') {
 		dummy_line();		/* Create new empty line */
-		DN();
+		DN(0);
 		return;
 	}
 	else {
-		(void) forward_scroll();
+		forward_scroll();
 		move_to(x, y);
 	}
   }
@@ -131,11 +131,11 @@
 /*
  * Move left one position.
  */
-void LF()
+void LF(int u __unused)
 {
   if (x == 0 && get_shift(cur_line->shift_count) == 0) {/* Begin of line */
 	if (cur_line->prev != header) {
-		UP();					/* Move one line up */
+		UP(0);					/* Move one line up */
 		move_to(LINE_END, y);
 	}
   }
@@ -146,11 +146,11 @@
 /*
  * Move right one position.
  */
-void RT()
+void RT(int u __unused)
 {
   if (*cur_text == '\n') {
   	if (cur_line->next != tail) {		/* Last char of file */
-		DN();				/* Move one line down */
+		DN(0);				/* Move one line down */
 		move_to(LINE_START, y);
 	}
   }
@@ -161,7 +161,7 @@
 /*
  * Move to coordinates [0, 0] on screen.
  */
-void HIGH()
+void HIGH(int u __unused)
 {
   move_to(0, 0);
 }
@@ -169,7 +169,7 @@
 /*
  * Move to coordinates [0, YMAX] on screen.
  */
-void LOW()
+void LOW(int u __unused)
 {
   move_to(0, last_y);
 }
@@ -177,7 +177,7 @@
 /*
  * Move to begin of line.
  */
-void BL()
+void BL(int u __unused)
 {
   move_to(LINE_START, y);
 }
@@ -185,7 +185,7 @@
 /*
  * Move to end of line.
  */
-void EL()
+void EL(int u __unused)
 {
   move_to(LINE_END, y);
 }
@@ -193,7 +193,7 @@
 /*
  * GOTO() prompts for a linenumber and moves to that line.
  */
-void GOTO()
+void GOTO(int u __unused)
 {
   int number;
   LINE *line;
@@ -212,9 +212,9 @@
  * 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.
  */
-void PD()
+void PD(int u __unused)
 {
-  register int i;
+  int i;
 
   for (i = 0; i < screenmax; i++)
   	if (forward_scroll() == ERRORS)
@@ -232,9 +232,9 @@
  * Try to leave the cursor on the same line. If this is not possible, leave
  * cursor on the line halfway the page.
  */
-void PU()
+void PU(int u __unused)
 {
-  register int i;
+  int i;
 
   for (i = 0; i < screenmax; i++)
   	if (reverse_scroll() == ERRORS)
@@ -254,13 +254,13 @@
 /*
  * Go to top of file, scrolling if possible, else redrawing screen.
  */
-void HO()
+void HO(int u __unused)
 {
   if (proceed(top_line, -screenmax) == header)
-  	PU();			/* It fits. Let PU do it */
+  	PU(0);			/* It fits. Let PU do it */
   else {
   	reset(header->next, 0);/* Reset top_line, etc. */
-  	RD();			/* Display full page */
+  	RD(0);			/* Display full page */
   }
   move_to(LINE_START, 0);
 }
@@ -268,15 +268,15 @@
 /*
  * Go to last line of file, scrolling if possible, else redrawing screen
  */
-void EF()
+void EF(int u __unused)
 {
   if (tail->prev->text[0] != '\n')
 	dummy_line();
   if (proceed(bot_line, screenmax) == tail)
-  	PD();			/* It fits. Let PD do it */
+  	PD(0);			/* It fits. Let PD do it */
   else {
   	reset(proceed(tail->prev, -screenmax), screenmax);
-  	RD();			/* Display full page */
+  	RD(0);			/* Display full page */
   }
   move_to(LINE_START, last_y);
 }
@@ -284,12 +284,12 @@
 /*
  * Scroll one line up. Leave the cursor on the same line (if possible).
  */
-void SU()
+void SU(int u __unused)
 {
   if (top_line->prev == header)	/* Top of file. Can't scroll */
   	return;
 
-  (void) reverse_scroll();
+  reverse_scroll();
   set_cursor(0, ymax);		/* Erase very bottom line */
 #ifdef UNIX
   tputs(CE, 0, _putchar);
@@ -302,7 +302,7 @@
 /*
  * Scroll one line down. Leave the cursor on the same line (if possible).
  */
-void SD()
+void SD(int u __unused)
 {
   if (forward_scroll() != ERRORS) 
   	move_to(x, (y == 0) ? 0 : y - 1);
@@ -314,7 +314,7 @@
  * Perform a forward scroll. It returns ERRORS if we're at the last line of the
  * file.
  */
-int forward_scroll()
+int forward_scroll(void)
 {
   if (bot_line->next == tail)		/* Last line of file. No dice */
   	return ERRORS;
@@ -331,7 +331,7 @@
  * Perform a backwards scroll. It returns ERRORS if we're at the first line
  * of the file.
  */
-int reverse_scroll()
+int reverse_scroll(void)
 {
   if (top_line->prev == header)
   	return ERRORS;		/* Top of file. Can't scroll */
@@ -365,16 +365,15 @@
  * 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.
  */
-void MP()
+void MP(int u __unused)
 {
   move_previous_word(NO_DELETE);
 }
 
-void move_previous_word(remove)
-FLAG remove;
+void move_previous_word(FLAG remove)
 {
-  register char *begin_line;
-  register char *textp;
+  char *begin_line;
+  char *textp;
   char start_char = *cur_text;
   char *start_pos = cur_text;
 
@@ -385,7 +384,7 @@
   	start_char = '\0';
   }
 
-  LF();
+  LF(0);
 
   begin_line = cur_line->text;
   textp = cur_text;
@@ -415,15 +414,14 @@
  * non-blank characters separated by tabs spaces or linefeeds. Always keep in
  * mind that the pointer shouldn't pass the '\n'.
  */
-void MN()
+void MN(int u __unused)
 {
   move_next_word(NO_DELETE);
 }
 
-void move_next_word(remove)
-FLAG remove;
+void move_next_word(FLAG remove)
 {
-  register char *textp = cur_text;
+  char *textp = cur_text;
 
 /* Move to the end of the current word. */
   while (*textp != '\n' && alpha(*textp))
@@ -440,7 +438,7 @@
 
 /* If we're at end of line. move to the first word on the next line. */
   if (*textp == '\n' && cur_line->next != tail) {
-  	DN();
+  	DN(0);
   	move_to(LINE_START, y);
   	textp = cur_text;
   	while (*textp != '\n' && white_space(*textp))
@@ -459,7 +457,7 @@
  * If this character is the only character of the line, the current line will
  * be deleted.
  */
-void DCC()
+void DCC(int u __unused)
 {
   if (*cur_text == '\n')
   	delete(cur_line,cur_text, cur_line->next,cur_line->next->text);
@@ -472,23 +470,23 @@
  * at the beginning of the line, the last character if the previous line is
  * deleted. 
  */
-void DPC()
+void DPC(int u __unused)
 {
   if (x == 0 && cur_line->prev == header)
   	return;			/* Top of file */
   
-  LF();				/* Move one left */
-  DCC();				/* Delete character under cursor */
+  LF(0);				/* Move one left */
+  DCC(0);				/* Delete character under cursor */
 }
 
 /*
  * DLN deletes all characters until the end of the line. If the current
  * character is a '\n', then delete that char.
  */
-void DLN()
+void DLN(int u __unused)
 {
   if (*cur_text == '\n')
-  	DCC();
+  	DCC(0);
   else
   	delete(cur_line, cur_text, cur_line, cur_text + length_of(cur_text) -1);
 }
@@ -496,10 +494,10 @@
 /*
  * DNW() deletes the next word (as described in MN())
  */
-void DNW()
+void DNW(int u __unused)
 {
   if (*cur_text == '\n')
-  	DCC();
+  	DCC(0);
   else
   	move_next_word(DELETE);
 }
@@ -507,10 +505,10 @@
 /*
  * DPW() deletes the next word (as described in MP())
  */
-void DPW()
+void DPW(int u __unused)
 {
   if (cur_text == cur_line->text)
-  	DPC();
+  	DPC(0);
   else
   	move_previous_word(DELETE);
 }
@@ -518,8 +516,7 @@
 /*
  * Insert character `character' at current location.
  */
-void S(character)
-register char character;
+void S(int character)
 {
   static char buffer[2];
 
@@ -533,7 +530,7 @@
   	set_cursor(0, y);
   	if (y == screenmax) {		/* Can't use display */
   		line_print(cur_line);
-  		(void) forward_scroll();
+  		forward_scroll();
   	}
   	else {
   		reset(top_line, y);	/* Reset pointers */
@@ -553,9 +550,9 @@
  * CTL inserts a control-char at the current location. A message that this
  * function is called is displayed at the status line.
  */
-void CTL()
+void CTL(int u __unused)
 {
-  register char ctrl;
+  char ctrl;
 
   status_line("Enter control character.", NIL_PTR);
   if ((ctrl = getchar()) >= '\01' && ctrl <= '\037') {
@@ -570,10 +567,10 @@
  * LIB insert a line at the current position and moves back to the end of
  * the previous line.
  */
-void LIB()
+void LIB(int u __unused)
 {
   S('\n');	  		/* Insert the line */
-  UP();				/* Move one line up */
+  UP(0);			/* Move one line up */
   move_to(LINE_END, y);		/* Move to end of this line */
 }
 
@@ -581,12 +578,9 @@
  * Line_insert() inserts a new line with text pointed to by `string'.
  * It returns the address of the new line.
  */
-LINE *line_insert(line, string, len)
-register LINE *line;
-char *string;
-int len;
+LINE *line_insert(LINE *line, char *string, int len)
 {
-  register LINE *new_line;
+  LINE *new_line;
 
 /* Allocate space for LINE structure and text */
   new_line = install_line(string, len);
@@ -606,12 +600,10 @@
 /*
  * Insert() insert the string `string' at the given line and location.
  */
-int insert(line, location, string)
-register LINE *line;
-char *location, *string;
+int insert(LINE *line, char *location, char *string)
 {
-  register char *bufp = text_buffer;	/* Buffer for building line */
-  register char *textp = line->text;
+  char *bufp = text_buffer;	/* Buffer for building line */
+  char *textp = line->text;
 
   if (length_of(textp) + length_of(string) >= MAX_CHARS) {
   	error("Line too long", NIL_PTR);
@@ -646,10 +638,9 @@
  * Line_delete() deletes the argument line out of the line list. The pointer to
  * the next line is returned.
  */
-LINE *line_delete(line)
-register LINE *line;
+LINE *line_delete(LINE *line)
 {
-  register LINE *next_line = line->next;
+  LINE *next_line = line->next;
 
 /* Delete the line */
   line->prev->next = line->next;
@@ -670,13 +661,11 @@
  * startposition and endposition and fixes the screen accordingly. It
  * returns the number of lines deleted.
  */
-void delete(start_line, start_textp, end_line, end_textp)
-register LINE *start_line;
-LINE *end_line;
-char *start_textp, *end_textp;
+void delete(LINE *start_line, char *start_textp,
+	    LINE *end_line, char *end_textp)
 {
-  register char *textp = start_line->text;
-  register char *bufp = text_buffer;	/* Storage for new line->text */
+  char *textp = start_line->text;
+  char *bufp = text_buffer;	/* Storage for new line->text */
   LINE *line, *stop;
   int line_cnt = 0;			/* Nr of lines deleted */
   int count = 0;
@@ -711,7 +700,7 @@
 /* Check if last line of file should be deleted */
   if (end_textp == NIL_PTR && length_of(start_line->text) == 1 && nlines > 1) {
   	start_line = start_line->prev;
-  	(void) line_delete(start_line->next);
+  	line_delete(start_line->next);
   	line_cnt++;
   }
   else {	/* Install new text */
@@ -762,9 +751,9 @@
 /*
  * PT() inserts the buffer at the current location.
  */
-void PT()
+void PT(int u __unused)
 {
-  register int fd;		/* File descriptor for buffer */
+  int fd;		/* File descriptor for buffer */
 
   if ((fd = scratch_file(READ)) == ERRORS)
   	error("Buffer is empty.", NIL_PTR);
@@ -778,9 +767,9 @@
  * IF() prompt for a filename and inserts the file at the current location 
  * in the file.
  */
-void IF()
+void IF(int u __unused)
 {
-  register int fd;		/* File descriptor of file */
+  int fd;		/* File descriptor of file */
   char name[LINE_LEN];		/* Buffer for file name */
 
 /* Get the file name */
@@ -799,13 +788,11 @@
  * File_insert() inserts a an opened file (as given by filedescriptor fd)
  * at the current location.
  */
-void file_insert(fd, old_pos)
-int fd;
-FLAG old_pos;
+void file_insert(int fd, FLAG old_pos)
 {
   char line_buffer[MAX_CHARS];		/* Buffer for next line */
-  register LINE *line = cur_line;
-  register int line_count = nlines;	/* Nr of lines inserted */
+  LINE *line = cur_line;
+  int line_count = nlines;	/* Nr of lines inserted */
   LINE *page = cur_line;
   int ret = ERRORS;
   
@@ -858,11 +845,11 @@
  * WB() writes the buffer (yank_file) into another file, which
  * is prompted for.
  */
-void WB()
+void WB(int u __unused)
 {
-  register int new_fd;		/* Filedescriptor to copy file */
+  int new_fd;		/* Filedescriptor to copy file */
   int yank_fd;			/* Filedescriptor to buffer */
-  register int cnt;		/* Count check for read/write */
+  int cnt;		/* Count check for read/write */
   int ret = 0;			/* Error check for write */
   char file[LINE_LEN];		/* Output file */
   
@@ -893,8 +880,8 @@
   	}
 
 /* Clean up open files and status_line */
-  (void) close(new_fd);
-  (void) close(yank_fd);
+  close(new_fd);
+  close(yank_fd);
 
   if (ret != ERRORS)			/* Bad write */
   	file_status("Wrote", chars_saved, file, lines_saved, TRUE, FALSE);
@@ -903,7 +890,7 @@
 /*
  * MA sets mark_line (mark_text) to the current line (text pointer). 
  */
-void MA()
+void MA(int u __unused)
 {
   mark_line = cur_line;
   mark_text = cur_text;
@@ -914,7 +901,7 @@
  * YA() puts the text between the marked position and the current
  * in the buffer.
  */
-void YA()
+void YA(int u __unused)
 {
   set_up(NO_DELETE);
 }
@@ -922,7 +909,7 @@
 /*
  * DT() is essentially the same as YA(), but in DT() the text is deleted.
  */
-void DT()
+void DT(int u __unused)
 {
   set_up(DELETE);
 }
@@ -931,9 +918,11 @@
  * Set_up is an interface to the actual yank. It calls checkmark () to check
  * if the marked position is still valid. If it is, yank is called with the
  * arguments in the right order.
+ *
+ * parameter
+ * remove:	DELETE if text should be deleted
  */
-void set_up(remove)
-FLAG remove;				/* DELETE if text should be deleted */
+void set_up(FLAG remove)
 {
   switch (checkmark()) {
   	case NOT_VALID :
@@ -960,9 +949,9 @@
  * 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.
  */
-FLAG checkmark()
+FLAG checkmark(void)
 {
-  register LINE *line;
+  LINE *line;
   FLAG cur_seen = FALSE;
 
 /* Special case: check is mark_line and cur_line are the same. */
@@ -993,9 +982,9 @@
 /*
  * Legal() checks if mark_text is still a valid pointer.
  */
-int legal()
+int legal(void)
 {
-  register char *textp = mark_line->text;
+  char *textp = mark_line->text;
 
 /* Locate mark_text on mark_line */
   while (textp != mark_text && *textp++ != '\0')
@@ -1008,14 +997,15 @@
  * the buffer.
  * The caller must check that the arguments to yank() are valid. (E.g. in
  * the right order)
+ *
+ * parameter
+ * remove:	DELETE if text should be deleted
  */
-void yank(start_line, start_textp, end_line, end_textp, remove)
-LINE *start_line, *end_line;
-char *start_textp, *end_textp;
-FLAG remove;				/* DELETE if text should be deleted */
+void yank(LINE *start_line, char *start_textp, LINE *end_line, char *end_textp,
+	  FLAG remove)
 {
-  register LINE *line = start_line;
-  register char *textp = start_textp;
+  LINE *line = start_line;
+  char *textp = start_textp;
   int fd;
 
 /* Creat file to hold buffer */
@@ -1029,7 +1019,7 @@
 /* Keep writing chars until the end_location is reached. */
   while (textp != end_textp) {
   	if (write_char(fd, *textp) == ERRORS) {
-  		(void) close(fd);
+  		close(fd);
   		return;
   	}
   	if (*textp++ == '\n') {	/* Move to the next line */
@@ -1042,10 +1032,10 @@
 
 /* Flush the I/O buffer and close file */
   if (flush_buffer(fd) == ERRORS) {
-  	(void) close(fd);
+  	close(fd);
   	return;
   }
-  (void) close(fd);
+  close(fd);
   yank_status = VALID;
 
 /*
@@ -1072,12 +1062,15 @@
 
 #define MAXTRAILS	26
 
-int scratch_file(mode)
-FLAG mode;				/* Can be READ or WRITE permission */
+/*
+ * parameter
+ * mode:	Can be READ or WRITE permission
+ */
+int scratch_file(FLAG mode)
 {
   static int trials = 0;		/* Keep track of trails */
-  register char *y_ptr, *n_ptr;
-  int fd;				/* Filedescriptor to buffer */
+  char *y_ptr, *n_ptr;
+  int fd = ERRORS;			/* Filedescriptor to buffer */
 
 /* If yank_status == NOT_VALID, scratch_file is called for the first time */
   if (yank_status == NOT_VALID && mode == WRITE) { /* Create new file */
@@ -1135,7 +1128,7 @@
 /*
  * SF searches forward for an expression.
  */
-void SF()
+void SF(int u __unused)
 {
   search("Search forward:", FORWARD);
 }
@@ -1143,7 +1136,7 @@
 /*
  * SF searches backwards for an expression.
  */
-void SR()
+void SR(int u __unused)
 {
   search("Search reverse:", REVERSE);
 }
@@ -1155,8 +1148,7 @@
  * The save flag indicates whether the expression should be appended at the
  * message pointer.
  */
-REGEX *get_expression(message)
-char *message;
+REGEX *get_expression(char *message)
 {
   static REGEX program;			/* Program of expression */
   char exp_buf[LINE_LEN];			/* Buffer for new expr. */
@@ -1185,7 +1177,7 @@
  * GR() a replaces all matches from the current position until the end
  * of the file.
  */
-void GR()
+void GR(int u __unused)
 {
   change("Global replace:", VALID);
 }
@@ -1193,7 +1185,7 @@
 /*
  * LR() replaces all matches on the current line.
  */
-void LR()
+void LR(int u __unused)
 {
   change("Line replace:", NOT_VALID);
 }
@@ -1203,16 +1195,17 @@
  * all matches of the expression into the substitution. change() start looking
  * for expressions at the current line and continues until the end of the file
  * if the FLAG file is VALID.
+ *
+ * parameter
+ * message:	Message to prompt for expression
  */
-void change(message, file)
-char *message;				/* Message to prompt for expression */
-FLAG file;
+void change(char *message, FLAG file)
 {
   char mess_buf[LINE_LEN];	/* Buffer to hold message */
   char replacement[LINE_LEN];	/* Buffer to hold subst. pattern */
   REGEX *program;			/* Program resulting from compilation */
-  register LINE *line = cur_line;
-  register char *textp;
+  LINE *line = cur_line;
+  char *textp;
   long lines = 0L;		/* Nr of lines on which subs occurred */
   long subs = 0L;			/* Nr of subs made */
   int page = y;			/* Index to check if line is on screen*/
@@ -1273,14 +1266,14 @@
  * Substitute() replaces the match on this line by the substitute pattern
  * as indicated by the program. Every '&' in the replacement is replaced by 
  * the original match. A \ in the replacement escapes the next character.
+ *
+ * parameter
+ * replacement:	Contains replacement pattern
  */
-char *substitute(line, program, replacement)
-LINE *line;
-REGEX *program;
-char *replacement;		/* Contains replacement pattern */
+char *substitute(LINE *line, REGEX *program, char *replacement)
 {
-  register char *textp = text_buffer;
-  register char *subp = replacement;
+  char *textp = text_buffer;
+  char *subp = replacement;
   char *linep = line->text;
   char *amp;
 
@@ -1332,12 +1325,10 @@
  * 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()
  */
-void search(message, method)
-char *message;
-FLAG method;
+void search(char *message, FLAG method)
 {
-  register REGEX *program;
-  register LINE *match_line;
+  REGEX *program;
+  LINE *match_line;
 
 /* Get the expression */
   if ((program = get_expression(message)) == NIL_REG)
@@ -1363,11 +1354,10 @@
  * returns the new y coordinate, else it displays the correct page with the
  * matched line in the middle and returns the new y value;
  */
-int find_y(match_line)
-LINE *match_line;
+int find_y(LINE *match_line)
 {
-  register LINE *line;
-  register int count = 0;
+  LINE *line;
+  int count = 0;
 
 /* Check if match_line is on the same page as currently displayed. */
   for (line = top_line; line != match_line && line != bot_line->next;
@@ -1389,7 +1379,7 @@
 
 /* Reset pointers and redraw the screen */
   reset(line, 0);
-  RD();
+  RD(0);
 
   return count;
 }
@@ -1427,11 +1417,9 @@
  * allocates space for the expression, and copies the expression buffer into
  * this field.
  */
-void finished(program, last_exp)
-register REGEX *program;
-int *last_exp;
+void finished(REGEX *program, int *last_exp)
 {
-  register int length = (last_exp - exp_buffer) * sizeof(int);
+  int length = (last_exp - exp_buffer) * sizeof(int);
 
 /* Allocate space */
   program->result.expression = (int *) alloc(length);
@@ -1445,14 +1433,15 @@
  * is set to REG_ERROR and an error message is set into the err_mess field of
  * the union. If all went well the expression is saved and the expression
  * pointer is set to the saved (and compiled) expression.
+ *
+ * parameter
+ * pattern:	Pointer to pattern
  */
-void compile(pattern, program)
-register char *pattern;			/* Pointer to pattern */
-REGEX *program;
+void compile(char *pattern, REGEX *program)
 {
-  register int *expression = exp_buffer;
+  int *expression = exp_buffer;
   int *prev_char;			/* Pointer to previous compiled atom */
-  int *acct_field;		/* Pointer to last BRACKET start */
+  int *acct_field = NULL;		/* Pointer to last BRACKET start */
   FLAG negate;			/* Negate flag for BRACKET */
   char low_char;			/* Index for chars in BRACKET */
   char c;
@@ -1587,12 +1576,9 @@
  * Match() will look through the whole file until a match is found.
  * NIL_LINE is returned if no match could be found.
  */
-LINE *match(program, string, method)
-REGEX *program;
-char *string;
-register FLAG method;
+LINE *match(REGEX *program, char *string, FLAG method)
 {
-  register LINE *line = cur_line;
+  LINE *line = cur_line;
   char old_char;				/* For saving chars */
 
 /* Corrupted program */
@@ -1634,12 +1620,9 @@
  * indicates FORWARD or REVERSE search. It scans through the whole string
  * until a match is found, or the end of the string is reached.
  */
-int line_check(program, string, method)
-register REGEX *program;
-char *string;
-FLAG method;
+int line_check(REGEX *program, char *string, FLAG method)
 {
-  register char *textp = string;
+  char *textp = string;
 
 /* Assign start_ptr field. We might find a match right away! */
   program->start_ptr = textp;
@@ -1682,14 +1665,11 @@
  * (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.
  */
-int check_string(program, string, expression)
-REGEX *program;
-register char *string;
-int *expression;
+int check_string(REGEX *program, char *string, int *expression)
 {
-  register int opcode;		/* Holds opcode of next expr. atom */
+  int opcode;		/* Holds opcode of next expr. atom */
   char c;				/* Char that must be matched */
-  char *mark;			/* For marking position */
+  char *mark = NULL;		/* For marking position */
   int star_fl;			/* A star has been born */
 
   if (expression == NIL_INT)
@@ -1700,7 +1680,7 @@
 					   *string != '\0' && *string != '\n') {
   	c = *expression & LOW_BYTE;	  /* Extract match char */
   	opcode = *expression & HIGH_BYTE; /* Extract opcode */
-  	if (star_fl = (opcode & STAR)) {  /* Check star occurrence */
+  	if ((star_fl = (opcode & STAR)) != 0) {  /* Check star occurrence */
   		opcode &= ~STAR;	  /* Strip opcode */
   		mark = string;		  /* Mark current position */
   	}
@@ -1758,11 +1738,7 @@
  * It searches backwards until the (in check_string()) marked position
  * is reached, or a match is found.
  */
-int star(program, end_position, string, expression)
-REGEX *program;
-register char *end_position;
-register char *string;
-int *expression;
+int star(REGEX *program, char *end_position, char *string, int *expression)
 {
   do {
   	string--;
@@ -1778,11 +1754,7 @@
  * 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.
  */
-int in_list(list, c, list_length, opcode)
-register int *list;
-char c;
-register int list_length;
-int opcode;
+int in_list(int *list, char c, int list_length, int opcode)
 {
   if (c == '\0' || c == '\n')	/* End of string, never matches */
   	return NO_MATCH;
@@ -1799,9 +1771,9 @@
  * useful in combination with the EF and DN command in combination with the
  * Yank command set.
  */
-void dummy_line()
+void dummy_line(void)
 {
-	(void) line_insert(tail->prev, "\n", 1);
+	line_insert(tail->prev, "\n", 1);
 	tail->prev->shift_count = DUMMY;
 	if (last_y != screenmax) {
 		last_y++;




More information about the Submit mailing list