shithub: scc

Download patch

ref: 696f09d26baafa1b2369c2b20784d5ad2f73dcc7
parent: cd933c3ca6494045d5d258c4aecb8372cf703976
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Aug 15 14:59:03 EDT 2012

Change of style

Putting the name of the function in the first column helps in order to
locate the places where functions are defined.

--- a/decl.c
+++ b/decl.c
@@ -13,7 +13,8 @@
 
 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 @@
 	return sym;
 }
 
-static void dirdcl(void)
+static void
+dirdcl(void)
 {
 	if (accept('(')) {
 		declarator();
@@ -58,7 +60,8 @@
 	}
 }
 
-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 @@
 	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 @@
 		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 @@
 	expect(';');
 }
 
-unsigned char decl(void)
+unsigned char
+decl(void)
 {
 	register struct ctype *tp;
 
@@ -169,7 +175,8 @@
 	return 1;
 }
 
-void type_name()
+void
+type_name()
 {
 
 }
--- 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 @@
 		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 @@
 	va_end(va);
 }
 
-
-void error(const char *fmt, ...)
+void
+error(const char *fmt, ...)
 {
 	va_list va;
 	va_start(va, fmt);
@@ -36,8 +37,8 @@
 	va_end(va);
 }
 
-
-void warning(const char *fmt, ...)
+void
+warning(const char *fmt, ...)
 {
 	va_list va;
 	va_start(va, fmt);
@@ -45,9 +46,8 @@
 	va_end(va);
 }
 
-
-
-void die(const char *fmt, ...)
+void
+die(const char *fmt, ...)
 {
 	va_list va;
 	va_start(va, fmt);
--- 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 @@
 	return np;
 }
 
-static struct node *postfix(void)
+static struct node *
+postfix(void)
 {
 	register struct node *np1, *np2;
 
@@ -76,7 +78,8 @@
 
 static struct node *cast(void);
 
-static struct node *unary(void)
+static struct node *
+unary(void)
 {
 	register unsigned char op;
 
@@ -110,7 +113,8 @@
 	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 @@
 	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 *add(void)
+static struct node *
+add(void)
 {
 	register unsigned char op;
 	register struct node *np;
@@ -154,7 +160,8 @@
 	}
 }
 
-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 *relational(void)
+static struct node *
+relational(void)
 {
 	register unsigned char op;
 	register struct node *np;
@@ -190,7 +198,8 @@
 	}
 }
 
-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 *bit_and(void)
+static struct node *
+bit_and(void)
 {
 	register struct node *np;
 
@@ -219,7 +229,8 @@
 	return np;
 }
 
-static struct node *bit_xor(void)
+static struct node *
+bit_xor(void)
 {
 	register struct node *np;
 
@@ -231,7 +242,8 @@
 	return np;
 }
 
-static struct node *bit_or(void)
+static struct node *
+bit_or(void)
 {
 	register struct node *np;
 
@@ -243,7 +255,8 @@
 	return np;
 }
 
-static struct node *and(void)
+static struct node *
+and(void)
 {
 	register struct node *np;
 
@@ -255,7 +268,8 @@
 	return np;
 }
 
-static struct node *or(void)
+static struct node *
+or(void)
 {
 	register struct node *np;
 
@@ -267,7 +281,8 @@
 	return np;
 }
 
-static struct node *cond(void)
+static struct node *
+cond(void)
 {
 	register struct node *np, *aux;
 
@@ -280,7 +295,8 @@
 	return np;
 }
 
-static struct node *assign(void)
+static struct node *
+assign(void)
 {
 	register unsigned char op;
 	register struct node *np;
@@ -307,7 +323,8 @@
 	return np;
 }
 
-struct node *expr(void)
+struct node *
+expr(void)
 {
 	register struct node *np;
 
--- 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 @@
 	stmt();
 }
 
-static void do_do(void)
+static void
+do_do(void)
 {
 	expect(DO);
 	stmt();
@@ -32,7 +35,8 @@
 	expect(')');
 }
 
-static void do_for(void)
+static void
+do_for(void)
 {
 	expect(FOR);
 	expect('(');
@@ -48,7 +52,8 @@
 	stmt();
 }
 
-static void do_if(void)
+static void
+do_if(void)
 {
 	expect(IF);
 	expect('(');
@@ -60,7 +65,8 @@
 
 }
 
