Convert function declarations from K&R to ANSI style.

cproto (http://invisible-island.net/cproto/) was used to do the bulk of
the work in batch; even the most recent version had some issues with
typedef'd parameters; a quick "patch" was to modify `lex.l` to
explicitly include all vim typedefs as known types. One example from
`vim.h` is

    typedef unsigned char char_u;

which was added in `lex.l` as

    <INITIAL>char_u    { save_text_offset(); return T_CHAR; }

Even with these changes there were some problems:

* Two files (`mbyte.c` and `os_unix.c`) were not cleanly converted.
* Any function with the `UNUSED` macro in its parameter list was not converted.

Rather than spend more time fixing the automated approach, the two files
`mbyte.c` and `os_unix.c` were converted by hand.

The `UNUSED` macros were compiler specific, and the alternative, generic
version would require a different syntax, so in order to simplify the
conversion all uses of `UNUSED` were stripped, and then the sources were
run back through cproto. It is planned to reconsider each use of
`UNUSED` manually using a new macro definition.
This commit is contained in:
scott-linder
2014-02-23 15:34:45 -05:00
parent 1bcbc42330
commit b76c358f3d
54 changed files with 6840 additions and 10886 deletions

View File

@@ -84,7 +84,7 @@ static int cause_abort = FALSE;
* cancellation of an expression evaluation after an aborting function call or
* due to a parsing error, aborting() always returns the same value.
*/
int aborting() {
int aborting(void) {
return (did_emsg && force_abort) || got_int || did_throw;
}
@@ -94,7 +94,7 @@ int aborting() {
* be necessary to restore "force_abort" even before the throw point for the
* error message has been reached. update_force_abort() should be called then.
*/
void update_force_abort() {
void update_force_abort(void) {
if (cause_abort)
force_abort = TRUE;
}
@@ -105,8 +105,7 @@ void update_force_abort() {
* execution of a failing subcommand as long as the error message has not been
* displayed and actually caused the abortion.
*/
int should_abort(retcode)
int retcode;
int should_abort(int retcode)
{
return (retcode == FAIL && trylevel != 0 && !emsg_silent) || aborting();
}
@@ -117,7 +116,7 @@ int retcode;
* to find finally clauses to be executed, and that some errors in skipped
* commands are still reported.
*/
int aborted_in_try() {
int aborted_in_try(void) {
/* This function is only called after an error. In this case, "force_abort"
* determines whether searching for finally clauses is necessary. */
return force_abort;
@@ -132,10 +131,7 @@ int aborted_in_try() {
* most specific one and used as the exception value. The "severe" flag can be
* set to TRUE, if a later but severer message should be used instead.
*/
int cause_errthrow(mesg, severe, ignore)
char_u *mesg;
int severe;
int *ignore;
int cause_errthrow(char_u *mesg, int severe, int *ignore)
{
struct msglist *elem;
struct msglist **plist;
@@ -275,8 +271,7 @@ int *ignore;
/*
* Free a "msg_list" and the messages it contains.
*/
static void free_msglist(l)
struct msglist *l;
static void free_msglist(struct msglist *l)
{
struct msglist *messages, *next;
@@ -293,7 +288,7 @@ struct msglist *l;
* Free global "*msg_list" and the messages it contains, then set "*msg_list"
* to NULL.
*/
void free_global_msglist() {
void free_global_msglist(void) {
free_msglist(*msg_list);
*msg_list = NULL;
}
@@ -303,9 +298,7 @@ void free_global_msglist() {
* error exception. If cstack is NULL, postpone the throw until do_cmdline()
* has returned (see do_one_cmd()).
*/
void do_errthrow(cstack, cmdname)
struct condstack *cstack;
char_u *cmdname;
void do_errthrow(struct condstack *cstack, char_u *cmdname)
{
/*
* Ensure that all commands in nested function calls and sourced files
@@ -337,8 +330,7 @@ char_u *cmdname;
* exception if appropriate. Return TRUE if the current exception is discarded,
* FALSE otherwise.
*/
int do_intthrow(cstack)
struct condstack *cstack;
int do_intthrow(struct condstack *cstack)
{
/*
* If no interrupt occurred or no try conditional is active and no exception
@@ -384,11 +376,7 @@ struct condstack *cstack;
/*
* Get an exception message that is to be stored in current_exception->value.
*/
char_u * get_exception_string(value, type, cmdname, should_free)
void *value;
int type;
char_u *cmdname;
int *should_free;
char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should_free)
{
char_u *ret, *mesg;
int cmdlen;
@@ -457,10 +445,7 @@ int *should_free;
* user or interrupt exception, or points to a message list in case of an
* error exception.
*/
static int throw_exception(value, type, cmdname)
void *value;
int type;
char_u *cmdname;
static int throw_exception(void *value, int type, char_u *cmdname)
{
except_T *excp;
int should_free;
@@ -541,9 +526,7 @@ fail:
* Discard an exception. "was_finished" is set when the exception has been
* caught and the catch clause has been ended normally.
*/
static void discard_exception(excp, was_finished)
except_T *excp;
int was_finished;
static void discard_exception(except_T *excp, int was_finished)
{
char_u *saved_IObuff;
@@ -589,7 +572,7 @@ int was_finished;
/*
* Discard the exception currently being thrown.
*/
void discard_current_exception() {
void discard_current_exception(void) {
discard_exception(current_exception, FALSE);
current_exception = NULL;
did_throw = FALSE;
@@ -599,8 +582,7 @@ void discard_current_exception() {
/*
* Put an exception on the caught stack.
*/
static void catch_exception(excp)
except_T *excp;
static void catch_exception(except_T *excp)
{
excp->caught = caught_stack;
caught_stack = excp;
@@ -643,8 +625,7 @@ except_T *excp;
/*
* Remove an exception from the caught stack.
*/
static void finish_exception(excp)
except_T *excp;
static void finish_exception(except_T *excp)
{
if (excp != caught_stack)
EMSG(_(e_internal));
@@ -687,10 +668,7 @@ except_T *excp;
* what is pending. "value" specifies the return value for a pending ":return"
* or the exception value for a pending exception.
*/
static void report_pending(action, pending, value)
int action;
int pending;
void *value;
static void report_pending(int action, int pending, void *value)
{
char_u *mesg;
char *s;
@@ -765,9 +743,7 @@ void *value;
* If something is made pending in a finally clause, report it if required by
* the 'verbose' option or when debugging.
*/
void report_make_pending(pending, value)
int pending;
void *value;
void report_make_pending(int pending, void *value)
{
if (p_verbose >= 14 || debug_break_level > 0) {
if (debug_break_level <= 0)
@@ -782,9 +758,7 @@ void *value;
* If something pending in a finally clause is resumed at the ":endtry", report
* it if required by the 'verbose' option or when debugging.
*/
void report_resume_pending(pending, value)
int pending;
void *value;
void report_resume_pending(int pending, void *value)
{
if (p_verbose >= 14 || debug_break_level > 0) {
if (debug_break_level <= 0)
@@ -799,9 +773,7 @@ void *value;
* If something pending in a finally clause is discarded, report it if required
* by the 'verbose' option or when debugging.
*/
void report_discard_pending(pending, value)
int pending;
void *value;
void report_discard_pending(int pending, void *value)
{
if (p_verbose >= 14 || debug_break_level > 0) {
if (debug_break_level <= 0)
@@ -816,8 +788,7 @@ void *value;
/*
* ":if".
*/
void ex_if(eap)
exarg_T *eap;
void ex_if(exarg_T *eap)
{
int error;
int skip;
@@ -854,8 +825,7 @@ exarg_T *eap;
/*
* ":endif".
*/
void ex_endif(eap)
exarg_T *eap;
void ex_endif(exarg_T *eap)
{
did_endif = TRUE;
if (eap->cstack->cs_idx < 0
@@ -883,8 +853,7 @@ exarg_T *eap;
/*
* ":else" and ":elseif".
*/
void ex_else(eap)
exarg_T *eap;
void ex_else(exarg_T *eap)
{
int error;
int skip;
@@ -965,8 +934,7 @@ exarg_T *eap;
/*
* Handle ":while" and ":for".
*/
void ex_while(eap)
exarg_T *eap;
void ex_while(exarg_T *eap)
{
int error;
int skip;
@@ -1055,8 +1023,7 @@ exarg_T *eap;
/*
* ":continue"
*/
void ex_continue(eap)
exarg_T *eap;
void ex_continue(exarg_T *eap)
{
int idx;
struct condstack *cstack = eap->cstack;
@@ -1089,8 +1056,7 @@ exarg_T *eap;
/*
* ":break"
*/
void ex_break(eap)
exarg_T *eap;
void ex_break(exarg_T *eap)
{
int idx;
struct condstack *cstack = eap->cstack;
@@ -1113,8 +1079,7 @@ exarg_T *eap;
/*
* ":endwhile" and ":endfor"
*/
void ex_endwhile(eap)
exarg_T *eap;
void ex_endwhile(exarg_T *eap)
{
struct condstack *cstack = eap->cstack;
int idx;
@@ -1190,8 +1155,7 @@ exarg_T *eap;
/*
* ":throw expr"
*/
void ex_throw(eap)
exarg_T *eap;
void ex_throw(exarg_T *eap)
{
char_u *arg = eap->arg;
char_u *value;
@@ -1218,8 +1182,7 @@ exarg_T *eap;
* for ":throw" (user exception) and error and interrupt exceptions. Also
* used for rethrowing an uncaught exception.
*/
void do_throw(cstack)
struct condstack *cstack;
void do_throw(struct condstack *cstack)
{
int idx;
int inactivate_try = FALSE;
@@ -1279,8 +1242,7 @@ struct condstack *cstack;
/*
* ":try"
*/
void ex_try(eap)
exarg_T *eap;
void ex_try(exarg_T *eap)
{
int skip;
struct condstack *cstack = eap->cstack;
@@ -1347,8 +1309,7 @@ exarg_T *eap;
/*
* ":catch /{pattern}/" and ":catch"
*/
void ex_catch(eap)
exarg_T *eap;
void ex_catch(exarg_T *eap)
{
int idx = 0;
int give_up = FALSE;
@@ -1489,8 +1450,7 @@ exarg_T *eap;
/*
* ":finally"
*/
void ex_finally(eap)
exarg_T *eap;
void ex_finally(exarg_T *eap)
{
int idx;
int skip = FALSE;
@@ -1608,8 +1568,7 @@ exarg_T *eap;
/*
* ":endtry"
*/
void ex_endtry(eap)
exarg_T *eap;
void ex_endtry(exarg_T *eap)
{
int idx;
int skip;
@@ -1797,8 +1756,7 @@ exarg_T *eap;
* do_cmdline() that is going to be made for the cleanup autocommand
* execution.
*/
void enter_cleanup(csp)
cleanup_T *csp;
void enter_cleanup(cleanup_T *csp)
{
int pending = CSTP_NONE;
@@ -1854,8 +1812,7 @@ cleanup_T *csp;
* cleanup autocommands. In the latter case, the saved error/interrupt/
* exception state is discarded.
*/
void leave_cleanup(csp)
cleanup_T *csp;
void leave_cleanup(cleanup_T *csp)
{
int pending = csp->pending;
@@ -1935,10 +1892,7 @@ cleanup_T *csp;
* entered, is restored (used by ex_endtry()). This is normally done only
* when such a try conditional is left.
*/
int cleanup_conditionals(cstack, searched_cond, inclusive)
struct condstack *cstack;
int searched_cond;
int inclusive;
int cleanup_conditionals(struct condstack *cstack, int searched_cond, int inclusive)
{
int idx;
int stop = FALSE;
@@ -2046,8 +2000,7 @@ int inclusive;
/*
* Return an appropriate error message for a missing endwhile/endfor/endif.
*/
static char_u * get_end_emsg(cstack)
struct condstack *cstack;
static char_u *get_end_emsg(struct condstack *cstack)
{
if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE)
return e_endwhile;
@@ -2064,11 +2017,7 @@ struct condstack *cstack;
* type.
* Also free "for info" structures where needed.
*/
void rewind_conditionals(cstack, idx, cond_type, cond_level)
struct condstack *cstack;
int idx;
int cond_type;
int *cond_level;
void rewind_conditionals(struct condstack *cstack, int idx, int cond_type, int *cond_level)
{
while (cstack->cs_idx > idx) {
if (cstack->cs_flags[cstack->cs_idx] & cond_type)
@@ -2082,8 +2031,7 @@ int *cond_level;
/*
* ":endfunction" when not after a ":function"
*/
void ex_endfunction(eap)
exarg_T *eap UNUSED;
void ex_endfunction(exarg_T *eap)
{
EMSG(_("E193: :endfunction not inside a function"));
}
@@ -2091,8 +2039,7 @@ exarg_T *eap UNUSED;
/*
* Return TRUE if the string "p" looks like a ":while" or ":for" command.
*/
int has_loop_cmd(p)
char_u *p;
int has_loop_cmd(char_u *p)
{
int len;