minor mods
This commit is contained in:
parent
852601d0b5
commit
d8771e87f9
|
@ -24,6 +24,8 @@ IDF_new(tg, size, cpy)
|
||||||
{
|
{
|
||||||
static int nidf;
|
static int nidf;
|
||||||
static struct idf *pidf;
|
static struct idf *pidf;
|
||||||
|
static struct idf null_idf;
|
||||||
|
register struct idf *id;
|
||||||
#define NIDS 50
|
#define NIDS 50
|
||||||
#define IBUFSIZ 2048
|
#define IBUFSIZ 2048
|
||||||
static unsigned int icnt;
|
static unsigned int icnt;
|
||||||
|
@ -34,9 +36,12 @@ IDF_new(tg, size, cpy)
|
||||||
if (! nidf--) {
|
if (! nidf--) {
|
||||||
nidf += NIDS;
|
nidf += NIDS;
|
||||||
pidf = (struct idf *) Malloc(NIDS * sizeof (struct idf));
|
pidf = (struct idf *) Malloc(NIDS * sizeof (struct idf));
|
||||||
clear((char *) pidf, NIDS * sizeof(struct idf));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id = *pidf;
|
||||||
|
pidf++;
|
||||||
|
*id = null_idf;
|
||||||
|
|
||||||
if (cpy) {
|
if (cpy) {
|
||||||
if (size > icnt) {
|
if (size > icnt) {
|
||||||
icnt = size > IBUFSIZ ? size : IBUFSIZ;
|
icnt = size > IBUFSIZ ? size : IBUFSIZ;
|
||||||
|
@ -44,14 +49,14 @@ IDF_new(tg, size, cpy)
|
||||||
}
|
}
|
||||||
else p = ip;
|
else p = ip;
|
||||||
icnt -= size;
|
icnt -= size;
|
||||||
pidf->id_text = p;
|
id->id_text = p;
|
||||||
while (size--) {
|
while (size--) {
|
||||||
*p++ = *tg++;
|
*p++ = *tg++;
|
||||||
}
|
}
|
||||||
ip = p;
|
ip = p;
|
||||||
}
|
}
|
||||||
else pidf->id_text = tg;
|
else id->id_text = tg;
|
||||||
return pidf++;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IDF_DEBUG
|
#ifdef IDF_DEBUG
|
||||||
|
@ -85,14 +90,15 @@ str2idf(tg, cpy)
|
||||||
struct idf **hook;
|
struct idf **hook;
|
||||||
register struct idf *notch;
|
register struct idf *notch;
|
||||||
register unsigned int hash;
|
register unsigned int hash;
|
||||||
|
register int c;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
IDF_STARTHASH(hash);
|
IDF_STARTHASH(hash);
|
||||||
while (*cp) {
|
while (c = *cp++) {
|
||||||
IDF_ENHASH(hash, *cp++);
|
IDF_ENHASH(hash, c);
|
||||||
}
|
}
|
||||||
IDF_STOPHASH(hash);
|
IDF_STOPHASH(hash);
|
||||||
size = cp - tg + 1;
|
size = cp - tg;
|
||||||
|
|
||||||
/* The tag tg with length size and known hash value hash is
|
/* The tag tg with length size and known hash value hash is
|
||||||
looked up in the identifier table; if not found, it is
|
looked up in the identifier table; if not found, it is
|
||||||
|
@ -103,18 +109,17 @@ str2idf(tg, cpy)
|
||||||
|
|
||||||
while ((notch = *hook)) {
|
while ((notch = *hook)) {
|
||||||
register char *s1 = tg;
|
register char *s1 = tg;
|
||||||
int cmp;
|
|
||||||
|
|
||||||
cp = notch->id_text;
|
cp = notch->id_text;
|
||||||
|
|
||||||
while (!(cmp = (*s1 - *cp++))) {
|
while (!(c = (*s1 - *cp++))) {
|
||||||
if (*s1++ == '\0') {
|
if (*s1++ == '\0') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmp == 0) return notch;
|
if (c == 0) return notch;
|
||||||
if (cmp < 0) break;
|
if (c < 0) break;
|
||||||
hook = ¬ch->id_next;
|
hook = ¬ch->id_next;
|
||||||
}
|
}
|
||||||
/* a new struct idf must be inserted at the hook */
|
/* a new struct idf must be inserted at the hook */
|
||||||
|
@ -124,6 +129,3 @@ str2idf(tg, cpy)
|
||||||
*hook = notch; /* hooked in */
|
*hook = notch; /* hooked in */
|
||||||
return notch;
|
return notch;
|
||||||
}
|
}
|
||||||
|
|
||||||
init_idf() {
|
|
||||||
}
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ struct idf {
|
||||||
|
|
||||||
/* init_idf()
|
/* init_idf()
|
||||||
|
|
||||||
Initializes the namelist
|
Initializes the namelist. Empty for now.
|
||||||
*/
|
*/
|
||||||
extern init_idf();
|
#define init_idf()
|
||||||
|
|
||||||
/* struct idf * str2idf(tg, cp)
|
/* struct idf * str2idf(tg, cp)
|
||||||
char *tg;
|
char *tg;
|
||||||
|
|
Loading…
Reference in a new issue