Apply r316339 to vendor area.

This commit is contained in:
Xin LI 2017-04-25 03:28:38 +00:00
parent 59d1fa4298
commit 1cabeb1f0c
38 changed files with 1083 additions and 1683 deletions

14
brac.c
View File

@ -24,18 +24,14 @@
* "close bracket" are given.
*/
public void
match_brac(obrac, cbrac, forwdir, n)
register int obrac;
register int cbrac;
int forwdir;
int n;
match_brac(int obrac, int cbrac, int forwdir, int n)
{
register int c;
register int nest;
int c;
int nest;
POSITION pos;
int (*chget)();
int (*chget)(void);
extern int ch_forw_get(), ch_back_get();
extern int ch_forw_get(void), ch_back_get(void);
/*
* Seek to the line containing the open bracket.

93
ch.c
View File

@ -144,13 +144,13 @@ static int ch_addbuf();
* Get the character pointed to by the read pointer.
*/
int
ch_get()
ch_get(void)
{
register struct buf *bp;
register struct bufnode *bn;
register int n;
register int slept;
register int h;
struct buf *bp;
struct bufnode *bn;
int n;
int slept;
int h;
POSITION pos;
POSITION len;
@ -378,8 +378,7 @@ ch_get()
* a single char onto an input file descriptor.
*/
public void
ch_ungetchar(c)
int c;
ch_ungetchar(int c)
{
if (c != -1 && ch_ungotchar != -1)
error("ch_ungetchar overrun", NULL_PARG);
@ -392,7 +391,7 @@ ch_ungetchar(c)
* If we haven't read all of standard input into it, do that now.
*/
public void
end_logfile()
end_logfile(void)
{
static int tried = FALSE;
@ -417,10 +416,10 @@ end_logfile()
* Write all the existing buffered data to the log file.
*/
public void
sync_logfile()
sync_logfile(void)
{
register struct buf *bp;
register struct bufnode *bn;
struct buf *bp;
struct bufnode *bn;
int warned = FALSE;
BLOCKNUM block;
BLOCKNUM nblocks;
@ -454,12 +453,11 @@ sync_logfile()
* Determine if a specific block is currently in one of the buffers.
*/
static int
buffered(block)
BLOCKNUM block;
buffered(BLOCKNUM block)
{
register struct buf *bp;
register struct bufnode *bn;
register int h;
struct buf *bp;
struct bufnode *bn;
int h;
h = BUFHASH(block);
FOR_BUFS_IN_CHAIN(h, bn)
@ -476,8 +474,7 @@ buffered(block)
* Return 0 if successful, non-zero if can't seek there.
*/
public int
ch_seek(pos)
register POSITION pos;
ch_seek(POSITION pos)
{
BLOCKNUM new_block;
POSITION len;
@ -515,7 +512,7 @@ ch_seek(pos)
* Seek to the end of the file.
*/
public int
ch_end_seek()
ch_end_seek(void)
{
POSITION len;
@ -542,10 +539,10 @@ ch_end_seek()
* Seek to the last position in the file that is currently buffered.
*/
public int
ch_end_buffer_seek()
ch_end_buffer_seek(void)
{
register struct buf *bp;
register struct bufnode *bn;
struct buf *bp;
struct bufnode *bn;
POSITION buf_pos;
POSITION end_pos;
@ -570,10 +567,10 @@ ch_end_buffer_seek()
* beginning of the pipe is no longer buffered.
*/
public int
ch_beg_seek()
ch_beg_seek(void)
{
register struct bufnode *bn;
register struct bufnode *firstbn;
struct bufnode *bn;
struct bufnode *firstbn;
/*
* Try a plain ch_seek first.
@ -602,7 +599,7 @@ ch_beg_seek()
* Return the length of the file, if known.
*/
public POSITION
ch_length()
ch_length(void)
{
if (thisfile == NULL)
return (NULL_POSITION);
@ -619,7 +616,7 @@ ch_length()
* Return the current position in the file.
*/
public POSITION
ch_tell()
ch_tell(void)
{
if (thisfile == NULL)
return (NULL_POSITION);
@ -630,9 +627,9 @@ ch_tell()
* Get the current char and post-increment the read pointer.
*/
public int
ch_forw_get()
ch_forw_get(void)
{
register int c;
int c;
if (thisfile == NULL)
return (EOI);
@ -653,7 +650,7 @@ ch_forw_get()
* Pre-decrement the read pointer and get the new current char.
*/
public int
ch_back_get()
ch_back_get(void)
{
if (thisfile == NULL)
return (EOI);
@ -676,8 +673,7 @@ ch_back_get()
* bufspace is in units of 1024 bytes. -1 mean no limit.
*/
public void
ch_setbufspace(bufspace)
int bufspace;
ch_setbufspace(int bufspace)
{
if (bufspace < 0)
maxbufs = -1;
@ -693,9 +689,9 @@ ch_setbufspace(bufspace)
* Flush (discard) any saved file state, including buffer contents.
*/
public void
ch_flush()
ch_flush(void)
{
register struct bufnode *bn;
struct bufnode *bn;
if (thisfile == NULL)
return;
@ -760,10 +756,10 @@ ch_flush()
* The buffer is added to the tail of the buffer chain.
*/
static int
ch_addbuf()
ch_addbuf(void)
{
register struct buf *bp;
register struct bufnode *bn;
struct buf *bp;
struct bufnode *bn;
/*
* Allocate and initialize a new buffer and link it
@ -785,9 +781,9 @@ ch_addbuf()
*
*/
static void
init_hashtbl()
init_hashtbl(void)
{
register int h;
int h;
for (h = 0; h < BUFHASH_SIZE; h++)
{
@ -800,9 +796,9 @@ init_hashtbl()
* Delete all buffers for this file.
*/
static void
ch_delbufs()
ch_delbufs(void)
{
register struct bufnode *bn;
struct bufnode *bn;
while (ch_bufhead != END_OF_CHAIN)
{
@ -818,8 +814,7 @@ ch_delbufs()
* Is it possible to seek on a file descriptor?
*/
public int
seekable(f)
int f;
seekable(int f)
{
#if MSDOS_COMPILER
extern int fd0;
@ -840,7 +835,7 @@ seekable(f)
* This is used after an ignore_eof read, during which the EOF may change.
*/
public void
ch_set_eof()
ch_set_eof(void)
{
ch_fsize = ch_fpos;
}
@ -850,9 +845,7 @@ ch_set_eof()
* Initialize file state for a new file.
*/
public void
ch_init(f, flags)
int f;
int flags;
ch_init(int f, int flags)
{
/*
* See if we already have a filestate for this file.
@ -891,7 +884,7 @@ ch_init(f, flags)
* Close a filestate.
*/
public void
ch_close()
ch_close(void)
{
int keepstate = FALSE;
@ -934,7 +927,7 @@ ch_close()
* Return ch_flags for the current file.
*/
public int
ch_getflags()
ch_getflags(void)
{
if (thisfile == NULL)
return (0);

View File

@ -130,12 +130,11 @@ public int binattr = AT_STANDOUT;
* c control character
*/
static void
ichardef(s)
char *s;
ichardef(char *s)
{
register char *cp;
register int n;
register char v;
char *cp;
int n;
char v;
n = 0;
v = 0;
@ -187,12 +186,10 @@ ichardef(s)
* The valid charset names are listed in the "charsets" array.
*/
static int
icharset(name, no_error)
register char *name;
int no_error;
icharset(char *name, int no_error)
{
register struct charset *p;
register struct cs_alias *a;
struct charset *p;
struct cs_alias *a;
if (name == NULL || *name == '\0')
return (0);
@ -230,9 +227,9 @@ icharset(name, no_error)
* Define a charset, given a locale name.
*/
static void
ilocale()
ilocale(void)
{
register int c;
int c;
for (c = 0; c < (int) sizeof(chardef); c++)
{
@ -250,10 +247,7 @@ ilocale()
* Define the printing format for control (or binary utf) chars.
*/
static void
setbinfmt(s, fmtvarptr, default_fmt)
char *s;
char **fmtvarptr;
char *default_fmt;
setbinfmt(char *s, char **fmtvarptr, char *default_fmt)
{
if (s && utf_mode)
{
@ -299,7 +293,7 @@ setbinfmt(s, fmtvarptr, default_fmt)
*
*/
static void
set_charset()
set_charset(void)
{
char *s;
@ -370,7 +364,7 @@ set_charset()
* Initialize charset data structures.
*/
public void
init_charset()
init_charset(void)
{
char *s;
@ -391,8 +385,7 @@ init_charset()
* Is a given character a "binary" character?
*/
public int
binary_char(c)
LWCHAR c;
binary_char(LWCHAR c)
{
if (utf_mode)
return (is_ubin_char(c));
@ -404,8 +397,7 @@ binary_char(c)
* Is a given character a "control" character?
*/
public int
control_char(c)
LWCHAR c;
control_char(LWCHAR c)
{
c &= 0377;
return (chardef[c] & IS_CONTROL_CHAR);
@ -416,8 +408,7 @@ control_char(c)
* For example, in the "ascii" charset '\3' is printed as "^C".
*/
public char *
prchar(c)
LWCHAR c;
prchar(LWCHAR c)
{
/* {{ This buffer can be overrun if LESSBINFMT is a long string. }} */
static char buf[32];
@ -452,8 +443,7 @@ prchar(c)
* Return the printable form of a UTF-8 character.
*/
public char *
prutfchar(ch)
LWCHAR ch;
prutfchar(LWCHAR ch)
{
static char buf[32];
@ -483,8 +473,7 @@ prutfchar(ch)
* Get the length of a UTF-8 character in bytes.
*/
public int
utf_len(ch)
char ch;
utf_len(char ch)
{
if ((ch & 0x80) == 0)
return 1;
@ -506,9 +495,7 @@ utf_len(ch)
* Does the parameter point to the lead byte of a well-formed UTF-8 character?
*/
public int
is_utf8_well_formed(s, slen)
unsigned char *s;
int slen;
is_utf8_well_formed(unsigned char *s, int slen)
{
int i;
int len;
@ -543,9 +530,7 @@ is_utf8_well_formed(s, slen)
* Return number of invalid UTF-8 sequences found in a buffer.
*/
public int
utf_bin_count(data, len)
unsigned char *data;
int len;
utf_bin_count(unsigned char *data, int len)
{
int bin_count = 0;
while (len > 0)
@ -572,8 +557,7 @@ utf_bin_count(data, len)
* Get the value of a UTF-8 character.
*/
public LWCHAR
get_wchar(p)
char *p;
get_wchar(constant char *p)
{
switch (utf_len(p[0]))
{
@ -624,9 +608,7 @@ get_wchar(p)
* Store a character into a UTF-8 string.
*/
public void
put_wchar(pp, ch)
char **pp;
LWCHAR ch;
put_wchar(char **pp, LWCHAR ch)
{
if (!utf_mode || ch < 0x80)
{
@ -674,14 +656,11 @@ put_wchar(pp, ch)
* Step forward or backward one character in a string.
*/
public LWCHAR
step_char(pp, dir, limit)
char **pp;
signed int dir;
char *limit;
step_char(constant char **pp, signed int dir, constant char *limit)
{
LWCHAR ch;
int len;
char *p = *pp;
constant char *p = *pp;
if (!utf_mode)
{
@ -744,9 +723,7 @@ static struct wchar_range comb_table[] = {
static int
is_in_table(ch, table)
LWCHAR ch;
struct wchar_range_table *table;
is_in_table(LWCHAR ch, struct wchar_range_table *table)
{
int hi;
int lo;
@ -774,8 +751,7 @@ is_in_table(ch, table)
* If a composing character follows any char, the two combine into one glyph.
*/
public int
is_composing_char(ch)
LWCHAR ch;
is_composing_char(LWCHAR ch)
{
return is_in_table(ch, &compose_table);
}
@ -784,8 +760,7 @@ is_composing_char(ch)
* Should this UTF-8 character be treated as binary?
*/
public int
is_ubin_char(ch)
LWCHAR ch;
is_ubin_char(LWCHAR ch)
{
return is_in_table(ch, &ubin_table);
}
@ -794,8 +769,7 @@ is_ubin_char(ch)
* Is this a double width UTF-8 character?
*/
public int
is_wide_char(ch)
LWCHAR ch;
is_wide_char(LWCHAR ch)
{
return is_in_table(ch, &wide_table);
}
@ -806,9 +780,7 @@ is_wide_char(ch)
* a specific char (not any char), the two combine into one glyph.
*/
public int
is_combining_char(ch1, ch2)
LWCHAR ch1;
LWCHAR ch2;
is_combining_char(LWCHAR ch1, LWCHAR ch2)
{
/* The table is small; use linear search. */
int i;

153
cmdbuf.c
View File

@ -32,7 +32,7 @@ static int literal; /* Next input char should not be interpreted */
static int updown_match = -1; /* Prefix length in up/down movement */
#if TAB_COMPLETE_FILENAME
static int cmd_complete();
static int cmd_complete(int action);
/*
* These variables are statics used by cmd_complete.
*/
@ -114,7 +114,7 @@ static int cmd_mbc_buf_index;
* Reset command buffer (to empty).
*/
public void
cmd_reset()
cmd_reset(void)
{
cp = cmdbuf;
*cp = '\0';
@ -129,7 +129,7 @@ cmd_reset()
* Clear command line.
*/
public void
clear_cmd()
clear_cmd(void)
{
cmd_col = prompt_col = 0;
cmd_mbc_buf_len = 0;
@ -140,15 +140,14 @@ clear_cmd()
* Display a string, usually as a prompt for input into the command buffer.
*/
public void
cmd_putstr(s)
char *s;
cmd_putstr(constant char *s)
{
LWCHAR prev_ch = 0;
LWCHAR ch;
char *endline = s + strlen(s);
constant char *endline = s + strlen(s);
while (*s != '\0')
{
char *ns = s;
constant char *ns = s;
ch = step_char(&ns, +1, endline);
while (s < ns)
putchr(*s++);
@ -171,10 +170,10 @@ cmd_putstr(s)
* How many characters are in the command buffer?
*/
public int
len_cmdbuf()
len_cmdbuf(void)
{
char *s = cmdbuf;
char *endline = s + strlen(s);
constant char *s = cmdbuf;
constant char *endline = s + strlen(s);
int len = 0;
while (*s != '\0')
@ -189,12 +188,7 @@ len_cmdbuf()
* Common part of cmd_step_right() and cmd_step_left().
*/
static char *
cmd_step_common(p, ch, len, pwidth, bswidth)
char *p;
LWCHAR ch;
int len;
int *pwidth;
int *bswidth;
cmd_step_common(constant char *p, LWCHAR ch, int len, int *pwidth, int *bswidth)
{
char *pr;
@ -256,13 +250,10 @@ cmd_step_common(p, ch, len, pwidth, bswidth)
* Step a pointer one character right in the command buffer.
*/
static char *
cmd_step_right(pp, pwidth, bswidth)
char **pp;
int *pwidth;
int *bswidth;
cmd_step_right(char **pp, int *pwidth, int *bswidth)
{
char *p = *pp;
LWCHAR ch = step_char(pp, +1, p + strlen(p));
LWCHAR ch = step_char((constant char **)pp, +1, p + strlen(p));
return cmd_step_common(p, ch, *pp - p, pwidth, bswidth);
}
@ -271,13 +262,10 @@ cmd_step_right(pp, pwidth, bswidth)
* Step a pointer one character left in the command buffer.
*/
static char *
cmd_step_left(pp, pwidth, bswidth)
char **pp;
int *pwidth;
int *bswidth;
cmd_step_left(char **pp, int *pwidth, int *bswidth)
{
char *p = *pp;
LWCHAR ch = step_char(pp, -1, cmdbuf);
LWCHAR ch = step_char((constant char **)pp, -1, cmdbuf);
return cmd_step_common(*pp, ch, p - *pp, pwidth, bswidth);
}
@ -287,8 +275,7 @@ cmd_step_left(pp, pwidth, bswidth)
* Then position the cursor just after the char old_cp (a pointer into cmdbuf).
*/
static void
cmd_repaint(old_cp)
char *old_cp;
cmd_repaint(char *old_cp)
{
/*
* Repaint the line from the current position.
@ -298,7 +285,7 @@ cmd_repaint(old_cp)
{
char *np = cp;
int width;
char *pr = cmd_step_right(&np, &width, NULL);
constant char *pr = cmd_step_right(&np, &width, NULL);
if (cmd_col + width >= sc_width)
break;
cp = np;
@ -328,7 +315,7 @@ cmd_repaint(old_cp)
* and set cp to the corresponding char in cmdbuf.
*/
static void
cmd_home()
cmd_home(void)
{
while (cmd_col > prompt_col)
{
@ -347,7 +334,7 @@ cmd_home()
* Shift the cmdbuf display left a half-screen.
*/
static void
cmd_lshift()
cmd_lshift(void)
{
char *s;
char *save_cp;
@ -385,7 +372,7 @@ cmd_lshift()
* Shift the cmdbuf display right a half-screen.
*/
static void
cmd_rshift()
cmd_rshift(void)
{
char *s;
char *save_cp;
@ -415,7 +402,7 @@ cmd_rshift()
* Move cursor right one character.
*/
static int
cmd_right()
cmd_right(void)
{
char *pr;
char *ncp;
@ -450,7 +437,7 @@ cmd_right()
* Move cursor left one character.
*/
static int
cmd_left()
cmd_left(void)
{
char *ncp;
int width, bswidth;
@ -480,9 +467,7 @@ cmd_left()
* Insert a char into the command buffer, at the current position.
*/
static int
cmd_ichar(cs, clen)
char *cs;
int clen;
cmd_ichar(char *cs, int clen)
{
char *s;
@ -517,9 +502,9 @@ cmd_ichar(cs, clen)
* Delete the char to the left of the cursor.
*/
static int
cmd_erase()
cmd_erase(void)
{
register char *s;
char *s;
int clen;
if (cp == cmdbuf)
@ -566,7 +551,7 @@ cmd_erase()
* Delete the char under the cursor.
*/
static int
cmd_delete()
cmd_delete(void)
{
if (*cp == '\0')
{
@ -585,7 +570,7 @@ cmd_delete()
* Delete the "word" to the left of the cursor.
*/
static int
cmd_werase()
cmd_werase(void)
{
if (cp > cmdbuf && cp[-1] == ' ')
{
@ -611,7 +596,7 @@ cmd_werase()
* Delete the "word" under the cursor.
*/
static int
cmd_wdelete()
cmd_wdelete(void)
{
if (*cp == ' ')
{
@ -637,7 +622,7 @@ cmd_wdelete()
* Delete all chars in the command buffer.
*/
static int
cmd_kill()
cmd_kill(void)
{
if (cmdbuf[0] == '\0')
{
@ -663,9 +648,7 @@ cmd_kill()
* Select an mlist structure to be the current command history.
*/
public void
set_mlist(mlist, cmdflags)
void *mlist;
int cmdflags;
set_mlist(constant void *mlist, int cmdflags)
{
#if CMD_HISTORY
curr_mlist = (struct mlist *) mlist;
@ -684,8 +667,7 @@ set_mlist(mlist, cmdflags)
* cmdbuf's corresponding chars.
*/
static int
cmd_updown(action)
int action;
cmd_updown(int action)
{
char *s;
struct mlist *ml;
@ -747,10 +729,7 @@ cmd_updown(action)
* Add a string to an mlist.
*/
public void
cmd_addhist(mlist, cmd, modified)
struct mlist *mlist;
char *cmd;
int modified;
cmd_addhist(struct mlist *constant mlist, char *cmd, int modified)
{
#if CMD_HISTORY
struct mlist *ml;
@ -793,7 +772,7 @@ cmd_addhist(mlist, cmd, modified)
* Add it to the currently selected history list.
*/
public void
cmd_accept()
cmd_accept(void)
{
#if CMD_HISTORY
/*
@ -815,8 +794,7 @@ cmd_accept()
* CC_QUIT The char requests the current command to be aborted.
*/
static int
cmd_edit(c)
int c;
cmd_edit(int c)
{
int action;
int flags;
@ -931,8 +909,7 @@ cmd_edit(c)
* Insert a string into the command buffer, at the current position.
*/
static int
cmd_istr(str)
char *str;
cmd_istr(char *str)
{
char *s;
int action;
@ -941,7 +918,7 @@ cmd_istr(str)
for (s = str; *s != '\0'; )
{
char *os = s;
step_char(&s, +1, endline);
step_char((constant char **)&s, +1, endline);
action = cmd_ichar(os, s - os);
if (action != CC_OK)
{
@ -959,7 +936,7 @@ cmd_istr(str)
* cursor at the end of the word.
*/
static char *
delimit_word()
delimit_word(void)
{
char *word;
#if SPACES_IN_FILENAMES
@ -1046,7 +1023,7 @@ delimit_word()
* which start with that word, and set tk_text to that list.
*/
static void
init_compl()
init_compl(void)
{
char *word;
char c;
@ -1109,9 +1086,7 @@ init_compl()
* Return the next word in the current completion list.
*/
static char *
next_compl(action, prev)
int action;
char *prev;
next_compl(int action, char *prev)
{
switch (action)
{
@ -1131,8 +1106,7 @@ next_compl(action, prev)
* or a subsequent time (step thru the list).
*/
static int
cmd_complete(action)
int action;
cmd_complete(int action)
{
char *s;
@ -1229,8 +1203,7 @@ fail:
* CC_ERROR The char could not be accepted due to an error.
*/
public int
cmd_char(c)
int c;
cmd_char(int c)
{
int action;
int len;
@ -1319,8 +1292,7 @@ cmd_char(c)
* Return the number currently in the command buffer.
*/
public LINENUM
cmd_int(frac)
long *frac;
cmd_int(long *frac)
{
char *p;
LINENUM n = 0;
@ -1341,7 +1313,7 @@ cmd_int(frac)
* Return a pointer to the command buffer.
*/
public char *
get_cmdbuf()
get_cmdbuf(void)
{
return (cmdbuf);
}
@ -1351,7 +1323,7 @@ get_cmdbuf()
* Return the last (most recent) string in the current command history.
*/
public char *
cmd_lastpattern()
cmd_lastpattern(void)
{
if (curr_mlist == NULL)
return (NULL);
@ -1363,8 +1335,7 @@ cmd_lastpattern()
/*
*/
static int
mlist_size(ml)
struct mlist *ml;
mlist_size(struct mlist *ml)
{
int size = 0;
for (ml = ml->next; ml->string != NULL; ml = ml->next)
@ -1376,7 +1347,7 @@ mlist_size(ml)
* Get the name of the history file.
*/
static char *
histfile_name()
histfile_name(void)
{
char *home;
char *name;
@ -1416,11 +1387,8 @@ histfile_name()
* Read a .lesshst file and call a callback for each line in the file.
*/
static void
read_cmdhist2(action, uparam, skip_search, skip_shell)
void (*action)(void*,struct mlist*,char*);
void *uparam;
int skip_search;
int skip_shell;
read_cmdhist2(void (*action)(void*,struct mlist*,char*), void *uparam,
int skip_search, int skip_shell)
{
struct mlist *ml = NULL;
char line[CMDBUF_SIZE];
@ -1480,11 +1448,8 @@ read_cmdhist2(action, uparam, skip_search, skip_shell)
}
static void
read_cmdhist(action, uparam, skip_search, skip_shell)
void (*action)(void*,struct mlist*,char*);
void *uparam;
int skip_search;
int skip_shell;
read_cmdhist(void (*action)(void*,struct mlist*,char*), void *uparam,
int skip_search, int skip_shell)
{
read_cmdhist2(action, uparam, skip_search, skip_shell);
(*action)(uparam, NULL, NULL); /* signal end of file */
@ -1503,7 +1468,7 @@ addhist_init(void *uparam, struct mlist *ml, char *string)
* Initialize history from a .lesshist file.
*/
public void
init_cmdhist()
init_cmdhist(void)
{
#if CMD_HISTORY
read_cmdhist(&addhist_init, NULL, 0, 0);
@ -1515,9 +1480,7 @@ init_cmdhist()
*/
#if CMD_HISTORY
static void
write_mlist_header(ml, f)
struct mlist *ml;
FILE *f;
write_mlist_header(struct mlist *ml, FILE *f)
{
if (ml == &mlist_search)
fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
@ -1531,9 +1494,7 @@ write_mlist_header(ml, f)
* Write all modified entries in an mlist to the history file.
*/
static void
write_mlist(ml, f)
struct mlist *ml;
FILE *f;
write_mlist(struct mlist *ml, FILE *f)
{
for (ml = ml->next; ml->string != NULL; ml = ml->next)
{
@ -1549,8 +1510,7 @@ write_mlist(ml, f)
* Make a temp name in the same directory as filename.
*/
static char *
make_tempname(filename)
char *filename;
make_tempname(char *filename)
{
char lastch;
char *tempname = ecalloc(1, strlen(filename)+1);
@ -1613,8 +1573,7 @@ copy_hist(void *uparam, struct mlist *ml, char *string)
* Make a file readable only by its owner.
*/
static void
make_file_private(f)
FILE *f;
make_file_private(FILE *f)
{
#if HAVE_FCHMOD
int do_chmod = 1;
@ -1634,7 +1593,7 @@ make_file_private(f)
* Does the history file need to be updated?
*/
static int
histfile_modified()
histfile_modified(void)
{
if (mlist_search.modified)
return 1;
@ -1649,7 +1608,7 @@ histfile_modified()
* Update the .lesshst file.
*/
public void
save_cmdhist()
save_cmdhist(void)
{
#if CMD_HISTORY
char *histname;

View File

@ -82,7 +82,7 @@ struct ungot {
};
static struct ungot* ungot = NULL;
static void multi_search();
static void multi_search(char *pattern, int n, int silent);
/*
* Move the cursor to start of prompt line before executing a command.
@ -90,7 +90,7 @@ static void multi_search();
* updating the screen.
*/
static void
cmd_exec()
cmd_exec(void)
{
#if HILITE_SEARCH
clear_attn();
@ -103,11 +103,7 @@ cmd_exec()
* Set up the display to start a new multi-character command.
*/
static void
start_mca(action, prompt, mlist, cmdflags)
int action;
constant char *prompt;
constant void *mlist;
int cmdflags;
start_mca(int action, constant char *prompt, constant void *mlist, int cmdflags)
{
mca = action;
clear_bot();
@ -117,7 +113,7 @@ start_mca(action, prompt, mlist, cmdflags)
}
public int
in_mca()
in_mca(void)
{
return (mca != 0 && mca != A_PREFIX);
}
@ -126,7 +122,7 @@ in_mca()
* Set up the display to start a new search command.
*/
static void
mca_search()
mca_search(void)
{
#if HILITE_SEARCH
if (search_type & SRCH_FILTER)
@ -169,7 +165,7 @@ mca_search()
* Set up the display to start a new toggle-option command.
*/
static void
mca_opt_toggle()
mca_opt_toggle(void)
{
int no_prompt;
int flag;
@ -204,9 +200,9 @@ mca_opt_toggle()
* Execute a multicharacter command.
*/
static void
exec_mca()
exec_mca(void)
{
register char *cbuf;
char *cbuf;
cmd_exec();
cbuf = get_cmdbuf();
@ -294,8 +290,7 @@ exec_mca()
* Is a character an erase or kill char?
*/
static int
is_erase_char(c)
int c;
is_erase_char(int c)
{
return (c == erase_char || c == erase2_char || c == kill_char);
}
@ -304,8 +299,7 @@ is_erase_char(c)
* Handle the first char of an option (after the initial dash).
*/
static int
mca_opt_first_char(c)
int c;
mca_opt_first_char(int c)
{
int flag = (optflag & ~OPT_NO_PROMPT);
if (flag == OPT_NO_TOGGLE)
@ -356,8 +350,7 @@ mca_opt_first_char(c)
* accepting chars until user hits RETURN.
*/
static int
mca_opt_nonfirst_char(c)
int c;
mca_opt_nonfirst_char(int c)
{
char *p;
char *oname;
@ -406,8 +399,7 @@ mca_opt_nonfirst_char(c)
* Handle a char of an option toggle command.
*/
static int
mca_opt_char(c)
int c;
mca_opt_char(int c)
{
PARG parg;
@ -472,8 +464,7 @@ mca_opt_char(c)
* Handle a char of a search command.
*/
static int
mca_search_char(c)
int c;
mca_search_char(int c)
{
int flag = 0;
@ -525,8 +516,7 @@ mca_search_char(c)
* Handle a character of a multi-character command.
*/
static int
mca_char(c)
int c;
mca_char(int c)
{
int ret;
@ -628,7 +618,7 @@ mca_char(c)
* Discard any buffered file data.
*/
static void
clear_buffers()
clear_buffers(void)
{
if (!(ch_getflags() & CH_CANSEEK))
return;
@ -643,7 +633,7 @@ clear_buffers()
* Make sure the screen is displayed.
*/
static void
make_display()
make_display(void)
{
/*
* If nothing is displayed yet, display starting from initial_scrpos.
@ -683,9 +673,9 @@ make_display()
* Display the appropriate prompt.
*/
static void
prompt()
prompt(void)
{
register constant char *p;
constant char *p;
if (ungot != NULL && !ungot->ug_end_command)
{
@ -760,7 +750,7 @@ prompt()
* Display the less version message.
*/
public void
dispversion()
dispversion(void)
{
PARG parg;
@ -775,7 +765,7 @@ dispversion()
* (characters previously given to ungetcc or ungetsc).
*/
public int
getcc()
getcc(void)
{
if (ungot == NULL)
{
@ -830,8 +820,7 @@ getcc()
* The next getcc() will return this character.
*/
public void
ungetcc(c)
int c;
ungetcc(int c)
{
struct ungot *ug = (struct ungot *) ecalloc(1, sizeof(struct ungot));
@ -846,10 +835,9 @@ ungetcc(c)
* The next sequence of getcc()'s will return this string.
*/
public void
ungetsc(s)
char *s;
ungetsc(char *s)
{
register char *p;
char *p;
for (p = s + strlen(s) - 1; p >= s; p--)
ungetcc(*p);
@ -861,12 +849,9 @@ ungetsc(s)
* If SRCH_PAST_EOF is set, continue the search thru multiple files.
*/
static void
multi_search(pattern, n, silent)
char *pattern;
int n;
int silent;
multi_search(char *pattern, int n, int silent)
{
register int nomore;
int nomore;
IFILE save_ifile;
int changed_file;
@ -958,8 +943,7 @@ multi_search(pattern, n, silent)
* Forward forever, or until a highlighted line appears.
*/
static int
forw_loop(until_hilite)
int until_hilite;
forw_loop(int until_hilite)
{
POSITION curr_len;
@ -999,11 +983,11 @@ forw_loop(until_hilite)
* Accept and execute commands until a quit command.
*/
public void
commands()
commands(void)
{
register int c;
register int action;
register char *cbuf;
int c;
int action;
char *cbuf;
int newaction;
int save_search_type;
char *extra;

18
cvt.c
View File

@ -20,9 +20,7 @@ extern int utf_mode;
* Get the length of a buffer needed to convert a string.
*/
public int
cvt_length(len, ops)
int len;
int ops;
cvt_length(int len, int ops)
{
if (utf_mode)
/*
@ -38,8 +36,7 @@ cvt_length(len, ops)
* Allocate a chpos array for use by cvt_text.
*/
public int *
cvt_alloc_chpos(len)
int len;
cvt_alloc_chpos(int len)
{
int i;
int *chpos = (int *) ecalloc(sizeof(int), len);
@ -55,17 +52,12 @@ cvt_alloc_chpos(len)
* odst character (when it was in osrc) is returned in the chpos array.
*/
public void
cvt_text(odst, osrc, chpos, lenp, ops)
char *odst;
char *osrc;
int *chpos;
int *lenp;
int ops;
cvt_text(char *odst, char *osrc, int *chpos, int *lenp, int ops)
{
char *dst;
char *edst = odst;
char *src;
register char *src_end;
char *src_end;
LWCHAR ch;
if (lenp != NULL)
@ -77,7 +69,7 @@ cvt_text(odst, osrc, chpos, lenp, ops)
{
int src_pos = (int) (src - osrc);
int dst_pos = (int) (dst - odst);
ch = step_char(&src, +1, src_end);
ch = step_char((constant char **)&src, +1, src_end);
if ((ops & CVT_BS) && ch == '\b' && dst > odst)
{
/* Delete backspace and preceding char. */

101
decode.c
View File

@ -229,13 +229,11 @@ static struct tablelist *list_sysvar_tables = NULL;
* Expand special key abbreviations in a command table.
*/
static void
expand_special_keys(table, len)
char *table;
int len;
expand_special_keys(char *table, int len)
{
register char *fm;
register char *to;
register int a;
char *fm;
char *to;
int a;
char *repl;
int klen;
@ -290,7 +288,7 @@ expand_special_keys(table, len)
* Initialize the command lists.
*/
public void
init_cmds()
init_cmds(void)
{
/*
* Add the default command tables.
@ -320,12 +318,9 @@ init_cmds()
* Add a command table.
*/
static int
add_cmd_table(tlist, buf, len)
struct tablelist **tlist;
char *buf;
int len;
add_cmd_table(struct tablelist **tlist, char *buf, int len)
{
register struct tablelist *t;
struct tablelist *t;
if (len == 0)
return (0);
@ -350,9 +345,7 @@ add_cmd_table(tlist, buf, len)
* Add a command table.
*/
public void
add_fcmd_table(buf, len)
char *buf;
int len;
add_fcmd_table(char *buf, int len)
{
if (add_cmd_table(&list_fcmd_tables, buf, len) < 0)
error("Warning: some commands disabled", NULL_PARG);
@ -362,9 +355,7 @@ add_fcmd_table(buf, len)
* Add an editing command table.
*/
public void
add_ecmd_table(buf, len)
char *buf;
int len;
add_ecmd_table(char *buf, int len)
{
if (add_cmd_table(&list_ecmd_tables, buf, len) < 0)
error("Warning: some edit commands disabled", NULL_PARG);
@ -374,10 +365,7 @@ add_ecmd_table(buf, len)
* Add an environment variable table.
*/
static void
add_var_table(tlist, buf, len)
struct tablelist **tlist;
char *buf;
int len;
add_var_table(struct tablelist **tlist, char *buf, int len)
{
if (add_cmd_table(tlist, buf, len) < 0)
error("Warning: environment variables from lesskey file unavailable", NULL_PARG);
@ -387,15 +375,11 @@ add_var_table(tlist, buf, len)
* Search a single command table for the command string in cmd.
*/
static int
cmd_search(cmd, table, endtable, sp)
char *cmd;
char *table;
char *endtable;
char **sp;
cmd_search(char *cmd, char *table, char *endtable, char **sp)
{
register char *p;
register char *q;
register int a;
char *p;
char *q;
int a;
*sp = NULL;
for (p = table, q = cmd; p < endtable; p++, q++)
@ -479,13 +463,10 @@ cmd_search(cmd, table, endtable, sp)
* The "extra" string, if any, is returned in sp.
*/
static int
cmd_decode(tlist, cmd, sp)
struct tablelist *tlist;
char *cmd;
char **sp;
cmd_decode(struct tablelist *tlist, char *cmd, char **sp)
{
register struct tablelist *t;
register int action = A_INVALID;
struct tablelist *t;
int action = A_INVALID;
/*
* Search thru all the command tables.
@ -506,9 +487,7 @@ cmd_decode(tlist, cmd, sp)
* Decode a command from the cmdtables list.
*/
public int
fcmd_decode(cmd, sp)
char *cmd;
char **sp;
fcmd_decode(char *cmd, char **sp)
{
return (cmd_decode(list_fcmd_tables, cmd, sp));
}
@ -517,9 +496,7 @@ fcmd_decode(cmd, sp)
* Decode a command from the edittables list.
*/
public int
ecmd_decode(cmd, sp)
char *cmd;
char **sp;
ecmd_decode(char *cmd, char **sp)
{
return (cmd_decode(list_ecmd_tables, cmd, sp));
}
@ -529,8 +506,7 @@ ecmd_decode(cmd, sp)
* Looks first in the lesskey file, then in the real environment.
*/
public char *
lgetenv(var)
char *var;
lgetenv(char *var)
{
int a;
char *s;
@ -554,8 +530,7 @@ lgetenv(var)
* two bytes, low order first, in radix KRADIX.
*/
static int
gint(sp)
char **sp;
gint(char **sp)
{
int n;
@ -568,9 +543,7 @@ gint(sp)
* Process an old (pre-v241) lesskey file.
*/
static int
old_lesskey(buf, len)
char *buf;
int len;
old_lesskey(char *buf, int len)
{
/*
* Old-style lesskey file.
@ -589,14 +562,11 @@ old_lesskey(buf, len)
* Process a new (post-v241) lesskey file.
*/
static int
new_lesskey(buf, len, sysvar)
char *buf;
int len;
int sysvar;
new_lesskey(char *buf, int len, int sysvar)
{
char *p;
register int c;
register int n;
int c;
int n;
/*
* New-style lesskey file.
@ -643,14 +613,12 @@ new_lesskey(buf, len, sysvar)
* Set up a user command table, based on a "lesskey" file.
*/
public int
lesskey(filename, sysvar)
char *filename;
int sysvar;
lesskey(char *filename, int sysvar)
{
register char *buf;
register POSITION len;
register long n;
register int f;
char *buf;
POSITION len;
long n;
int f;
if (secure)
return (1);
@ -713,10 +681,7 @@ lesskey(filename, sysvar)
* Add the standard lesskey file "$HOME/.less"
*/
public void
add_hometable(envname, def_filename, sysvar)
char *envname;
char *def_filename;
int sysvar;
add_hometable(char *envname, char *def_filename, int sysvar)
{
char *filename;
PARG parg;
@ -742,9 +707,7 @@ add_hometable(envname, def_filename, sysvar)
* See if a char is a special line-editing command.
*/
public int
editchar(c, flags)
int c;
int flags;
editchar(int c, int flags)
{
int action;
int nch;

74
edit.c
View File

@ -26,7 +26,7 @@ extern int sigs;
extern IFILE curr_ifile;
extern IFILE old_ifile;
extern struct scrpos initial_scrpos;
extern void constant *ml_examine;
extern void * constant ml_examine;
#if SPACES_IN_FILENAMES
extern char openquote;
extern char closequote;
@ -55,9 +55,7 @@ static void *curr_altpipe;
* back_textlist does the same, but runs thru the list backwards.
*/
public void
init_textlist(tlist, str)
struct textlist *tlist;
char *str;
init_textlist(struct textlist *tlist, char *str)
{
char *s;
#if SPACES_IN_FILENAMES
@ -99,9 +97,7 @@ init_textlist(tlist, str)
}
public char *
forw_textlist(tlist, prev)
struct textlist *tlist;
char *prev;
forw_textlist(struct textlist *tlist, char *prev)
{
char *s;
@ -123,9 +119,7 @@ forw_textlist(tlist, prev)
}
public char *
back_textlist(tlist, prev)
struct textlist *tlist;
char *prev;
back_textlist(struct textlist *tlist, char *prev)
{
char *s;
@ -152,7 +146,7 @@ back_textlist(tlist, prev)
* Close the current input file.
*/
static void
close_file()
close_file(void)
{
struct scrpos scrpos;
@ -196,8 +190,7 @@ close_file()
* Filename == NULL means just close the current file.
*/
public int
edit(filename)
char *filename;
edit(char *filename)
{
if (filename == NULL)
return (edit_ifile(NULL_IFILE));
@ -209,8 +202,7 @@ edit(filename)
* ifile == NULL means just close the current file.
*/
public int
edit_ifile(ifile)
IFILE ifile;
edit_ifile(IFILE ifile)
{
int f;
int answer;
@ -460,8 +452,7 @@ edit_ifile(ifile)
* Then edit the first one.
*/
public int
edit_list(filelist)
char *filelist;
edit_list(char *filelist)
{
IFILE save_ifile;
char *good_filename;
@ -518,7 +509,7 @@ edit_list(filelist)
* Edit the first file in the command line (ifile) list.
*/
public int
edit_first()
edit_first(void)
{
curr_ifile = NULL_IFILE;
return (edit_next(1));
@ -528,7 +519,7 @@ edit_first()
* Edit the last file in the command line (ifile) list.
*/
public int
edit_last()
edit_last(void)
{
curr_ifile = NULL_IFILE;
return (edit_prev(1));
@ -539,10 +530,7 @@ edit_last()
* Edit the n-th next or previous file in the command line (ifile) list.
*/
static int
edit_istep(h, n, dir)
IFILE h;
int n;
int dir;
edit_istep(IFILE h, int n, int dir)
{
IFILE next;
@ -581,31 +569,25 @@ edit_istep(h, n, dir)
}
static int
edit_inext(h, n)
IFILE h;
int n;
edit_inext(IFILE h, int n)
{
return (edit_istep(h, n, +1));
}
public int
edit_next(n)
int n;
edit_next(int n)
{
return edit_istep(curr_ifile, n, +1);
}
static int
edit_iprev(h, n)
IFILE h;
int n;
edit_iprev(IFILE h, int n)
{
return (edit_istep(h, n, -1));
}
public int
edit_prev(n)
int n;
edit_prev(int n)
{
return edit_istep(curr_ifile, n, -1);
}
@ -614,8 +596,7 @@ edit_prev(n)
* Edit a specific file in the command line (ifile) list.
*/
public int
edit_index(n)
int n;
edit_index(int n)
{
IFILE h;
@ -635,7 +616,7 @@ edit_index(n)
}
public IFILE
save_curr_ifile()
save_curr_ifile(void)
{
if (curr_ifile != NULL_IFILE)
hold_ifile(curr_ifile, 1);
@ -643,8 +624,7 @@ save_curr_ifile()
}
public void
unsave_ifile(save_ifile)
IFILE save_ifile;
unsave_ifile(IFILE save_ifile)
{
if (save_ifile != NULL_IFILE)
hold_ifile(save_ifile, -1);
@ -654,8 +634,7 @@ unsave_ifile(save_ifile)
* Reedit the ifile which was previously open.
*/
public void
reedit_ifile(save_ifile)
IFILE save_ifile;
reedit_ifile(IFILE save_ifile)
{
IFILE next;
IFILE prev;
@ -688,7 +667,7 @@ reedit_ifile(save_ifile)
}
public void
reopen_curr_ifile()
reopen_curr_ifile(void)
{
IFILE save_ifile = save_curr_ifile();
close_file();
@ -699,7 +678,7 @@ reopen_curr_ifile()
* Edit standard input.
*/
public int
edit_stdin()
edit_stdin(void)
{
if (isatty(fd0))
{
@ -714,9 +693,9 @@ edit_stdin()
* Used if standard output is not a tty.
*/
public void
cat_file()
cat_file(void)
{
register int c;
int c;
while ((c = ch_forw_get()) != EOI)
putchr(c);
@ -731,11 +710,10 @@ cat_file()
* We take care not to blindly overwrite an existing file.
*/
public void
use_logfile(filename)
char *filename;
use_logfile(char *filename)
{
register int exists;
register int answer;
int exists;
int answer;
PARG parg;
if (ch_getflags() & CH_CANSEEK)

View File

@ -63,8 +63,7 @@ extern char closequote;
* Remove quotes around a filename.
*/
public char *
shell_unquote(str)
char *str;
shell_unquote(char *str)
{
char *name;
char *p;
@ -102,7 +101,7 @@ shell_unquote(str)
* Get the shell's escape character.
*/
public char *
get_meta_escape()
get_meta_escape(void)
{
char *s;
@ -116,7 +115,7 @@ get_meta_escape()
* Get the characters which the shell considers to be "metacharacters".
*/
static char *
metachars()
metachars(void)
{
static char *mchars = NULL;
@ -133,8 +132,7 @@ metachars()
* Is this a shell metacharacter?
*/
static int
metachar(c)
char c;
metachar(char c)
{
return (strchr(metachars(), c) != NULL);
}
@ -143,8 +141,7 @@ metachar(c)
* Insert a backslash before each metacharacter in a string.
*/
public char *
shell_quote(s)
char *s;
shell_quote(char *s)
{
char *p;
char *newstr;
@ -221,9 +218,7 @@ shell_quote(s)
* Return NULL if the file does not exist in the directory.
*/
static char *
dirfile(dirname, filename)
char *dirname;
char *filename;
dirfile(char *dirname, char *filename)
{
char *pathname;
char *qpathname;
@ -261,10 +256,9 @@ dirfile(dirname, filename)
* Return the full pathname of the given file in the "home directory".
*/
public char *
homefile(filename)
char *filename;
homefile(char *filename)
{
register char *pathname;
char *pathname;
/*
* Try $HOME/filename.
@ -311,12 +305,11 @@ homefile(filename)
* {{ This is a lot of work just to support % and #. }}
*/
public char *
fexpand(s)
char *s;
fexpand(char *s)
{
register char *fr, *to;
register int n;
register char *e;
char *fr, *to;
int n;
char *e;
IFILE ifile;
#define fchar_ifile(c) \
@ -407,8 +400,7 @@ fexpand(s)
* the given string.
*/
public char *
fcomplete(s)
char *s;
fcomplete(char *s)
{
char *fpat;
char *qs;
@ -467,13 +459,12 @@ fcomplete(s)
* This is just a guess, and we need not try too hard to make it accurate.
*/
public int
bin_file(f)
int f;
bin_file(int f)
{
int n;
int bin_count = 0;
char data[256];
char* p;
constant char* p;
char* pend;
if (!seekable(f))
@ -512,8 +503,7 @@ bin_file(f)
* Try to determine the size of a file by seeking to the end.
*/
static POSITION
seek_filesize(f)
int f;
seek_filesize(int f)
{
off_t spos;
@ -528,8 +518,7 @@ seek_filesize(f)
* Return a pointer to the string in memory.
*/
static char *
readfd(fd)
FILE *fd;
readfd(FILE *fd)
{
int len;
int ch;
@ -577,8 +566,7 @@ FILE *popen();
* Return a pointer to a pipe connected to the shell command's standard output.
*/
static FILE *
shellcmd(cmd)
char *cmd;
shellcmd(char *cmd)
{
FILE *fd;
@ -628,8 +616,7 @@ shellcmd(cmd)
* Expand a filename, doing any system-specific metacharacter substitutions.
*/
public char *
lglob(filename)
char *filename;
lglob(char *filename)
{
char *gfilename;
char *ofilename;
@ -690,9 +677,9 @@ lglob(filename)
* The globbing function returns a single name, and
* is called multiple times to walk thru all names.
*/
register char *p;
register int len;
register int n;
char *p;
int len;
int n;
char *pathname;
char *qpathname;
DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle)
@ -818,8 +805,7 @@ lglob(filename)
* Return a large number if there are any other % escapes besides %s.
*/
static int
num_pct_s(lessopen)
char *lessopen;
num_pct_s(char *lessopen)
{
int num = 0;
@ -844,10 +830,7 @@ num_pct_s(lessopen)
* instead of the file we're about to open.
*/
public char *
open_altfile(filename, pf, pfd)
char *filename;
int *pf;
void **pfd;
open_altfile(char *filename, int *pf, void **pfd)
{
#if !HAVE_POPEN
return (NULL);
@ -956,10 +939,7 @@ open_altfile(filename, pf, pfd)
* Close a replacement file.
*/
public void
close_altfile(altfilename, filename, pipefd)
char *altfilename;
char *filename;
void *pipefd;
close_altfile(char *altfilename, char *filename, void *pipefd)
{
#if HAVE_POPEN
char *lessclose;
@ -1001,8 +981,7 @@ close_altfile(altfilename, filename, pipefd)
* Is the specified file a directory?
*/
public int
is_dir(filename)
char *filename;
is_dir(char *filename)
{
int isdir = 0;
@ -1018,7 +997,7 @@ is_dir(filename)
#else
#ifdef _OSK
{
register int f;
int f;
f = open(filename, S_IREAD | S_IFDIR);
if (f >= 0)
@ -1037,10 +1016,9 @@ is_dir(filename)
* (if it cannot be opened or is a directory, etc.)
*/
public char *
bad_file(filename)
char *filename;
bad_file(char *filename)
{
register char *m = NULL;
char *m = NULL;
filename = shell_unquote(filename);
if (!force_open && is_dir(filename))
@ -1083,8 +1061,7 @@ bad_file(filename)
* In Unix, we can stat the file.
*/
public POSITION
filesize(f)
int f;
filesize(int f)
{
#if HAVE_STAT
struct stat statbuf;
@ -1106,7 +1083,7 @@ filesize(f)
*
*/
public char *
shell_coption()
shell_coption(void)
{
return ("-c");
}
@ -1115,8 +1092,7 @@ shell_coption()
* Return last component of a pathname.
*/
public char *
last_component(name)
char *name;
last_component(char *name)
{
char *slash;

View File

@ -46,7 +46,7 @@ extern char *tagoption;
* Sound the bell to indicate user is trying to move past end of file.
*/
static void
eof_bell()
eof_bell(void)
{
if (quiet == NOT_QUIET)
bell();
@ -58,7 +58,7 @@ eof_bell()
* Check to see if the end of file is currently displayed.
*/
public int
eof_displayed()
eof_displayed(void)
{
POSITION pos;
@ -85,7 +85,7 @@ eof_displayed()
* Check to see if the entire file is currently displayed.
*/
public int
entire_file_displayed()
entire_file_displayed(void)
{
POSITION pos;
@ -105,7 +105,7 @@ entire_file_displayed()
* for the first time.
*/
public void
squish_check()
squish_check(void)
{
if (!squished)
return;
@ -123,12 +123,7 @@ squish_check()
* The first real line after the blanks will start at ch_zero().
*/
public void
forw(n, pos, force, only_last, nblank)
register int n;
POSITION pos;
int force;
int only_last;
int nblank;
forw(int n, POSITION pos, int force, int only_last, int nblank)
{
int nlines = 0;
int do_repaint;
@ -297,11 +292,7 @@ forw(n, pos, force, only_last, nblank)
* Display n lines, scrolling backward.
*/
public void
back(n, pos, force, only_last)
register int n;
POSITION pos;
int force;
int only_last;
back(int n, POSITION pos, int force, int only_last)
{
int nlines = 0;
int do_repaint;
@ -359,10 +350,7 @@ back(n, pos, force, only_last)
* Start just after the line currently displayed at the bottom of the screen.
*/
public void
forward(n, force, only_last)
int n;
int force;
int only_last;
forward(int n, int force, int only_last)
{
POSITION pos;
@ -411,10 +399,7 @@ forward(n, force, only_last)
* Start just before the line currently displayed at the top of the screen.
*/
public void
backward(n, force, only_last)
int n;
int force;
int only_last;
backward(int n, int force, int only_last)
{
POSITION pos;
@ -434,7 +419,7 @@ backward(n, force, only_last)
* top_scroll, as well as back_scroll.
*/
public int
get_back_scroll()
get_back_scroll(void)
{
if (no_back_scroll)
return (0);

600
funcs.h
View File

@ -1,298 +1,302 @@
public char * save ();
public VOID_POINTER ecalloc ();
public char * skipsp ();
public int sprefix ();
public void quit ();
public void raw_mode ();
public void scrsize ();
public char * special_key_str ();
public void get_term ();
public void init ();
public void deinit ();
public void home ();
public void add_line ();
public void remove_top ();
public void win32_scroll_up ();
public void lower_left ();
public void line_left ();
public void check_winch ();
public void goto_line ();
public void vbell ();
public void bell ();
public void clear ();
public void clear_eol ();
public void clear_bot ();
public void at_enter ();
public void at_exit ();
public void at_switch ();
public int is_at_equiv ();
public int apply_at_specials ();
public void backspace ();
public void putbs ();
public char WIN32getch ();
public void WIN32setcolors ();
public void WIN32textout ();
public void match_brac ();
public void ch_ungetchar ();
public void end_logfile ();
public void sync_logfile ();
public int ch_seek ();
public int ch_end_seek ();
public int ch_end_buffer_seek ();
public int ch_beg_seek ();
public POSITION ch_length ();
public POSITION ch_tell ();
public int ch_forw_get ();
public int ch_back_get ();
public void ch_setbufspace ();
public void ch_flush ();
public int seekable ();
public void ch_set_eof ();
public void ch_init ();
public void ch_close ();
public int ch_getflags ();
public void ch_dump ();
public void init_charset ();
public int binary_char ();
public int control_char ();
public char * prchar ();
public char * prutfchar ();
public int utf_len ();
public int is_utf8_well_formed ();
public int utf_bin_count ();
public LWCHAR get_wchar ();
public void put_wchar ();
public LWCHAR step_char ();
public int is_composing_char ();
public int is_ubin_char ();
public int is_wide_char ();
public int is_combining_char ();
public void cmd_reset ();
public void clear_cmd ();
public void cmd_putstr ();
public int len_cmdbuf ();
public void set_mlist ();
public void cmd_addhist ();
public void cmd_accept ();
public int cmd_char ();
public LINENUM cmd_int ();
public char * get_cmdbuf ();
public char * cmd_lastpattern ();
public void init_cmdhist ();
public void save_cmdhist ();
public int in_mca ();
public void dispversion ();
public int getcc ();
public void ungetcc ();
public void ungetsc ();
public void commands ();
public int cvt_length ();
public int * cvt_alloc_chpos ();
public void cvt_text ();
public void init_cmds ();
public void add_fcmd_table ();
public void add_ecmd_table ();
public int fcmd_decode ();
public int ecmd_decode ();
public char * lgetenv ();
public int lesskey ();
public void add_hometable ();
public int editchar ();
public void init_textlist ();
public char * forw_textlist ();
public char * back_textlist ();
public int edit ();
public int edit_ifile ();
public int edit_list ();
public int edit_first ();
public int edit_last ();
public int edit_next ();
public int edit_prev ();
public int edit_index ();
public IFILE save_curr_ifile ();
public void unsave_ifile ();
public void reedit_ifile ();
public void reopen_curr_ifile ();
public int edit_stdin ();
public void cat_file ();
public void use_logfile ();
public char * shell_unquote ();
public char * get_meta_escape ();
public char * shell_quote ();
public char * homefile ();
public char * fexpand ();
public char * fcomplete ();
public int bin_file ();
public char * lglob ();
public char * open_altfile ();
public void close_altfile ();
public int is_dir ();
public char * bad_file ();
public POSITION filesize ();
public char * shell_coption ();
public char * last_component ();
public int eof_displayed ();
public int entire_file_displayed ();
public void squish_check ();
public void forw ();
public void back ();
public void forward ();
public void backward ();
public int get_back_scroll ();
public void del_ifile ();
public IFILE next_ifile ();
public IFILE prev_ifile ();
public IFILE getoff_ifile ();
public int nifile ();
public IFILE get_ifile ();
public char * get_filename ();
public int get_index ();
public void store_pos ();
public void get_pos ();
public void set_open ();
public int opened ();
public void hold_ifile ();
public int held_ifile ();
public void * get_filestate ();
public void set_filestate ();
public void if_dump ();
public POSITION forw_line ();
public POSITION back_line ();
public void set_attnpos ();
public void jump_forw ();
public void jump_forw_buffered ();
public void jump_back ();
public void repaint ();
public void jump_percent ();
public void jump_line_loc ();
public void jump_loc ();
public void init_line ();
public int is_ascii_char ();
public void prewind ();
public void plinenum ();
public void pshift_all ();
public int is_ansi_end ();
public int is_ansi_middle ();
public int pappend ();
public int pflushmbc ();
public void pdone ();
public void set_status_col ();
public int gline ();
public void null_line ();
public POSITION forw_raw_line ();
public POSITION back_raw_line ();
public void clr_linenum ();
public void add_lnum ();
public LINENUM find_linenum ();
public POSITION find_pos ();
public LINENUM currline ();
public void lsystem ();
public int pipe_mark ();
public int pipe_data ();
public void init_mark ();
public int badmark ();
public void setmark ();
public void lastmark ();
public void gomark ();
public POSITION markpos ();
public void unmark ();
public void opt_o ();
public void opt__O ();
public void opt_j ();
public void calc_jump_sline ();
public void opt_shift ();
public void calc_shift_count ();
public void opt_k ();
public void opt_t ();
public void opt__T ();
public void opt_p ();
public void opt__P ();
public void opt_b ();
public void opt_i ();
public void opt__V ();
public void opt_D ();
public void opt_x ();
public void opt_quote ();
public void opt_query ();
public int get_swindow ();
public char * propt ();
public void scan_option ();
public void toggle_option ();
public int opt_has_param ();
public char * opt_prompt ();
public int isoptpending ();
public void nopendopt ();
public int getnum ();
public long getfraction ();
public int get_quit_at_eof ();
public void init_option ();
public struct loption * findopt ();
public struct loption * findopt_name ();
public int iread ();
public void intread ();
public time_type get_time ();
public char * errno_message ();
public int percentage ();
public POSITION percent_pos ();
public int os9_signal ();
public void put_line ();
public void flush ();
public int putchr ();
public void putstr ();
public void get_return ();
public void error ();
public void ierror ();
public int query ();
public int compile_pattern ();
public void uncompile_pattern ();
public int valid_pattern ();
public int is_null_pattern ();
public int match_pattern ();
public POSITION position ();
public void add_forw_pos ();
public void add_back_pos ();
public void pos_clear ();
public void pos_init ();
public int onscreen ();
public int empty_screen ();
public int empty_lines ();
public void get_scrpos ();
public int adjsline ();
public void init_prompt ();
public char * pr_expand ();
public char * eq_message ();
public char * pr_string ();
public char * wait_message ();
public void init_search ();
public void repaint_hilite ();
public void clear_attn ();
public void undo_search ();
public void clr_hlist ();
public void clr_hilite ();
public void clr_filter ();
public int is_filtered ();
public POSITION next_unfiltered ();
public POSITION prev_unfiltered ();
public int is_hilited ();
public void chg_caseless ();
public void chg_hilite ();
public int search ();
public void prep_hilite ();
public void set_filter_pattern ();
public int is_filtering ();
public RETSIGTYPE winch ();
public RETSIGTYPE winch ();
public void init_signals ();
public void psignals ();
public void cleantags ();
public int gettagtype ();
public void findtag ();
public POSITION tagsearch ();
public char * nexttag ();
public char * prevtag ();
public int ntags ();
public int curr_tag ();
public int edit_tagfile ();
public void open_getchr ();
public void close_getchr ();
public int getchr ();
public char * save (constant char *s);
public VOID_POINTER ecalloc (int count, unsigned int size);
public char * skipsp (char *s);
public char * skipnsp(char *s);
public int sprefix (char *ps, char *s, int uppercase);
public void quit (int status);
public void raw_mode (int on);
public void scrsize (void);
public char * special_key_str (int key);
public void get_term (void);
public void init (void);
public void deinit (void);
public void home (void);
public void add_line (void);
public void remove_top (int n);
public void win32_scroll_up (int n);
public void lower_left (void);
public void line_left (void);
public void check_winch (void);
public void goto_line (int slinenum);
public void vbell (void);
public void bell (void);
public void clear (void);
public void clear_eol (void);
public void clear_bot (void);
public void at_enter (int attr);
public void at_exit (void);
public void at_switch (int attr);
public int is_at_equiv (int attr1, int attr2);
public int apply_at_specials (int attr);
public void backspace (void);
public void putbs (void);
public char WIN32getch (int tty);
public void WIN32setcolors (int fg, int bg);
public void WIN32textout (char *text, int len);
public void match_brac(int obrac, int cbrac, int forwdir, int n);
public void ch_ungetchar (int c);
public void end_logfile (void);
public void sync_logfile (void);
public int ch_seek (POSITION pos);
public int ch_end_seek (void);
public int ch_end_buffer_seek (void);
public int ch_beg_seek (void);
public POSITION ch_length (void);
public POSITION ch_tell (void);
public int ch_forw_get (void);
public int ch_back_get (void);
public void ch_setbufspace (int bufspace);
public void ch_flush (void);
public int seekable (int f);
public void ch_set_eof (void);
public void ch_init (int f, int flags);
public void ch_close (void);
public int ch_getflags (void);
struct filestate;
public void ch_dump (struct filestate *fs);
public void init_charset (void);
public int binary_char (LWCHAR c);
public int control_char (LWCHAR c);
public char * prchar (LWCHAR c);
public char * prutfchar (LWCHAR ch);
public int utf_len (char ch);
public int is_utf8_well_formed (unsigned char *s, int slen);
public int utf_bin_count (unsigned char *data, int len);
public LWCHAR get_wchar (constant char *p);
public void put_wchar (char **pp, LWCHAR ch);
public LWCHAR step_char (constant char **pp, signed int dir, constant char *limit);
public int is_composing_char (LWCHAR ch);
public int is_ubin_char (LWCHAR ch);
public int is_wide_char (LWCHAR ch);
public int is_combining_char (LWCHAR ch1, LWCHAR ch2);
public void cmd_reset (void);
public void clear_cmd (void);
public void cmd_putstr (constant char *s);
public int len_cmdbuf (void);
public void set_mlist (constant void *mlist, int cmdflags);
struct mlist;
public void cmd_addhist (struct mlist *constant mlist, char *cmd, int modified);
public void cmd_accept (void);
public int cmd_char (int c);
public LINENUM cmd_int (long *frac);
public char * get_cmdbuf (void);
public char * cmd_lastpattern (void);
public void init_cmdhist (void);
public void save_cmdhist (void);
public int in_mca (void);
public void dispversion (void);
public int getcc (void);
public void ungetcc (int c);
public void ungetsc (char *s);
public void commands (void);
public int cvt_length (int len, int ops);
public int * cvt_alloc_chpos (int len);
public void cvt_text (char *odst, char *osrc, int *chpos, int *lenp, int ops);
public void init_cmds (void);
public void add_fcmd_table (char *buf, int len);
public void add_ecmd_table (char *buf, int len);
public int fcmd_decode (char *cmd, char **sp);
public int ecmd_decode (char *cmd, char **sp);
public char * lgetenv (char *var);
public int lesskey (char *filename, int sysvar);
public void add_hometable (char *envname, char *def_filename, int sysvar);
public int editchar (int c, int flags);
public void init_textlist (struct textlist *tlist, char *str);
public char * forw_textlist (struct textlist *tlist, char *prev);
public char * back_textlist (struct textlist *tlist, char *prev);
public int edit (char *filename);
public int edit_ifile (IFILE ifile);
public int edit_list (char *filelist);
public int edit_first (void);
public int edit_last (void);
public int edit_next (int n);
public int edit_prev (int n);
public int edit_index (int n);
public IFILE save_curr_ifile (void);
public void unsave_ifile (IFILE save_ifile);
public void reedit_ifile (IFILE save_ifiler);
public void reopen_curr_ifile (void);
public int edit_stdin (void);
public void cat_file (void);
public void use_logfile (char *filename);
public char * shell_unquote (char *str);
public char * get_meta_escape (void);
public char * shell_quote (char *s);
public char * homefile (char *filename);
public char * fexpand (char *s);
public char * fcomplete (char *s);
public int bin_file (int f);
public char * lglob (char *filename);
public char * open_altfile (char *filename, int *pf, void **pfd);
public void close_altfile (char *altfilename, char *filename, void *pipefd);
public int is_dir (char *filename);
public char * bad_file (char *filename);
public POSITION filesize (int f);
public char * shell_coption (void);
public char * last_component (char *name);
public int eof_displayed (void);
public int entire_file_displayed (void);
public void squish_check (void);
public void forw (int n, POSITION pos, int force, int only_last, int nblank);
public void back (int n, POSITION pos, int force, int only_last);
public void forward (int n, int force, int only_last);
public void backward (int n, int force, int only_last);
public int get_back_scroll (void);
public void del_ifile (IFILE h);
public IFILE next_ifile (IFILE h);
public IFILE prev_ifile (IFILE h);
public IFILE getoff_ifile (IFILE ifile);
public int nifile (void);
public IFILE get_ifile (char *filename, IFILE prev);
public char * get_filename (IFILE ifile);
public int get_index (IFILE ifile);
public void store_pos (IFILE ifile, struct scrpos *scrpos);
public void get_pos (IFILE ifile, struct scrpos *scrpos);
public void set_open (IFILE ifile);
public int opened (IFILE ifile);
public void hold_ifile (IFILE ifile, int incr);
public int held_ifile (IFILE ifile);
public void * get_filestate (IFILE ifile);
public void set_filestate (IFILE ifile, void *filestate);
public void if_dump (void);
public POSITION forw_line (POSITION curr_pos);
public POSITION back_line (POSITION curr_pos);
public void set_attnpos (POSITION pos);
public void jump_forw (void);
public void jump_forw_buffered (void);
public void jump_back (LINENUM linenum);
public void repaint (void);
public void jump_percent (int percent, long fraction);
public void jump_line_loc (POSITION pos, int sline);
public void jump_loc (POSITION pos, int sline);
public void init_line (void);
public int is_ascii_char (LWCHAR ch);
public void prewind (void);
public void plinenum (POSITION pos);
public void pshift_all (void);
public int is_ansi_end (LWCHAR ch);
public int is_ansi_middle (LWCHAR ch);
public int pappend (unsigned char c, POSITION pos);
public int pflushmbc (void);
public void pdone (int endline, int forw);
public void set_status_col (char c);
public int gline (int i, int *ap);
public void null_line (void);
public POSITION forw_raw_line (POSITION curr_pos, char **linep, int *line_lenp);
public POSITION back_raw_line (POSITION curr_pos, char **linep, int *line_lenp);
public void clr_linenum (void);
public void add_lnum (LINENUM linenum, POSITION pos);
public LINENUM find_linenum (POSITION pos);
public POSITION find_pos (LINENUM linenum);
public LINENUM currline (int where);
public void lsystem (char *cmd, char *donemsg);
public int pipe_mark (int c, char *cmd);
public int pipe_data (char *cmd, POSITION spos, POSITION epos);
public void init_mark (void);
public int badmark (int c);
public void setmark (int c);
public void lastmark (void);
public void gomark (int c);
public POSITION markpos (int c);
public void unmark (IFILE ifile);
public void opt_o (int type, char *s);
public void opt__O (int type, char *s);
public void opt_j (int type, char *s);
public void calc_jump_sline (void);
public void opt_shift (int type, char *s);
public void calc_shift_count (void);
public void opt_k (int type, char *s);
public void opt_t (int type, char *s);
public void opt__T (int type, char *s);
public void opt_p (int type, char *s);
public void opt__P (int type, char *s);
public void opt_b (int type, char *s);
public void opt_i (int type, char *s);
public void opt__V (int type, char *s);
public void opt_D (int type, char *s);
public void opt_x (int type, char *s);
public void opt_quote (int type, char *s);
public void opt_query (int type, char *s);
public int get_swindow (void);
public char * propt (int c);
public void scan_option (char *s);
struct loption;
public void toggle_option (struct loption *o, int lower, char *s, int how_toggle);
public int opt_has_param (struct loption *o);
public char * opt_prompt (struct loption *o);
public int isoptpending (void);
public void nopendopt (void);
public int getnum (char **sp, char *printopt, int *errp);
public long getfraction (char **sp, char *printopt, int *errp);
public int get_quit_at_eof (void);
public void init_option (void);
public struct loption * findopt (int c);
public struct loption * findopt_name (char **p_optname, char **p_oname, int *p_err);
public int iread (int fd, char *buf, unsigned int len);
public void intread (void);
public time_type get_time (void);
public char * errno_message (char *filename);
public int percentage (POSITION num, POSITION den);
public POSITION percent_pos (POSITION pos, int percent, long fraction);
public int os9_signal (int type, RETSIGTYPE (*handler)());
public void put_line (void);
public void flush (void);
public int putchr (int c);
public void putstr (constant char *s);
public void get_return (void);
public void error (char *fmt, PARG *parg);
public void ierror (char *fmt, PARG *parg);
public int query (char *fmt, PARG *parg);
public int compile_pattern (char *pattern, int search_type, void **comp_pattern);
public void uncompile_pattern (void **pattern);
public int valid_pattern (char *pattern);
public int is_null_pattern (void *pattern);
public int match_pattern (void *pattern, char *tpattern, char *line, int line_len, char **sp, char **ep, int notbol, int search_type);
public POSITION position (int where);
public void add_forw_pos (POSITION pos);
public void add_back_pos (POSITION pos);
public void pos_clear (void);
public void pos_init (void);
public int onscreen (POSITION pos);
public int empty_screen (void);
public int empty_lines (int s, int e);
public void get_scrpos (struct scrpos *scrpos);
public int adjsline (int sline);
public void init_prompt (void);
public char * pr_expand (constant char *proto, int maxwidth);
public char * eq_message (void);
public char * pr_string (void);
public char * wait_message (void);
public void init_search (void);
public void repaint_hilite (int on);
public void clear_attn (void);
public void undo_search (void);
struct hilite_tree;
public void clr_hlist (struct hilite_tree *anchor);
public void clr_hilite (void);
public void clr_filter (void);
public int is_filtered (POSITION pos);
public POSITION next_unfiltered (POSITION pos);
public POSITION prev_unfiltered (POSITION pos);
public int is_hilited (POSITION pos, POSITION epos, int nohide, int *p_matches);
public void chg_caseless (void);
public void chg_hilite (void);
public int search (int search_type, char *pattern, int n);
public void prep_hilite (POSITION spos, POSITION epos, int maxlines);
public void set_filter_pattern (char *pattern, int search_type);
public int is_filtering (void);
public RETSIGTYPE winch (int type);
public void init_signals (int on);
public void psignals (void);
public void cleantags (void);
public int gettagtype (void);
public void findtag (char *tag);
public POSITION tagsearch (void);
public char * nexttag (int n);
public char * prevtag (int n);
public int ntags (void);
public int curr_tag (void);
public int edit_tagfile (void);
public void open_getchr (void);
public void close_getchr (void);
public int getchr (void);

86
ifile.c
View File

@ -49,9 +49,7 @@ static struct ifile anchor = { &anchor, &anchor, NULL, NULL, 0, 0, '\0',
static int ifiles = 0;
static void
incr_index(p, incr)
register struct ifile *p;
int incr;
incr_index(struct ifile *p, int incr)
{
for (; p != &anchor; p = p->h_next)
p->h_index += incr;
@ -61,9 +59,7 @@ incr_index(p, incr)
* Link an ifile into the ifile list.
*/
static void
link_ifile(p, prev)
struct ifile *p;
struct ifile *prev;
link_ifile(struct ifile *p, struct ifile *prev)
{
/*
* Link into list.
@ -87,8 +83,7 @@ link_ifile(p, prev)
* Unlink an ifile from the ifile list.
*/
static void
unlink_ifile(p)
struct ifile *p;
unlink_ifile(struct ifile *p)
{
p->h_next->h_prev = p->h_prev;
p->h_prev->h_next = p->h_next;
@ -103,11 +98,9 @@ unlink_ifile(p)
* Return a pointer to the new ifile structure.
*/
static struct ifile *
new_ifile(filename, prev)
char *filename;
struct ifile *prev;
new_ifile(char *filename, struct ifile *prev)
{
register struct ifile *p;
struct ifile *p;
/*
* Allocate and initialize structure.
@ -126,10 +119,9 @@ new_ifile(filename, prev)
* Delete an existing ifile structure.
*/
public void
del_ifile(h)
IFILE h;
del_ifile(IFILE h)
{
register struct ifile *p;
struct ifile *p;
if (h == NULL_IFILE)
return;
@ -150,10 +142,9 @@ del_ifile(h)
* Get the ifile after a given one in the list.
*/
public IFILE
next_ifile(h)
IFILE h;
next_ifile(IFILE h)
{
register struct ifile *p;
struct ifile *p;
p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
if (p->h_next == &anchor)
@ -165,10 +156,9 @@ next_ifile(h)
* Get the ifile before a given one in the list.
*/
public IFILE
prev_ifile(h)
IFILE h;
prev_ifile(IFILE h)
{
register struct ifile *p;
struct ifile *p;
p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
if (p->h_prev == &anchor)
@ -180,8 +170,7 @@ prev_ifile(h)
* Return a different ifile from the given one.
*/
public IFILE
getoff_ifile(ifile)
IFILE ifile;
getoff_ifile(IFILE ifile)
{
IFILE newifile;
@ -196,7 +185,7 @@ getoff_ifile(ifile)
* Return the number of ifiles.
*/
public int
nifile()
nifile(void)
{
return (ifiles);
}
@ -205,10 +194,9 @@ nifile()
* Find an ifile structure, given a filename.
*/
static struct ifile *
find_ifile(filename)
char *filename;
find_ifile(char *filename)
{
register struct ifile *p;
struct ifile *p;
for (p = anchor.h_next; p != &anchor; p = p->h_next)
if (strcmp(filename, p->h_filename) == 0)
@ -222,11 +210,9 @@ find_ifile(filename)
* insert the new ifile after "prev" in the list.
*/
public IFILE
get_ifile(filename, prev)
char *filename;
IFILE prev;
get_ifile(char *filename, IFILE prev)
{
register struct ifile *p;
struct ifile *p;
if ((p = find_ifile(filename)) == NULL)
p = new_ifile(filename, int_ifile(prev));
@ -237,8 +223,7 @@ get_ifile(filename, prev)
* Get the filename associated with a ifile.
*/
public char *
get_filename(ifile)
IFILE ifile;
get_filename(IFILE ifile)
{
if (ifile == NULL)
return (NULL);
@ -249,8 +234,7 @@ get_filename(ifile)
* Get the index of the file associated with a ifile.
*/
public int
get_index(ifile)
IFILE ifile;
get_index(IFILE ifile)
{
return (int_ifile(ifile)->h_index);
}
@ -259,9 +243,7 @@ get_index(ifile)
* Save the file position to be associated with a given file.
*/
public void
store_pos(ifile, scrpos)
IFILE ifile;
struct scrpos *scrpos;
store_pos(IFILE ifile, struct scrpos *scrpos)
{
int_ifile(ifile)->h_scrpos = *scrpos;
}
@ -271,9 +253,7 @@ store_pos(ifile, scrpos)
* If no position has been associated with the file, return NULL_POSITION.
*/
public void
get_pos(ifile, scrpos)
IFILE ifile;
struct scrpos *scrpos;
get_pos(IFILE ifile, struct scrpos *scrpos)
{
*scrpos = int_ifile(ifile)->h_scrpos;
}
@ -282,8 +262,7 @@ get_pos(ifile, scrpos)
* Mark the ifile as "opened".
*/
public void
set_open(ifile)
IFILE ifile;
set_open(IFILE ifile)
{
int_ifile(ifile)->h_opened = 1;
}
@ -292,47 +271,40 @@ set_open(ifile)
* Return whether the ifile has been opened previously.
*/
public int
opened(ifile)
IFILE ifile;
opened(IFILE ifile)
{
return (int_ifile(ifile)->h_opened);
}
public void
hold_ifile(ifile, incr)
IFILE ifile;
int incr;
hold_ifile(IFILE ifile, int incr)
{
int_ifile(ifile)->h_hold += incr;
}
public int
held_ifile(ifile)
IFILE ifile;
held_ifile(IFILE ifile)
{
return (int_ifile(ifile)->h_hold);
}
public void *
get_filestate(ifile)
IFILE ifile;
get_filestate(IFILE ifile)
{
return (int_ifile(ifile)->h_filestate);
}
public void
set_filestate(ifile, filestate)
IFILE ifile;
void *filestate;
set_filestate(IFILE ifile, void *filestate)
{
int_ifile(ifile)->h_filestate = filestate;
}
#if 0
public void
if_dump()
if_dump(void)
{
register struct ifile *p;
struct ifile *p;
for (p = anchor.h_next; p != &anchor; p = p->h_next)
{

11
input.c
View File

@ -42,12 +42,11 @@ extern int size_linebuf;
* of the NEXT line. The line obtained is the line starting at curr_pos.
*/
public POSITION
forw_line(curr_pos)
POSITION curr_pos;
forw_line(POSITION curr_pos)
{
POSITION base_pos;
POSITION new_pos;
register int c;
int c;
int blankline;
int endline;
int backchars;
@ -249,8 +248,7 @@ get_forw_line:
* of the PREVIOUS line. The line obtained is the one starting at new_pos.
*/
public POSITION
back_line(curr_pos)
POSITION curr_pos;
back_line(POSITION curr_pos)
{
POSITION new_pos, begin_new_pos, base_pos;
int c;
@ -429,8 +427,7 @@ get_back_line:
* Set attnpos.
*/
public void
set_attnpos(pos)
POSITION pos;
set_attnpos(POSITION pos)
{
int c;

23
jump.c
View File

@ -26,7 +26,7 @@ extern int top_scroll;
* Jump to the end of the file.
*/
public void
jump_forw()
jump_forw(void)
{
POSITION pos;
POSITION end_pos;
@ -64,7 +64,7 @@ jump_forw()
* Jump to the last buffered line in the file.
*/
public void
jump_forw_buffered()
jump_forw_buffered(void)
{
POSITION end;
@ -82,8 +82,7 @@ jump_forw_buffered()
* Jump to line n in the file.
*/
public void
jump_back(linenum)
LINENUM linenum;
jump_back(LINENUM linenum)
{
POSITION pos;
PARG parg;
@ -115,7 +114,7 @@ jump_back(linenum)
* Repaint the screen.
*/
public void
repaint()
repaint(void)
{
struct scrpos scrpos;
/*
@ -131,9 +130,7 @@ repaint()
* Jump to a specified percentage into the file.
*/
public void
jump_percent(percent, fraction)
int percent;
long fraction;
jump_percent(int percent, long fraction)
{
POSITION pos, len;
@ -164,9 +161,7 @@ jump_percent(percent, fraction)
* the first character in a line.
*/
public void
jump_line_loc(pos, sline)
POSITION pos;
int sline;
jump_line_loc(POSITION pos, int sline)
{
int c;
@ -192,11 +187,9 @@ jump_line_loc(pos, sline)
* Place the target line on a specified line on the screen.
*/
public void
jump_loc(pos, sline)
POSITION pos;
int sline;
jump_loc(POSITION pos, int sline)
{
register int nline;
int nline;
POSITION tpos;
POSITION bpos;

6
less.h
View File

@ -528,6 +528,6 @@ struct wchar_range_table
#include "funcs.h"
/* Functions not included in funcs.h */
void postoa();
void linenumtoa();
void inttoa();
void postoa(POSITION num, char *buf);
void linenumtoa(LINENUM num, char *buf);
void inttoa(int num, char *buf);

View File

@ -38,14 +38,14 @@ static char metachars[64] = "";
static int num_metachars = 0;
static void
pr_usage()
pr_usage(void)
{
fprintf(stderr,
"usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n");
}
static void
pr_version()
pr_version(void)
{
char *p;
char buf[10];
@ -61,18 +61,14 @@ pr_version()
}
static void
pr_error(s)
char *s;
pr_error(char *s)
{
fprintf(stderr, "%s\n", s);
exit(1);
}
static long
lstrtol(s, radix, pend)
char *s;
int radix;
char **pend;
lstrtol(char *s, int radix, char **pend)
{
int v;
int neg = 0;

View File

@ -213,19 +213,19 @@ char *outfile = NULL ;
int linenum;
int errors;
static void lk_error(char *s);
extern char version[];
void
usage()
usage(void)
{
fprintf(stderr, "usage: lesskey [-o output] [input]\n");
exit(1);
}
char *
mkpathname(dirname, filename)
char *dirname;
char *filename;
mkpathname(char *dirname, char *filename)
{
char *pathname;
@ -240,8 +240,7 @@ mkpathname(dirname, filename)
* Figure out the name of a default file (in the user's HOME directory).
*/
char *
homefile(filename)
char *filename;
homefile(char *filename)
{
char *p;
char *pathname;
@ -264,9 +263,7 @@ homefile(filename)
* Parse command line arguments.
*/
void
parse_args(argc, argv)
int argc;
char **argv;
parse_args(int argc, char **argv)
{
char *arg;
@ -339,7 +336,7 @@ parse_args(argc, argv)
* Initialize data structures.
*/
void
init_tables()
init_tables(void)
{
cmdtable.names = cmdnames;
cmdtable.pbuffer = cmdtable.buffer;
@ -355,13 +352,11 @@ init_tables()
* Parse one character of a string.
*/
char *
tstr(pp, xlate)
char **pp;
int xlate;
tstr(char **pp, int xlate)
{
register char *p;
register char ch;
register int i;
char *p;
char ch;
int i;
static char buf[10];
static char tstr_control_k[] =
{ SK_SPECIAL_KEY, SK_CONTROL_K, 6, 1, 1, 1, '\0' };
@ -421,7 +416,7 @@ tstr(pp, xlate)
case 'e': ch = SK_END; break;
case 'x': ch = SK_DELETE; break;
default:
error("illegal char after \\k");
lk_error("illegal char after \\k");
*pp = p+1;
return ("");
}
@ -471,8 +466,7 @@ tstr(pp, xlate)
* Skip leading spaces in a string.
*/
public char *
skipsp(s)
register char *s;
skipsp(char *s)
{
while (*s == ' ' || *s == '\t')
s++;
@ -483,8 +477,7 @@ skipsp(s)
* Skip non-space characters in a string.
*/
public char *
skipnsp(s)
register char *s;
skipnsp(char *s)
{
while (*s != '\0' && *s != ' ' && *s != '\t')
s++;
@ -496,10 +489,9 @@ skipnsp(s)
* strip off the trailing newline & any trailing # comment.
*/
char *
clean_line(s)
char *s;
clean_line(char *s)
{
register int i;
int i;
s = skipsp(s);
for (i = 0; s[i] != '\n' && s[i] != '\r' && s[i] != '\0'; i++)
@ -513,12 +505,11 @@ clean_line(s)
* Add a byte to the output command table.
*/
void
add_cmd_char(c)
int c;
add_cmd_char(int c)
{
if (currtable->pbuffer >= currtable->buffer + MAX_USERCMD)
{
error("too many commands");
lk_error("too many commands");
exit(1);
}
*(currtable->pbuffer)++ = c;
@ -528,8 +519,7 @@ add_cmd_char(c)
* Add a string to the output command table.
*/
void
add_cmd_str(s)
char *s;
add_cmd_str(char *s)
{
for ( ; *s != '\0'; s++)
add_cmd_char(*s);
@ -539,8 +529,7 @@ add_cmd_str(s)
* See if we have a special "control" line.
*/
int
control_line(s)
char *s;
control_line(char *s)
{
#define PREFIX(str,pat) (strncmp(str,pat,strlen(pat)) == 0)
@ -572,10 +561,7 @@ control_line(s)
* Output some bytes.
*/
void
fputbytes(fd, buf, len)
FILE *fd;
char *buf;
int len;
fputbytes(FILE *fd, char *buf, int len)
{
while (len-- > 0)
{
@ -588,9 +574,7 @@ fputbytes(fd, buf, len)
* Output an integer, in special KRADIX form.
*/
void
fputint(fd, val)
FILE *fd;
unsigned int val;
fputint(FILE *fd, unsigned int val)
{
char c;
@ -610,21 +594,19 @@ fputint(fd, val)
* Find an action, given the name of the action.
*/
int
findaction(actname)
char *actname;
findaction(char *actname)
{
int i;
for (i = 0; currtable->names[i].cn_name != NULL; i++)
if (strcmp(currtable->names[i].cn_name, actname) == 0)
return (currtable->names[i].cn_action);
error("unknown action");
lk_error("unknown action");
return (A_INVALID);
}
void
error(s)
char *s;
static void
lk_error(char *s)
{
fprintf(stderr, "line %d: %s\n", linenum, s);
errors++;
@ -632,8 +614,7 @@ error(s)
void
parse_cmdline(p)
char *p;
parse_cmdline(char *p)
{
int cmdlen;
char *actname;
@ -650,7 +631,7 @@ parse_cmdline(p)
s = tstr(&p, 1);
cmdlen += (int) strlen(s);
if (cmdlen > MAX_CMDLEN)
error("command too long");
lk_error("command too long");
else
add_cmd_str(s);
} while (*p != ' ' && *p != '\t' && *p != '\0');
@ -667,7 +648,7 @@ parse_cmdline(p)
p = skipsp(p);
if (*p == '\0')
{
error("missing action");
lk_error("missing action");
return;
}
actname = p;
@ -702,8 +683,7 @@ parse_cmdline(p)
}
void
parse_varline(p)
char *p;
parse_varline(char *p)
{
char *s;
@ -720,7 +700,7 @@ parse_varline(p)
p = skipsp(p);
if (*p++ != '=')
{
error("missing =");
lk_error("missing =");
return;
}
@ -739,8 +719,7 @@ parse_varline(p)
* Parse a line from the lesskey file.
*/
void
parse_line(line)
char *line;
parse_line(char *line)
{
char *p;
@ -765,9 +744,7 @@ parse_line(line)
}
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
FILE *desc;
FILE *out;

117
line.c
View File

@ -40,9 +40,9 @@ static POSITION pendpos;
static char *end_ansi_chars;
static char *mid_ansi_chars;
static int attr_swidth();
static int attr_ewidth();
static int do_append();
static int attr_swidth(int);
static int attr_ewidth(int);
static int do_append(LWCHAR, char *, POSITION);
extern int sigs;
extern int bs_mode;
@ -70,7 +70,7 @@ static POSITION mbc_pos;
* Initialize from environment variables.
*/
public void
init_line()
init_line(void)
{
end_ansi_chars = lgetenv("LESSANSIENDCHARS");
if (end_ansi_chars == NULL || *end_ansi_chars == '\0')
@ -89,7 +89,7 @@ init_line()
* Expand the line buffer.
*/
static int
expand_linebuf()
expand_linebuf(void)
{
/* Double the size of the line buffer. */
int new_size = size_linebuf * 2;
@ -137,8 +137,7 @@ expand_linebuf()
* Is a character ASCII?
*/
public int
is_ascii_char(ch)
LWCHAR ch;
is_ascii_char(LWCHAR ch)
{
return (ch <= 0x7F);
}
@ -147,7 +146,7 @@ is_ascii_char(ch)
* Rewind the line buffer.
*/
public void
prewind()
prewind(void)
{
curr = 0;
column = 0;
@ -166,11 +165,10 @@ prewind()
* Insert the line number (of the given position) into the line buffer.
*/
public void
plinenum(pos)
POSITION pos;
plinenum(POSITION pos)
{
register LINENUM linenum = 0;
register int i;
LINENUM linenum = 0;
int i;
if (linenums == OPT_ONPLUS)
{
@ -237,8 +235,7 @@ plinenum(pos)
* This means discarding N printable chars at the start of the buffer.
*/
static void
pshift(shift)
int shift;
pshift(int shift)
{
LWCHAR prev_ch = 0;
unsigned char c;
@ -355,7 +352,7 @@ pshift(shift)
*
*/
public void
pshift_all()
pshift_all(void)
{
pshift(column);
}
@ -365,8 +362,7 @@ pshift_all()
* for a given character attribute.
*/
static int
attr_swidth(a)
int a;
attr_swidth(int a)
{
int w = 0;
@ -389,8 +385,7 @@ attr_swidth(a)
* for a given character attribute.
*/
static int
attr_ewidth(a)
int a;
attr_ewidth(int a)
{
int w = 0;
@ -415,10 +410,7 @@ attr_ewidth(a)
* attribute sequence to be inserted, so this must be taken into account.
*/
static int
pwidth(ch, a, prev_ch)
LWCHAR ch;
int a;
LWCHAR prev_ch;
pwidth(LWCHAR ch, int a, LWCHAR prev_ch)
{
int w;
@ -479,10 +471,10 @@ pwidth(ch, a, prev_ch)
* Return 1 if one is found.
*/
static int
backc()
backc(void)
{
LWCHAR prev_ch;
char *p = linebuf + curr;
constant char *p = linebuf + curr;
LWCHAR ch = step_char(&p, -1, linebuf + lmargin);
int width;
@ -507,9 +499,9 @@ backc()
* Are we currently within a recognized ANSI escape sequence?
*/
static int
in_ansi_esc_seq()
in_ansi_esc_seq(void)
{
char *p;
constant char *p;
/*
* Search backwards for either an ESC (which means we ARE in a seq);
@ -530,8 +522,7 @@ in_ansi_esc_seq()
* Is a character the end of an ANSI escape sequence?
*/
public int
is_ansi_end(ch)
LWCHAR ch;
is_ansi_end(LWCHAR ch)
{
if (!is_ascii_char(ch))
return (0);
@ -542,8 +533,7 @@ is_ansi_end(ch)
*
*/
public int
is_ansi_middle(ch)
LWCHAR ch;
is_ansi_middle(LWCHAR ch)
{
if (!is_ascii_char(ch))
return (0);
@ -561,11 +551,7 @@ is_ansi_middle(ch)
} while (0)
static int
store_char(ch, a, rep, pos)
LWCHAR ch;
int a;
char *rep;
POSITION pos;
store_char(LWCHAR ch, int a, char *rep, POSITION pos)
{
int w;
int replen;
@ -599,7 +585,7 @@ store_char(ch, a, rep, pos)
{
if (!is_ansi_end(ch) && !is_ansi_middle(ch)) {
/* Remove whole unrecognized sequence. */
char *p = &linebuf[curr];
constant char *p = &linebuf[curr];
LWCHAR bch;
do {
bch = step_char(&p, -1, linebuf);
@ -617,7 +603,7 @@ store_char(ch, a, rep, pos)
}
else
{
char *p = &linebuf[curr];
constant char *p = &linebuf[curr];
LWCHAR prev_ch = step_char(&p, -1, linebuf);
w = pwidth(ch, a, prev_ch);
}
@ -665,9 +651,7 @@ store_char(ch, a, rep, pos)
do { if (store_tab((a),(pos))) return (1); } while (0)
static int
store_tab(attr, pos)
int attr;
POSITION pos;
store_tab(int attr, POSITION pos)
{
int to_tab = column + cshift - lmargin;
int i;
@ -696,9 +680,7 @@ store_tab(attr, pos)
do { if (store_prchar((c), (pos))) return 1; } while (0)
static int
store_prchar(c, pos)
LWCHAR c;
POSITION pos;
store_prchar(LWCHAR c, POSITION pos)
{
char *s;
@ -722,8 +704,7 @@ store_prchar(c, pos)
}
static int
flush_mbc_buf(pos)
POSITION pos;
flush_mbc_buf(POSITION pos)
{
int i;
@ -740,9 +721,7 @@ flush_mbc_buf(pos)
* Returns 0 if ok, 1 if couldn't fit in buffer.
*/
public int
pappend(c, pos)
unsigned char c;
POSITION pos;
pappend(unsigned char c, POSITION pos)
{
int r;
@ -845,12 +824,9 @@ pappend(c, pos)
}
static int
do_append(ch, rep, pos)
LWCHAR ch;
char *rep;
POSITION pos;
do_append(LWCHAR ch, char *rep, POSITION pos)
{
register int a;
int a;
LWCHAR prev_ch;
a = AT_NORMAL;
@ -985,7 +961,7 @@ do_append(ch, rep, pos)
*
*/
public int
pflushmbc()
pflushmbc(void)
{
int r = 0;
@ -1002,9 +978,7 @@ pflushmbc()
* Terminate the line in the line buffer.
*/
public void
pdone(endline, forw)
int endline;
int forw;
pdone(int endline, int forw)
{
(void) pflushmbc();
@ -1081,8 +1055,7 @@ pdone(endline, forw)
*
*/
public void
set_status_col(c)
char c;
set_status_col(char c)
{
linebuf[0] = c;
attr[0] = AT_NORMAL|AT_HILITE;
@ -1094,9 +1067,7 @@ set_status_col(c)
* and the character attribute in *ap.
*/
public int
gline(i, ap)
register int i;
register int *ap;
gline(int i, int *ap)
{
if (is_null_line)
{
@ -1126,7 +1097,7 @@ gline(i, ap)
* Indicate that there is no current line.
*/
public void
null_line()
null_line(void)
{
is_null_line = 1;
cshift = 0;
@ -1138,13 +1109,10 @@ null_line()
* {{ This is supposed to be more efficient than forw_line(). }}
*/
public POSITION
forw_raw_line(curr_pos, linep, line_lenp)
POSITION curr_pos;
char **linep;
int *line_lenp;
forw_raw_line(POSITION curr_pos, char **linep, int *line_lenp)
{
register int n;
register int c;
int n;
int c;
POSITION new_pos;
if (curr_pos == NULL_POSITION || ch_seek(curr_pos) ||
@ -1187,13 +1155,10 @@ forw_raw_line(curr_pos, linep, line_lenp)
* {{ This is supposed to be more efficient than back_line(). }}
*/
public POSITION
back_raw_line(curr_pos, linep, line_lenp)
POSITION curr_pos;
char **linep;
int *line_lenp;
back_raw_line(POSITION curr_pos, char **linep, int *line_lenp)
{
register int n;
register int c;
int n;
int c;
POSITION new_pos;
if (curr_pos == NULL_POSITION || curr_pos <= ch_zero() ||

View File

@ -73,9 +73,9 @@ extern int screen_trashed;
* Initialize the line number structures.
*/
public void
clr_linenum()
clr_linenum(void)
{
register struct linenum_info *p;
struct linenum_info *p;
/*
* Put all the entries on the free list.
@ -101,8 +101,7 @@ clr_linenum()
* Calculate the gap for an entry.
*/
static void
calcgap(p)
register struct linenum_info *p;
calcgap(struct linenum_info *p)
{
/*
* Don't bother to compute a gap for the anchor.
@ -121,15 +120,13 @@ calcgap(p)
* FIRST character in the specified line.
*/
public void
add_lnum(linenum, pos)
LINENUM linenum;
POSITION pos;
add_lnum(LINENUM linenum, POSITION pos)
{
register struct linenum_info *p;
register struct linenum_info *new;
register struct linenum_info *nextp;
register struct linenum_info *prevp;
register POSITION mingap;
struct linenum_info *p;
struct linenum_info *new;
struct linenum_info *nextp;
struct linenum_info *prevp;
POSITION mingap;
/*
* Find the proper place in the list for the new one.
@ -209,7 +206,7 @@ add_lnum(linenum, pos)
* line number, print a message to tell the user what we're doing.
*/
static void
longloopmessage()
longloopmessage(void)
{
ierror("Calculating line numbers", NULL_PARG);
}
@ -220,7 +217,7 @@ static time_type startime;
#endif
static void
longish()
longish(void)
{
#if HAVE_TIME
if (loopcount >= 0 && ++loopcount > 100)
@ -246,7 +243,7 @@ longish()
* a lengthy line number calculation.
*/
static void
abort_long()
abort_long(void)
{
if (linenums == OPT_ONPLUS)
/*
@ -262,11 +259,10 @@ abort_long()
* Return 0 if we can't figure it out.
*/
public LINENUM
find_linenum(pos)
POSITION pos;
find_linenum(POSITION pos)
{
register struct linenum_info *p;
register LINENUM linenum;
struct linenum_info *p;
LINENUM linenum;
POSITION cpos;
if (!linenums)
@ -377,10 +373,9 @@ find_linenum(pos)
* Return NULL_POSITION if we can't figure it out.
*/
public POSITION
find_pos(linenum)
LINENUM linenum;
find_pos(LINENUM linenum)
{
register struct linenum_info *p;
struct linenum_info *p;
POSITION cpos;
LINENUM clinenum;
@ -450,8 +445,7 @@ find_pos(linenum)
* the "current" line (e.g. TOP, BOTTOM, MIDDLE, etc).
*/
public LINENUM
currline(where)
int where;
currline(int where)
{
POSITION pos;
POSITION len;

View File

@ -38,14 +38,12 @@ extern IFILE curr_ifile;
* Like plain "system()", but handles resetting terminal modes, etc.
*/
public void
lsystem(cmd, donemsg)
char *cmd;
char *donemsg;
lsystem(char *cmd, char *donemsg)
{
register int inp;
int inp;
#if HAVE_SHELL
register char *shell;
register char *p;
char *shell;
char *p;
#endif
IFILE save_ifile;
#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
@ -250,9 +248,7 @@ lsystem(cmd, donemsg)
* the whole current screen is piped.
*/
public int
pipe_mark(c, cmd)
int c;
char *cmd;
pipe_mark(int c, char *cmd)
{
POSITION mpos, tpos, bpos;
@ -284,13 +280,10 @@ pipe_mark(c, cmd)
* Feed it the file contents between the positions spos and epos.
*/
public int
pipe_data(cmd, spos, epos)
char *cmd;
POSITION spos;
POSITION epos;
pipe_data(char *cmd, POSITION spos, POSITION epos)
{
register FILE *f;
register int c;
FILE *f;
int c;
extern FILE *popen();
/*

28
main.c
View File

@ -291,10 +291,9 @@ main(argc, argv)
* (that is, to a buffer allocated by calloc).
*/
public char *
save(s)
char *s;
save(constant char *s)
{
register char *p;
char *p;
p = (char *) ecalloc(strlen(s)+1, sizeof(char));
strcpy(p, s);
@ -306,11 +305,9 @@ save(s)
* Like calloc(), but never returns an error (NULL).
*/
public VOID_POINTER
ecalloc(count, size)
int count;
unsigned int size;
ecalloc(int count, unsigned int size)
{
register VOID_POINTER p;
VOID_POINTER p;
p = (VOID_POINTER) calloc(count, size);
if (p != NULL)
@ -325,8 +322,7 @@ ecalloc(count, size)
* Skip leading spaces in a string.
*/
public char *
skipsp(s)
register char *s;
skipsp(char *s)
{
while (*s == ' ' || *s == '\t')
s++;
@ -339,14 +335,11 @@ skipsp(s)
* character; the remainder of the first string may be either case.
*/
public int
sprefix(ps, s, uppercase)
char *ps;
char *s;
int uppercase;
sprefix(char *ps, char *s, int uppercase)
{
register int c;
register int sc;
register int len = 0;
int c;
int sc;
int len = 0;
for ( ; *s != '\0'; s++, ps++)
{
@ -372,8 +365,7 @@ sprefix(ps, s, uppercase)
* Exit the program.
*/
public void
quit(status)
int status;
quit(int status)
{
static int save_status;

33
mark.c
View File

@ -27,7 +27,7 @@ static struct mark marks[NMARKS];
* Initialize the mark table to show no marks are set.
*/
public void
init_mark()
init_mark(void)
{
int i;
@ -39,8 +39,7 @@ init_mark()
* See if a mark letter is valid (between a and z).
*/
static struct mark *
getumark(c)
int c;
getumark(int c)
{
if (c >= 'a' && c <= 'z')
return (&marks[c-'a']);
@ -58,10 +57,9 @@ getumark(c)
* or may be constructed on the fly for certain characters like ^, $.
*/
static struct mark *
getmark(c)
int c;
getmark(int c)
{
register struct mark *m;
struct mark *m;
static struct mark sm;
switch (c)
@ -124,8 +122,7 @@ getmark(c)
* Is a mark letter is invalid?
*/
public int
badmark(c)
int c;
badmark(int c)
{
return (getmark(c) == NULL);
}
@ -134,10 +131,9 @@ badmark(c)
* Set a user-defined mark.
*/
public void
setmark(c)
int c;
setmark(int c)
{
register struct mark *m;
struct mark *m;
struct scrpos scrpos;
m = getumark(c);
@ -152,7 +148,7 @@ setmark(c)
* Set lmark (the mark named by the apostrophe).
*/
public void
lastmark()
lastmark(void)
{
struct scrpos scrpos;
@ -169,10 +165,9 @@ lastmark()
* Go to a mark.
*/
public void
gomark(c)
int c;
gomark(int c)
{
register struct mark *m;
struct mark *m;
struct scrpos scrpos;
m = getmark(c);
@ -217,10 +212,9 @@ gomark(c)
* because it's always the first non-blank line on the screen.
*/
public POSITION
markpos(c)
int c;
markpos(int c)
{
register struct mark *m;
struct mark *m;
m = getmark(c);
if (m == NULL)
@ -238,8 +232,7 @@ markpos(c)
* Clear the marks associated with a specified ifile.
*/
public void
unmark(ifile)
IFILE ifile;
unmark(IFILE ifile)
{
int i;

View File

@ -18,9 +18,7 @@
#include <stdio.h>
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
int ch;
int prevch;

View File

@ -75,9 +75,7 @@ extern int bl_fg_color, bl_bg_color;
* Handler for -o option.
*/
public void
opt_o(type, s)
int type;
char *s;
opt_o(int type, char *s)
{
PARG parg;
@ -125,9 +123,7 @@ opt_o(type, s)
* Handler for -O option.
*/
public void
opt__O(type, s)
int type;
char *s;
opt__O(int type, char *s)
{
force_logfile = TRUE;
opt_o(type, s);
@ -138,9 +134,7 @@ opt__O(type, s)
* Handlers for -j option.
*/
public void
opt_j(type, s)
int type;
char *s;
opt_j(int type, char *s)
{
PARG parg;
char buf[16];
@ -192,7 +186,7 @@ opt_j(type, s)
}
public void
calc_jump_sline()
calc_jump_sline(void)
{
if (jump_sline_fraction < 0)
return;
@ -203,9 +197,7 @@ calc_jump_sline()
* Handlers for -# option.
*/
public void
opt_shift(type, s)
int type;
char *s;
opt_shift(int type, char *s)
{
PARG parg;
char buf[16];
@ -256,7 +248,7 @@ opt_shift(type, s)
}
}
public void
calc_shift_count()
calc_shift_count(void)
{
if (shift_count_fraction < 0)
return;
@ -265,9 +257,7 @@ calc_shift_count()
#if USERFILE
public void
opt_k(type, s)
int type;
char *s;
opt_k(int type, char *s)
{
PARG parg;
@ -289,9 +279,7 @@ opt_k(type, s)
* Handler for -t option.
*/
public void
opt_t(type, s)
int type;
char *s;
opt_t(int type, char *s)
{
IFILE save_ifile;
POSITION pos;
@ -330,9 +318,7 @@ opt_t(type, s)
* Handler for -T option.
*/
public void
opt__T(type, s)
int type;
char *s;
opt__T(int type, char *s)
{
PARG parg;
@ -359,9 +345,7 @@ opt__T(type, s)
* Handler for -p option.
*/
public void
opt_p(type, s)
int type;
register char *s;
opt_p(int type, char *s)
{
switch (type)
{
@ -395,11 +379,9 @@ opt_p(type, s)
* Handler for -P option.
*/
public void
opt__P(type, s)
int type;
register char *s;
opt__P(int type, char *s)
{
register char **proto;
char **proto;
PARG parg;
switch (type)
@ -434,9 +416,7 @@ opt__P(type, s)
*/
/*ARGSUSED*/
public void
opt_b(type, s)
int type;
char *s;
opt_b(int type, char *s)
{
switch (type)
{
@ -457,9 +437,7 @@ opt_b(type, s)
*/
/*ARGSUSED*/
public void
opt_i(type, s)
int type;
char *s;
opt_i(int type, char *s)
{
switch (type)
{
@ -477,9 +455,7 @@ opt_i(type, s)
*/
/*ARGSUSED*/
public void
opt__V(type, s)
int type;
char *s;
opt__V(int type, char *s)
{
switch (type)
{
@ -532,10 +508,7 @@ opt__V(type, s)
* Parse an MSDOS color descriptor.
*/
static void
colordesc(s, fg_color, bg_color)
char *s;
int *fg_color;
int *bg_color;
colordesc(char *s, int *fg_color, int *bg_color)
{
int fg, bg;
int err;
@ -569,9 +542,7 @@ colordesc(s, fg_color, bg_color)
*/
/*ARGSUSED*/
public void
opt_D(type, s)
int type;
char *s;
opt_D(int type, char *s)
{
switch (type)
{
@ -614,9 +585,7 @@ opt_D(type, s)
* Handler for the -x option.
*/
public void
opt_x(type, s)
int type;
register char *s;
opt_x(int type, char *s)
{
extern int tabstops[];
extern int ntabstops;
@ -672,9 +641,7 @@ opt_x(type, s)
* Handler for the -" option.
*/
public void
opt_quote(type, s)
int type;
register char *s;
opt_quote(int type, char *s)
{
char buf[3];
PARG parg;
@ -715,9 +682,7 @@ opt_quote(type, s)
*/
/*ARGSUSED*/
public void
opt_query(type, s)
int type;
char *s;
opt_query(int type, char *s)
{
switch (type)
{
@ -734,7 +699,7 @@ opt_query(type, s)
* Get the "screen window" size.
*/
public int
get_swindow()
get_swindow(void)
{
if (swindow > 0)
return (swindow);

View File

@ -23,8 +23,8 @@
static struct loption *pendopt;
public int plusoption = FALSE;
static char *optstring();
static int flip_triple();
static char *optstring(char *s, char **p_str, char *printopt, char *validchars);
static int flip_triple(int val, int lc);
extern int screen_trashed;
extern int less_is_more;
@ -36,8 +36,7 @@ extern int opt_use_backslash;
* Return a printable description of an option.
*/
static char *
opt_desc(o)
struct loption *o;
opt_desc(struct loption *o)
{
static char buf[OPTNAME_MAX + 10];
if (o->oletter == OLETTER_NONE)
@ -52,8 +51,7 @@ opt_desc(o)
* For example, if the option letter is 'x', just return "-x".
*/
public char *
propt(c)
int c;
propt(int c)
{
static char buf[8];
@ -66,11 +64,10 @@ propt(c)
* LESS environment variable) and process it.
*/
public void
scan_option(s)
char *s;
scan_option(char *s)
{
register struct loption *o;
register int optc;
struct loption *o;
int optc;
char *optname;
char *printopt;
char *str;
@ -299,13 +296,9 @@ scan_option(s)
* OPT_SET set to the inverse of the default value
*/
public void
toggle_option(o, lower, s, how_toggle)
struct loption *o;
int lower;
char *s;
int how_toggle;
toggle_option(struct loption *o, int lower, char *s, int how_toggle)
{
register int num;
int num;
int no_prompt;
int err;
PARG parg;
@ -485,9 +478,7 @@ toggle_option(o, lower, s, how_toggle)
* "Toggle" a triple-valued option.
*/
static int
flip_triple(val, lc)
int val;
int lc;
flip_triple(int val, int lc)
{
if (lc)
return ((val == OPT_ON) ? OPT_OFF : OPT_ON);
@ -499,8 +490,7 @@ flip_triple(val, lc)
* Determine if an option takes a parameter.
*/
public int
opt_has_param(o)
struct loption *o;
opt_has_param(struct loption *o)
{
if (o == NULL)
return (0);
@ -514,8 +504,7 @@ opt_has_param(o)
* Only string and number valued options have prompts.
*/
public char *
opt_prompt(o)
struct loption *o;
opt_prompt(struct loption *o)
{
if (o == NULL || (o->otype & (STRING|NUMBER)) == 0)
return ("?");
@ -530,7 +519,7 @@ opt_prompt(o)
* the previous option.
*/
public int
isoptpending()
isoptpending(void)
{
return (pendopt != NULL);
}
@ -539,8 +528,7 @@ isoptpending()
* Print error message about missing string.
*/
static void
nostring(printopt)
char *printopt;
nostring(char *printopt)
{
PARG parg;
parg.p_string = printopt;
@ -551,7 +539,7 @@ nostring(printopt)
* Print error message if a STRING type option is not followed by a string.
*/
public void
nopendopt()
nopendopt(void)
{
nostring(opt_desc(pendopt));
}
@ -562,14 +550,10 @@ nopendopt()
* Return a pointer to the remainder of the string, if any.
*/
static char *
optstring(s, p_str, printopt, validchars)
char *s;
char **p_str;
char *printopt;
char *validchars;
optstring(char *s, char **p_str, char *printopt, char *validchars)
{
register char *p;
register char *out;
char *p;
char *out;
if (*s == '\0')
{
@ -602,9 +586,7 @@ optstring(s, p_str, printopt, validchars)
/*
*/
static int
num_error(printopt, errp)
char *printopt;
int *errp;
num_error(char *printopt, int *errp)
{
PARG parg;
@ -627,14 +609,11 @@ num_error(printopt, errp)
* the char * to point after the translated number.
*/
public int
getnum(sp, printopt, errp)
char **sp;
char *printopt;
int *errp;
getnum(char **sp, char *printopt, int *errp)
{
register char *s;
register int n;
register int neg;
char *s;
int n;
int neg;
s = skipsp(*sp);
neg = FALSE;
@ -664,12 +643,9 @@ getnum(sp, printopt, errp)
* That is, if "n" is returned, the fraction intended is n/NUM_FRAC_DENOM.
*/
public long
getfraction(sp, printopt, errp)
char **sp;
char *printopt;
int *errp;
getfraction(char **sp, char *printopt, int *errp)
{
register char *s;
char *s;
long frac = 0;
int fraclen = 0;
@ -699,7 +675,7 @@ getfraction(sp, printopt, errp)
* Get the value of the -e flag.
*/
public int
get_quit_at_eof()
get_quit_at_eof(void)
{
if (!less_is_more)
return quit_at_eof;

View File

@ -464,9 +464,9 @@ static struct loption option[] =
* Initialize each option to its default value.
*/
public void
init_option()
init_option(void)
{
register struct loption *o;
struct loption *o;
char *p;
p = lgetenv("LESS_IS_MORE");
@ -489,10 +489,9 @@ init_option()
* Find an option in the option table, given its option letter.
*/
public struct loption *
findopt(c)
int c;
findopt(int c)
{
register struct loption *o;
struct loption *o;
for (o = option; o->oletter != '\0'; o++)
{
@ -508,8 +507,7 @@ findopt(c)
*
*/
static int
is_optchar(c)
char c;
is_optchar(char c)
{
if (ASCII_IS_UPPER(c))
return 1;
@ -527,15 +525,12 @@ is_optchar(c)
* p_oname if non-NULL is set to point to the full option name.
*/
public struct loption *
findopt_name(p_optname, p_oname, p_err)
char **p_optname;
char **p_oname;
int *p_err;
findopt_name(char **p_optname, char **p_oname, int *p_err)
{
char *optname = *p_optname;
register struct loption *o;
register struct optname *oname;
register int len;
struct loption *o;
struct optname *oname;
int len;
int uppercase;
struct loption *maxo = NULL;
struct optname *maxoname = NULL;

36
os.c
View File

@ -60,12 +60,9 @@ extern int sigs;
* any pending iread().
*/
public int
iread(fd, buf, len)
int fd;
char *buf;
unsigned int len;
iread(int fd, char *buf, unsigned int len)
{
register int n;
int n;
start:
#if MSDOS_COMPILER==WIN32C
@ -176,7 +173,7 @@ start:
* Interrupt a pending iread().
*/
public void
intread()
intread(void)
{
LONG_JUMP(read_label, 1);
}
@ -186,7 +183,7 @@ intread()
*/
#if HAVE_TIME
public time_type
get_time()
get_time(void)
{
time_type t;
@ -201,8 +198,7 @@ get_time()
* Local version of strerror, if not available from the system.
*/
static char *
strerror(err)
int err;
strerror(int err)
{
#if HAVE_SYS_ERRLIST
static char buf[16];
@ -223,11 +219,10 @@ strerror(err)
* errno_message: Return an error message based on the value of "errno".
*/
public char *
errno_message(filename)
char *filename;
errno_message(char *filename)
{
register char *p;
register char *m;
char *p;
char *m;
int len;
#if HAVE_ERRNO
#if MUST_DEFINE_ERRNO
@ -246,8 +241,7 @@ errno_message(filename)
/* #define HAVE_FLOAT 0 */
static POSITION
muldiv(val, num, den)
POSITION val, num, den;
muldiv(POSITION val, POSITION num, POSITION den)
{
#if HAVE_FLOAT
double v = (((double) val) * num) / den;
@ -270,8 +264,7 @@ muldiv(val, num, den)
* {{ Assumes a POSITION is a long int. }}
*/
public int
percentage(num, den)
POSITION num, den;
percentage(POSITION num, POSITION den)
{
return (int) muldiv(num, (POSITION) 100, den);
}
@ -280,10 +273,7 @@ percentage(num, den)
* Return the specified percentage of a POSITION.
*/
public POSITION
percent_pos(pos, percent, fraction)
POSITION pos;
int percent;
long fraction;
percent_pos(POSITION pos, int percent, long fraction)
{
/* Change percent (parts per 100) to perden (parts per NUM_FRAC_DENOM). */
POSITION perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
@ -334,9 +324,7 @@ memcpy(dst, src, len)
* This implements an ANSI-style intercept setup for Microware C 3.2
*/
public int
os9_signal(type, handler)
int type;
RETSIGTYPE (*handler)();
os9_signal(int type, RETSIGTYPE (*handler)())
{
intercept(handler);
}

View File

@ -43,10 +43,10 @@ extern int bl_fg_color, bl_bg_color;
* Display the line which is in the line buffer.
*/
public void
put_line()
put_line(void)
{
register int c;
register int i;
int c;
int i;
int a;
if (ABORT_SIGS())
@ -93,10 +93,10 @@ static char *ob = obuf;
* overwritten or scrolled away.
*/
public void
flush()
flush(void)
{
register int n;
register int fd;
int n;
int fd;
n = (int) (ob - obuf);
if (n == 0)
@ -326,8 +326,7 @@ flush()
* Output a character.
*/
public int
putchr(c)
int c;
putchr(int c)
{
#if 0 /* fake UTF-8 output for testing */
extern int utf_mode;
@ -380,8 +379,7 @@ putchr(c)
* Output a string.
*/
public void
putstr(s)
register char *s;
putstr(constant char *s)
{
while (*s != '\0')
putchr(*s++);
@ -398,7 +396,7 @@ void funcname(num, buf) \
{ \
int neg = (num < 0); \
char tbuf[INT_STRLEN_BOUND(num)+2]; \
register char *s = tbuf + sizeof(tbuf); \
char *s = tbuf + sizeof(tbuf); \
if (neg) num = -num; \
*--s = '\0'; \
do { \
@ -416,8 +414,7 @@ TYPE_TO_A_FUNC(inttoa, int)
* Output an integer in a given radix.
*/
static int
iprint_int(num)
int num;
iprint_int(int num)
{
char buf[INT_STRLEN_BOUND(num)];
@ -430,8 +427,7 @@ iprint_int(num)
* Output a line number in a given radix.
*/
static int
iprint_linenum(num)
LINENUM num;
iprint_linenum(LINENUM num)
{
char buf[INT_STRLEN_BOUND(num)];
@ -445,12 +441,10 @@ iprint_linenum(num)
* using a more portable argument list mechanism than printf's.
*/
static int
less_printf(fmt, parg)
register char *fmt;
PARG *parg;
less_printf(char *fmt, PARG *parg)
{
register char *s;
register int col;
char *s;
int col;
col = 0;
while (*fmt != '\0')
@ -493,7 +487,7 @@ less_printf(fmt, parg)
* become the next command.
*/
public void
get_return()
get_return(void)
{
int c;
@ -512,9 +506,7 @@ get_return()
* and wait for carriage return.
*/
public void
error(fmt, parg)
char *fmt;
PARG *parg;
error(char *fmt, PARG *parg)
{
int col = 0;
static char return_to_continue[] = " (press RETURN)";
@ -567,9 +559,7 @@ static char intr_to_abort[] = "... (interrupt to abort)";
* time-consuming operation.
*/
public void
ierror(fmt, parg)
char *fmt;
PARG *parg;
ierror(char *fmt, PARG *parg)
{
at_exit();
clear_bot();
@ -586,11 +576,9 @@ ierror(fmt, parg)
* and return a single-character response.
*/
public int
query(fmt, parg)
char *fmt;
PARG *parg;
query(char *fmt, PARG *parg)
{
register int c;
int c;
int col = 0;
if (any_display && is_tty)

View File

@ -20,11 +20,7 @@ extern int caseless;
* Compile a search pattern, for future use by match_pattern.
*/
static int
compile_pattern2(pattern, search_type, comp_pattern, show_error)
char *pattern;
int search_type;
void **comp_pattern;
int show_error;
compile_pattern2(char *pattern, int search_type, void **comp_pattern, int show_error)
{
if (search_type & SRCH_NO_REGEX)
return (0);
@ -127,10 +123,7 @@ compile_pattern2(pattern, search_type, comp_pattern, show_error)
* Like compile_pattern2, but convert the pattern to lowercase if necessary.
*/
public int
compile_pattern(pattern, search_type, comp_pattern)
char *pattern;
int search_type;
void **comp_pattern;
compile_pattern(char *pattern, int search_type, void **comp_pattern)
{
char *cvt_pattern;
int result;
@ -152,8 +145,7 @@ compile_pattern(pattern, search_type, comp_pattern)
* Forget that we have a compiled pattern.
*/
public void
uncompile_pattern(pattern)
void **pattern;
uncompile_pattern(void **pattern)
{
#if HAVE_GNU_REGEX
struct re_pattern_buffer **pcomp = (struct re_pattern_buffer **) pattern;
@ -195,8 +187,7 @@ uncompile_pattern(pattern)
* Can a pattern be successfully compiled?
*/
public int
valid_pattern(pattern)
char *pattern;
valid_pattern(char *pattern)
{
void *comp_pattern;
int result;
@ -213,8 +204,7 @@ valid_pattern(pattern)
* Is a compiled pattern null?
*/
public int
is_null_pattern(pattern)
void *pattern;
is_null_pattern(void *pattern)
{
#if HAVE_GNU_REGEX
return (pattern == NULL);
@ -244,16 +234,11 @@ is_null_pattern(pattern)
* It supports no metacharacters like *, etc.
*/
static int
match(pattern, pattern_len, buf, buf_len, pfound, pend)
char *pattern;
int pattern_len;
char *buf;
int buf_len;
char **pfound, **pend;
match(char *pattern, int pattern_len, char *buf, int buf_len, char **pfound, char **pend)
{
register char *pp, *lp;
register char *pattern_end = pattern + pattern_len;
register char *buf_end = buf + buf_len;
char *pp, *lp;
char *pattern_end = pattern + pattern_len;
char *buf_end = buf + buf_len;
for ( ; buf < buf_end; buf++)
{
@ -285,15 +270,7 @@ match(pattern, pattern_len, buf, buf_len, pfound, pend)
* Set sp and ep to the start and end of the matched string.
*/
public int
match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type)
void *pattern;
char *tpattern;
char *line;
int line_len;
char **sp;
char **ep;
int notbol;
int search_type;
match_pattern(void *pattern, char *tpattern, char *line, int line_len, char **sp, char **ep, int notbol, int search_type)
{
int matched;
#if HAVE_GNU_REGEX

View File

@ -36,8 +36,7 @@ extern int sc_width, sc_height;
* the line after the bottom line on the screen
*/
public POSITION
position(where)
int where;
position(int where)
{
switch (where)
{
@ -57,10 +56,9 @@ position(where)
* Add a new file position to the bottom of the position table.
*/
public void
add_forw_pos(pos)
POSITION pos;
add_forw_pos(POSITION pos)
{
register int i;
int i;
/*
* Scroll the position table up.
@ -74,10 +72,9 @@ add_forw_pos(pos)
* Add a new file position to the top of the position table.
*/
public void
add_back_pos(pos)
POSITION pos;
add_back_pos(POSITION pos)
{
register int i;
int i;
/*
* Scroll the position table down.
@ -91,9 +88,9 @@ add_back_pos(pos)
* Initialize the position table, done whenever we clear the screen.
*/
public void
pos_clear()
pos_clear(void)
{
register int i;
int i;
for (i = 0; i < sc_height; i++)
table[i] = NULL_POSITION;
@ -103,7 +100,7 @@ pos_clear()
* Allocate or reallocate the position table.
*/
public void
pos_init()
pos_init(void)
{
struct scrpos scrpos;
@ -132,10 +129,9 @@ pos_init()
* Return the position table entry if found, -1 if not.
*/
public int
onscreen(pos)
POSITION pos;
onscreen(POSITION pos)
{
register int i;
int i;
if (pos < table[0])
return (-1);
@ -149,17 +145,15 @@ onscreen(pos)
* See if the entire screen is empty.
*/
public int
empty_screen()
empty_screen(void)
{
return (empty_lines(0, sc_height-1));
}
public int
empty_lines(s, e)
int s;
int e;
empty_lines(int s, int e)
{
register int i;
int i;
for (i = s; i <= e; i++)
if (table[i] != NULL_POSITION && table[i] != 0)
@ -176,10 +170,9 @@ empty_lines(s, e)
* the screen line to a number > 0.
*/
public void
get_scrpos(scrpos)
struct scrpos *scrpos;
get_scrpos(struct scrpos *scrpos)
{
register int i;
int i;
/*
* Find the first line on the screen which has something on it,
@ -208,8 +201,7 @@ get_scrpos(scrpos)
* relative to the bottom of the screen.
*/
public int
adjsline(sline)
int sline;
adjsline(int sline)
{
/*
* Negative screen line number means

View File

@ -66,7 +66,7 @@ static char *mp;
* Initialize the prompt prototype strings.
*/
public void
init_prompt()
init_prompt(void)
{
prproto[0] = save(s_proto);
prproto[1] = save(less_is_more ? more_proto : m_proto);
@ -80,8 +80,7 @@ init_prompt()
* Append a string to the end of the message.
*/
static void
ap_str(s)
char *s;
ap_str(char *s)
{
int len;
@ -97,8 +96,7 @@ ap_str(s)
* Append a character to the end of the message.
*/
static void
ap_char(c)
char c;
ap_char(char c)
{
char buf[2];
@ -111,8 +109,7 @@ ap_char(c)
* Append a POSITION (as a decimal integer) to the end of the message.
*/
static void
ap_pos(pos)
POSITION pos;
ap_pos(POSITION pos)
{
char buf[INT_STRLEN_BOUND(pos) + 2];
@ -124,8 +121,7 @@ ap_pos(pos)
* Append a line number to the end of the message.
*/
static void
ap_linenum(linenum)
LINENUM linenum;
ap_linenum(LINENUM linenum)
{
char buf[INT_STRLEN_BOUND(linenum) + 2];
@ -137,8 +133,7 @@ ap_linenum(linenum)
* Append an integer to the end of the message.
*/
static void
ap_int(num)
int num;
ap_int(int num)
{
char buf[INT_STRLEN_BOUND(num) + 2];
@ -150,7 +145,7 @@ ap_int(num)
* Append a question mark to the end of the message.
*/
static void
ap_quest()
ap_quest(void)
{
ap_str("?");
}
@ -159,8 +154,7 @@ ap_quest()
* Return the "current" byte offset in the file.
*/
static POSITION
curr_byte(where)
int where;
curr_byte(int where)
{
POSITION pos;
@ -179,9 +173,7 @@ curr_byte(where)
* Here we decode that letter and return the appropriate boolean value.
*/
static int
cond(c, where)
char c;
int where;
cond(char c, int where)
{
POSITION len;
@ -243,10 +235,7 @@ cond(c, where)
* usually by appending something to the message being built.
*/
static void
protochar(c, where, iseditproto)
int c;
int where;
int iseditproto;
protochar(int c, int where, int iseditproto)
{
POSITION pos;
POSITION len;
@ -393,10 +382,9 @@ protochar(c, where, iseditproto)
* We must keep track of nested IFs and skip them properly.
*/
static constant char *
skipcond(p)
register constant char *p;
skipcond(constant char *p)
{
register int iflevel;
int iflevel;
/*
* We came in here after processing a ? or :,
@ -451,9 +439,7 @@ skipcond(p)
* Decode a char that represents a position on the screen.
*/
static constant char *
wherechar(p, wp)
char constant *p;
int *wp;
wherechar(char constant *p, int *wp)
{
switch (*p)
{
@ -475,12 +461,10 @@ wherechar(p, wp)
* Construct a message based on a prototype string.
*/
public char *
pr_expand(proto, maxwidth)
constant char *proto;
int maxwidth;
pr_expand(constant char *proto, int maxwidth)
{
register constant char *p;
register int c;
constant char *p;
int c;
int where;
mp = message;
@ -551,7 +535,7 @@ pr_expand(proto, maxwidth)
* Return a message suitable for printing by the "=" command.
*/
public char *
eq_message()
eq_message(void)
{
return (pr_expand(eqproto, 0));
}
@ -563,7 +547,7 @@ eq_message()
* and the caller will prompt with a colon.
*/
public char *
pr_string()
pr_string(void)
{
char *prompt;
int type;
@ -580,7 +564,7 @@ pr_string()
* Return a message suitable for printing while waiting in the F command.
*/
public char *
wait_message()
wait_message(void)
{
return (pr_expand(wproto, sc_width-so_s_width-so_e_width-2));
}

176
regexp.c
View File

@ -207,13 +207,12 @@ STATIC int strcspn();
* of the structure of the compiled regexp.
*/
regexp *
regcomp(exp)
char *exp;
regcomp(char *exp)
{
register regexp *r;
register char *scan;
register char *longest;
register int len;
regexp *r;
char *scan;
char *longest;
int len;
int flags;
if (exp == NULL)
@ -297,14 +296,12 @@ char *exp;
* follows makes it hard to avoid.
*/
static char *
reg(paren, flagp)
int paren; /* Parenthesized? */
int *flagp;
reg(int paren, int *flagp)
{
register char *ret;
register char *br;
register char *ender;
register int parno = 0;
char *ret;
char *br;
char *ender;
int parno = 0;
int flags;
*flagp = HASWIDTH; /* Tentatively. */
@ -369,12 +366,11 @@ int *flagp;
* Implements the concatenation operator.
*/
static char *
regbranch(flagp)
int *flagp;
regbranch(int *flagp)
{
register char *ret;
register char *chain;
register char *latest;
char *ret;
char *chain;
char *latest;
int flags;
*flagp = WORST; /* Tentatively. */
@ -408,12 +404,11 @@ int *flagp;
* endmarker role is not redundant.
*/
static char *
regpiece(flagp)
int *flagp;
regpiece(int *flagp)
{
register char *ret;
register char op;
register char *next;
char *ret;
char op;
char *next;
int flags;
ret = regatom(&flags);
@ -472,10 +467,9 @@ int *flagp;
* separate node; the code is simpler that way and it's not worth fixing.
*/
static char *
regatom(flagp)
int *flagp;
regatom(int *flagp)
{
register char *ret;
char *ret;
int flags;
*flagp = WORST; /* Tentatively. */
@ -492,8 +486,8 @@ int *flagp;
*flagp |= HASWIDTH|SIMPLE;
break;
case '[': {
register int clss;
register int classend;
int clss;
int classend;
if (*regparse == '^') { /* Complement of range. */
ret = regnode(ANYBUT);
@ -553,8 +547,8 @@ int *flagp;
*flagp |= HASWIDTH|SIMPLE;
break;
default: {
register int len;
register char ender;
int len;
char ender;
regparse--;
len = (int) strcspn(regparse, META);
@ -583,11 +577,10 @@ int *flagp;
- regnode - emit a node
*/
static char * /* Location. */
regnode(op)
char op;
regnode(char op)
{
register char *ret;
register char *ptr;
char *ret;
char *ptr;
ret = regcode;
if (ret == &regdummy) {
@ -608,8 +601,7 @@ char op;
- regc - emit (if appropriate) a byte of code
*/
static void
regc(b)
char b;
regc(char b)
{
if (regcode != &regdummy)
*regcode++ = b;
@ -623,13 +615,11 @@ char b;
* Means relocating the operand.
*/
static void
reginsert(op, opnd)
char op;
char *opnd;
reginsert(char op, char *opnd)
{
register char *src;
register char *dst;
register char *place;
char *src;
char *dst;
char *place;
if (regcode == &regdummy) {
regsize += 3;
@ -652,13 +642,11 @@ char *opnd;
- regtail - set the next-pointer at the end of a node chain
*/
static void
regtail(p, val)
char *p;
char *val;
regtail(char *p, char *val)
{
register char *scan;
register char *temp;
register int offset;
char *scan;
char *temp;
int offset;
if (p == &regdummy)
return;
@ -684,9 +672,7 @@ char *val;
- regoptail - regtail on operand of first argument; nop if operandless
*/
static void
regoptail(p, val)
char *p;
char *val;
regoptail(char *p, char *val)
{
/* "Operandless" and "op != BRANCH" are synonymous in practice. */
if (p == NULL || p == &regdummy || OP(p) != BRANCH)
@ -723,12 +709,9 @@ STATIC char *regprop();
- regexec - match a regexp against a string
*/
int
regexec2(prog, string, notbol)
register regexp *prog;
register char *string;
int notbol;
regexec2(regexp *prog, char *string, int notbol)
{
register char *s;
char *s;
/* Be paranoid... */
if (prog == NULL || string == NULL) {
@ -785,9 +768,7 @@ int notbol;
}
int
regexec(prog, string)
register regexp *prog;
register char *string;
regexec(regexp *prog, char *string)
{
return regexec2(prog, string, 0);
}
@ -796,13 +777,11 @@ register char *string;
- regtry - try match at specific point
*/
static int /* 0 failure, 1 success */
regtry(prog, string)
regexp *prog;
char *string;
regtry(regexp *prog, char *string)
{
register int i;
register char **sp;
register char **ep;
int i;
char **sp;
char **ep;
reginput = string;
regstartp = prog->startp;
@ -833,11 +812,10 @@ char *string;
* by recursion.
*/
static int /* 0 failure, 1 success */
regmatch(prog)
char *prog;
regmatch(char *prog)
{
register char *scan; /* Current node. */
char *next; /* Next node. */
char *scan; /* Current node. */
char *next; /* Next node. */
scan = prog;
#ifdef DEBUG
@ -866,8 +844,8 @@ char *prog;
reginput++;
break;
case EXACTLY: {
register int len;
register char *opnd;
int len;
char *opnd;
opnd = OPERAND(scan);
/* Inline the first character, for speed. */
@ -902,8 +880,8 @@ char *prog;
case OPEN+7:
case OPEN+8:
case OPEN+9: {
register int no;
register char *save;
int no;
char *save;
no = OP(scan) - OPEN;
save = reginput;
@ -931,8 +909,8 @@ char *prog;
case CLOSE+7:
case CLOSE+8:
case CLOSE+9: {
register int no;
register char *save;
int no;
char *save;
no = OP(scan) - CLOSE;
save = reginput;
@ -952,7 +930,7 @@ char *prog;
/* NOTREACHED */
break;
case BRANCH: {
register char *save;
char *save;
if (OP(next) != BRANCH) /* No choice. */
next = OPERAND(scan); /* Avoid recursion. */
@ -972,10 +950,10 @@ char *prog;
break;
case STAR:
case PLUS: {
register char nextch;
register int no;
register char *save;
register int min;
char nextch;
int no;
char *save;
int min;
/*
* Lookahead to avoid useless match attempts
@ -1026,12 +1004,11 @@ char *prog;
- regrepeat - repeatedly match something simple, report how many
*/
static int
regrepeat(p)
char *p;
regrepeat(char *p)
{
register int count = 0;
register char *scan;
register char *opnd;
int count = 0;
char *scan;
char *opnd;
scan = reginput;
opnd = OPERAND(p);
@ -1072,10 +1049,9 @@ char *p;
- regnext - dig the "next" pointer out of a node
*/
static char *
regnext(p)
register char *p;
regnext(char *p)
{
register int offset;
int offset;
if (p == &regdummy)
return(NULL);
@ -1098,12 +1074,11 @@ STATIC char *regprop();
- regdump - dump a regexp onto stdout in vaguely comprehensible form
*/
void
regdump(r)
regexp *r;
regdump(regexp *r)
{
register char *s;
register char op = EXACTLY; /* Arbitrary non-END op. */
register char *next;
char *s;
char op = EXACTLY; /* Arbitrary non-END op. */
char *next;
s = r->program + 1;
@ -1141,10 +1116,9 @@ regexp *r;
- regprop - printable representation of opcode
*/
static char *
regprop(op)
char *op;
regprop(char *op)
{
register char *p;
char *p;
static char buf[50];
(void) strcpy(buf, ":");
@ -1233,13 +1207,11 @@ char *op;
*/
static int
strcspn(s1, s2)
char *s1;
char *s2;
strcspn(char *s1, char *s2)
{
register char *scan1;
register char *scan2;
register int count;
char *scan1;
char *scan2;
int count;
count = 0;
for (scan1 = s1; *scan1 != '\0'; scan1++) {

141
screen.c
View File

@ -205,8 +205,9 @@ static int attrmode = AT_NORMAL;
extern int binattr;
#if !MSDOS_COMPILER
static char *cheaper();
static void tmodes();
static char *cheaper(char *t1, char *t2, char *def);
static void tmodes(char *incap, char *outcap, char **instr, char **outstr,
char *def_instr, char *def_outstr, char **spp);
#endif
/*
@ -253,8 +254,7 @@ extern char *tgoto();
* It doesn't matter whether an input \n is mapped to \r, or vice versa.
*/
public void
raw_mode(on)
int on;
raw_mode(int on)
{
static int curr_on = 0;
@ -618,8 +618,7 @@ raw_mode(on)
static int hardcopy;
static char *
ltget_env(capname)
char *capname;
ltget_env(char *capname)
{
char name[16];
char *s;
@ -647,8 +646,7 @@ ltget_env(capname)
}
static int
ltgetflag(capname)
char *capname;
ltgetflag(char *capname)
{
char *s;
@ -660,8 +658,7 @@ ltgetflag(capname)
}
static int
ltgetnum(capname)
char *capname;
ltgetnum(char *capname)
{
char *s;
@ -673,9 +670,7 @@ ltgetnum(capname)
}
static char *
ltgetstr(capname, pp)
char *capname;
char **pp;
ltgetstr(char *capname, char **pp)
{
char *s;
@ -691,9 +686,9 @@ ltgetstr(capname, pp)
* Get size of the output screen.
*/
public void
scrsize()
scrsize(void)
{
register char *s;
char *s;
int sys_height;
int sys_width;
#if !MSDOS_COMPILER
@ -821,7 +816,7 @@ scrsize()
* Figure out how many empty loops it takes to delay a millisecond.
*/
static void
get_clock()
get_clock(void)
{
clock_t start;
@ -849,15 +844,14 @@ get_clock()
* Delay for a specified number of milliseconds.
*/
static void
dummy_func()
dummy_func(void)
{
static long delay_dummy = 0;
delay_dummy++;
}
static void
delay(msec)
int msec;
delay(int msec)
{
long i;
@ -879,8 +873,7 @@ delay(msec)
* Return the characters actually input by a "special" key.
*/
public char *
special_key_str(key)
int key;
special_key_str(int key)
{
static char tbuf[40];
char *s;
@ -1052,7 +1045,7 @@ special_key_str(key)
* Get terminal capabilities via termcap.
*/
public void
get_term()
get_term(void)
{
#if MSDOS_COMPILER
auto_wrap = 1;
@ -1117,7 +1110,7 @@ get_term()
#else /* !MSDOS_COMPILER */
char *sp;
register char *t1, *t2;
char *t1, *t2;
char *term;
char termbuf[TERMBUF_SIZE];
@ -1349,16 +1342,14 @@ static int costcount;
/*ARGSUSED*/
static int
inc_costcount(c)
int c;
inc_costcount(int c)
{
costcount++;
return (c);
}
static int
cost(t)
char *t;
cost(char *t)
{
costcount = 0;
tputs(t, sc_height, inc_costcount);
@ -1371,9 +1362,7 @@ cost(t)
* cost (see cost() function).
*/
static char *
cheaper(t1, t2, def)
char *t1, *t2;
char *def;
cheaper(char *t1, char *t2, char *def)
{
if (*t1 == '\0' && *t2 == '\0')
{
@ -1390,14 +1379,8 @@ cheaper(t1, t2, def)
}
static void
tmodes(incap, outcap, instr, outstr, def_instr, def_outstr, spp)
char *incap;
char *outcap;
char **instr;
char **outstr;
char *def_instr;
char *def_outstr;
char **spp;
tmodes(char *incap, char *outcap, char **instr, char **outstr, char *def_instr,
char *def_outstr, char **spp)
{
*instr = ltgetstr(incap, spp);
if (*instr == NULL)
@ -1446,7 +1429,7 @@ _settextposition(int row, int col)
* Initialize the screen to the correct color at startup.
*/
static void
initcolor()
initcolor(void)
{
SETCOLORS(nm_fg_color, nm_bg_color);
#if 0
@ -1479,7 +1462,7 @@ initcolor()
* Termcap-like init with a private win32 console.
*/
static void
win32_init_term()
win32_init_term(void)
{
CONSOLE_SCREEN_BUFFER_INFO scr;
COORD size;
@ -1530,7 +1513,7 @@ win32_deinit_term()
* Initialize terminal
*/
public void
init()
init(void)
{
#if !MSDOS_COMPILER
if (!no_init)
@ -1566,7 +1549,7 @@ init()
* Deinitialize terminal
*/
public void
deinit()
deinit(void)
{
if (!init_done)
return;
@ -1593,7 +1576,7 @@ deinit()
* Home cursor (move to upper left corner of screen).
*/
public void
home()
home(void)
{
#if !MSDOS_COMPILER
tputs(sc_home, 1, putchr);
@ -1608,7 +1591,7 @@ home()
* Should scroll the display down.
*/
public void
add_line()
add_line(void)
{
#if !MSDOS_COMPILER
tputs(sc_addline, sc_height, putchr);
@ -1666,8 +1649,7 @@ add_line()
* into the scrollback buffer when we go down-one-line (in WIN32).
*/
public void
remove_top(n)
int n;
remove_top(int n)
{
#if MSDOS_COMPILER==WIN32C
SMALL_RECT rcSrc, rcClip;
@ -1720,7 +1702,7 @@ remove_top(n)
* Clear the screen.
*/
static void
win32_clear()
win32_clear(void)
{
/*
* This will clear only the currently visible rows of the NT
@ -1751,8 +1733,7 @@ win32_clear()
* window upward.
*/
public void
win32_scroll_up(n)
int n;
win32_scroll_up(int n)
{
SMALL_RECT rcSrc, rcClip;
CHAR_INFO fillchar;
@ -1817,7 +1798,7 @@ win32_scroll_up(n)
* Move cursor to lower left corner of screen.
*/
public void
lower_left()
lower_left(void)
{
#if !MSDOS_COMPILER
tputs(sc_lower_left, 1, putchr);
@ -1831,7 +1812,7 @@ lower_left()
* Move cursor to left position of current line.
*/
public void
line_left()
line_left(void)
{
#if !MSDOS_COMPILER
tputs(sc_return, 1, putchr);
@ -1863,7 +1844,7 @@ line_left()
* (in lieu of SIGWINCH for WIN32).
*/
public void
check_winch()
check_winch(void)
{
#if MSDOS_COMPILER==WIN32C
CONSOLE_SCREEN_BUFFER_INFO scr;
@ -1893,8 +1874,7 @@ check_winch()
* Goto a specific line on the screen.
*/
public void
goto_line(slinenum)
int slinenum;
goto_line(int slinenum)
{
#if !MSDOS_COMPILER
tputs(tgoto(sc_move, 0, slinenum), 1, putchr);
@ -1912,7 +1892,7 @@ goto_line(slinenum)
* {{ Yuck! There must be a better way to get a visual bell. }}
*/
static void
create_flash()
create_flash(void)
{
#if MSDOS_COMPILER==MSOFTC
struct videoconfig w;
@ -1941,7 +1921,7 @@ create_flash()
}
#else
#if MSDOS_COMPILER==BORLANDC
register int n;
int n;
whitescreen = (unsigned short *)
malloc(sc_width * sc_height * sizeof(short));
@ -1951,7 +1931,7 @@ create_flash()
whitescreen[n] = 0x7020;
#else
#if MSDOS_COMPILER==WIN32C
register int n;
int n;
whitescreen = (WORD *)
malloc(sc_height * sc_width * sizeof(WORD));
@ -1971,7 +1951,7 @@ create_flash()
* Output the "visual bell", if there is one.
*/
public void
vbell()
vbell(void)
{
#if !MSDOS_COMPILER
if (*sc_visual_bell == '\0')
@ -2035,7 +2015,7 @@ vbell()
* Make a noise.
*/
static void
beep()
beep(void)
{
#if !MSDOS_COMPILER
putchr(CONTROL('G'));
@ -2052,7 +2032,7 @@ beep()
* Ring the terminal bell.
*/
public void
bell()
bell(void)
{
if (quiet == VERY_QUIET)
vbell();
@ -2064,7 +2044,7 @@ bell()
* Clear the screen.
*/
public void
clear()
clear(void)
{
#if !MSDOS_COMPILER
tputs(sc_clear, sc_height, putchr);
@ -2083,7 +2063,7 @@ clear()
* {{ This must not move the cursor. }}
*/
public void
clear_eol()
clear_eol(void)
{
#if !MSDOS_COMPILER
tputs(sc_eol_clear, 1, putchr);
@ -2142,7 +2122,7 @@ clear_eol()
* Clear the screen if there's off-screen memory below the display.
*/
static void
clear_eol_bot()
clear_eol_bot(void)
{
#if MSDOS_COMPILER
clear_eol();
@ -2159,7 +2139,7 @@ clear_eol_bot()
* Leave the cursor at the beginning of the bottom line.
*/
public void
clear_bot()
clear_bot(void)
{
/*
* If we're in a non-normal attribute mode, temporarily exit
@ -2184,8 +2164,7 @@ clear_bot()
}
public void
at_enter(attr)
int attr;
at_enter(int attr)
{
attr = apply_at_specials(attr);
@ -2223,7 +2202,7 @@ at_enter(attr)
}
public void
at_exit()
at_exit(void)
{
#if !MSDOS_COMPILER
/* Undo things in the reverse order we did them. */
@ -2244,8 +2223,7 @@ at_exit()
}
public void
at_switch(attr)
int attr;
at_switch(int attr)
{
int new_attrmode = apply_at_specials(attr);
int ignore_modes = AT_ANSI;
@ -2258,9 +2236,7 @@ at_switch(attr)
}
public int
is_at_equiv(attr1, attr2)
int attr1;
int attr2;
is_at_equiv(int attr1, int attr2)
{
attr1 = apply_at_specials(attr1);
attr2 = apply_at_specials(attr2);
@ -2269,8 +2245,7 @@ is_at_equiv(attr1, attr2)
}
public int
apply_at_specials(attr)
int attr;
apply_at_specials(int attr)
{
if (attr & AT_BINARY)
attr |= binattr;
@ -2287,7 +2262,7 @@ apply_at_specials(attr)
* and move the cursor left.
*/
public void
backspace()
backspace(void)
{
#if !MSDOS_COMPILER
/*
@ -2336,7 +2311,7 @@ backspace()
* Output a plain backspace, without erasing the previous char.
*/
public void
putbs()
putbs(void)
{
#if !MSDOS_COMPILER
tputs(sc_backspace, 1, putchr);
@ -2375,8 +2350,7 @@ putbs()
* Determine whether an input character is waiting to be read.
*/
static int
win32_kbhit(tty)
HANDLE tty;
win32_kbhit(HANDLE tty)
{
INPUT_RECORD ip;
DWORD read;
@ -2440,8 +2414,7 @@ win32_kbhit(tty)
* Read a character from the keyboard.
*/
public char
WIN32getch(tty)
int tty;
WIN32getch(int tty)
{
int ascii;
@ -2474,9 +2447,7 @@ WIN32getch(tty)
/*
*/
public void
WIN32setcolors(fg, bg)
int fg;
int bg;
WIN32setcolors(int fg, int bg)
{
SETCOLORS(fg, bg);
}
@ -2484,9 +2455,7 @@ WIN32setcolors(fg, bg)
/*
*/
public void
WIN32textout(text, len)
char *text;
int len;
WIN32textout(char *text, int len)
{
#if MSDOS_COMPILER==WIN32C
DWORD written;

View File

@ -45,11 +45,7 @@
#include <stdlib.h>
#include <stdio.h>
static int get_winsize(dpy, window, p_width, p_height)
Display *dpy;
Window window;
int *p_width;
int *p_height;
static int get_winsize(Display *dpy, Window window, int *p_width, int *p_height)
{
XWindowAttributes win_attributes;
XSizeHints hints;
@ -79,9 +75,7 @@ static int get_winsize(dpy, window, p_width, p_height)
return 0;
}
int main(argc, argv)
int argc;
char *argv[];
int main(int argc, char *argv[])
{
char *cp;
Display *dpy;

133
search.c
View File

@ -121,10 +121,9 @@ static struct pattern_info filter_info;
* Are there any uppercase letters in this string?
*/
static int
is_ucase(str)
char *str;
is_ucase(constant char *str)
{
char *str_end = str + strlen(str);
constant char *str_end = str + strlen(str);
LWCHAR ch;
while (str < str_end)
@ -140,15 +139,13 @@ is_ucase(str)
* Compile and save a search pattern.
*/
static int
set_pattern(info, pattern, search_type)
struct pattern_info *info;
char *pattern;
int search_type;
set_pattern(struct pattern_info *info, char *pattern, int search_type)
{
#if !NO_REGEX
if (pattern == NULL)
CLEAR_PATTERN(info->compiled);
else if (compile_pattern(pattern, search_type, &info->compiled) < 0)
else if (compile_pattern(pattern, search_type,
(void **)&info->compiled) < 0)
return -1;
#endif
/* Pattern compiled successfully; save the text too. */
@ -178,14 +175,13 @@ set_pattern(info, pattern, search_type)
* Discard a saved pattern.
*/
static void
clear_pattern(info)
struct pattern_info *info;
clear_pattern(struct pattern_info *info)
{
if (info->text != NULL)
free(info->text);
info->text = NULL;
#if !NO_REGEX
uncompile_pattern(&info->compiled);
uncompile_pattern((void **)&info->compiled);
#endif
}
@ -193,8 +189,7 @@ clear_pattern(info)
* Initialize saved pattern to nothing.
*/
static void
init_pattern(info)
struct pattern_info *info;
init_pattern(struct pattern_info *info)
{
CLEAR_PATTERN(info->compiled);
info->text = NULL;
@ -205,7 +200,7 @@ init_pattern(info)
* Initialize search variables.
*/
public void
init_search()
init_search(void)
{
init_pattern(&search_info);
init_pattern(&filter_info);
@ -215,7 +210,7 @@ init_search()
* Determine which text conversions to perform before pattern matching.
*/
static int
get_cvt_ops()
get_cvt_ops(void)
{
int ops = 0;
if (is_caseless || bs_mode == BS_SPECIAL)
@ -239,8 +234,7 @@ get_cvt_ops()
* Is there a previous (remembered) search pattern?
*/
static int
prev_pattern(info)
struct pattern_info *info;
prev_pattern(struct pattern_info *info)
{
#if !NO_REGEX
if ((info->search_type & SRCH_NO_REGEX) == 0)
@ -256,8 +250,7 @@ prev_pattern(info)
* If on==0, force all hilites off.
*/
public void
repaint_hilite(on)
int on;
repaint_hilite(int on)
{
int slinenum;
POSITION pos;
@ -298,7 +291,7 @@ repaint_hilite(on)
* Clear the attn hilite.
*/
public void
clear_attn()
clear_attn(void)
{
int slinenum;
POSITION old_start_attnpos;
@ -345,7 +338,7 @@ clear_attn()
* Hide search string highlighting.
*/
public void
undo_search()
undo_search(void)
{
if (!prev_pattern(&search_info))
{
@ -363,8 +356,7 @@ undo_search()
* Clear the hilite list.
*/
public void
clr_hlist(anchor)
struct hilite_tree *anchor;
clr_hlist(struct hilite_tree *anchor)
{
struct hilite_storage *hls;
struct hilite_storage *nexthls;
@ -385,13 +377,13 @@ clr_hlist(anchor)
}
public void
clr_hilite()
clr_hilite(void)
{
clr_hlist(&hilite_anchor);
}
public void
clr_filter()
clr_filter(void)
{
clr_hlist(&filter_anchor);
}
@ -520,9 +512,7 @@ hlist_find(anchor, pos)
* Should any characters in a specified range be highlighted?
*/
static int
is_hilited_range(pos, epos)
POSITION pos;
POSITION epos;
is_hilited_range(POSITION pos, POSITION epos)
{
struct hilite_node *n = hlist_find(&hilite_anchor, pos);
return (n != NULL && (epos == NULL_POSITION || epos > n->r.hl_startpos));
@ -532,8 +522,7 @@ is_hilited_range(pos, epos)
* Is a line "filtered" -- that is, should it be hidden?
*/
public int
is_filtered(pos)
POSITION pos;
is_filtered(POSITION pos)
{
struct hilite_node *n;
@ -549,8 +538,7 @@ is_filtered(pos)
* just return pos.
*/
public POSITION
next_unfiltered(pos)
POSITION pos;
next_unfiltered(POSITION pos)
{
struct hilite_node *n;
@ -571,8 +559,7 @@ next_unfiltered(pos)
* we're filtered right to the beginning, otherwise just return pos.
*/
public POSITION
prev_unfiltered(pos)
POSITION pos;
prev_unfiltered(POSITION pos)
{
struct hilite_node *n;
@ -597,11 +584,7 @@ prev_unfiltered(pos)
* If nohide is nonzero, don't consider hide_hilite.
*/
public int
is_hilited(pos, epos, nohide, p_matches)
POSITION pos;
POSITION epos;
int nohide;
int *p_matches;
is_hilited(POSITION pos, POSITION epos, int nohide, int *p_matches)
{
int match;
@ -647,8 +630,7 @@ is_hilited(pos, epos, nohide, p_matches)
* capacity, or create a new one if not.
*/
static struct hilite_storage*
hlist_getstorage(anchor)
struct hilite_tree *anchor;
hlist_getstorage(struct hilite_tree *anchor)
{
int capacity = 1;
struct hilite_storage *s;
@ -678,8 +660,7 @@ hlist_getstorage(anchor)
* tree.
*/
static struct hilite_node*
hlist_getnode(anchor)
struct hilite_tree *anchor;
hlist_getnode(struct hilite_tree *anchor)
{
struct hilite_storage *s = hlist_getstorage(anchor);
return &s->nodes[s->used++];
@ -689,9 +670,7 @@ hlist_getnode(anchor)
* Rotate the tree left around a pivot node.
*/
static void
hlist_rotate_left(anchor, n)
struct hilite_tree *anchor;
struct hilite_node *n;
hlist_rotate_left(struct hilite_tree *anchor, struct hilite_node *n)
{
struct hilite_node *np = n->parent;
struct hilite_node *nr = n->right;
@ -720,9 +699,7 @@ hlist_rotate_left(anchor, n)
* Rotate the tree right around a pivot node.
*/
static void
hlist_rotate_right(anchor, n)
struct hilite_tree *anchor;
struct hilite_node *n;
hlist_rotate_right(struct hilite_tree *anchor, struct hilite_node *n)
{
struct hilite_node *np = n->parent;
struct hilite_node *nl = n->left;
@ -752,9 +729,7 @@ hlist_rotate_right(anchor, n)
* Add a new hilite to a hilite list.
*/
static void
add_hilite(anchor, hl)
struct hilite_tree *anchor;
struct hilite *hl;
add_hilite(struct hilite_tree *anchor, struct hilite *hl)
{
struct hilite_node *p, *n, *u;
@ -931,11 +906,7 @@ add_hilite(anchor, hl)
* Hilight every character in a range of displayed characters.
*/
static void
create_hilites(linepos, start_index, end_index, chpos)
POSITION linepos;
int start_index;
int end_index;
int *chpos;
create_hilites(POSITION linepos, int start_index, int end_index, int *chpos)
{
struct hilite hl;
int i;
@ -972,14 +943,8 @@ create_hilites(linepos, start_index, end_index, chpos)
* sp,ep delimit the first match already found.
*/
static void
hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
POSITION linepos;
char *line;
int line_len;
int *chpos;
char *sp;
char *ep;
int cvt_ops;
hilite_line(POSITION linepos, char *line, int line_len, int *chpos, char *sp,
char *ep, int cvt_ops)
{
char *searchp;
char *line_end = line + line_len;
@ -1020,7 +985,7 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
* Updates the internal search state to reflect a change in the -i flag.
*/
public void
chg_caseless()
chg_caseless(void)
{
if (!is_ucase_pattern)
/*
@ -1041,7 +1006,7 @@ chg_caseless()
* Find matching text which is currently on screen and highlight it.
*/
static void
hilite_screen()
hilite_screen(void)
{
struct scrpos scrpos;
@ -1056,7 +1021,7 @@ hilite_screen()
* Change highlighting parameters.
*/
public void
chg_hilite()
chg_hilite(void)
{
/*
* Erase any highlights currently on screen.
@ -1076,8 +1041,7 @@ chg_hilite()
* Figure out where to start a search.
*/
static POSITION
search_pos(search_type)
int search_type;
search_pos(int search_type)
{
POSITION pos;
int linenum;
@ -1169,14 +1133,8 @@ search_pos(search_type)
* Search a subset of the file, specified by start/end position.
*/
static int
search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
POSITION pos;
POSITION endpos;
int search_type;
int matches;
int maxlines;
POSITION *plinepos;
POSITION *pendpos;
search_range(POSITION pos, POSITION endpos, int search_type, int matches,
int maxlines, POSITION *plinepos, POSITION *pendpos)
{
char *line;
char *cline;
@ -1355,8 +1313,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
* search for a pattern in history. If found, compile that pattern.
*/
static int
hist_pattern(search_type)
int search_type;
hist_pattern(int search_type)
{
#if CMD_HISTORY
char *pattern;
@ -1390,10 +1347,7 @@ hist_pattern(search_type)
* if less than n matches are found in this file.
*/
public int
search(search_type, pattern, n)
int search_type;
char *pattern;
int n;
search(int search_type, char *pattern, int n)
{
POSITION pos;
@ -1527,10 +1481,7 @@ search(search_type, pattern, n)
* prep_hilite asks that the range (spos,epos) be covered by the prep region.
*/
public void
prep_hilite(spos, epos, maxlines)
POSITION spos;
POSITION epos;
int maxlines;
prep_hilite(POSITION spos, POSITION epos, int maxlines)
{
POSITION nprep_startpos = prep_startpos;
POSITION nprep_endpos = prep_endpos;
@ -1697,9 +1648,7 @@ prep_hilite(spos, epos, maxlines)
* Set the pattern to be used for line filtering.
*/
public void
set_filter_pattern(pattern, search_type)
char *pattern;
int search_type;
set_filter_pattern(char *pattern, int search_type)
{
clr_filter();
if (pattern == NULL || *pattern == '\0')
@ -1713,7 +1662,7 @@ set_filter_pattern(pattern, search_type)
* Is there a line filter in effect?
*/
public int
is_filtering()
is_filtering(void)
{
if (ch_getflags() & CH_HELPFILE)
return (0);

View File

@ -40,8 +40,7 @@ extern long jump_sline_fraction;
*/
/* ARGSUSED*/
static RETSIGTYPE
u_interrupt(type)
int type;
u_interrupt(int type)
{
bell();
#if OS2
@ -68,8 +67,7 @@ u_interrupt(type)
*/
/* ARGSUSED*/
static RETSIGTYPE
stop(type)
int type;
stop(int type)
{
LSIGNAL(SIGTSTP, stop);
sigs |= S_STOP;
@ -84,8 +82,7 @@ stop(type)
*/
/* ARGSUSED*/
public RETSIGTYPE
winch(type)
int type;
winch(int type)
{
LSIGNAL(SIGWINCH, winch);
sigs |= S_WINCH;
@ -99,8 +96,7 @@ winch(type)
*/
/* ARGSUSED*/
public RETSIGTYPE
winch(type)
int type;
winch(int type)
{
LSIGNAL(SIGWIND, winch);
sigs |= S_WINCH;
@ -117,8 +113,7 @@ winch(type)
#include "windows.h"
static BOOL WINAPI
wbreak_handler(dwCtrlType)
DWORD dwCtrlType;
wbreak_handler(DWORD dwCtrlType)
{
switch (dwCtrlType)
{
@ -137,8 +132,7 @@ wbreak_handler(dwCtrlType)
* Set up the signal handlers.
*/
public void
init_signals(on)
int on;
init_signals(int on)
{
if (on)
{
@ -190,9 +184,9 @@ init_signals(on)
* A received signal cause a bit to be set in "sigs".
*/
public void
psignals()
psignals(void)
{
register int tsignals;
int tsignals;
if ((tsignals = sigs) == 0)
return;

71
tags.c
View File

@ -43,13 +43,13 @@ enum {
T_GPATH /* 'GPATH': path name (global) */
};
static enum tag_result findctag();
static enum tag_result findgtag();
static char *nextgtag();
static char *prevgtag();
static POSITION ctagsearch();
static POSITION gtagsearch();
static int getentry();
static enum tag_result findctag(char *tag);
static enum tag_result findgtag(char *tag, int type);
static char *nextgtag(void);
static char *prevgtag(void);
static POSITION ctagsearch(void);
static POSITION gtagsearch(void);
static int getentry(char *buf, char **tag, char **file, char **line);
/*
* The list of tags generated by the last findgtag() call.
@ -88,9 +88,9 @@ static struct tag *curtag;
* Delete tag structures.
*/
public void
cleantags()
cleantags(void)
{
register struct tag *tp;
struct tag *tp;
/*
* Delete any existing tag list.
@ -110,14 +110,9 @@ cleantags()
* Create a new tag entry.
*/
static struct tag *
maketagent(name, file, linenum, pattern, endline)
char *name;
char *file;
LINENUM linenum;
char *pattern;
int endline;
maketagent(char *name, char *file, LINENUM linenum, char *pattern, int endline)
{
register struct tag *tp;
struct tag *tp;
tp = (struct tag *) ecalloc(sizeof(struct tag), 1);
tp->tag_file = (char *) ecalloc(strlen(file) + 1, sizeof(char));
@ -138,7 +133,7 @@ maketagent(name, file, linenum, pattern, endline)
* Get tag mode.
*/
public int
gettagtype()
gettagtype(void)
{
int f;
@ -169,8 +164,7 @@ gettagtype()
* to find the tag.
*/
public void
findtag(tag)
register char *tag;
findtag(char *tag)
{
int type = gettagtype();
enum tag_result result;
@ -200,7 +194,7 @@ findtag(tag)
* Search for a tag.
*/
public POSITION
tagsearch()
tagsearch(void)
{
if (curtag == NULL)
return (NULL_POSITION); /* No gtags loaded! */
@ -214,8 +208,7 @@ tagsearch()
* Go to the next tag.
*/
public char *
nexttag(n)
int n;
nexttag(int n)
{
char *tagfile = (char *) NULL;
@ -228,8 +221,7 @@ nexttag(n)
* Go to the previous tag.
*/
public char *
prevtag(n)
int n;
prevtag(int n)
{
char *tagfile = (char *) NULL;
@ -242,7 +234,7 @@ prevtag(n)
* Return the total number of tags.
*/
public int
ntags()
ntags(void)
{
return total;
}
@ -251,7 +243,7 @@ ntags()
* Return the sequence number of current tag.
*/
public int
curr_tag()
curr_tag(void)
{
return curseq;
}
@ -265,12 +257,11 @@ curr_tag()
* Sets curtag to the first tag entry.
*/
static enum tag_result
findctag(tag)
register char *tag;
findctag(char *tag)
{
char *p;
register FILE *f;
register int taglen;
FILE *f;
int taglen;
LINENUM taglinenum;
char *tagfile;
char *tagpattern;
@ -377,7 +368,7 @@ findctag(tag)
* Edit current tagged file.
*/
public int
edit_tagfile()
edit_tagfile(void)
{
if (curtag == NULL)
return (1);
@ -394,7 +385,7 @@ edit_tagfile()
* parentheses (which are almost always found in a tag).
*/
static POSITION
ctagsearch()
ctagsearch(void)
{
POSITION pos, linepos;
LINENUM linenum;
@ -470,9 +461,7 @@ ctagsearch()
* Sets curtag to the first tag entry.
*/
static enum tag_result
findgtag(tag, type)
char *tag; /* tag to load */
int type; /* tags type */
findgtag(char *tag, int type)
{
char buf[256];
FILE *fp;
@ -605,7 +594,7 @@ static int circular = 0; /* 1: circular tag structure */
* appropriate tag.
*/
static char *
nextgtag()
nextgtag(void)
{
struct tag *tp;
@ -635,7 +624,7 @@ nextgtag()
* at the appropriate tag.
*/
static char *
prevgtag()
prevgtag(void)
{
struct tag *tp;
@ -665,7 +654,7 @@ prevgtag()
* if it was unable to position at the tag, 0 if successful.
*/
static POSITION
gtagsearch()
gtagsearch(void)
{
if (curtag == NULL)
return (NULL_POSITION); /* No gtags loaded! */
@ -701,11 +690,7 @@ gtagsearch()
* into buf.
*/
static int
getentry(buf, tag, file, line)
char *buf; /* standard or extended ctags -x format data */
char **tag; /* name of the tag we actually found */
char **file; /* file in which to find this tag */
char **line; /* line number of file where this tag is found */
getentry(char *buf, char **tag, char **file, char **line)
{
char *p = buf;

View File

@ -31,7 +31,7 @@ extern int utf_mode;
* Open keyboard for input.
*/
public void
open_getchr()
open_getchr(void)
{
#if MSDOS_COMPILER==WIN32C
/* Need this to let child processes inherit our console handle */
@ -85,7 +85,7 @@ open_getchr()
* Close the keyboard.
*/
public void
close_getchr()
close_getchr(void)
{
#if MSDOS_COMPILER==WIN32C
SetConsoleMode((HANDLE)tty, console_mode);
@ -97,7 +97,7 @@ close_getchr()
* Get a character from the keyboard.
*/
public int
getchr()
getchr(void)
{
char c;
int result;