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

@@ -41,8 +41,7 @@ static void sha256_process __ARGS((context_sha256_T *ctx, char_u data[64]));
(b)[(i) + 3] = (char_u)((n) ); \
}
void sha256_start(ctx)
context_sha256_T *ctx;
void sha256_start(context_sha256_T *ctx)
{
ctx->total[0] = 0;
ctx->total[1] = 0;
@@ -57,9 +56,7 @@ context_sha256_T *ctx;
ctx->state[7] = 0x5BE0CD19;
}
static void sha256_process(ctx, data)
context_sha256_T *ctx;
char_u data[64];
static void sha256_process(context_sha256_T *ctx, char_u data[64])
{
UINT32_T temp1, temp2, W[64];
UINT32_T A, B, C, D, E, F, G, H;
@@ -190,10 +187,7 @@ char_u data[64];
ctx->state[7] += H;
}
void sha256_update(ctx, input, length)
context_sha256_T *ctx;
char_u *input;
UINT32_T length;
void sha256_update(context_sha256_T *ctx, char_u *input, UINT32_T length)
{
UINT32_T left, fill;
@@ -234,9 +228,7 @@ static char_u sha256_padding[64] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
void sha256_finish(ctx, digest)
context_sha256_T *ctx;
char_u digest[32];
void sha256_finish(context_sha256_T *ctx, char_u digest[32])
{
UINT32_T last, padn;
UINT32_T high, low;
@@ -270,11 +262,7 @@ static unsigned int get_some_time __ARGS((void));
* Returns hex digest of "buf[buf_len]" in a static array.
* if "salt" is not NULL also do "salt[salt_len]".
*/
char_u * sha256_bytes(buf, buf_len, salt, salt_len)
char_u *buf;
int buf_len;
char_u *salt;
int salt_len;
char_u *sha256_bytes(char_u *buf, int buf_len, char_u *salt, int salt_len)
{
char_u sha256sum[32];
static char_u hexit[65];
@@ -297,10 +285,7 @@ int salt_len;
/*
* Returns sha256(buf) as 64 hex chars in static array.
*/
char_u * sha256_key(buf, salt, salt_len)
char_u *buf;
char_u *salt;
int salt_len;
char_u *sha256_key(char_u *buf, char_u *salt, int salt_len)
{
/* No passwd means don't encrypt */
if (buf == NULL || *buf == NUL)
@@ -332,7 +317,7 @@ static char *sha_self_test_vector[] = {
* Perform a test on the SHA256 algorithm.
* Return FAIL or OK.
*/
int sha256_self_test() {
int sha256_self_test(void) {
int i, j;
char output[65];
context_sha256_T ctx;
@@ -370,7 +355,7 @@ int sha256_self_test() {
return failures > 0 ? FAIL : OK;
}
static unsigned int get_some_time() {
static unsigned int get_some_time(void) {
# ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
@@ -386,11 +371,7 @@ static unsigned int get_some_time() {
* Fill "header[header_len]" with random_data.
* Also "salt[salt_len]" when "salt" is not NULL.
*/
void sha2_seed(header, header_len, salt, salt_len)
char_u *header;
int header_len;
char_u *salt;
int salt_len;
void sha2_seed(char_u *header, int header_len, char_u *salt, int salt_len)
{
int i;
static char_u random_data[1000];