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
This commit is contained in:
Vadim Zeitlin
2003-06-15 20:13:20 +00:00
parent 5447d1b493
commit 817670e454

View File

@@ -244,23 +244,38 @@ int wxParseFileFilter(const wxString& filterStr,
wxArrayString& descriptions, wxArrayString& descriptions,
wxArrayString& filters) wxArrayString& filters)
{ {
descriptions.Clear();
filters.Clear();
wxString str(filterStr); wxString str(filterStr);
wxString description, filter; wxString description, filter;
int pos = -1; for ( int pos = 0; pos != wxNOT_FOUND; )
bool finished = FALSE;
do
{ {
pos = str.Find(wxT('|')); pos = str.Find(wxT('|'));
if (pos == -1) if ( pos == wxNOT_FOUND )
return 0; // Problem {
// 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); description = str.Left(pos);
str = str.Mid(pos + 1); str = str.Mid(pos + 1);
pos = str.Find(wxT('|')); pos = str.Find(wxT('|'));
if (pos == -1) if ( pos == wxNOT_FOUND )
{ {
filter = str; filter = str;
finished = TRUE;
} }
else else
{ {
@@ -271,7 +286,6 @@ int wxParseFileFilter(const wxString& filterStr,
descriptions.Add(description); descriptions.Add(description);
filters.Add(filter); filters.Add(filter);
} }
while (!finished);
return filters.GetCount(); return filters.GetCount();
} }