static char *sccsid
= "@(#)misc.c 4.3 (Berkeley) 85/08/30";
FSTATIC
struct nameblock
*hashtab
[HASHSIZE
];
/* simple linear hash. hash function is sum of
characters mod hash table size.
hashtab
[i
]!=0 && unequal(s
,hashtab
[i
]->namep
);
struct nameblock
*srchname(s
)
return( hashtab
[hashloc(s
)] );
struct nameblock
*makename(s
)
/* make a fresh copy of the string s */
register struct nameblock
*p
;
if(nhashed
++ > HASHSIZE
-3)
fatal("Hash table overflow");
p
->nxtnameblock
= firstname
;
if(s
[0]!='.' || hasslash(s
) )
if( (t
= t0
= calloc( strlen(s
)+1 , sizeof(char)) ) == NULL
)
char *concat(a
,b
,c
) /* c = concatenation of a and b */
suffix(a
,b
,p
) /* is b the suffix of a? if so, set p = prefix */
if( (a
-a0
) < (b
-b0
) ) return(0);
if(*--a
!= *--b
) return(0);
while(a0
<a
) *p
++ = *a0
++;
if( p
= (int *) calloc(1,n
) )
/* copy string a into b, substituting for arguments */
struct varblock
*varptr(), *vbp
;
fatal("infinitely recursive macro?");
if(*a
!= '$') *b
++ = *a
++;
else if(*++a
=='\0' || *a
=='$')
closer
= ( *a
=='(' ? ')' : '}');
while(*a
!=' ' && *a
!=closer
&& *a
!='\0') *s
++ = *a
++;
while(*a
!=closer
&& *a
!='\0') ++a
;
if( (vbp
= varptr(vname
)) ->varval
!= 0)
b
= subst(vbp
->varval
, b
);
struct varblock
*varptr(), *p
;
if(p
->used
&& unequal(v
,"@") && unequal(v
,"*")
&& unequal(v
,"<") && unequal(v
,"?") )
fprintf(stderr
, "Warning: %s changed after being used\n",v
);
eqsign(a
) /*look for arguments with equal signs but not colons */
for(s
=a
; *s
!='\0' && *s
!=':' ; ++s
)
for(t
= a
; *t
!='=' && *t
!=' ' && *t
!='\t' ; ++t
);
for(++s
; *s
==' ' || *s
=='\t' ; ++s
);
struct varblock
*varptr(v
)
register struct varblock
*vp
;
for(vp
= firstvar
; vp
; vp
= vp
->nxtvarblock
)
if(! unequal(v
, vp
->varname
))
vp
->nxtvarblock
= firstvar
;
if(s
) fprintf(stderr
, "Make: %s. Stop.\n", s
);
else fprintf(stderr
, "\nStop.\n");
sprintf(buf
, "line %d: %s", yylineno
, s
);
struct chain
*appendq(head
, tail
)
register struct chain
*p
, *q
;
for(q
= head
; q
->nextp
; q
= q
->nextp
)
register char *qbufp
, *s
;
static char qbuf
[QBUFMAX
];
if(qbufp
+strlen(s
) > &qbuf
[QBUFMAX
-3])
fprintf(stderr
, "$? list too long\n");