aboutsummaryrefslogtreecommitdiff
path: root/6.5/main.c
blob: 90bc87e506ca02a7ee5ed46bd3f14ca2962a3633 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "word.h"
#include "hash.h"

#define MAXWORD		100
#define HASHSIZE	100

struct nlist *hashtab[HASHSIZE];

int main(void)
{
	char word[MAXWORD];
	char *name;

	while (getword(word, MAXWORD) != EOF) {
		if (!strcmp(word, "#define")) {
			getword(word, MAXWORD);
			name = strdup(word);
			getword(word, MAXWORD);
			install(hashtab, HASHSIZE, name, word);
			free(name);
		} else if (!strcmp(word, "#undef")) {
			getword(word, MAXWORD);
			undef(hashtab, HASHSIZE, word);
		}
	}

	phashtab(hashtab, HASHSIZE);
	hashfree(hashtab, HASHSIZE);

	return 0;
}