aboutsummaryrefslogtreecommitdiff
path: root/6.6/main.c
blob: 19a732318f00689f10d8c51184fb3533d23f84d9 (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
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "word.h"
#include "hash.h"
#include "def.h"

#define MAXWORD		100
#define HASHSIZE	100

struct nlist *hashtab[HASHSIZE];

int main(void)
{
	char word[MAXWORD];
	struct nlist *np, *temp;

	while (getword(word, MAXWORD) != EOF) {
		if (!strcmp(word, "#")) {
			getdef(hashtab, HASHSIZE);
		} else if (!isalpha(word[0])) {
			printf("%s", word);
		} else if ((np = lookup(hashtab, HASHSIZE, word)) == NULL) {
			printf("%s", word);
		} else {
			ungetword(np->defn);
		}
	}

	hashfree(hashtab, HASHSIZE);
	return 0;
}