Skip to content

Commit

Permalink
Convert function definitions from K&R to C89.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Dec 29, 2022
1 parent 0f41e66 commit 76a7805
Show file tree
Hide file tree
Showing 42 changed files with 717 additions and 2,236 deletions.
8 changes: 3 additions & 5 deletions Makefile.aut
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ REL := $(shell sed -e '/char version/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q $

ifeq ($(USE_PYTHON),1)
MKHELP = mkhelp.py
MKFUNCS = mkfuncs.py
else
MKHELP = mkhelp.pl
MKFUNCS = mkfuncs.pl
endif

SRC = \
Expand All @@ -41,8 +39,8 @@ DISTFILES = \
install.sh defines.h.in mkinstalldirs \
less.nro less.man lesskey.nro lesskey.man lessecho.nro lessecho.man \
less.hlp \
mkfuncs.pl mkhelp.pl \
mkfuncs.py mkhelp.py \
mkhelp.pl \
mkhelp.py \
mkutable $(UNICODE_FILES) \
${DISTFILES_W}

Expand All @@ -68,7 +66,7 @@ ${srcdir}/configure ${srcdir}/defines.h.in: ${srcdir}/configure.ac ${srcdir}/Mak

funcs.h: ${SRC:%=${srcdir}/%}
-mv -f ${srcdir}/funcs.h ${srcdir}/funcs.h.old
${srcdir}/${MKFUNCS} ${SRC:%=${srcdir}/%} >${srcdir}/funcs.h
grep -h '^public [^;]*$$' ${SRC:%=${srcdir}/%} | sed 's/$$/;/' >${srcdir}/funcs.h

lint:
lint -I. ${CPPFLAGS} ${SRC}
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

* Implement lesstest test suite.

* Convert function parameter definitions from K&R to C89 (github #316).

======================================================================

Major changes between "less" versions 590 and 608
Expand Down
7 changes: 1 addition & 6 deletions brac.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
* The characters which serve as "open bracket" and
* "close bracket" are given.
*/
public void
match_brac(obrac, cbrac, forwdir, n)
int obrac;
int cbrac;
int forwdir;
int n;
public void match_brac(int obrac, int cbrac, int forwdir, int n)
{
int c;
int nest;
Expand Down
79 changes: 24 additions & 55 deletions ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ static int ch_addbuf();
/*
* Get the character pointed to by the read pointer.
*/
static int
ch_get(VOID_PARAM)
static int ch_get(void)
{
struct buf *bp;
struct bufnode *bn;
Expand Down Expand Up @@ -362,9 +361,7 @@ ch_get(VOID_PARAM)
* ch_ungetchar is a rather kludgy and limited way to push
* a single char onto an input file descriptor.
*/
public void
ch_ungetchar(c)
int c;
public void ch_ungetchar(int c)
{
if (c != -1 && ch_ungotchar != -1)
error("ch_ungetchar overrun", NULL_PARG);
Expand All @@ -376,8 +373,7 @@ ch_ungetchar(c)
* Close the logfile.
* If we haven't read all of standard input into it, do that now.
*/
public void
end_logfile(VOID_PARAM)
public void end_logfile(void)
{
static int tried = FALSE;

Expand All @@ -402,8 +398,7 @@ end_logfile(VOID_PARAM)
* Invoked from the - command; see toggle_option().
* Write all the existing buffered data to the log file.
*/
public void
sync_logfile(VOID_PARAM)
public void sync_logfile(void)
{
struct buf *bp;
struct bufnode *bn;
Expand Down Expand Up @@ -439,9 +434,7 @@ sync_logfile(VOID_PARAM)
/*
* Determine if a specific block is currently in one of the buffers.
*/
static int
buffered(block)
BLOCKNUM block;
static int buffered(BLOCKNUM block)
{
struct buf *bp;
struct bufnode *bn;
Expand All @@ -461,9 +454,7 @@ buffered(block)
* Seek to a specified position in the file.
* Return 0 if successful, non-zero if can't seek there.
*/
public int
ch_seek(pos)
POSITION pos;
public int ch_seek(POSITION pos)
{
BLOCKNUM new_block;
POSITION len;
Expand Down Expand Up @@ -500,8 +491,7 @@ ch_seek(pos)
/*
* Seek to the end of the file.
*/
public int
ch_end_seek(VOID_PARAM)
public int ch_end_seek(void)
{
POSITION len;

Expand All @@ -527,8 +517,7 @@ ch_end_seek(VOID_PARAM)
/*
* Seek to the last position in the file that is currently buffered.
*/
public int
ch_end_buffer_seek(VOID_PARAM)
public int ch_end_buffer_seek(void)
{
struct buf *bp;
struct bufnode *bn;
Expand All @@ -555,8 +544,7 @@ ch_end_buffer_seek(VOID_PARAM)
* We may not be able to seek there if input is a pipe and the
* beginning of the pipe is no longer buffered.
*/
public int
ch_beg_seek(VOID_PARAM)
public int ch_beg_seek(void)
{
struct bufnode *bn;
struct bufnode *firstbn;
Expand Down Expand Up @@ -587,8 +575,7 @@ ch_beg_seek(VOID_PARAM)
/*
* Return the length of the file, if known.
*/
public POSITION
ch_length(VOID_PARAM)
public POSITION ch_length(void)
{
if (thisfile == NULL)
return (NULL_POSITION);
Expand All @@ -604,8 +591,7 @@ ch_length(VOID_PARAM)
/*
* Return the current position in the file.
*/
public POSITION
ch_tell(VOID_PARAM)
public POSITION ch_tell(void)
{
if (thisfile == NULL)
return (NULL_POSITION);
Expand All @@ -615,8 +601,7 @@ ch_tell(VOID_PARAM)
/*
* Get the current char and post-increment the read pointer.
*/
public int
ch_forw_get(VOID_PARAM)
public int ch_forw_get(void)
{
int c;

Expand All @@ -638,8 +623,7 @@ ch_forw_get(VOID_PARAM)
/*
* Pre-decrement the read pointer and get the new current char.
*/
public int
ch_back_get(VOID_PARAM)
public int ch_back_get(void)
{
if (thisfile == NULL)
return (EOI);
Expand All @@ -661,9 +645,7 @@ ch_back_get(VOID_PARAM)
* Set max amount of buffer space.
* bufspace is in units of 1024 bytes. -1 mean no limit.
*/
public void
ch_setbufspace(bufspace)
int bufspace;
public void ch_setbufspace(int bufspace)
{
if (bufspace < 0)
maxbufs = -1;
Expand All @@ -678,8 +660,7 @@ ch_setbufspace(bufspace)
/*
* Flush (discard) any saved file state, including buffer contents.
*/
public void
ch_flush(VOID_PARAM)
public void ch_flush(void)
{
struct bufnode *bn;

Expand Down Expand Up @@ -752,8 +733,7 @@ ch_flush(VOID_PARAM)
* Allocate a new buffer.
* The buffer is added to the tail of the buffer chain.
*/
static int
ch_addbuf(VOID_PARAM)
static int ch_addbuf(void)
{
struct buf *bp;
struct bufnode *bn;
Expand All @@ -777,8 +757,7 @@ ch_addbuf(VOID_PARAM)
/*
*
*/
static void
init_hashtbl(VOID_PARAM)
static void init_hashtbl(void)
{
int h;

Expand All @@ -792,8 +771,7 @@ init_hashtbl(VOID_PARAM)
/*
* Delete all buffers for this file.
*/
static void
ch_delbufs(VOID_PARAM)
static void ch_delbufs(void)
{
struct bufnode *bn;

Expand All @@ -810,9 +788,7 @@ ch_delbufs(VOID_PARAM)
/*
* Is it possible to seek on a file descriptor?
*/
public int
seekable(f)
int f;
public int seekable(int f)
{
#if MSDOS_COMPILER
extern int fd0;
Expand All @@ -832,8 +808,7 @@ seekable(f)
* Force EOF to be at the current read position.
* This is used after an ignore_eof read, during which the EOF may change.
*/
public void
ch_set_eof(VOID_PARAM)
public void ch_set_eof(void)
{
if (ch_fsize != NULL_POSITION && ch_fsize < ch_fpos)
ch_fsize = ch_fpos;
Expand All @@ -843,10 +818,7 @@ ch_set_eof(VOID_PARAM)
/*
* Initialize file state for a new file.
*/
public void
ch_init(f, flags)
int f;
int flags;
public void ch_init(int f, int flags)
{
/*
* See if we already have a filestate for this file.
Expand Down Expand Up @@ -883,8 +855,7 @@ ch_init(f, flags)
/*
* Close a filestate.
*/
public void
ch_close(VOID_PARAM)
public void ch_close(void)
{
int keepstate = FALSE;

Expand Down Expand Up @@ -926,17 +897,15 @@ ch_close(VOID_PARAM)
/*
* Return ch_flags for the current file.
*/
public int
ch_getflags(VOID_PARAM)
public int ch_getflags(void)
{
if (thisfile == NULL)
return (0);
return (ch_flags);
}

#if 0
public void
ch_dump(struct filestate *fs)
static void ch_dump(struct filestate *fs)
{
struct buf *bp;
struct bufnode *bn;
Expand Down

0 comments on commit 76a7805

Please sign in to comment.