From c7899d080782888e16958d5fa6c3183486d3c187 Mon Sep 17 00:00:00 2001 From: Antoine Fraboulet Date: Sat, 19 Jun 2004 18:43:35 +0000 Subject: [PATCH] *** empty log message *** --- INSTALL | 8 ----- dic/Makefile.am | 5 +-- dic/dic_search.c | 79 ++++++++++++++++++++++++++++++++++++++++++-- dic/dic_search.h | 4 ++- wxwin/main.cc | 4 +-- wxwin/searchpanel.cc | 40 ++++++++++++++++++++-- 6 files changed, 123 insertions(+), 17 deletions(-) diff --git a/INSTALL b/INSTALL index 3986a79..bfa12f9 100644 --- a/INSTALL +++ b/INSTALL @@ -34,12 +34,4 @@ Installation sous Windows (moins bien/facile) mingw32 et wxMSW soient correctement installés mais cette étape ne rentre pas dans le présent document. -* Borland/Inprise C/C++ compiler 5.5.1 - La version en ligne de commande du compilateur Borland est disponible - gratuitement par téléchargement. Cet (excellent) compilateur - permet aussi de produire un executable d'Eliot. - Toujours dans le répertoir eliot\msw il vous faudra taper - - make -f makefile.b32 - diff --git a/dic/Makefile.am b/dic/Makefile.am index 15b26ee..7405e25 100644 --- a/dic/Makefile.am +++ b/dic/Makefile.am @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# $Id: Makefile.am,v 1.1 2004/04/08 09:43:06 afrab Exp $ +# $Id: Makefile.am,v 1.2 2004/06/19 18:43:35 afrab Exp $ bin_PROGRAMS = compdic listdic @@ -26,7 +26,8 @@ libdic_a_CFLAGS=-Wall -pipe -g libdic_a_SOURCES = \ dic_internals.h \ dic_search.c dic_search.h \ - dic.c dic.h + dic.c dic.h \ + automaton.c automaton.h compdic_SOURCES= \ dic_internals.h \ diff --git a/dic/dic_search.c b/dic/dic_search.c index 2e5171f..ff495f3 100644 --- a/dic/dic_search.c +++ b/dic/dic_search.c @@ -16,7 +16,7 @@ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - * $Id: dic_search.c,v 1.1 2004/04/08 09:43:06 afrab Exp $ + * $Id: dic_search.c,v 1.2 2004/06/19 18:43:35 afrab Exp $ */ #include @@ -26,7 +26,7 @@ #include "dic_internals.h" #include "dic.h" #include "dic_search.h" - +#include "automaton.h" /****************************************/ /****************************************/ @@ -385,3 +385,78 @@ Dic_search_Cros(Dictionary dic, char* mask, char wordlist[RES_CROS_MAX][DIC_WORD /****************************************/ /****************************************/ +struct params_regexp_t { + Dictionary dic; + int wordlen; + int wordlistlen; + int wordlistlenmax; + struct _automaton *automaton; +}; + +void +Dic_search_regexp_rec(struct params_regexp_t *params, char wordlist[RES_CROS_MAX][DIC_WORD_MAX], Dawg_edge *edgeptr, int state) +{ + // Dawg_edge *current = params->dic->dawg + edgeptr->ptr; +/* // fin du motif et fin de mot */ +/* if (params->mask[params->wordlen] == '\0' && edgeptr->term) */ +/* { */ +/* if (params->wordlistlen < params->wordlistlenmax) */ +/* strcpy(wordlist[params->wordlistlen++],params->mask); */ +/* } */ +/* // n'importe quel char */ +/* else if (params->mask[params->wordlen] == '.') */ +/* { */ +/* do */ +/* { */ +/* params->mask[params->wordlen] = current->chr + 'a' - 1; */ +/* params->wordlen ++; */ +/* Dic_search_regexp_rec(params,wordlist,current, ??); */ +/* params->wordlen --; */ +/* params->mask[params->wordlen] = '.'; */ +/* } */ +/* while (!(*current++).last); */ +/* } */ +/* // une lettre dans le motif */ +/* else */ +/* { */ +/* do */ +/* { */ +/* if (current->chr == (params->mask[params->wordlen] & CHAR)) */ +/* { */ +/* params->wordlen ++; */ +/* Dic_search_cross_rec(params,wordlist,current); */ +/* params->wordlen --; */ +/* break; */ +/* } */ +/* } */ +/* while (!(*current++).last); */ +/* } */ +} + +void +Dic_search_RegE(Dictionary dic, char* mask, char wordlist[RES_REGE_MAX][DIC_WORD_MAX]) +{ + int i; + struct params_regexp_t params; + struct _automaton a; + + for(i=0; i < RES_REGE_MAX; i++) + wordlist[i][0] = 0; + + if (dic == NULL || mask == NULL) + return; + + if (automaton_build("",&a)) + return; + + params.dic = dic; + params.wordlen = 0; + params.wordlistlen = 0; + params.wordlistlenmax = RES_REGE_MAX; + params.automaton = &a; + Dic_search_regexp_rec(¶ms, wordlist, dic->dawg + dic->root, 0); +} + +/****************************************/ +/****************************************/ + diff --git a/dic/dic_search.h b/dic/dic_search.h index 825502d..86fe791 100644 --- a/dic/dic_search.h +++ b/dic/dic_search.h @@ -16,7 +16,7 @@ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: dic_search.h,v 1.1 2004/04/08 09:43:06 afrab Exp $ */ +/* $Id: dic_search.h,v 1.2 2004/06/19 18:43:35 afrab Exp $ */ #ifndef _DIC_SEARCH_H_ #define _DIC_SEARCH_H_ @@ -31,12 +31,14 @@ extern "C" #define RES_RACC_MAX 100 #define RES_BENJ_MAX 100 #define RES_CROS_MAX 200 +#define RES_REGE_MAX 200 int Dic_search_word(Dictionary,const char*); void Dic_search_7pl1(Dictionary,char* rack, char wordlist[LETTERS][RES_7PL1_MAX][DIC_WORD_MAX], int joker); void Dic_search_Racc(Dictionary,char* word, char wordlist[RES_RACC_MAX][DIC_WORD_MAX]); void Dic_search_Benj(Dictionary,char* word, char wordlist[RES_BENJ_MAX][DIC_WORD_MAX]); void Dic_search_Cros(Dictionary,char* mask, char wordlist[RES_CROS_MAX][DIC_WORD_MAX]); +void Dic_search_RegE(Dictionary,char* mask, char wordlist[RES_CROS_MAX][DIC_WORD_MAX]); #if defined(__cplusplus) } diff --git a/wxwin/main.cc b/wxwin/main.cc index 2de1a3c..3a229db 100644 --- a/wxwin/main.cc +++ b/wxwin/main.cc @@ -16,7 +16,7 @@ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: main.cc,v 1.1 2004/04/08 09:43:06 afrab Exp $ */ +/* $Id: main.cc,v 1.2 2004/06/19 18:43:35 afrab Exp $ */ #include #include @@ -48,7 +48,7 @@ EliotApp::OnInit() { srand(time(NULL)); SetVendorName("Afrab"); - SetAppName("eliot"); + SetAppName(wxString("eliot") + wxString("-") + wxString(VERSION)); SetClassName("eliot"); wxConfigBase* config = wxConfigBase::Get(); diff --git a/wxwin/searchpanel.cc b/wxwin/searchpanel.cc index 929f91a..9834082 100644 --- a/wxwin/searchpanel.cc +++ b/wxwin/searchpanel.cc @@ -16,7 +16,7 @@ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: searchpanel.cc,v 1.1 2004/04/08 09:43:06 afrab Exp $ */ +/* $Id: searchpanel.cc,v 1.2 2004/06/19 18:43:35 afrab Exp $ */ #include #include "ewx.h" @@ -197,12 +197,48 @@ PPlus1::compute_enter(wxCommandEvent&) // ************************************************************ // ************************************************************ +class PRegExp : public SimpleSearchPanel +{ +private: +public: + void compute_char(wxCommandEvent&) { }; + void compute_enter(wxCommandEvent&); + PRegExp(wxWindow* parent, int id, Dictionary dic) : SimpleSearchPanel(parent,id,dic) {}; +}; + +void +PRegExp::compute_enter(wxCommandEvent&) +{ + int i; + char re[DIC_WORD_MAX]; + char buff[RES_REGE_MAX][DIC_WORD_MAX]; + + if (!check()) + return; + + strncpy(re,t->GetValue().c_str(),DIC_WORD_MAX); + Dic_search_RegE(dic_,re,buff); + + int resnum = 0; + wxString res[RES_REGE_MAX]; + for(i=0; i < RES_REGE_MAX && buff[i][0]; i++) + res[resnum++] = wxString(buff[i]); + l->Set(resnum,res); + + if (l->Number() == 0) + l->Append("Aucun résultat"); +} + +// ************************************************************ +// ************************************************************ +// ************************************************************ + SearchPanel::SearchPanel(wxFrame *parent, Dictionary dic) : wxNotebook(parent, -1) { AddPage(new PCross(this,ID_PANEL_CROSS,dic),"Mots croisés"); AddPage(new PPlus1(this,ID_PANEL_PLUS1,dic),"Plus 1"); - // AddPage(new PCross(this,ID_PANEL_REGEXP,dic),"RegExp"); + AddPage(new PRegExp(this,ID_PANEL_REGEXP,dic),"Exp. Rationnelle"); SetSelection(0); }