From: drowe67 Date: Tue, 10 Jun 2014 07:40:23 +0000 (+0000) Subject: first pass at matching multiple regexp X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=0268469820cc7a0ff5c93b746124357f8aef6cdd;p=freetel-svn-tracking.git first pass at matching multiple regexp git-svn-id: https://svn.code.sf.net/p/freetel/code@1643 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/fdmdv2/src/Makefile.linux b/fdmdv2/src/Makefile.linux index 632f146d..19b43a1e 100644 --- a/fdmdv2/src/Makefile.linux +++ b/fdmdv2/src/Makefile.linux @@ -52,7 +52,7 @@ endif # Codec 2 ----------------------------------------------- -CODEC2=codec2 +CODEC2=codec2-dev CODEC2_INC=-I$(CODEC2)/src CODEC2_LIB=$(CODEC2)/build_dir/src/libcodec2.a @@ -112,7 +112,7 @@ dlg_filter.o \ dlg_options.o \ varicode.o \ sox_biquad.o \ -codec2/src/golay23.c \ +codec2-dev/src/golay23.c \ hamlib.o all: $(LIBS_TO_BUILD) $(CODEC2)/.built freedv diff --git a/fdmdv2/src/dlg_options.cpp b/fdmdv2/src/dlg_options.cpp index f5c16be7..e19c2085 100644 --- a/fdmdv2/src/dlg_options.cpp +++ b/fdmdv2/src/dlg_options.cpp @@ -39,7 +39,7 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c wxStaticBoxSizer* sbSizer_testFrames; sbSizer_testFrames = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Test Frames")), wxVERTICAL); - m_ckboxTestFrame = new wxCheckBox(this, wxID_ANY, _("Enable System Calls"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); + m_ckboxTestFrame = new wxCheckBox(this, wxID_ANY, _("Enable"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); sbSizer_testFrames->Add(m_ckboxTestFrame, 0, wxALIGN_LEFT, 0); bSizer30->Add(sbSizer_testFrames,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3); @@ -80,7 +80,7 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c // event processing enable - m_ckbox_events = new wxCheckBox(this, wxID_ANY, _("Enable"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); + m_ckbox_events = new wxCheckBox(this, wxID_ANY, _("Enable System Calls"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); sbSizer_events->Add(m_ckbox_events, 0, 0, 5); // list of regexps @@ -105,18 +105,6 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c sbSizer_event_log->Add(bSizer33, 1, wxEXPAND, 5); sbSizer_events->Add(sbSizer_event_log, 1, wxEXPAND, 5); - // test event - - wxStaticBoxSizer* sbSizer_event_test = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Test your Regular Expression")), wxVERTICAL); - wxBoxSizer* bSizer34 = new wxBoxSizer(wxHORIZONTAL); - m_txt_event_test = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); - m_txt_event_test->SetToolTip(_("Enter event text to test a regular expression")); - bSizer34->Add(m_txt_event_test, 1, wxEXPAND|wxALL, 5); - m_btn_event_test = new wxButton(this, wxID_ANY, _("Test"), wxDefaultPosition, wxDefaultSize, 0); - bSizer34->Add(m_btn_event_test, 0, wxEXPAND|wxALL, 5); - sbSizer_event_test->Add(bSizer34, 0, wxEXPAND, 5); - sbSizer_events->Add(sbSizer_event_test, 0, wxEXPAND, 5); - bSizer30->Add(sbSizer_events,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3); //------------------------------ diff --git a/fdmdv2/src/dlg_options.h b/fdmdv2/src/dlg_options.h index 49da32c7..767ce364 100644 --- a/fdmdv2/src/dlg_options.h +++ b/fdmdv2/src/dlg_options.h @@ -60,8 +60,6 @@ class OptionsDlg : public wxDialog wxTextCtrl *m_txt_events_regexp_replace; wxTextCtrl *m_txt_events_in; wxTextCtrl *m_txt_events_out; - wxTextCtrl *m_txt_event_test; - wxButton *m_btn_event_test; wxButton* m_sdbSizer5OK; wxButton* m_sdbSizer5Cancel; diff --git a/fdmdv2/src/fdmdv2_main.cpp b/fdmdv2/src/fdmdv2_main.cpp index e072c7a2..e01af5a0 100644 --- a/fdmdv2/src/fdmdv2_main.cpp +++ b/fdmdv2/src/fdmdv2_main.cpp @@ -2520,39 +2520,64 @@ void MainFrame::processTxtEvent(char event[]) { // process with regexp and issue system command + // Each regexp in our list is separated by a newline. We want to try all of them. + wxString event_str(event); - wxRegEx re(wxGetApp().m_events_regexp_match); - wxString regexp_replace_str(wxGetApp().m_events_regexp_replace); - re.Replace(&event_str, regexp_replace_str); - const char *event_out = event_str.ToUTF8(); - - wxString event_out_with_return_code; - - bool enableSystem = false; - if (wxGetApp().m_events) - enableSystem = true; - - // If options dialog is up current value of events checkbox overrides - - if (optionsDlg != NULL) { - if (optionsDlg->enableEventsChecked()) - enableSystem = true; - else - enableSystem = false; - } - - if (enableSystem) { - int ret = wxExecute(event_str); - event_out_with_return_code.Printf(_T("%s -> process ID %d"), event_out, ret); - } - else { - event_out_with_return_code.Printf(_T("%s)"), event_out); - } + int match_end, replace_end; + match_end = replace_end = 0; + wxString regexp_match_list = wxGetApp().m_events_regexp_match; + wxString regexp_replace_list = wxGetApp().m_events_regexp_replace; + + while ((match_end = regexp_match_list.Find('\n')) != wxNOT_FOUND) { + printf("match_end: %d\n", match_end); + if ((replace_end = regexp_replace_list.Find('\n')) != wxNOT_FOUND) { + printf("replace_end = %d\n", replace_end); + // candidate match and replace regexps strings exist, so lets try them + + wxString regexp_match = regexp_match_list.SubString(0, match_end-1); + wxString regexp_replace = regexp_replace_list.SubString(0, replace_end-1); + printf("match: %s replace: %s\n", (const char *)regexp_match.c_str(), (const char *)regexp_replace.c_str()); + wxRegEx re(regexp_match); + + // if we found a match, lets run the replace regexp and issue the system command + + wxString event_str_rep = event_str; + + if (re.Replace(&event_str_rep, regexp_replace) != 0) { + printf("found match!\n"); + bool enableSystem = false; + if (wxGetApp().m_events) + enableSystem = true; + + // If options dialog is up current value of events checkbox overrides wxGetApp().m_events - // update event log GUI if currently displayed + if (optionsDlg != NULL) { + if (optionsDlg->enableEventsChecked()) + enableSystem = true; + else + enableSystem = false; + } - if (optionsDlg != NULL) { - optionsDlg->updateEventLog(wxString(event), event_out_with_return_code); + const char *event_out = event_str_rep.ToUTF8(); + wxString event_out_with_return_code; + + if (enableSystem) { + int ret = wxExecute(event_str_rep); + event_out_with_return_code.Printf(_T("%s -> process ID %d"), event_out, ret); + } + else + event_out_with_return_code.Printf(_T("%s)"), event_out); + + // update event log GUI if currently displayed + printf("hello\n"); + if (optionsDlg != NULL) { + printf("hello\n"); + optionsDlg->updateEventLog(wxString(event), event_out_with_return_code); + } + } + } + regexp_match_list = regexp_match_list.SubString(match_end+1, regexp_match_list.length()); + regexp_replace_list = regexp_replace_list.SubString(replace_end+1, regexp_replace_list.length()); } }