-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmatch.c
36 lines (33 loc) · 861 Bytes
/
dmatch.c
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
35
36
/*--------------------------------------------------------------*
* Find words matching pattern such as "p#tt*n" *
*--------------------------------------------------------------*/
#include "d2.h"
#include "match.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(int argc,
char *argv[])
{
Dict d = Dict_open(NULL);
const char *word;
int i,len;
if (argc != 2) {
fprintf(stderr, "Usage: %s pattern\n", argv[0]);
exit(1);
}
for (i=0; argv[1][i]; i++) argv[1][i] = toupper(argv[1][i]);
init_match(argv[1]);
for (len=(match_min<1? 1: match_min); len<=match_max; len++) {
Dscan ds = Dscan_open(d, len);
while ((word = Dscan_read(ds)) != NULL) {
if (match_word(word)) {
printf("%s\n", word);
}
}
Dscan_close(ds);
}
Dict_close(d);
exit(0);
}