commit 696f09d26baafa1b2369c2b20784d5ad2f73dcc7
parent cd933c3ca6494045d5d258c4aecb8372cf703976
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 15 Aug 2012 18:59:03 +0200
Change of style
Putting the name of the function in the first column helps in order to
locate the places where functions are defined.
Diffstat:
10 files changed, 132 insertions(+), 71 deletions(-)
diff --git a/decl.c b/decl.c
@@ -13,7 +13,8 @@ char parser_out_home;
static void declarator(void);
-static struct symbol *newiden(char *s)
+static struct symbol *
+newiden(char *s)
{
register struct symbol *sym = lookup(yytext);
@@ -24,7 +25,8 @@ static struct symbol *newiden(char *s)
return sym;
}
-static void dirdcl(void)
+static void
+dirdcl(void)
{
if (accept('(')) {
declarator();
@@ -58,7 +60,8 @@ static void dirdcl(void)
}
}
-static unsigned char spec(register struct ctype *cp)
+static unsigned char
+spec(register struct ctype *cp)
{
register unsigned char sign, n;
@@ -96,7 +99,8 @@ signed_and_unsigned:
error("both 'signed' and 'unsigned' in declaration specifiers");
}
-static void declarator(void)
+static void
+declarator(void)
{
unsigned char qlf[NR_DECLARATORS];
register unsigned char *bp, *lim;
@@ -126,7 +130,8 @@ static void declarator(void)
pushtype(*bp);
}
-static void listdcl(register struct ctype *tp)
+static void
+listdcl(register struct ctype *tp)
{
do {
register struct ctype *new;
@@ -145,7 +150,8 @@ static void listdcl(register struct ctype *tp)
expect(';');
}
-unsigned char decl(void)
+unsigned char
+decl(void)
{
register struct ctype *tp;
@@ -169,7 +175,8 @@ unsigned char decl(void)
return 1;
}
-void type_name()
+void
+type_name()
{
}
diff --git a/error.c b/error.c
@@ -8,7 +8,8 @@
-static void warning_error_helper(char flag, const char *fmt, va_list va)
+static void
+warning_error_helper(char flag, const char *fmt, va_list va)
{
fprintf(stderr, "%s:%s:%u:%u: ",
(!flag) ? "warning" : "error", filename, linenum, columnum);
@@ -18,8 +19,8 @@ static void warning_error_helper(char flag, const char *fmt, va_list va)
exit(EXIT_FAILURE); /* TODO: uhmmmm */
}
-
-void warning_error(char flag, const char *fmt, ...)
+void
+warning_error(char flag, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
@@ -27,8 +28,8 @@ void warning_error(char flag, const char *fmt, ...)
va_end(va);
}
-
-void error(const char *fmt, ...)
+void
+error(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
@@ -36,8 +37,8 @@ void error(const char *fmt, ...)
va_end(va);
}
-
-void warning(const char *fmt, ...)
+void
+warning(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
@@ -45,9 +46,8 @@ void warning(const char *fmt, ...)
va_end(va);
}
-
-
-void die(const char *fmt, ...)
+void
+die(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
diff --git a/expr.c b/expr.c
@@ -10,7 +10,8 @@
struct node *expr(void);
-static struct node *primary(void)
+static struct node *
+primary(void)
{
register struct node *np;
@@ -33,7 +34,8 @@ static struct node *primary(void)
return np;
}
-static struct node *postfix(void)
+static struct node *
+postfix(void)
{
register struct node *np1, *np2;
@@ -76,7 +78,8 @@ static struct node *postfix(void)
static struct node *cast(void);
-static struct node *unary(void)
+static struct node *
+unary(void)
{
register unsigned char op;
@@ -110,7 +113,8 @@ call_unary:
return node1(op, unary());
}
-static struct node *cast(void)
+static struct node *
+cast(void)
{
while (accept('(')) { /* TODO: Implement casts */
type_name(); /* check if it really is a type name */
@@ -119,7 +123,8 @@ static struct node *cast(void)
return unary();
}
-static struct node *mul(void)
+static struct node *
+mul(void)
{
register struct node *np;
register unsigned char op;
@@ -137,7 +142,8 @@ static struct node *mul(void)
}
}
-static struct node *add(void)
+static struct node *
+add(void)
{
register unsigned char op;
register struct node *np;
@@ -154,7 +160,8 @@ static struct node *add(void)
}
}
-static struct node *shift(void)
+static struct node *
+shift(void)
{
register unsigned char op;
register struct node *np;
@@ -171,7 +178,8 @@ static struct node *shift(void)
}
}
-static struct node *relational(void)
+static struct node *
+relational(void)
{
register unsigned char op;
register struct node *np;
@@ -190,7 +198,8 @@ static struct node *relational(void)
}
}
-static struct node *eq(void)
+static struct node *
+eq(void)
{
register unsigned char op;
register struct node *np;
@@ -207,7 +216,8 @@ static struct node *eq(void)
}
}
-static struct node *bit_and(void)
+static struct node *
+bit_and(void)
{
register struct node *np;
@@ -219,7 +229,8 @@ static struct node *bit_and(void)
return np;
}
-static struct node *bit_xor(void)
+static struct node *
+bit_xor(void)
{
register struct node *np;
@@ -231,7 +242,8 @@ static struct node *bit_xor(void)
return np;
}
-static struct node *bit_or(void)
+static struct node *
+bit_or(void)
{
register struct node *np;
@@ -243,7 +255,8 @@ static struct node *bit_or(void)
return np;
}
-static struct node *and(void)
+static struct node *
+and(void)
{
register struct node *np;
@@ -255,7 +268,8 @@ static struct node *and(void)
return np;
}
-static struct node *or(void)
+static struct node *
+or(void)
{
register struct node *np;
@@ -267,7 +281,8 @@ static struct node *or(void)
return np;
}
-static struct node *cond(void)
+static struct node *
+cond(void)
{
register struct node *np, *aux;
@@ -280,7 +295,8 @@ static struct node *cond(void)
return np;
}
-static struct node *assign(void)
+static struct node *
+assign(void)
{
register unsigned char op;
register struct node *np;
@@ -307,7 +323,8 @@ static struct node *assign(void)
return np;
}
-struct node *expr(void)
+struct node *
+expr(void)
{
register struct node *np;
diff --git a/flow.c b/flow.c
@@ -7,13 +7,15 @@
void stmt(void);
-static void do_goto(void)
+static void
+do_goto(void)
{
expect(GOTO);
expect(IDEN);
}
-static void do_while(void)
+static void
+do_while(void)
{
expect(WHILE);
expect('(');
@@ -22,7 +24,8 @@ static void do_while(void)
stmt();
}
-static void do_do(void)
+static void
+do_do(void)
{
expect(DO);
stmt();
@@ -32,7 +35,8 @@ static void do_do(void)
expect(')');
}
-static void do_for(void)
+static void
+do_for(void)
{
expect(FOR);
expect('(');
@@ -48,7 +52,8 @@ static void do_for(void)
stmt();
}
-static void do_if(void)
+static void
+do_if(void)
{
expect(IF);
expect('(');
@@ -60,7 +65,8 @@ static void do_if(void)
}
-static void do_switch(void)
+static void
+do_switch(void)
{
expect(SWITCH);
expect('(');
@@ -69,7 +75,8 @@ static void do_switch(void)
stmt();
}
-void stmt(void)
+void
+stmt(void)
{
switch (yytoken) {
@@ -112,7 +119,8 @@ void stmt(void)
expect(';');
}
-void compound(void)
+void
+compound(void)
{
if (accept('{')) {
new_ctx();
diff --git a/keyword.c b/keyword.c
@@ -44,7 +44,8 @@ static struct keyword {
NULL, 0,
};
-void init_keywords(void)
+void
+init_keywords(void)
{
register struct keyword *bp;
register struct symbol *sym;
diff --git a/lex.c b/lex.c
@@ -19,7 +19,8 @@ unsigned columnum;
const char *filename;
-static char number(void)
+static char
+number(void)
{
register char *bp;
register char ch;
@@ -39,7 +40,8 @@ static char number(void)
return CONSTANT;
}
-static unsigned char iden(void)
+static unsigned char
+iden(void)
{
register char ch, *bp;
register struct symbol *sym;
@@ -58,7 +60,8 @@ static unsigned char iden(void)
return IDEN;
}
-static unsigned char skip(void)
+static unsigned char
+skip(void)
{
register int c;
extern char parser_out_home;
@@ -92,7 +95,8 @@ follow(unsigned char op, unsigned char eq, unsigned char rep)
return op;
}
-static unsigned char rel_shift(unsigned char op)
+static unsigned char
+rel_shift(unsigned char op)
{
static char tokens[2][3] = {
{GE, SHL, SHL_EQ},
@@ -111,7 +115,8 @@ static unsigned char rel_shift(unsigned char op)
return c;
}
-static unsigned char minus(void)
+static unsigned char
+minus(void)
{
register int c;
@@ -125,7 +130,8 @@ static unsigned char minus(void)
}
}
-static unsigned char operator(void)
+static unsigned char
+operator(void)
{
register unsigned char c;
@@ -144,7 +150,8 @@ static unsigned char operator(void)
}
}
-void next(void)
+void
+next(void)
{
register unsigned char c;
@@ -165,7 +172,8 @@ void next(void)
}
}
-unsigned char ahead(void)
+unsigned char
+ahead(void)
{
static unsigned char oldtok;
@@ -176,7 +184,8 @@ unsigned char ahead(void)
return aheadtok;
}
-char accept(register unsigned char tok)
+char
+accept(register unsigned char tok)
{
if (yytoken == tok) {
next();
@@ -185,14 +194,16 @@ char accept(register unsigned char tok)
return 0;
}
-void expect(register unsigned char tok)
+void
+expect(register unsigned char tok)
{
if (yytoken != tok)
error("unexpected %s", yytext);
next();
}
-void open_file(register const char *file)
+void
+open_file(register const char *file)
{
if (yyin != NULL)
fclose(yyin);
diff --git a/main.c b/main.c
@@ -11,7 +11,8 @@ struct user_opt options;
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
init_keywords();
open_file(NULL);
diff --git a/symbol.c b/symbol.c
@@ -13,7 +13,8 @@ static struct symbol *htab[NR_SYM_HASH];
static struct symbol *head;
-static inline unsigned char hash(register const char *s)
+static inline unsigned char
+hash(register const char *s)
{
register unsigned char h, ch;
@@ -22,12 +23,14 @@ static inline unsigned char hash(register const char *s)
return h & NR_SYM_HASH - 1;
}
-void new_ctx(void)
+void
+new_ctx(void)
{
++curctx;
}
-void del_ctx(void)
+void
+del_ctx(void)
{
register struct symbol *sym, *aux;
static char *s;
@@ -46,7 +49,8 @@ void del_ctx(void)
}
}
-struct symbol *install(const char *s)
+struct symbol *
+install(const char *s)
{
register struct symbol *sym;
register unsigned char key;
@@ -69,7 +73,8 @@ struct symbol *install(const char *s)
return sym;
}
-struct symbol *lookup(const char *s)
+struct symbol *
+lookup(const char *s)
{
register struct symbol *sym;
static unsigned char l;
diff --git a/types.c b/types.c
@@ -12,7 +12,8 @@ static unsigned char stack[NR_DECLARATORS];
static unsigned char *stackp = stack;
-struct ctype *newctype(void)
+struct ctype *
+newctype(void)
{
register struct ctype *tp = xcalloc(sizeof(tp), 1);
@@ -20,7 +21,8 @@ struct ctype *newctype(void)
return tp;
}
-void delctype(register struct ctype *tp)
+void
+delctype(register struct ctype *tp)
{
if (--tp->refcnt == 0) {
if (tp->base)
@@ -59,14 +61,16 @@ mktype(register struct ctype *tp, unsigned char op)
return tp;
}
-void pushtype(unsigned char mod)
+void
+pushtype(unsigned char mod)
{
if (stackp == stack + NR_DECLARATORS)
error("Too much type declarators");
*stackp++ = mod;
}
-struct ctype *decl_type(struct ctype *tp)
+struct ctype *
+decl_type(struct ctype *tp)
{
while (stackp != stack)
tp = mktype(tp, *--stackp);
@@ -74,7 +78,8 @@ struct ctype *decl_type(struct ctype *tp)
return tp;
}
-unsigned char btype(unsigned char type, unsigned char tok)
+unsigned char
+btype(unsigned char type, unsigned char tok)
{
switch (tok) {
case VOID:
@@ -124,7 +129,8 @@ unsigned char btype(unsigned char type, unsigned char tok)
error("two or more basic types");
}
-void ctype(struct ctype *cp, unsigned char mod)
+void
+ctype(struct ctype *cp, unsigned char mod)
{
extern unsigned char curctx;
@@ -190,7 +196,8 @@ duplicated:
#ifndef NDEBUG
#include <stdio.h>
-void ptype(register struct ctype *tp)
+void
+ptype(register struct ctype *tp)
{
static const char *strings[] = {
[0] = "[no type]",
diff --git a/wrapper.c b/wrapper.c
@@ -5,13 +5,15 @@
#include "cc.h"
-static void out_of_memory(void)
+static void
+out_of_memory(void)
{
/* TODO: deal with out of memory errors */
error("out of memory");
}
-void *xmalloc(size_t size)
+void *
+xmalloc(size_t size)
{
register void *p = malloc(size);
@@ -20,7 +22,8 @@ void *xmalloc(size_t size)
return p;
}
-void *xcalloc(size_t nmemb, size_t size)
+void *
+xcalloc(size_t nmemb, size_t size)
{
register size_t nbytes = nmemb * size;
register void *p = xmalloc(nbytes);
@@ -28,7 +31,8 @@ void *xcalloc(size_t nmemb, size_t size)
return memset(p, nbytes, 0);
}
-char *xstrdup(const char *s)
+char *
+xstrdup(const char *s)
{
register size_t len = strlen(s);
register char *p = xmalloc(len);