From 817670e45489f4a0f596b9b4fb2a792181bf8212 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 15 Jun 2003 20:13:20 +0000 Subject: [PATCH] fixed bug with parsing filter string without description git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21173 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/fldlgcmn.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/common/fldlgcmn.cpp b/src/common/fldlgcmn.cpp index 102c036b3a..fc6f7366ff 100644 --- a/src/common/fldlgcmn.cpp +++ b/src/common/fldlgcmn.cpp @@ -244,34 +244,48 @@ int wxParseFileFilter(const wxString& filterStr, wxArrayString& descriptions, wxArrayString& filters) { + descriptions.Clear(); + filters.Clear(); + wxString str(filterStr); wxString description, filter; - int pos = -1; - bool finished = FALSE; - do + for ( int pos = 0; pos != wxNOT_FOUND; ) { pos = str.Find(wxT('|')); - if (pos == -1) - return 0; // Problem + if ( pos == wxNOT_FOUND ) + { + // if there are no '|'s at all in the string just take the entire + // string as filter + if ( filters.IsEmpty() ) + { + description.Add(wxEmptyString); + filters.Add(filterStr); + } + else + { + wxFAIL_MSG( _T("missing '|' in the wildcard string!") ); + } + + break; + } + description = str.Left(pos); - str = str.Mid(pos+1); + str = str.Mid(pos + 1); pos = str.Find(wxT('|')); - if (pos == -1) + if ( pos == wxNOT_FOUND ) { filter = str; - finished = TRUE; } else { filter = str.Left(pos); - str = str.Mid(pos+1); + str = str.Mid(pos + 1); } descriptions.Add(description); filters.Add(filter); } - while (!finished); return filters.GetCount(); } -- 2.45.2