ANSI C conversion.
This commit is contained in:
parent
21e15965cc
commit
53d2894ed1
|
@ -17,8 +17,8 @@ struct symtab *idtable, *deftable;
|
||||||
|
|
||||||
extern void error(char *s, char* s1);
|
extern void error(char *s, char* s1);
|
||||||
|
|
||||||
struct symtab *
|
struct symtab * findident(char *s, int mode, struct symtab **table)
|
||||||
findident(s, mode, table) char *s; struct symtab **table; {
|
{
|
||||||
/*
|
/*
|
||||||
* Look for identifier s in the symboltable referred to by *table.
|
* Look for identifier s in the symboltable referred to by *table.
|
||||||
* If mode = LOOKING, no new entry's will be made.
|
* If mode = LOOKING, no new entry's will be made.
|
||||||
|
@ -28,29 +28,35 @@ findident(s, mode, table) char *s; struct symtab **table; {
|
||||||
register struct symtab *p;
|
register struct symtab *p;
|
||||||
register int n;
|
register int n;
|
||||||
|
|
||||||
if (!*table) { /* No entry for this symbol */
|
if (!*table)
|
||||||
if (mode == LOOKING) return (struct symtab *) 0;
|
{ /* No entry for this symbol */
|
||||||
|
if (mode == LOOKING)
|
||||||
|
return (struct symtab *) 0;
|
||||||
/*
|
/*
|
||||||
* Make new entry
|
* Make new entry
|
||||||
*/
|
*/
|
||||||
p = (struct symtab *) malloc(sizeof *p);
|
p = (struct symtab *) malloc(sizeof *p);
|
||||||
p->s_left = p->s_right = (struct symtab *) 0;
|
p->s_left = p->s_right = (struct symtab *) 0;
|
||||||
p->s_name = malloc( (unsigned) (strlen(s) + 1));
|
p->s_name = malloc((unsigned) (strlen(s) + 1));
|
||||||
strcpy(p->s_name,s);
|
strcpy(p->s_name, s);
|
||||||
*table = p;
|
*table = p;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
p = *table;
|
p = *table;
|
||||||
if ((n = strcmp(p->s_name,s)) == 0) { /* This is it! */
|
if ((n = strcmp(p->s_name, s)) == 0)
|
||||||
if (mode == ENTERING) {
|
{ /* This is it! */
|
||||||
error("Identifier %s redefined",s);
|
if (mode == ENTERING)
|
||||||
|
{
|
||||||
|
error("Identifier %s redefined", s);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
/* Binary tree ..... */
|
/* Binary tree ..... */
|
||||||
if (n < 0) return findident(s,mode,&(p->s_left));
|
if (n < 0)
|
||||||
return findident(s,mode,&(p->s_right));
|
return findident(s, mode, &(p->s_left));
|
||||||
|
return findident(s, mode, &(p->s_right));
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue