shithub: scc

Download patch

ref: cbf56869f601cec10f2e34496016b628352b5388
parent: 5800a17b4c0575160843305eb85a9a53aa4386b1
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Feb 14 04:03:19 EST 2015

Remove register declarations

The usage of register must be done at the end. At this moment in some
moments is good show the code to other persons, and some time people
blame what the fuck are you doing using this old feature.

--- a/cc1/code.c
+++ b/cc1/code.c
@@ -104,7 +104,7 @@
 static void
 emitconst(Node *np)
 {
-	register char *bp, c;
+	char *bp, c;
 	Symbol *sym = np->u.sym;
 
 	if (np->type == inttype) {
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -106,7 +106,7 @@
 static struct dcldata *
 directdcl(struct dcldata *dp, uint8_t ns)
 {
-	register Symbol *sym;
+	Symbol *sym;
 
 	if (accept('(')) {
 		dp = declarator0(dp, ns);
@@ -131,7 +131,7 @@
 static struct dcldata*
 declarator0(struct dcldata *dp, uint8_t ns)
 {
-	register uint8_t  n;
+	uint8_t  n;
 
 	for (n = 0; accept('*'); ++n) {
 		while (accept(TQUALIFIER))
@@ -150,7 +150,7 @@
 declarator(Type *tp, int8_t flags, uint8_t ns)
 {
 	struct dcldata data[NR_DECLARATORS+2];
-	register struct dcldata *bp;
+	struct dcldata *bp;
 	Symbol *sym;
 
 	memset(data, 0, sizeof(data));
@@ -186,7 +186,7 @@
 	qlf = sign = type = cls = size = 0;
 
 	for (;;) {
-		register int8_t *p;
+		int8_t *p;
 		Type *(*dcl)(void) = NULL;
 
 		switch (yytoken) {
@@ -270,7 +270,7 @@
 static Symbol *
 newtag(uint8_t tag)
 {
-	register Symbol *sym;
+	Symbol *sym;
 	static uint8_t ns = NS_STRUCTS;
 
 	switch (yytoken) {
@@ -363,7 +363,7 @@
 static Type *
 enumdcl(void)
 {
-	register Type *tp;
+	Type *tp;
 	Symbol *sym;
 	int val = 0;
 
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -465,7 +465,7 @@
 static Node *
 postfix(void)
 {
-	register Node *np1, *np2;
+	Node *np1, *np2;
 
 	np1 = primary();
 	for (;;) {
@@ -511,7 +511,7 @@
 static Type *
 sizeexp(void)
 {
-	register Type *tp;
+	Type *tp;
 
 	expect('(');
 	switch (yytoken) {
@@ -531,8 +531,8 @@
 static Node *
 unary(void)
 {
-	register Node *(*fun)(char, Node *);
-	register char op;
+	Node *(*fun)(char, Node *);
+	char op;
 	Type *tp;
 
 	switch (yytoken) {
@@ -560,8 +560,8 @@
 static Node *
 cast(void)
 {
-	register Node *np1, *np2;
-	register Type *tp;
+	Node *np1, *np2;
+	Type *tp;
 
 	if (!accept('('))
 		return unary();
@@ -594,8 +594,8 @@
 static Node *
 mul(void)
 {
-	register Node *np, *(*fun)(char, Node *, Node *);
-	register char op;
+	Node *np, *(*fun)(char, Node *, Node *);
+	char op;
 
 	np = cast();
 	for (;;) {
@@ -613,8 +613,8 @@
 static Node *
 add(void)
 {
-	register char op;
-	register Node *np;
+	char op;
+	Node *np;
 
 	np = mul();
 	for (;;) {
@@ -631,8 +631,8 @@
 static Node *
 shift(void)
 {
-	register char op;
-	register Node *np;
+	char op;
+	Node *np;
 
 	np = add();
 	for (;;) {
@@ -649,8 +649,8 @@
 static Node *
 relational(void)
 {
-	register char op;
-	register Node *np;
+	char op;
+	Node *np;
 
 	np = shift();
 	for (;;) {
@@ -669,8 +669,8 @@
 static Node *
 eq(void)
 {
-	register char op;
-	register Node *np;
+	char op;
+	Node *np;
 
 	np = relational();
 	for (;;) {
@@ -687,7 +687,7 @@
 static Node *
 bit_and(void)
 {
-	register Node *np;
+	Node *np;
 
 	np = eq();
 	while (accept('&'))
@@ -698,7 +698,7 @@
 static Node *
 bit_xor(void)
 {
-	register Node *np;
+	Node *np;
 
 	np = bit_and();
 	while (accept('^'))
@@ -709,7 +709,7 @@
 static Node *
 bit_or(void)
 {
-	register Node *np;
+	Node *np;
 
 	np = bit_xor();
 	while (accept('|'))
@@ -720,7 +720,7 @@
 static Node *
 and(void)
 {
-	register Node *np;
+	Node *np;
 
 	np = bit_or();
 	while (accept(AND))
@@ -731,7 +731,7 @@
 static Node *
 or(void)
 {
-	register Node *np;
+	Node *np;
 
 	np = and();
 	while (accept(OR))
@@ -758,8 +758,8 @@
 static Node *
 assign(void)
 {
-	register Node *np, *(*fun)(char , Node *, Node *);
-	register char op;
+	Node *np, *(*fun)(char , Node *, Node *);
+	char op;
 
 	np = ternary();
 	for (;;) {
@@ -786,7 +786,7 @@
 Node *
 expr(void)
 {
-	register Node *np1, *np2;
+	Node *np1, *np2;
 
 	np1 = assign();
 	while (accept(',')) {
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -58,7 +58,7 @@
 static uint8_t
 number(void)
 {
-	register char ch, *bp;
+	char ch, *bp;
 	static char base;
 
 	if ((ch = getc(yyin)) == '0') {
@@ -137,7 +137,7 @@
 character(void)
 {
 	static char c;
-	register Symbol *sym;
+	Symbol *sym;
 
 	getc(yyin);   /* discard the initial ' */
 	c = getc(yyin);
@@ -156,8 +156,8 @@
 string(void)
 {
 	static char buf[STRINGSIZ+1];
-	register char *bp;
-	register int c;
+	char *bp;
+	int c;
 	static Symbol *sym;
 
 	getc(yyin); /* discard the initial " */
@@ -190,9 +190,9 @@
 static uint8_t
 iden(void)
 {
-	register char *bp;
-	register int c;
-	register Symbol *sym;
+	char *bp;
+	int c;
+	Symbol *sym;
 
 	for (bp = yytext; bp < &yytext[IDENTSIZ]; *bp++ = c) {
 		if (!isalnum(c = getc(yyin)) && c != '_')
@@ -213,7 +213,7 @@
 static uint8_t
 follow(int expect, int ifyes, int ifno)
 {
-	register int c = getc(yyin);
+	int c = getc(yyin);
 
 	if (c == expect) {
 		yytext[1] = c;
@@ -227,7 +227,7 @@
 static uint8_t
 minus(void)
 {
-	register int c = getc(yyin);
+	int c = getc(yyin);
 
 	yytext[1] = c;
 	yytext[2] = '\0';
@@ -245,7 +245,7 @@
 static uint8_t
 plus(void)
 {
-	register int c = getc(yyin);
+	int c = getc(yyin);
 
 	yytext[1] = c;
 	yytext[2] = '\0';
@@ -262,7 +262,7 @@
 static uint8_t
 relational(uint8_t op, uint8_t equal, uint8_t shift, uint8_t assig)
 {
-	register int c = getc(yyin);
+	int c = getc(yyin);
 
 	yytext[1] = c;
 	yytext[2] = '\0';
@@ -279,7 +279,7 @@
 static uint8_t
 logic(uint8_t op, uint8_t equal, uint8_t logic)
 {
-	register int c = getc(yyin);
+	int c = getc(yyin);
 
 	yytext[1] = c;
 	yytext[2] = '\0';
@@ -313,7 +313,7 @@
 static uint8_t
 operator(void)
 {
-	register uint8_t c = getc(yyin);
+	uint8_t c = getc(yyin);
 
 	yytext[0] = c;
 	yytext[1] = '\0';
@@ -338,7 +338,7 @@
 skipspaces(void)
 {
 
-	register int c;
+	int c;
 
 	while (isspace(c = getc(yyin))) {
 		if (c == '\n')
@@ -350,7 +350,7 @@
 uint8_t
 next(void)
 {
-	register int c;
+	int c;
 
 	ungetc(c = skipspaces(), yyin);
 
@@ -372,7 +372,7 @@
 }
 
 void
-expect(register uint8_t tok)
+expect(uint8_t tok)
 {
 	if (yytoken != tok)
 		unexpected();
@@ -382,7 +382,7 @@
 uint8_t
 ahead(void)
 {
-	register int c;
+	int c;
 	
 	ungetc(c = skipspaces(), yyin);
 
@@ -390,7 +390,7 @@
 }
 
 void
-open_file(register const char *file)
+open_file(const char *file)
 {
 	if (yyin != NULL)
 		fclose(yyin);
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -19,9 +19,9 @@
 } symtab [NR_NAMESPACES];
 
 static inline uint8_t
-hash(register const char *s)
+hash(const char *s)
 {
-	register uint8_t h, ch;
+	uint8_t h, ch;
 
 	for (h = 0; ch = *s++; h += ch)
 		/* nothing */;
@@ -32,7 +32,7 @@
 freesyms(uint8_t ns)
 {
 	static struct symtab *tbl;
-	register Symbol *sym, *next;
+	Symbol *sym, *next;
 
 	tbl = &symtab[ns];
 	for (sym = tbl->head; sym; sym = next) {
@@ -69,10 +69,10 @@
 }
 
 Symbol *
-lookup(register char *s, uint8_t ns)
+lookup(char *s, uint8_t ns)
 {
 	struct symtab *tbl;
-	register Symbol *sym;
+	Symbol *sym;
 
 	tbl = &symtab[(ns > NS_STRUCTS) ? NS_STRUCTS : ns];
 	for (sym = tbl->htab[hash(s)]; sym; sym = sym->hash) {
@@ -86,7 +86,7 @@
 Symbol *
 install(char *s, uint8_t ns)
 {
-	register Symbol *sym, **t;
+	Symbol *sym, **t;
 	struct symtab *tbl;
 
 	sym = xcalloc(1, sizeof(*sym));
@@ -148,7 +148,7 @@
 		{"while", WHILE, WHILE},
 		{NULL, 0, 0},
 	};
-	register Symbol *sym;
+	Symbol *sym;
 
 	for (bp = buff; bp->str; ++bp) {
 		sym = install(bp->str, NS_IDEN);
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -190,7 +190,7 @@
 {
 	static Type *typetab[NR_TYPE_HASH], **tbl, type;
 	static uint8_t t;
-	register Type *bp;
+	Type *bp;
 	static char letters[] = {
 		[PTR] = L_POINTER,   [ARY] = L_ARRAY,
 		[FTN] = L_FUNCTION,  [ENUM] = L_INT,
--- a/lib/xcalloc.c
+++ b/lib/xcalloc.c
@@ -5,7 +5,7 @@
 void *
 xcalloc(size_t n, size_t size)
 {
-	register void *p = calloc(n, size);
+	void *p = calloc(n, size);
 
 	if (!p)
 		die("out of memory");
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -5,7 +5,7 @@
 void *
 xmalloc(size_t size)
 {
-	register void *p = malloc(size);
+	void *p = malloc(size);
 
 	if (!p)
 		die("out of memory");
--- a/lib/xrealloc.c
+++ b/lib/xrealloc.c
@@ -3,9 +3,9 @@
 #include "../inc/cc.h"
 
 void *
-xrealloc(void *buff, register size_t size)
+xrealloc(void *buff, size_t size)
 {
-	register void *p = realloc(buff, size);
+	void *p = realloc(buff, size);
 
 	if (!p)
 		die("out of memory");
--- a/lib/xstrdup.c
+++ b/lib/xstrdup.c
@@ -5,8 +5,8 @@
 char *
 xstrdup(const char *s)
 {
-	register size_t len = strlen(s) + 1;
-	register char *p = xmalloc(len);
+	size_t len = strlen(s) + 1;
+	char *p = xmalloc(len);
 
 	return memcpy(p, s, len);
 }