ANSI C conversion.

This commit is contained in:
carl 2019-05-11 01:18:01 +08:00
parent 21e15965cc
commit 53d2894ed1

View file

@ -17,8 +17,8 @@ struct symtab *idtable, *deftable;
extern void error(char *s, char* s1);
struct symtab *
findident(s, mode, table) char *s; struct symtab **table; {
struct symtab * findident(char *s, int mode, struct symtab **table)
{
/*
* Look for identifier s in the symboltable referred to by *table.
* If mode = LOOKING, no new entry's will be made.
@ -28,8 +28,10 @@ findident(s, mode, table) char *s; struct symtab **table; {
register struct symtab *p;
register int n;
if (!*table) { /* No entry for this symbol */
if (mode == LOOKING) return (struct symtab *) 0;
if (!*table)
{ /* No entry for this symbol */
if (mode == LOOKING)
return (struct symtab *) 0;
/*
* Make new entry
*/
@ -40,16 +42,20 @@ findident(s, mode, table) char *s; struct symtab **table; {
*table = p;
return p;
}
else {
else
{
p = *table;
if ((n = strcmp(p->s_name,s)) == 0) { /* This is it! */
if (mode == ENTERING) {
if ((n = strcmp(p->s_name, s)) == 0)
{ /* This is it! */
if (mode == ENTERING)
{
error("Identifier %s redefined", s);
}
return p;
}
/* Binary tree ..... */
if (n < 0) return findident(s,mode,&(p->s_left));
if (n < 0)
return findident(s, mode, &(p->s_left));
return findident(s, mode, &(p->s_right));
}
/* NOTREACHED */