#include #include #include "wsearch.h" void next(); char *wptr[MAXWORD]; extern int LINK; int wsearch() { int i,j,ls; char *temp; for(i=0;i0) { j=0; for(i=0;i7) d=0; } s = 0; do { if(Stop_Flag()) return(-1); if(link==1) { error = advance(&x,&y,&d,pos,link); if(error!=0) { link = 0; error = advance(&x,&y,&d,pos,link); } } else error = advance(&x,&y,&d,pos,link); if(error!=0) return(1); if(s==0) { s = 1; x0 = x; y0 = y; d0 = d; } buffer[strlen((wptr[pos]))] = NULL; for(i=0;ipx) { *x = 0; *y = *y + 1; } if(*y>py) { *x = 0; *y = 0; *d = *d + 1; } if(*d>7) { *x = 0; *y = 0; *d = 0; } while((1<<*d & filter) == 0) { *d = *d + 1; if(*d>7) *d=0; } } int advance(x,y,d,pos,link) int *x,*y,*d,pos,link; { int x0,y0,d0,i,x1,y1; x0=*x;y0=*y;d0=*d; for(i=0;ipx || y1<0 || y1>py) { i = 0; if(link!=0) link=1; next(x,y,d); if(x0==*x && y0==*y && d0==*d) return(1); } else { if(link==1 && (wptr[pos])[i]==Key(x1,y1)) link = -1; /* the link is used to indicate both if a link was requested (not 0) and if the current position does link (-1) */ i = i + 1; } if(link==1 && i==strlen(wptr[pos])) /* finished word but no link */ { i = 0; next(x,y,d); if(x0==*x && y0==*y && d0==*d) return(1); } } return(0); }