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:
parent
228e84ad2a
commit
d06d9df7af
2 changed files with 123 additions and 229 deletions
|
@ -425,7 +425,7 @@ int screenmax = SCREENMAX;
|
|||
/*
|
||||
* Print file status.
|
||||
*/
|
||||
void FS()
|
||||
void FS(void)
|
||||
{
|
||||
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
|
||||
* he wants to save it.
|
||||
*/
|
||||
void VI()
|
||||
void VI(void)
|
||||
{
|
||||
char new_file[LINE_LEN]; /* Buffer to hold new file name */
|
||||
|
||||
|
@ -458,7 +458,7 @@ void VI()
|
|||
/*
|
||||
* Write file in core to disc.
|
||||
*/
|
||||
int WT()
|
||||
int WT(void)
|
||||
{
|
||||
register LINE *line;
|
||||
register long count = 0L; /* Nr of chars written */
|
||||
|
@ -516,7 +516,7 @@ int WT()
|
|||
}
|
||||
|
||||
/* Call WT and discard value returned. */
|
||||
void XWT()
|
||||
void XWT(void)
|
||||
{
|
||||
(void) WT();
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ void XWT()
|
|||
/*
|
||||
* Call an interactive shell.
|
||||
*/
|
||||
void SH()
|
||||
void SH(void)
|
||||
{
|
||||
register int w;
|
||||
int pid, status;
|
||||
|
@ -572,9 +572,7 @@ void SH()
|
|||
* 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(register LINE *line, register int count)
|
||||
{
|
||||
if (count < 0)
|
||||
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
|
||||
* 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];
|
||||
|
@ -602,10 +596,10 @@ FLAG statfl;
|
|||
|
||||
*p++ = ' ';
|
||||
if (s1 != NULL)
|
||||
while (*p = *s1++)
|
||||
while ((*p = *s1++))
|
||||
p++;
|
||||
if (s2 != NULL)
|
||||
while (*p = *s2++)
|
||||
while ((*p = *s2++))
|
||||
p++;
|
||||
*p++ = ' ';
|
||||
*p++ = 0;
|
||||
|
@ -651,8 +645,7 @@ FLAG statfl;
|
|||
* 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;
|
||||
|
@ -686,10 +679,7 @@ LINE *line;
|
|||
* 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(register int new_x, char *new_address, int new_y)
|
||||
{
|
||||
register LINE *line = cur_line; /* For building new cur_line */
|
||||
int shift = 0; /* How many shifts to make */
|
||||
|
@ -752,9 +742,7 @@ char *new_address;
|
|||
* 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;
|
||||
|
@ -772,10 +760,7 @@ char *address;
|
|||
* 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;
|
||||
|
@ -800,8 +785,7 @@ int *old_x;
|
|||
* Length_of() returns the number of characters int the string `string'
|
||||
* excluding the '\0'.
|
||||
*/
|
||||
int length_of(string)
|
||||
register char *string;
|
||||
int length_of(register char *string)
|
||||
{
|
||||
register int count = 0;
|
||||
|
||||
|
@ -816,11 +800,9 @@ register char *string;
|
|||
* 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(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 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;
|
||||
|
||||
|
@ -852,8 +832,7 @@ int screen_y;
|
|||
/*
|
||||
* 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();
|
||||
|
@ -870,7 +849,7 @@ int nx, ny;
|
|||
/*
|
||||
* 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");
|
||||
|
@ -880,7 +859,7 @@ void open_device()
|
|||
* 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);
|
||||
|
@ -900,10 +879,7 @@ int getchar()
|
|||
* 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, register LINE *line, register int count)
|
||||
{
|
||||
set_cursor(x_coord, y_coord);
|
||||
|
||||
|
@ -935,9 +911,7 @@ register int count;
|
|||
/*
|
||||
* Write_char does a buffered output.
|
||||
*/
|
||||
int write_char(fd, c)
|
||||
int fd;
|
||||
char c;
|
||||
int write_char(int fd, int c)
|
||||
{
|
||||
screen [out_count++] = c;
|
||||
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.
|
||||
*/
|
||||
int writeline(fd, text)
|
||||
register int fd;
|
||||
register char *text;
|
||||
int writeline(register int fd, register char *text)
|
||||
{
|
||||
while(*text)
|
||||
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
|
||||
* reached.
|
||||
*/
|
||||
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;
|
||||
|
@ -1028,8 +997,7 @@ FLAG clear_line; /* Clear to eoln if TRUE */
|
|||
/*
|
||||
* 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;
|
||||
|
@ -1051,8 +1019,7 @@ int fd;
|
|||
/*
|
||||
* 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);
|
||||
|
@ -1067,8 +1034,7 @@ int fd;
|
|||
/*
|
||||
* Catch the SIGQUIT signal (^\) send to mined. It turns on the quitflag.
|
||||
*/
|
||||
void catch(sig)
|
||||
int sig;
|
||||
void catch(int sig)
|
||||
{
|
||||
/* Reset the signal */
|
||||
signal(SIGQUIT, catch);
|
||||
|
@ -1078,7 +1044,7 @@ int sig;
|
|||
/*
|
||||
* Abort_mined() will leave mined. Confirmation is asked first.
|
||||
*/
|
||||
void abort_mined()
|
||||
void abort_mined(void)
|
||||
{
|
||||
quit = FALSE;
|
||||
|
||||
|
@ -1107,8 +1073,7 @@ void abort_mined()
|
|||
* 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;
|
||||
|
@ -1140,8 +1105,7 @@ FLAG state;
|
|||
* 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(register char *message)
|
||||
{
|
||||
extern char yank_file[];
|
||||
|
||||
|
@ -1166,8 +1130,7 @@ register char *message;
|
|||
#endif /* UNIX */
|
||||
}
|
||||
|
||||
char *alloc(bytes)
|
||||
int bytes;
|
||||
char *alloc(int bytes)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
@ -1180,8 +1143,7 @@ int bytes;
|
|||
return(p);
|
||||
}
|
||||
|
||||
void free_space(p)
|
||||
char *p;
|
||||
void free_space(char *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
|
||||
* space and sets modified back to FALSE and fixes the header/tail pointer.
|
||||
*/
|
||||
void initialize()
|
||||
void initialize(void)
|
||||
{
|
||||
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.
|
||||
*/
|
||||
char *basename(path)
|
||||
char *path;
|
||||
char *basename(char *path)
|
||||
{
|
||||
register char *ptr = path;
|
||||
register char *last = NULL;
|
||||
|
@ -1302,8 +1263,7 @@ char *path;
|
|||
* 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;
|
||||
|
@ -1366,9 +1326,7 @@ char *file;
|
|||
* 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, register char *buffer)
|
||||
{
|
||||
static char *last = 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
|
||||
* 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));
|
||||
|
||||
|
@ -1421,9 +1377,7 @@ int length;
|
|||
return new_line;
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* mined is the Minix editor. */
|
||||
|
||||
|
@ -1490,7 +1444,7 @@ char *argv[];
|
|||
/*
|
||||
* Redraw the screen
|
||||
*/
|
||||
void RD()
|
||||
void RD(void)
|
||||
{
|
||||
/* Clear screen */
|
||||
#ifdef UNIX
|
||||
|
@ -1516,14 +1470,14 @@ void RD()
|
|||
/*
|
||||
* Ignore this keystroke.
|
||||
*/
|
||||
void I()
|
||||
void I(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
return;
|
||||
|
@ -1536,8 +1490,7 @@ void XT()
|
|||
exit(0);
|
||||
}
|
||||
|
||||
void (*escfunc(c))()
|
||||
int c;
|
||||
void (*escfunc(int c))(void)
|
||||
{
|
||||
if (c == '[') {
|
||||
/* Start of ASCII escape sequence. */
|
||||
|
@ -1568,7 +1521,7 @@ int c;
|
|||
* command count times. If a ^\ is given during repeating, stop looping and
|
||||
* return to main loop.
|
||||
*/
|
||||
void ESC()
|
||||
void ESC(void)
|
||||
{
|
||||
register int count = 0;
|
||||
register void (*func)();
|
||||
|
@ -1608,7 +1561,7 @@ void ESC()
|
|||
/*
|
||||
* Ask the user if he wants to save his file or not.
|
||||
*/
|
||||
int ask_save()
|
||||
int ask_save(void)
|
||||
{
|
||||
register int c;
|
||||
|
||||
|
@ -1635,7 +1588,7 @@ int ask_save()
|
|||
/*
|
||||
* 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;
|
||||
|
@ -1652,12 +1605,8 @@ int line_number()
|
|||
* Display a line telling how many chars and lines the file contains. Also tell
|
||||
* whether the file is readonly and/or modified.
|
||||
*/
|
||||
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, register long count, char *file, int lines,
|
||||
FLAG writefl, FLAG changed)
|
||||
{
|
||||
register LINE *line;
|
||||
char msg[LINE_LEN + 40];/* Buffer to hold line */
|
||||
|
@ -1696,9 +1645,7 @@ FLAG writefl, changed;
|
|||
void build_string(char *buf, char *fmt, ...)
|
||||
{
|
||||
#else
|
||||
void build_string(buf, fmt, va_alist)
|
||||
char *buf, *fmt;
|
||||
va_dcl
|
||||
void build_string(char *buf, char *fmt, va_dcl va_alist)
|
||||
{
|
||||
#endif
|
||||
va_list argptr;
|
||||
|
@ -1726,7 +1673,7 @@ va_dcl
|
|||
default :
|
||||
scanp = "";
|
||||
}
|
||||
while (*buf++ = *scanp++)
|
||||
while ((*buf++ = *scanp++))
|
||||
;
|
||||
buf--;
|
||||
}
|
||||
|
@ -1741,8 +1688,7 @@ va_dcl
|
|||
* 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 */
|
||||
|
@ -1771,9 +1717,7 @@ long number;
|
|||
* 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;
|
||||
|
@ -1806,9 +1750,7 @@ int *result;
|
|||
* 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 */
|
||||
|
@ -1867,8 +1809,7 @@ FLAG clearfl;
|
|||
* 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;
|
||||
|
@ -1887,7 +1828,7 @@ char *message, *file;
|
|||
#ifdef UNIX
|
||||
#undef putchar
|
||||
|
||||
int _getchar()
|
||||
int _getchar(void)
|
||||
{
|
||||
char c;
|
||||
|
||||
|
@ -1896,18 +1837,17 @@ int _getchar()
|
|||
return c & 0377;
|
||||
}
|
||||
|
||||
void _flush()
|
||||
void _flush(void)
|
||||
{
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
|
||||
void _putchar(c)
|
||||
char c;
|
||||
void _putchar(char c)
|
||||
{
|
||||
(void) write_char(STD_OUT, c);
|
||||
}
|
||||
|
||||
void get_term()
|
||||
void get_term(void)
|
||||
{
|
||||
static char termbuf[50];
|
||||
extern char *tgetstr(), *getenv();
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
/*
|
||||
* Move one line up.
|
||||
*/
|
||||
void UP()
|
||||
void UP(void)
|
||||
{
|
||||
if (y == 0) { /* Top line of screen. Scroll one line */
|
||||
(void) reverse_scroll();
|
||||
|
@ -25,7 +25,7 @@ void UP()
|
|||
/*
|
||||
* Move one line down.
|
||||
*/
|
||||
void DN()
|
||||
void DN(void)
|
||||
{
|
||||
if (y == last_y) { /* Last line of screen. Scroll one line */
|
||||
if (bot_line->next == tail && bot_line->text[0] != '\n') {
|
||||
|
@ -45,7 +45,7 @@ void DN()
|
|||
/*
|
||||
* Move left one position.
|
||||
*/
|
||||
void LF()
|
||||
void LF(void)
|
||||
{
|
||||
if (x == 0 && get_shift(cur_line->shift_count) == 0) {/* Begin of line */
|
||||
if (cur_line->prev != header) {
|
||||
|
@ -60,7 +60,7 @@ void LF()
|
|||
/*
|
||||
* Move right one position.
|
||||
*/
|
||||
void RT()
|
||||
void RT(void)
|
||||
{
|
||||
if (*cur_text == '\n') {
|
||||
if (cur_line->next != tail) { /* Last char of file */
|
||||
|
@ -75,7 +75,7 @@ void RT()
|
|||
/*
|
||||
* Move to coordinates [0, 0] on screen.
|
||||
*/
|
||||
void HIGH()
|
||||
void HIGH(void)
|
||||
{
|
||||
move_to(0, 0);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ void HIGH()
|
|||
/*
|
||||
* Move to coordinates [0, YMAX] on screen.
|
||||
*/
|
||||
void LOW()
|
||||
void LOW(void)
|
||||
{
|
||||
move_to(0, last_y);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ void LOW()
|
|||
/*
|
||||
* Move to begin of line.
|
||||
*/
|
||||
void BL()
|
||||
void BL(void)
|
||||
{
|
||||
move_to(LINE_START, y);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void BL()
|
|||
/*
|
||||
* Move to end of line.
|
||||
*/
|
||||
void EL()
|
||||
void EL(void)
|
||||
{
|
||||
move_to(LINE_END, y);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ void EL()
|
|||
/*
|
||||
* GOTO() prompts for a linenumber and moves to that line.
|
||||
*/
|
||||
void GOTO()
|
||||
void GOTO(void)
|
||||
{
|
||||
int number;
|
||||
LINE *line;
|
||||
|
@ -126,7 +126,7 @@ void GOTO()
|
|||
* 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(void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
|
@ -146,7 +146,7 @@ void PD()
|
|||
* 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(void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
|
@ -168,7 +168,7 @@ void PU()
|
|||
/*
|
||||
* Go to top of file, scrolling if possible, else redrawing screen.
|
||||
*/
|
||||
void HO()
|
||||
void HO(void)
|
||||
{
|
||||
if (proceed(top_line, -screenmax) == header)
|
||||
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
|
||||
*/
|
||||
void EF()
|
||||
void EF(void)
|
||||
{
|
||||
if (tail->prev->text[0] != '\n')
|
||||
dummy_line();
|
||||
|
@ -198,7 +198,7 @@ void EF()
|
|||
/*
|
||||
* 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 */
|
||||
return;
|
||||
|
@ -216,7 +216,7 @@ void SU()
|
|||
/*
|
||||
* Scroll one line down. Leave the cursor on the same line (if possible).
|
||||
*/
|
||||
void SD()
|
||||
void SD(void)
|
||||
{
|
||||
if (forward_scroll() != ERRORS)
|
||||
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
|
||||
* file.
|
||||
*/
|
||||
int forward_scroll()
|
||||
int forward_scroll(void)
|
||||
{
|
||||
if (bot_line->next == tail) /* Last line of file. No dice */
|
||||
return ERRORS;
|
||||
|
@ -245,7 +245,7 @@ int forward_scroll()
|
|||
* 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 */
|
||||
|
@ -279,13 +279,12 @@ int reverse_scroll()
|
|||
* 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(void)
|
||||
{
|
||||
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;
|
||||
|
@ -329,13 +328,12 @@ FLAG remove;
|
|||
* 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(void)
|
||||
{
|
||||
move_next_word(NO_DELETE);
|
||||
}
|
||||
|
||||
void move_next_word(remove)
|
||||
FLAG remove;
|
||||
void move_next_word(FLAG remove)
|
||||
{
|
||||
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
|
||||
* be deleted.
|
||||
*/
|
||||
void DCC()
|
||||
void DCC(void)
|
||||
{
|
||||
if (*cur_text == '\n')
|
||||
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
|
||||
* deleted.
|
||||
*/
|
||||
void DPC()
|
||||
void DPC(void)
|
||||
{
|
||||
if (x == 0 && cur_line->prev == header)
|
||||
return; /* Top of file */
|
||||
|
@ -399,7 +397,7 @@ void DPC()
|
|||
* 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(void)
|
||||
{
|
||||
if (*cur_text == '\n')
|
||||
DCC();
|
||||
|
@ -410,7 +408,7 @@ void DLN()
|
|||
/*
|
||||
* DNW() deletes the next word (as described in MN())
|
||||
*/
|
||||
void DNW()
|
||||
void DNW(void)
|
||||
{
|
||||
if (*cur_text == '\n')
|
||||
DCC();
|
||||
|
@ -421,7 +419,7 @@ void DNW()
|
|||
/*
|
||||
* DPW() deletes the next word (as described in MP())
|
||||
*/
|
||||
void DPW()
|
||||
void DPW(void)
|
||||
{
|
||||
if (cur_text == cur_line->text)
|
||||
DPC();
|
||||
|
@ -432,8 +430,7 @@ void DPW()
|
|||
/*
|
||||
* Insert character `character' at current location.
|
||||
*/
|
||||
void S(character)
|
||||
register char character;
|
||||
void S(int character)
|
||||
{
|
||||
static char buffer[2];
|
||||
|
||||
|
@ -467,7 +464,7 @@ register char character;
|
|||
* 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(void)
|
||||
{
|
||||
register char ctrl;
|
||||
|
||||
|
@ -484,7 +481,7 @@ void CTL()
|
|||
* LIB insert a line at the current position and moves back to the end of
|
||||
* the previous line.
|
||||
*/
|
||||
void LIB()
|
||||
void LIB(void)
|
||||
{
|
||||
S('\n'); /* Insert the line */
|
||||
UP(); /* Move one line up */
|
||||
|
@ -495,10 +492,7 @@ void LIB()
|
|||
* 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(register LINE *line, char *string, int len)
|
||||
{
|
||||
register LINE *new_line;
|
||||
|
||||
|
@ -520,9 +514,7 @@ int len;
|
|||
/*
|
||||
* Insert() insert the string `string' at the given line and location.
|
||||
*/
|
||||
int insert(line, location, string)
|
||||
register LINE *line;
|
||||
char *location, *string;
|
||||
int insert(register LINE *line, char *location, char *string)
|
||||
{
|
||||
register char *bufp = text_buffer; /* Buffer for building line */
|
||||
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
|
||||
* the next line is returned.
|
||||
*/
|
||||
LINE *line_delete(line)
|
||||
register LINE *line;
|
||||
LINE *line_delete(register LINE *line)
|
||||
{
|
||||
register LINE *next_line = line->next;
|
||||
|
||||
|
@ -584,10 +575,8 @@ register LINE *line;
|
|||
* 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(register 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 */
|
||||
|
@ -676,7 +665,7 @@ int lines_saved; /* Nr of lines in buffer */
|
|||
/*
|
||||
* PT() inserts the buffer at the current location.
|
||||
*/
|
||||
void PT()
|
||||
void PT(void)
|
||||
{
|
||||
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
|
||||
* in the file.
|
||||
*/
|
||||
void IF()
|
||||
void IF(void)
|
||||
{
|
||||
register int fd; /* File descriptor of file */
|
||||
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)
|
||||
* 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;
|
||||
|
@ -772,7 +759,7 @@ FLAG old_pos;
|
|||
* WB() writes the buffer (yank_file) into another file, which
|
||||
* is prompted for.
|
||||
*/
|
||||
void WB()
|
||||
void WB(void)
|
||||
{
|
||||
register int new_fd; /* Filedescriptor to copy file */
|
||||
int yank_fd; /* Filedescriptor to buffer */
|
||||
|
@ -817,7 +804,7 @@ void WB()
|
|||
/*
|
||||
* MA sets mark_line (mark_text) to the current line (text pointer).
|
||||
*/
|
||||
void MA()
|
||||
void MA(void)
|
||||
{
|
||||
mark_line = cur_line;
|
||||
mark_text = cur_text;
|
||||
|
@ -828,7 +815,7 @@ void MA()
|
|||
* YA() puts the text between the marked position and the current
|
||||
* in the buffer.
|
||||
*/
|
||||
void YA()
|
||||
void YA(void)
|
||||
{
|
||||
set_up(NO_DELETE);
|
||||
}
|
||||
|
@ -836,7 +823,7 @@ void YA()
|
|||
/*
|
||||
* DT() is essentially the same as YA(), but in DT() the text is deleted.
|
||||
*/
|
||||
void DT()
|
||||
void DT(void)
|
||||
{
|
||||
set_up(DELETE);
|
||||
}
|
||||
|
@ -846,8 +833,7 @@ void DT()
|
|||
* if the marked position is still valid. If it is, yank is called with the
|
||||
* arguments in the right order.
|
||||
*/
|
||||
void set_up(remove)
|
||||
FLAG remove; /* DELETE if text should be deleted */
|
||||
void set_up(FLAG remove)
|
||||
{
|
||||
switch (checkmark()) {
|
||||
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.
|
||||
* Legal() checks if mark_text is valid on the mark_line.
|
||||
*/
|
||||
FLAG checkmark()
|
||||
FLAG checkmark(void)
|
||||
{
|
||||
register LINE *line;
|
||||
FLAG cur_seen = FALSE;
|
||||
|
@ -907,7 +893,7 @@ FLAG checkmark()
|
|||
/*
|
||||
* Legal() checks if mark_text is still a valid pointer.
|
||||
*/
|
||||
int legal()
|
||||
int legal(void)
|
||||
{
|
||||
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 right order)
|
||||
*/
|
||||
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;
|
||||
|
@ -986,8 +970,7 @@ FLAG remove; /* DELETE if text should be deleted */
|
|||
|
||||
#define MAXTRAILS 26
|
||||
|
||||
int scratch_file(mode)
|
||||
FLAG 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;
|
||||
|
@ -1049,7 +1032,7 @@ char typed_expression[LINE_LEN]; /* Holds previous expr. */
|
|||
/*
|
||||
* SF searches forward for an expression.
|
||||
*/
|
||||
void SF()
|
||||
void SF(void)
|
||||
{
|
||||
search("Search forward:", FORWARD);
|
||||
}
|
||||
|
@ -1057,7 +1040,7 @@ void SF()
|
|||
/*
|
||||
* SF searches backwards for an expression.
|
||||
*/
|
||||
void SR()
|
||||
void SR(void)
|
||||
{
|
||||
search("Search reverse:", REVERSE);
|
||||
}
|
||||
|
@ -1069,8 +1052,7 @@ void SR()
|
|||
* 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. */
|
||||
|
@ -1099,7 +1081,7 @@ char *message;
|
|||
* GR() a replaces all matches from the current position until the end
|
||||
* of the file.
|
||||
*/
|
||||
void GR()
|
||||
void GR(void)
|
||||
{
|
||||
change("Global replace:", VALID);
|
||||
}
|
||||
|
@ -1107,7 +1089,7 @@ void GR()
|
|||
/*
|
||||
* LR() replaces all matches on the current line.
|
||||
*/
|
||||
void LR()
|
||||
void LR(void)
|
||||
{
|
||||
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
|
||||
* if the FLAG file is VALID.
|
||||
*/
|
||||
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 */
|
||||
|
@ -1188,10 +1168,7 @@ FLAG file;
|
|||
* as indicated by the program. Every '&' in the replacement is replaced by
|
||||
* the original match. A \ in the replacement escapes the next character.
|
||||
*/
|
||||
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;
|
||||
|
@ -1246,9 +1223,7 @@ char *replacement; /* Contains replacement pattern */
|
|||
* 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;
|
||||
|
@ -1277,8 +1252,7 @@ FLAG method;
|
|||
* 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;
|
||||
|
@ -1341,9 +1315,7 @@ char *too_long = "Regular expression too long";
|
|||
* 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(register REGEX *program, int *last_exp)
|
||||
{
|
||||
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
|
||||
* pointer is set to the saved (and compiled) expression.
|
||||
*/
|
||||
void compile(pattern, program)
|
||||
register char *pattern; /* Pointer to pattern */
|
||||
REGEX *program;
|
||||
void compile(register char *pattern, REGEX *program)
|
||||
{
|
||||
register int *expression = exp_buffer;
|
||||
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.
|
||||
* NULL 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, register FLAG method)
|
||||
{
|
||||
register LINE *line = cur_line;
|
||||
char old_char; /* For saving chars */
|
||||
|
@ -1548,10 +1515,7 @@ register FLAG method;
|
|||
* 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(register REGEX *program, char *string, FLAG method)
|
||||
{
|
||||
register char *textp = string;
|
||||
|
||||
|
@ -1596,10 +1560,7 @@ FLAG method;
|
|||
* (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, register char *string, int *expression)
|
||||
{
|
||||
register int opcode; /* Holds opcode of next expr. atom */
|
||||
char c; /* Char that must be matched */
|
||||
|
@ -1614,7 +1575,7 @@ int *expression;
|
|||
*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))) { /* Check star occurrence */
|
||||
opcode &= ~STAR; /* Strip opcode */
|
||||
mark = string; /* Mark current position */
|
||||
}
|
||||
|
@ -1672,11 +1633,8 @@ int *expression;
|
|||
* 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, register char *end_position, register char *string,
|
||||
int *expression)
|
||||
{
|
||||
do {
|
||||
string--;
|
||||
|
@ -1692,11 +1650,7 @@ int *expression;
|
|||
* 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, int c, register int list_length, int opcode)
|
||||
{
|
||||
if (c == '\0' || c == '\n') /* End of string, never matches */
|
||||
return NO_MATCH;
|
||||
|
@ -1713,7 +1667,7 @@ int opcode;
|
|||
* 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);
|
||||
tail->prev->shift_count = DUMMY;
|
||||
|
|
Loading…
Reference in a new issue