/[eliot]/eliot/dic/dic_search.c
ViewVC logotype

Diff of /eliot/dic/dic_search.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12.2.2 by afrab, Sun Oct 23 18:38:18 2005 UTC revision 1.12.2.3 by ipkiss, Sun Oct 23 20:58:19 2005 UTC
# Line 17  Line 17 
17  /* along with this program; if not, write to the Free Software               */  /* along with this program; if not, write to the Free Software               */
18  /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */  /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
19    
 /* $Id$ */  
   
20  /**  /**
21   *  \file   dic_search.c   *  \file   dic_search.c
22   *  \brief  Dictionary lookup functions   *  \brief  Dictionary lookup functions
# Line 342  struct params_cross_t { Line 340  struct params_cross_t {
340    
341    
342  void  void
343  Dic_search_cross_rec(struct params_cross_t *params,  Dic_search_cross_rec(struct params_cross_t *params,
344                       char wordlist[RES_CROS_MAX][DIC_WORD_MAX],                       char wordlist[RES_CROS_MAX][DIC_WORD_MAX],
345                       Dawg_edge *edgeptr)                       Dawg_edge *edgeptr)
346  {  {
347    Dawg_edge *current = params->dic->dawg + edgeptr->ptr;    Dawg_edge *current = params->dic->dawg + edgeptr->ptr;
# Line 420  struct params_regexp_t { Line 418  struct params_regexp_t {
418    int minlength;    int minlength;
419    int maxlength;    int maxlength;
420    automaton automaton;    automaton automaton;
421    struct search_RegE_list_t *charlist;      struct search_RegE_list_t *charlist;
422    char word[DIC_WORD_MAX];    char word[DIC_WORD_MAX];
423    int  wordlen;    int  wordlen;
424    int  wordlistlen;    int  wordlistlen;
# Line 428  struct params_regexp_t { Line 426  struct params_regexp_t {
426  };  };
427    
428  void  void
429  Dic_search_regexp_rec(struct params_regexp_t *params,  Dic_search_regexp_rec(struct params_regexp_t *params,
430                        int state,                        int state,
431                        Dawg_edge *edgeptr,                        Dawg_edge *edgeptr,
432                        char wordlist[RES_REGE_MAX][DIC_WORD_MAX])                        char wordlist[RES_REGE_MAX][DIC_WORD_MAX])
433  {  {
434    int next_state;    int next_state;
# Line 439  Dic_search_regexp_rec(struct params_rege Line 437  Dic_search_regexp_rec(struct params_rege
437    if (automaton_get_accept(params->automaton,state) && edgeptr->term)    if (automaton_get_accept(params->automaton,state) && edgeptr->term)
438      {      {
439        int l = strlen(params->word);        int l = strlen(params->word);
440        if (params->wordlistlen < params->wordlistlenmax &&        if (params->wordlistlen < params->wordlistlenmax &&
441            params->minlength <= l                        &&            params->minlength <= l                        &&
442            params->maxlength >= l)            params->maxlength >= l)
443          {          {
444            strcpy(wordlist[params->wordlistlen++],params->word);            strcpy(wordlist[params->wordlistlen++],params->word);
445          }          }
446      }        }
447    /* we now drive the search by exploring the dictionary */    /* we now drive the search by exploring the dictionary */
448    current = params->dic->dawg + edgeptr->ptr;    current = params->dic->dawg + edgeptr->ptr;
449    do {    do {
# Line 464  Dic_search_regexp_rec(struct params_rege Line 462  Dic_search_regexp_rec(struct params_rege
462  }  }
463    
464    
465      /**      /**
466       * function prototype for parser generated by bison       * function prototype for parser generated by bison
467       */       */
468  int  regexpparse(yyscan_t scanner, NODE** root,  int  regexpparse(yyscan_t scanner, NODE** root,
469                   struct search_RegE_list_t *list,                   struct search_RegE_list_t *list,
470                   struct regexp_error_report_t *err);                   struct regexp_error_report_t *err);
471    
# Line 477  Dic_search_RegE(const Dictionary dic, co Line 475  Dic_search_RegE(const Dictionary dic, co
475                  struct search_RegE_list_t *list)                  struct search_RegE_list_t *list)
476  {  {
477    int i,p,n,value;    int i,p,n,value;
478    int ptl[REGEXP_MAX+1];    int ptl[REGEXP_MAX+1];
479    int PS [REGEXP_MAX+1];    int PS [REGEXP_MAX+1];
480    NODE* root;    NODE* root;
481    yyscan_t scanner;    yyscan_t scanner;
482    YY_BUFFER_STATE buf;    YY_BUFFER_STATE buf;
# Line 519  Dic_search_RegE(const Dictionary dic, co Line 517  Dic_search_RegE(const Dictionary dic, co
517  #ifdef DEBUG_FLEX_IS_BROKEN  #ifdef DEBUG_FLEX_IS_BROKEN
518        fprintf(stderr,"parser error at pos %d - %d : %s\n",        fprintf(stderr,"parser error at pos %d - %d : %s\n",
519                report.pos1, report.pos2, report.msg);                report.pos1, report.pos2, report.msg);
520  #endif        #endif
521        regexp_delete_tree(root);        regexp_delete_tree(root);
522        return ;        return ;
523      }      }
# Line 544  Dic_search_RegE(const Dictionary dic, co Line 542  Dic_search_RegE(const Dictionary dic, co
542        params.wordlistlen    = 0;        params.wordlistlen    = 0;
543        params.wordlistlenmax = RES_REGE_MAX;        params.wordlistlenmax = RES_REGE_MAX;
544        Dic_search_regexp_rec(&params, automaton_get_init(a), dic->dawg + dic->root, wordlist);        Dic_search_regexp_rec(&params, automaton_get_init(a), dic->dawg + dic->root, wordlist);
545          
546        automaton_delete(a);        automaton_delete(a);
547      }      }
548    regexp_delete_tree(root);    regexp_delete_tree(root);

Legend:
Removed from v.1.12.2.2  
changed lines
  Added in v.1.12.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26