Rev 3718 | Rev 8086 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3718 | Rev 8084 | ||
---|---|---|---|
Line 13... | Line 13... | ||
13 | * You should have received a copy of the GNU General Public License |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software |
14 | * along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | */ |
16 | */ |
17 | 17 | ||
18 |
|
18 | /* This program makes comparison between two text strings, |
19 |
|
19 | * according to the symtext syntax. */ |
20 | 20 | ||
21 | /* Input data: via environment variables. |
21 | /* Input data: via environment variables. |
22 | * wims_exec_parm: line 1 = command (comp,expand,wordlist,random,1,2,3,...) |
22 | * wims_exec_parm: line 1 = command (comp,expand,wordlist,random,1,2,3,...) |
23 | * line 2 = text to examine (for comp). |
23 | * line 2 = text to examine (for comp). |
24 | * line 3 and up = symtext syntax. |
24 | * line 3 and up = symtext syntax. |
25 | * w_symtext: dictionary style. |
25 | * w_symtext: dictionary style. |
26 | * w_symtext_option: option words. |
26 | * w_symtext_option: option words. |
27 | * |
27 | * |
28 | * Output: two lines. |
28 | * Output: two lines. |
29 | * Line 1: ERROR or OK |
29 | * Line 1: ERROR or OK |
30 | * Line 2: result depending on command. |
30 | * Line 2: result depending on command. |
31 | */ |
31 | */ |
32 | 32 | ||
Line 44... | Line 44... | ||
44 | 44 | ||
45 | struct poolstruct poolbuf[MAX_POOLS]; |
45 | struct poolstruct poolbuf[MAX_POOLS]; |
46 | int nextpool; |
46 | int nextpool; |
47 | 47 | ||
48 | int options; |
48 | int options; |
49 | #define op_nocase |
49 | #define op_nocase (1<<0) |
50 | #define op_deaccent |
50 | #define op_deaccent (1<<1) |
51 | #define op_reaccent |
51 | #define op_reaccent (1<<2) |
52 | #define op_nopunct |
52 | #define op_nopunct (1<<3) |
53 | #define op_nomath |
53 | #define op_nomath (1<<4) |
54 | #define op_noparenth |
54 | #define op_noparenth (1<<5) |
55 | #define op_nocs |
55 | #define op_nocs (1<<6) |
56 | #define op_noquote |
56 | #define op_noquote (1<<7) |
57 | #define op_matchall |
57 | #define op_matchall (1<<8) |
58 | #define op_alphaonly |
58 | #define op_alphaonly (1<<9) |
59 | #define op_alnumonly |
59 | #define op_alnumonly (1<<10) |
60 | 60 | ||
61 | char cmdbuf[256], stbuf[MAX_LINELEN+1], textbuf[MAX_LINELEN+1]; |
61 | char cmdbuf[256], stbuf[MAX_LINELEN+1], textbuf[MAX_LINELEN+1]; |
62 | char wbuf[MAX_LINELEN+1]; |
62 | char wbuf[MAX_LINELEN+1]; |
63 | char cmdparm[1024]; |
63 | char cmdparm[1024]; |
64 | char defbuf[MAX_LINELEN+1]; |
64 | char defbuf[MAX_LINELEN+1]; |
Line 73... | Line 73... | ||
73 | cmd_none, cmd_comp, cmd_debug, cmd_random, cmd_1, cmd_wordlist |
73 | cmd_none, cmd_comp, cmd_debug, cmd_random, cmd_1, cmd_wordlist |
74 | }; |
74 | }; |
75 | struct { |
75 | struct { |
76 | char *name; int value; |
76 | char *name; int value; |
77 | } cmdlist[]={ |
77 | } cmdlist[]={ |
78 | {"1", cmd_1}, |
78 | {"1", cmd_1}, |
79 | {"comp", |
79 | {"comp", cmd_comp}, |
80 | {"compare", cmd_comp}, |
80 | {"compare", cmd_comp}, |
81 | {"debug", cmd_debug}, |
81 | {"debug", cmd_debug}, |
82 | {"match", cmd_comp}, |
82 | {"match", cmd_comp}, |
83 | {"rand", |
83 | {"rand", cmd_random}, |
84 | {"random", |
84 | {"random", cmd_random}, |
85 | {"wordlist",cmd_wordlist}, |
85 | {"wordlist",cmd_wordlist}, |
86 | {"words", cmd_wordlist} |
86 | {"words", cmd_wordlist} |
87 | }; |
87 | }; |
88 | #define cmdcnt (sizeof(cmdlist)/sizeof(cmdlist[0])) |
88 | #define cmdcnt (sizeof(cmdlist)/sizeof(cmdlist[0])) |
89 | int cmd; |
89 | int cmd; |
90 | 90 | ||
91 | void error(char *msg,...) |
91 | void error(char *msg,...) |
Line 103... | Line 103... | ||
103 | void _error(char *msg) |
103 | void _error(char *msg) |
104 | { |
104 | { |
105 | error(msg); |
105 | error(msg); |
106 | } |
106 | } |
107 | 107 | ||
108 |
|
108 | /* read-in a file into buffer. Use open() and read(). |
109 |
|
109 | * Return buffer address which will be malloc'ed if buf=NULL. |
- | 110 | */ |
|
110 | char *readfile(char *fname, char buf[], long int buflen) |
111 | char *readfile(char *fname, char buf[], long int buflen) |
111 | { |
112 | { |
112 | int fd, t; |
113 | int fd, t; |
113 | struct stat st; |
114 | struct stat st; |
114 | long int l, lc; |
115 | long int l, lc; |
115 | char *bf; |
116 | char *bf; |
116 | t=0; if(buf) buf[0]=0; |
117 | t=0; if(buf) buf[0]=0; |
117 | if(stat(fname,&st)) return NULL; |
118 | if(stat(fname,&st)) return NULL; |
118 | l=st.st_size; if(l<0) return NULL; |
119 | l=st.st_size; if(l<0) return NULL; |
119 | if(l>=buflen) { |
120 | if(l>=buflen) { |
120 |
|
121 | if(buflen<MAX_LINELEN) l=buflen-1; |
121 |
|
122 | else error("file_too_long %s",fname); |
122 | } |
123 | } |
123 | fd=open(fname,O_RDONLY); if(fd==-1) return NULL; |
124 | fd=open(fname,O_RDONLY); if(fd==-1) return NULL; |
124 | if(buf==NULL) bf=xmalloc(l+8); else {bf=buf;if(l==0) {t=1; l=buflen-1;}} |
125 | if(buf==NULL) bf=xmalloc(l+8); else {bf=buf;if(l==0) {t=1; l=buflen-1;}} |
125 | lc=read(fd,bf,l); close(fd); |
126 | lc=read(fd,bf,l); close(fd); |
126 | if(lc<0 || lc>l || (lc!=l && t==0)) |
127 | if(lc<0 || lc>l || (lc!=l && t==0)) |
127 |
|
128 | {if(buf==NULL) free(bf); else buf[0]=0; return NULL;} |
128 | bf[lc]=0; _tolinux(bf); return bf; |
129 | bf[lc]=0; _tolinux(bf); return bf; |
129 | } |
130 | } |
130 | 131 | ||
131 |
|
132 | /* get option word in a string */ |
132 | void _getopt(char *name, char *p) |
133 | void _getopt(char *name, char *p) |
133 | { |
134 | { |
134 | char *p1, *p2, *p3, *p4; |
135 | char *p1, *p2, *p3, *p4; |
135 | char buf[MAX_LINELEN+1]; |
136 | char buf[MAX_LINELEN+1]; |
136 | 137 | ||
137 | snprintf(buf,sizeof(buf),"%s",p); |
138 | snprintf(buf,sizeof(buf),"%s",p); |
138 | p1=find_word_start(name); |
139 | p1=find_word_start(name); |
139 | for(p2=buf;*p2;p2++) { |
140 | for(p2=buf;*p2;p2++) { |
140 |
|
141 | if(myisspace(*p2)) *p2=' '; |
141 |
|
142 | if(*p2=='=') *p2=' '; |
142 | } |
143 | } |
143 | *p=0; |
144 | *p=0; |
144 | p2=wordchr(buf,p1); if(p2==NULL) return; |
145 | p2=wordchr(buf,p1); if(p2==NULL) return; |
145 | for(p3=find_word_end(p2);myisspace(*p3);p3++) { |
146 | for(p3=find_word_end(p2);myisspace(*p3);p3++) { |
146 |
|
147 | if(*p3==' ') { |
147 |
|
148 | p3=find_word_start(p3); |
148 |
|
149 | switch(*p3) { |
149 |
|
150 | case '"': { |
150 |
|
151 | p4=strchr(p3+1,'"'); |
151 |
|
152 | goto tested; |
152 |
|
153 | } |
153 |
|
154 | case '(': { |
154 |
|
155 | p4=find_matching(p3+1,')'); |
155 |
|
156 | goto tested; |
156 |
|
157 | } |
157 |
|
158 | case '[': { |
158 |
|
159 | p4=find_matching(p3+1,']'); |
159 |
|
160 | goto tested; |
160 |
|
161 | } |
161 |
|
162 | case '{': { |
162 |
|
163 | p4=find_matching(p3+1,'}'); |
163 |
|
164 | tested: |
164 |
|
165 | if(p4) { |
165 |
|
166 | p3++; *p4=0; break; |
166 |
|
167 | } |
167 |
|
168 | else goto nomatch; |
168 |
|
169 | } |
169 |
|
170 | default: { |
170 |
|
171 | nomatch: |
171 |
|
172 | *find_word_end(p3)=0; |
172 |
|
173 | } |
173 |
|
174 | } |
174 |
|
175 | mystrncpy(p,p3,MAX_LINELEN); |
175 |
|
176 | return; |
176 |
|
177 | } |
177 | } |
178 | } |
178 | *find_word_end(p2)=0; |
179 | *find_word_end(p2)=0; |
179 | memmove(p,p2,strlen(p2)+1); |
180 | memmove(p,p2,strlen(p2)+1); |
180 | } |
181 | } |
181 | 182 | ||
182 | void _getdef(char buf[], char *name, char value[]) |
183 | void _getdef(char buf[], char *name, char value[]) |
183 | { |
184 | { |
184 | char *p1, *p2, *p3, *p4; |
185 | char *p1, *p2, *p3, *p4; |
185 | 186 | ||
186 | if(*name==0) goto nothing; /* this would create segfault. */ |
187 | if(*name==0) goto nothing; /* this would create segfault. */ |
187 | for(p1=strstr(buf,name); p1!=NULL; p1=strstr(p1+1,name)) { |
188 | for(p1=strstr(buf,name); p1!=NULL; p1=strstr(p1+1,name)) { |
188 |
|
189 | p2=find_word_start(p1+strlen(name)); |
189 |
|
190 | if((p1>buf && !isspace(*(p1-1))) || *p2!='=') continue; |
190 |
|
191 | p3=p1; while(p3>buf && *(p3-1)!='\n') p3--; |
191 |
|
192 | p3=find_word_start(p3); |
192 |
|
193 | if(p3<p1 && *p3!='!') continue; |
193 |
|
194 | if(p3<p1) { |
194 |
|
195 | p3++; p4=find_word_end(p3); |
195 |
|
196 | if(find_word_start(p4)!=p1) continue; |
196 |
|
197 | if(p4-p3!=3 || (strncmp(p3,"set",3)!=0 && |
197 |
|
198 | strncmp(p3,"let",3)!=0 && |
198 |
|
199 | strncmp(p3,"def",3)!=0)) { |
199 |
|
200 | if(p4-p3!=6 || strncmp(p3,"define",6)!=0) continue; |
200 |
|
201 | } |
201 |
|
202 | } |
202 |
|
203 | p2++;p3=strchr(p2,'\n'); if(p3==NULL) p3=p2+strlen(p2); |
203 |
|
204 | p2=find_word_start(p2); |
204 |
|
205 | if(p2>p3) goto nothing; |
205 |
|
206 | if(p3-p2>=MAX_LINELEN) error("string_too_long def %s",name); |
206 |
|
207 | memmove(value,p2,p3-p2); value[p3-p2]=0; |
207 |
|
208 | strip_trailing_spaces(value); return; |
208 | } |
209 | } |
209 | nothing: |
210 | nothing: |
210 | value[0]=0; return; |
211 | value[0]=0; return; |
211 | } |
212 | } |
212 | 213 | ||
213 | char fnbuf[MAX_FNAME+1]; |
214 | char fnbuf[MAX_FNAME+1]; |
214 | 215 | ||
215 |
|
216 | /* make a filename and check length */ |
216 | char *mkfname(char buf[], char *s,...) |
217 | char *mkfname(char buf[], char *s,...) |
217 | { |
218 | { |
218 | va_list vp; |
219 | va_list vp; |
219 | char *p; |
220 | char *p; |
220 | 221 | ||
Line 235... | Line 236... | ||
235 | { |
236 | { |
236 | char *p, *p2, *p3, lbuf[8]; |
237 | char *p, *p2, *p3, lbuf[8]; |
237 | char buf[MAX_LINELEN+1], pbuf[MAX_LINELEN+1]; |
238 | char buf[MAX_LINELEN+1], pbuf[MAX_LINELEN+1]; |
238 | struct stat st; |
239 | struct stat st; |
239 | int i; |
240 | int i; |
240 | 241 | ||
241 | cmd=0; |
242 | cmd=0; |
242 | p=getenv("wims_exec_parm"); |
243 | p=getenv("wims_exec_parm"); |
243 | if(p==NULL) return; |
244 | if(p==NULL) return; |
244 | snprintf(pbuf,sizeof(pbuf),"%s",p); |
245 | snprintf(pbuf,sizeof(pbuf),"%s",p); |
245 | rows2lines(pbuf); |
246 | rows2lines(pbuf); |
246 | p2=strchr(pbuf,'\n'); if(p2==NULL) return; else *p2++=0; |
247 | p2=strchr(pbuf,'\n'); if(p2==NULL) return; else *p2++=0; |
247 | p=find_word_start(pbuf); |
248 | p=find_word_start(pbuf); |
248 | p3=find_word_end(p); if(p3-p>=sizeof(cmdbuf)) return; |
249 | p3=find_word_end(p); if(p3-p>=sizeof(cmdbuf)) return; |
249 | if(*p==0) return; else *p3++=0; |
250 | if(*p==0) return; else *p3++=0; |
250 | memmove(cmdbuf,p,p3-p); cmdbuf[p3-p]=0; |
251 | memmove(cmdbuf,p,p3-p); cmdbuf[p3-p]=0; |
251 | p=p2; p2=strchr(p,'\n'); if(p2==NULL) p2=p+strlen(p); else *p2++=0; |
252 | p=p2; p2=strchr(p,'\n'); if(p2==NULL) p2=p+strlen(p); else *p2++=0; |
252 | if(p2<=find_word_start(p)) return; |
253 | if(p2<=find_word_start(p)) return; |
253 | if(p2-p<sizeof(textbuf)) { |
254 | if(p2-p<sizeof(textbuf)) { |
254 |
|
255 | memmove(textbuf,p,p2-p); textbuf[p2-p]=0; |
255 | } |
256 | } |
256 | p=p2; p2=p+strlen(p); |
257 | p=p2; p2=p+strlen(p); |
257 | if(p2>p && p2-p<sizeof(stbuf)) { |
258 | if(p2>p && p2-p<sizeof(stbuf)) { |
258 |
|
259 | memmove(stbuf,p,p2-p); stbuf[p2-p]=0; |
259 | } |
260 | } |
260 | i=search_list(cmdlist,cmdcnt,sizeof(cmdlist[0]),cmdbuf); |
261 | i=search_list(cmdlist,cmdcnt,sizeof(cmdlist[0]),cmdbuf); |
261 | if(i>=0) cmd=cmdlist[i].value; |
262 | if(i>=0) cmd=cmdlist[i].value; |
262 | else error("bad_command %.20s",cmdbuf); |
263 | else error("bad_command %.20s",cmdbuf); |
263 | snprintf(cmdparm,sizeof(cmdparm),"%s",p2); |
264 | snprintf(cmdparm,sizeof(cmdparm),"%s",p2); |
264 | 265 | ||
265 | options=0; |
266 | options=0; |
266 | p=getenv("w_module_language"); if(p==NULL) p=""; |
267 | p=getenv("w_module_language"); if(p==NULL) p=""; |
267 | snprintf(lbuf,sizeof(lbuf),"%2s",p); |
268 | snprintf(lbuf,sizeof(lbuf),"%2s",p); |
268 | if(*p3) { |
269 | if(*p3) { |
269 |
|
270 | snprintf(buf,sizeof(buf),"%s",p3); |
270 |
|
271 | _getopt("style",buf); |
271 |
|
272 | snprintf(style,sizeof(style),"%s",find_word_start(buf)); |
272 |
|
273 | *find_word_end(style)=0; |
273 |
|
274 | snprintf(buf,sizeof(buf),"%s",p3); |
274 |
|
275 | _getopt("language",buf); |
275 |
|
276 | if(buf[0]) snprintf(lbuf,sizeof(lbuf),"%2s",buf); |
276 | } |
277 | } |
277 | lbuf[2]=0; |
278 | lbuf[2]=0; |
278 | if(!myisalpha(lbuf[0]) || !myisalpha(lbuf[1])) ovlstrcpy(lbuf,"en"); |
279 | if(!myisalpha(lbuf[0]) || !myisalpha(lbuf[1])) ovlstrcpy(lbuf,"en"); |
279 | styledir[0]=defbuf[0]=optionbuf[0]=buf[0]=0; |
280 | styledir[0]=defbuf[0]=optionbuf[0]=buf[0]=0; |
280 | if(*style) { |
281 | if(*style) { |
281 |
|
282 | p=getenv("module_dir"); |
282 |
|
283 | if(p==NULL) { /* non-wims operation */ |
283 |
|
284 | snprintf(styledir,sizeof(styledir),"%s",style); |
284 |
|
285 | } |
285 |
|
286 | else { |
286 |
|
287 | for(i=0;i<MAX_NAMELEN && myisalnum(style[i]);i++); |
287 |
|
288 | style[i]=0; |
288 |
|
289 | if(style[0]) { /* style defined */ |
289 |
|
290 | if(*p!='/' && strstr(p,"..")==NULL) { /* check module dir */ |
290 |
|
291 | snprintf(styledir,sizeof(styledir),"%s/symtext/%s/%s/def",p,lbuf,style); |
291 |
|
292 | if(stat(styledir,&st)) styledir[0]=0; |
292 |
|
293 | } |
293 |
|
294 | if(styledir[0]==0) { /* check default */ |
294 |
|
295 | snprintf(styledir,sizeof(styledir),"%s/symtext/%s/%s/def",defaultdir,lbuf,style); |
295 |
|
296 | if(stat(styledir,&st)) error("style_not_found %s",style); |
296 |
|
297 | } |
297 |
|
298 | } |
298 |
|
299 | } |
299 |
|
300 | if(styledir[0]) { /* get def */ |
300 |
|
301 | readfile(styledir,defbuf,sizeof(defbuf)); |
301 |
|
302 | styledir[strlen(styledir)-4]=0; |
302 |
|
303 | suffix_dic(mkfname(NULL,"%s/suffix",styledir)); |
303 |
|
304 | transdic=diccnt; |
304 |
|
305 | if(prepare_dic("trans")==NULL) transdic=-1; |
305 |
|
306 | dic[transdic].unknown_type=unk_leave; |
306 |
|
307 | macrodic=diccnt; |
307 |
|
308 | if(prepare_dic("macros")==NULL) macrodic=-1; |
308 |
|
309 | dic[macrodic].unknown_type=unk_delete; |
309 |
|
310 | } |
310 | } |
311 | } |
311 | _getdef(defbuf,"option",buf); |
312 | _getdef(defbuf,"option",buf); |
312 | snprintf(optionbuf,sizeof(optionbuf),"%s %s",p3,buf); |
313 | snprintf(optionbuf,sizeof(optionbuf),"%s %s",p3,buf); |
313 | if(wordchr(optionbuf,"nocase")!=NULL) options|=op_nocase; |
314 | if(wordchr(optionbuf,"nocase")!=NULL) options|=op_nocase; |
314 | if(wordchr(optionbuf,"deaccent")!=NULL) options|=op_deaccent; |
315 | if(wordchr(optionbuf,"deaccent")!=NULL) options|=op_deaccent; |
Line 322... | Line 323... | ||
322 | if(wordchr(optionbuf,"matchall")!=NULL) options|=op_matchall; |
323 | if(wordchr(optionbuf,"matchall")!=NULL) options|=op_matchall; |
323 | if(wordchr(optionbuf,"abconly")!=NULL) options|=op_alphaonly; |
324 | if(wordchr(optionbuf,"abconly")!=NULL) options|=op_alphaonly; |
324 | if(wordchr(optionbuf,"onlyabc")!=NULL) options|=op_alphaonly; |
325 | if(wordchr(optionbuf,"onlyabc")!=NULL) options|=op_alphaonly; |
325 | if(wordchr(optionbuf,"alnumonly")!=NULL) options|=op_alnumonly; |
326 | if(wordchr(optionbuf,"alnumonly")!=NULL) options|=op_alnumonly; |
326 | if(wordchr(optionbuf,"onlyalnum")!=NULL) options|=op_alnumonly; |
327 | if(wordchr(optionbuf,"onlyalnum")!=NULL) options|=op_alnumonly; |
327 | 328 | ||
328 | if(cmd==cmd_comp || cmd==cmd_debug) { |
329 | if(cmd==cmd_comp || cmd==cmd_debug) { |
329 |
|
330 | _getopt("debug",optionbuf); |
330 |
|
331 | if(optionbuf[0]) { |
331 |
|
332 | i=atoi(optionbuf); |
332 |
|
333 | if(i>0 || strcmp(optionbuf,"0")==0) debug=i; else debug=1; |
333 |
|
334 | if(debug>0) cmd=cmd_debug; |
334 |
|
335 | } |
335 | } |
336 | } |
336 | strip_enclosing_par(textbuf); |
337 | strip_enclosing_par(textbuf); |
337 | strfold(textbuf); |
338 | strfold(textbuf); |
338 | } |
339 | } |
339 | 340 | ||
340 | int verify_tables(void) |
341 | int verify_tables(void) |
341 | { |
342 | { |
342 | if(verify_order(builtin,builtincnt,sizeof(builtin[0]))) return -1; |
343 | if(verify_order(builtin,builtincnt,sizeof(builtin[0]))) return -1; |
343 | if(verify_order(cmdlist,cmdcnt,sizeof(cmdlist[0]))) return -1; |
344 | if(verify_order(cmdlist,cmdcnt,sizeof(cmdlist[0]))) return -1; |
344 | 345 | ||
345 | return 0; |
346 | return 0; |
346 | } |
347 | } |
347 | 348 | ||
348 | int main(int argc, char *argv[]) |
349 | int main(int argc, char *argv[]) |
349 | { |
350 | { |
350 | int i, n, mat; |
351 | int i, n, mat; |
351 | char *p1, *p2; |
352 | char *p1, *p2; |
352 | char lbuf[MAX_LINELEN+1]; |
353 | char lbuf[MAX_LINELEN+1]; |
353 | 354 | ||
354 | if(argc>1 && strcmp(argv[1],"-t")==0) { |
355 | if(argc>1 && strcmp(argv[1],"-t")==0) { |
355 |
|
356 | if(verify_tables()==0) { |
356 |
|
357 | printf("Table orders OK.\n"); |
357 |
|
358 | return 0; |
358 |
|
359 | } |
359 |
|
360 | else return 1; |
360 | } |
361 | } |
361 | error1=error2=_error; debug=0; |
362 | error1=error2=_error; debug=0; |
362 | wptr=wbuf; wbuf[0]=0; |
363 | wptr=wbuf; wbuf[0]=0; |
363 | getparms(); |
364 | getparms(); |
364 | Mnext=Mbuf; Mcnt=0; |
365 | Mnext=Mbuf; Mcnt=0; |
365 | switch(cmd) { |
366 | switch(cmd) { |
366 |
|
367 | case cmd_comp: { |
367 |
|
368 | comp: |
368 |
|
369 | n=linenum(stbuf); |
369 |
|
370 | for(mat=0,i=1,p1=stbuf;i<=n;i++,p1=p2) { |
370 |
|
371 | p2=find_line_end(p1); if(*p2) *p2++=0; |
371 |
|
372 | p1=find_word_start(p1); |
372 |
|
373 | if(*p1==0) continue; |
373 |
|
374 | snprintf(lbuf,sizeof(lbuf),"%s",p1); |
374 |
|
375 | compile(lbuf); |
375 |
|
376 | mat=match(textbuf); |
376 |
|
377 | if(mat) { |
377 |
|
378 | printf("MATCH %d %s\n",i,outbuf); |
378 |
|
379 | if((options&op_matchall)==0) break; |
379 |
|
380 | } |
380 |
|
381 | } |
381 |
|
382 | if(debug) fprintf(stderr,"word list: %s\n",wbuf); |
382 |
|
383 | break; |
383 |
|
384 | } |
384 |
|
385 | case cmd_debug: { |
385 |
|
386 | if(debug==0) debug=1; |
386 |
|
387 | fprintf(stderr,"debug=%d.\n",debug); |
387 |
|
388 | for(i=0;i<diccnt;i++) |
388 |
|
389 | fprintf(stderr,"Dictionary %d: %s, %d entries.\n", |
389 |
|
390 | i+1,dic[i].name,dic[i].len); |
390 |
|
391 | goto comp; |
391 |
|
392 | } |
392 |
|
393 | case cmd_random: { |
393 | 394 | ||
394 |
|
395 | break; |
395 |
|
396 | } |
396 |
|
397 | case cmd_wordlist: { |
397 | 398 | ||
398 |
|
399 | break; |
399 |
|
400 | } |
400 |
|
401 | case cmd_1: { |
401 | 402 | ||
402 |
|
403 | break; |
403 |
|
404 | } |
404 | 405 | ||
405 |
|
406 | case cmd_none: |
406 |
|
407 | default: return 1; |
407 | } |
408 | } |
408 | return 0; |
409 | return 0; |
409 | } |
410 | } |
410 | 411 |