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

@@ -53,8 +53,10 @@ static char_u e_nomenu[] = N_("E329: No menu \"%s\"");
/*
* Do the :menu command and relatives.
*/
void ex_menu(eap)
exarg_T *eap; /* Ex command arguments */
void
ex_menu (
exarg_T *eap /* Ex command arguments */
)
{
char_u *menu_path;
int modes;
@@ -262,12 +264,14 @@ theend:
/*
* Add the menu with the given name to the menu hierarchy
*/
static int add_menu_path(menu_path, menuarg, pri_tab, call_data)
char_u *menu_path;
vimmenu_T *menuarg; /* passes modes, iconfile, iconidx,
static int
add_menu_path (
char_u *menu_path,
vimmenu_T *menuarg, /* passes modes, iconfile, iconidx,
icon_builtin, silent[0], noremap[0] */
int *pri_tab;
char_u *call_data;
int *pri_tab,
char_u *call_data
)
{
char_u *path_name;
int modes = menuarg->modes;
@@ -506,11 +510,7 @@ erret:
* Set the (sub)menu with the given name to enabled or disabled.
* Called recursively.
*/
static int menu_nable_recurse(menu, name, modes, enable)
vimmenu_T *menu;
char_u *name;
int modes;
int enable;
static int menu_nable_recurse(vimmenu_T *menu, char_u *name, int modes, int enable)
{
char_u *p;
@@ -559,11 +559,13 @@ int enable;
* Remove the (sub)menu with the given name from the menu hierarchy
* Called recursively.
*/
static int remove_menu(menup, name, modes, silent)
vimmenu_T **menup;
char_u *name;
int modes;
int silent; /* don't give error messages */
static int
remove_menu (
vimmenu_T **menup,
char_u *name,
int modes,
int silent /* don't give error messages */
)
{
vimmenu_T *menu;
vimmenu_T *child;
@@ -666,8 +668,7 @@ int silent; /* don't give error messages */
/*
* Free the given menu structure and remove it from the linked list.
*/
static void free_menu(menup)
vimmenu_T **menup;
static void free_menu(vimmenu_T **menup)
{
int i;
vimmenu_T *menu;
@@ -692,9 +693,7 @@ vimmenu_T **menup;
/*
* Free the menu->string with the given index.
*/
static void free_menu_string(menu, idx)
vimmenu_T *menu;
int idx;
static void free_menu_string(vimmenu_T *menu, int idx)
{
int count = 0;
int i;
@@ -710,9 +709,7 @@ int idx;
/*
* Show the mapping associated with a menu item or hierarchy in a sub-menu.
*/
static int show_menus(path_name, modes)
char_u *path_name;
int modes;
static int show_menus(char_u *path_name, int modes)
{
char_u *p;
char_u *name;
@@ -765,10 +762,7 @@ int modes;
/*
* Recursively show the mappings associated with the menus under the given one
*/
static void show_menus_recursive(menu, modes, depth)
vimmenu_T *menu;
int modes;
int depth;
static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
{
int i;
int bit;
@@ -844,11 +838,7 @@ static int expand_emenu; /* TRUE for ":emenu" command */
/*
* Work out what to complete when doing command line completion of menu names.
*/
char_u * set_context_in_menu_cmd(xp, cmd, arg, forceit)
expand_T *xp;
char_u *cmd;
char_u *arg;
int forceit;
char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forceit)
{
char_u *after_dot;
char_u *p;
@@ -952,9 +942,7 @@ int forceit;
* Function given to ExpandGeneric() to obtain the list of (sub)menus (not
* entries).
*/
char_u * get_menu_name(xp, idx)
expand_T *xp UNUSED;
int idx;
char_u *get_menu_name(expand_T *xp, int idx)
{
static vimmenu_T *menu = NULL;
char_u *str;
@@ -999,9 +987,7 @@ int idx;
* Function given to ExpandGeneric() to obtain the list of menus and menu
* entries.
*/
char_u * get_menu_names(xp, idx)
expand_T *xp UNUSED;
int idx;
char_u *get_menu_names(expand_T *xp, int idx)
{
static vimmenu_T *menu = NULL;
#define TBUFFER_LEN 256
@@ -1065,8 +1051,7 @@ int idx;
* element. Any \ and ^Vs are removed from the current element.
* "name" may be modified.
*/
char_u * menu_name_skip(name)
char_u *name;
char_u *menu_name_skip(char_u *name)
{
char_u *p;
@@ -1086,9 +1071,7 @@ char_u *name;
* Return TRUE when "name" matches with menu "menu". The name is compared in
* two ways: raw menu name and menu name without '&'. ignore part after a TAB.
*/
static int menu_name_equal(name, menu)
char_u *name;
vimmenu_T *menu;
static int menu_name_equal(char_u *name, vimmenu_T *menu)
{
if (menu->en_name != NULL
&& (menu_namecmp(name, menu->en_name)
@@ -1097,9 +1080,7 @@ vimmenu_T *menu;
return menu_namecmp(name, menu->name) || menu_namecmp(name, menu->dname);
}
static int menu_namecmp(name, mname)
char_u *name;
char_u *mname;
static int menu_namecmp(char_u *name, char_u *mname)
{
int i;
@@ -1118,11 +1099,13 @@ char_u *mname;
* If "unmenu" is not NULL, then the flag it points to is set according to
* whether the command is an "unmenu" command.
*/
static int get_menu_cmd_modes(cmd, forceit, noremap, unmenu)
char_u *cmd;
int forceit; /* Was there a "!" after the command? */
int *noremap;
int *unmenu;
static int
get_menu_cmd_modes (
char_u *cmd,
int forceit, /* Was there a "!" after the command? */
int *noremap,
int *unmenu
)
{
int modes;
@@ -1179,9 +1162,7 @@ int *unmenu;
* Modify a menu name starting with "PopUp" to include the mode character.
* Returns the name in allocated memory (NULL for failure).
*/
static char_u * popup_mode_name(name, idx)
char_u *name;
int idx;
static char_u *popup_mode_name(char_u *name, int idx)
{
char_u *p;
int len = (int)STRLEN(name);
@@ -1202,10 +1183,7 @@ int idx;
* If mnemonic != NULL, *mnemonic is set to the character after the first '&'.
* If actext != NULL, *actext is set to the text after the first TAB.
*/
static char_u * menu_text(str, mnemonic, actext)
char_u *str;
int *mnemonic;
char_u **actext;
static char_u *menu_text(char_u *str, int *mnemonic, char_u **actext)
{
char_u *p;
char_u *text;
@@ -1251,8 +1229,7 @@ char_u **actext;
/*
* Return TRUE if "name" can be a menu in the MenuBar.
*/
int menu_is_menubar(name)
char_u *name;
int menu_is_menubar(char_u *name)
{
return !menu_is_popup(name)
&& !menu_is_toolbar(name)
@@ -1262,8 +1239,7 @@ char_u *name;
/*
* Return TRUE if "name" is a popup menu name.
*/
int menu_is_popup(name)
char_u *name;
int menu_is_popup(char_u *name)
{
return STRNCMP(name, "PopUp", 5) == 0;
}
@@ -1272,8 +1248,7 @@ char_u *name;
/*
* Return TRUE if "name" is a toolbar menu name.
*/
int menu_is_toolbar(name)
char_u *name;
int menu_is_toolbar(char_u *name)
{
return STRNCMP(name, "ToolBar", 7) == 0;
}
@@ -1282,8 +1257,7 @@ char_u *name;
* Return TRUE if the name is a menu separator identifier: Starts and ends
* with '-'
*/
int menu_is_separator(name)
char_u *name;
int menu_is_separator(char_u *name)
{
return name[0] == '-' && name[STRLEN(name) - 1] == '-';
}
@@ -1291,8 +1265,7 @@ char_u *name;
/*
* Return TRUE if the menu is hidden: Starts with ']'
*/
static int menu_is_hidden(name)
char_u *name;
static int menu_is_hidden(char_u *name)
{
return (name[0] == ']') || (menu_is_popup(name) && name[5] != NUL);
}
@@ -1302,8 +1275,7 @@ char_u *name;
/*
* Return TRUE if the menu is the tearoff menu.
*/
static int menu_is_tearoff(name)
char_u *name UNUSED;
static int menu_is_tearoff(char_u *name)
{
return FALSE;
}
@@ -1315,8 +1287,7 @@ char_u *name UNUSED;
* Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy and
* execute it.
*/
void ex_emenu(eap)
exarg_T *eap;
void ex_emenu(exarg_T *eap)
{
vimmenu_T *menu;
char_u *name;
@@ -1430,8 +1401,7 @@ exarg_T *eap;
/*
* Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy.
*/
vimmenu_T * gui_find_menu(path_name)
char_u *path_name;
vimmenu_T *gui_find_menu(char_u *path_name)
{
vimmenu_T *menu = NULL;
char_u *name;
@@ -1499,8 +1469,7 @@ static garray_T menutrans_ga = {0, 0, 0, 0, NULL};
* This function is also defined without the +multi_lang feature, in which
* case the commands are ignored.
*/
void ex_menutranslate(eap)
exarg_T *eap UNUSED;
void ex_menutranslate(exarg_T *eap)
{
char_u *arg = eap->arg;
menutrans_T *tp;
@@ -1562,8 +1531,7 @@ exarg_T *eap UNUSED;
/*
* Find the character just after one part of a menu name.
*/
static char_u * menu_skip_part(p)
char_u *p;
static char_u *menu_skip_part(char_u *p)
{
while (*p != NUL && *p != '.' && !vim_iswhite(*p)) {
if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL)
@@ -1577,9 +1545,7 @@ char_u *p;
* Lookup part of a menu name in the translations.
* Return a pointer to the translation or NULL if not found.
*/
static char_u * menutrans_lookup(name, len)
char_u *name;
int len;
static char_u *menutrans_lookup(char_u *name, int len)
{
menutrans_T *tp = (menutrans_T *)menutrans_ga.ga_data;
int i;
@@ -1609,8 +1575,7 @@ int len;
/*
* Unescape the name in the translate dictionary table.
*/
static void menu_unescape_name(name)
char_u *name;
static void menu_unescape_name(char_u *name)
{
char_u *p;
@@ -1623,8 +1588,7 @@ char_u *name;
* Isolate the menu name.
* Skip the menu name, and translate <Tab> into a real TAB.
*/
static char_u * menu_translate_tab_and_shift(arg_start)
char_u *arg_start;
static char_u *menu_translate_tab_and_shift(char_u *arg_start)
{
char_u *arg = arg_start;