Fixed problem with global names used for statics as well as externs

This commit is contained in:
ceriel 1990-10-08 11:44:15 +00:00
parent 06e6c8638f
commit 7f8a099a15
2 changed files with 24 additions and 38 deletions

View file

@ -159,37 +159,11 @@ STATIC getpnames(dumpp)
}
STATIC bool name_exists(name,endp,endd)
char *name;
proc_p endp;
dblock_p endd;
{
/* Search the proctable (from fproc to endp)
* and the data block table (from fdblock to endd)
* to see if the name is already in use.
*/
proc_p p;
dblock_p d;
if (! name) return FALSE; /* HOL blocks don't have names */
for (p = fproc; p != endp; p = p->p_next) {
if (strcmp(name,pnames[p->p_id]) == 0) return TRUE;
}
for (d = fdblock; d != endd; d = d->d_next) {
if (dnames[d->d_id] != 0 && /* HOL blocks excluded */
strcmp(name,dnames[d->d_id]) == 0) return TRUE;
}
return FALSE;
}
static int nn = 0;
STATIC new_name(s)
char **s;
{
static int nn = 0;
char buf[20];
int len = strlen(*s);
@ -204,7 +178,7 @@ STATIC new_name(s)
}
STATIC uniq_names()
{
/* The names of all internal procedures and data blocks
@ -218,18 +192,18 @@ STATIC uniq_names()
dblock_p d;
for (p = fproc; p != (proc_p) 0; p = p->p_next) {
if (!(p->p_flags1 & PF_EXTERNAL) &&
name_exists(pnames[p->p_id],p,fdblock)) {
if (!(p->p_flags1 & PF_EXTERNAL)) {
new_name(&(pnames[p->p_id]));
}
}
for (d = fdblock; d != (dblock_p) 0; d = d->d_next) {
if (!(d->d_flags1 & DF_EXTERNAL) &&
name_exists(dnames[d->d_id],(proc_p) 0,d) ) {
if (!(d->d_flags1 & DF_EXTERNAL) && dnames[d->d_id]) {
new_name(&(dnames[d->d_id]));
}
}
}
main(argc,argv)
int argc;
char *argv[];

View file

@ -118,9 +118,13 @@ dblock_p symlookup(name, status)
* list.
*/
if (strcmp((*spp)->sy_name, name) == 0) {
/* found */
lastname = (*spp)->sy_name;
return ((*spp)->sy_dblock);
if (status != DEFINING ||
(*spp)->sy_dblock->d_pseudo == DUNKNOWN) {
/* found */
lastname = (*spp)->sy_name;
return ((*spp)->sy_dblock);
}
break;
} else {
spp = &(*spp)->sy_next;
}
@ -130,7 +134,9 @@ dblock_p symlookup(name, status)
* indicating that we don't need this name.
*/
if (status == IMPORTING) return (dblock_p) 0;
*spp = sp = newsym();
sp = newsym();
sp->sy_next = *spp;
*spp = sp;
sp->sy_name = (char *) newcore(strlen(name)+1);
strcpy(sp->sy_name, name);
lastname = sp->sy_name; /* quick hack to get at
@ -210,7 +216,11 @@ proc_p proclookup(name, status)
*/
if (strcmp((*ppp)->pr_name, name) == 0) {
/* found */
return ((*ppp)->pr_proc);
if (status != DEFINING ||
! ((*ppp)->pr_proc->p_flags1 & PF_BODYSEEN)) {
return ((*ppp)->pr_proc);
}
break;
} else {
ppp = &(*ppp)->pr_next;
}
@ -220,7 +230,9 @@ proc_p proclookup(name, status)
* return 0, indicating we don't want this proc.
*/
if (status == IMPORTING) return (proc_p) 0;
*ppp = pp = newprc();
pp = newprc();
pp->pr_next = *ppp;
*ppp = pp;
pp->pr_name = (char *) newcore(strlen(name)+1);
strcpy(pp->pr_name, name);
dp = pp->pr_proc = newproc();