-static void do_switch(void)
+static void
+do_switch(void)
 {
 	expect(SWITCH);
 	expect('(');
@@ -69,7 +75,8 @@
 	stmt();
 }
 
-void stmt(void)
+void
+stmt(void)
 {
 
 	switch (yytoken) {
@@ -112,7 +119,8 @@
 	expect(';');
 }
 
-void compound(void)
+void
+compound(void)
 {
 	if (accept('{')) {
 		new_ctx();
--- a/keyword.c
+++ b/keyword.c
@@ -44,7 +44,8 @@
 		 NULL, 0,
 };
 
-void init_keywords(void)
+void
+init_keywords(void)
 {
 	register struct keyword *bp;
 	register struct symbol *sym;
--- a/lex.c
+++ b/lex.c
@@ -19,7 +19,8 @@
 const char *filename;
 
 
-static char number(void)
+static char
+number(void)
 {
 	register char *bp;
 	register char ch;
@@ -39,7 +40,8 @@
 	return CONSTANT;
 }
 
-static unsigned char iden(void)
+static unsigned char
+iden(void)
 {
 	register char ch, *bp;
 	register struct symbol *sym;
@@ -58,7 +60,8 @@
 	return IDEN;
 }
 
-static unsigned char skip(void)
+static unsigned char
+skip(void)
 {
 	register int c;
 	extern char parser_out_home;
@@ -92,7 +95,8 @@
 	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 @@
 	return c;
 }
 
-static unsigned char minus(void)
+static unsigned char
+minus(void)
 {
 	register int c;
 
@@ -125,7 +130,8 @@
 	}
 }
 
-static unsigned char operator(void)
+static unsigned char
+operator(void)
 {
 	register unsigned char c;
 
@@ -144,7 +150,8 @@
 	}
 }
 
-void next(void)
+void
+next(void)
 {
 	register unsigned char c;
 
@@ -165,7 +172,8 @@
 	}
 }
 
-unsigned char ahead(void)
+unsigned char
+ahead(void)
 {
 	static unsigned char oldtok;
 
@@ -176,7 +184,8 @@
 	return aheadtok;
 }
 
-char accept(register unsigned char tok)
+char
+accept(register unsigned char tok)
 {
 	if (yytoken == tok) {
 		next();
@@ -185,7 +194,8 @@
 	return 0;
 }
 
-void expect(register unsigned char tok)
+void
+expect(register unsigned char tok)
 {
 	if (yytoken != tok)
 		error("unexpected %s", yytext);
@@ -192,7 +202,8 @@
 	next();
 }
 
-void open_file(register const char *file)
+void
+open_file(register const char *file)
 {
 	if (yyin != NULL)
 		fclose(yyin);
--- a/main.c
+++ b/main.c
@@ -11,7 +11,8 @@
 
 
 
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
 	init_keywords();
 	open_file(NULL);
--- a/symbol.c
+++ b/symbol.c
@@ -13,7 +13,8 @@
 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 @@
 	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 @@
 	}
 }
 
-struct symbol *install(const char *s)
+struct symbol *
+install(const char *s)
 {
 	register struct symbol *sym;
 	register unsigned char key;
@@ -69,7 +73,8 @@
 	return sym;
 }
 
-struct symbol *lookup(const char *s)
+struct symbol *
+lookup(const char *s)
 {
 	register struct symbol *sym;
 	static  unsigned char l;
--- a/types.c
+++ b/types.c
@@ -12,7 +12,8 @@
 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 @@
 	return tp;
 }
 
-void delctype(register struct ctype *tp)
+void
+delctype(register struct ctype *tp)
 {
 	if (--tp->refcnt == 0) {
 		if (tp->base)
@@ -59,7 +61,8 @@
 	return tp;
 }
 
-void pushtype(unsigned char mod)
+void
+pushtype(unsigned char mod)
 {
 	if (stackp == stack + NR_DECLARATORS)
 		error("Too much type declarators");
@@ -66,7 +69,8 @@
 	*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 @@
 	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 @@
 	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 @@
 #ifndef NDEBUG
 #include <stdio.h>
 
-void ptype(register struct ctype *tp)
+void
+ptype(register struct ctype *tp)
 {
 	static const char *strings[] = {
 		[0] =        "[no type]",
--- 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 @@
 	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 @@
 	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);
--