From b76c358f3de9106a4bdbf853b4c4371f6f7a62c2 Mon Sep 17 00:00:00 2001 From: scott-linder Date: Sun, 23 Feb 2014 15:34:45 -0500 Subject: 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 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. --- src/version.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'src/version.c') diff --git a/src/version.c b/src/version.c index 62a7aa8bc8..a928e840bd 100644 --- a/src/version.c +++ b/src/version.c @@ -568,7 +568,7 @@ static char *(extra_patches[]) = NULL }; -int highest_patch() { +int highest_patch(void) { int i; int h = 0; @@ -581,8 +581,7 @@ int highest_patch() { /* * Return TRUE if patch "n" has been included. */ -int has_patch(n) -int n; +int has_patch(int n) { int i; @@ -592,8 +591,7 @@ int n; return FALSE; } -void ex_version(eap) -exarg_T *eap; +void ex_version(exarg_T *eap) { /* * Ignore a ":version 9.99" command. @@ -607,7 +605,7 @@ exarg_T *eap; /* * List all features aligned in columns, dictionary style. */ -static void list_features() { +static void list_features(void) { int i; int ncol; int nrow; @@ -662,7 +660,7 @@ static void list_features() { } } -void list_version() { +void list_version(void) { int i; int first; char *s = ""; @@ -792,8 +790,7 @@ void list_version() { * Output a string for the version message. If it's going to wrap, output a * newline, unless the message is too long to fit on the screen anyway. */ -static void version_msg(s) -char *s; +static void version_msg(char *s) { int len = (int)STRLEN(s); @@ -810,7 +807,7 @@ static void do_intro_line __ARGS((int row, char_u *mesg, int add_version, /* * Show the intro message when not editing a file. */ -void maybe_intro_message() { +void maybe_intro_message(void) { if (bufempty() && curbuf->b_fname == NULL && firstwin->w_next == NULL @@ -823,8 +820,10 @@ void maybe_intro_message() { * Only used when starting Vim on an empty file, without a file name. * Or with the ":intro" command (for Sven :-). */ -void intro_message(colon) -int colon; /* TRUE for ":intro" */ +void +intro_message ( + int colon /* TRUE for ":intro" */ +) { int i; int row; @@ -904,11 +903,7 @@ int colon; /* TRUE for ":intro" */ msg_row = row; } -static void do_intro_line(row, mesg, add_version, attr) -int row; -char_u *mesg; -int add_version; -int attr; +static void do_intro_line(int row, char_u *mesg, int add_version, int attr) { char_u vers[20]; int col; @@ -969,8 +964,7 @@ int attr; /* * ":intro": clear screen, display intro screen and wait for return. */ -void ex_intro(eap) -exarg_T *eap UNUSED; +void ex_intro(exarg_T *eap) { screenclear(); intro_message(TRUE); -- cgit From 0ef90c13b72b74928bfb3c183c7a5bd7240b51ad Mon Sep 17 00:00:00 2001 From: scott-linder Date: Tue, 25 Feb 2014 15:41:16 -0500 Subject: Removes 'proto' dir See #137 for the issue. Every header in the proto directory was: * Given include guards in the form #ifndef NEOVIM_FILENAME_H #define NEOVIM_FILENAME_H ... #endif /* NEOVIM_FILENAM_H */ * Renamed from *.pro -> *.h * Moved from src/proto/ to src/ This would have caused conficts with some existing headers in src/; rather than merge these conflicts now (which is a whole other can of worms involving multiple and conditional inclusion), any header in src/ with a conflicting name was renamed from *.h -> *_defs.h (which may or may not actually describe its purpose, the change is purely a namespacing issue). Once all of these changes were made a script was developed to determine what #includes needed to be added to each source file to describe its dependencies and allow it to compile; because the script is so short and I'll just list it here: #! /bin/bash cd $(dirname $0) # Scrapes `make` output for provided error messages and outputs #includes # needed to resolve them. # $1 : part of the clang error message between filename and identifier list_missing_includes() { for file_missing_pair in $(CC=clang make 2>&1 >/dev/null | sed -n "s/\/\(.*\.[hc]\).*$1.*'\(.*\)'.*/\1:\2/p"); do fields=(${file_missing_pair//:/ }) source_file=${fields[0]} missing_func=${fields[1]} # Try to find the declaration of the missing function. echo $(basename $source_file) \ \#include \"$(grep -r "\b$missing_func __ARGS" | sed -n "s/.*\/\(.*\)\:.*/\1/p")\" # Remove duplicates done | sort | uniq } echo "Finding missing function prototypes..." list_missing_includes "implicit declaration of function" echo "Finding missing identifier declarations..." list_missing_includes "use of undeclared identifier" Each list of required headers was added by hand in the following format: #include "vim.h" #include "*_defs.h" #include "filename.h" /* All other includes in same module here, in alphabetical order. */ /* All includes from other modules (e.g. "os/*.h") here in alphabetical * order. */ --- src/version.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/version.c') diff --git a/src/version.c b/src/version.c index a928e840bd..e85f7a57ec 100644 --- a/src/version.c +++ b/src/version.c @@ -8,7 +8,12 @@ */ #include "vim.h" - +#include "version.h" +#include "charset.h" +#include "memline.h" +#include "message.h" +#include "misc2.h" +#include "screen.h" /* * Vim originated from Stevie version 3.6 (Fish disk 217) by GRWalter (Fred) @@ -22,7 +27,7 @@ * interesting. */ -#include "version.h" +#include "version_defs.h" char *Version = VIM_VERSION_SHORT; static char *mediumVersion = VIM_VERSION_MEDIUM; -- cgit