What does the following code snippet do?
bool test(const wstring& first, const wstring& second)
{
if (first.empty() && second.empty())
return true;
if (first.empty())
return (second[0] == L'*') && test(first, second.substr(1));
if (second.empty())
return (first[0] == L'*') && test(first.substr(1), second);
switch(first[0]) {
case L'?':
if (second[0] == L'*') {
return test(first.substr(1), second) || test(first, second.substr(1));
}
return test(first.substr(1), second.substr(1));
case L'*':
return test(first, second.substr(1)) || test(first.substr(1), second);
default:
switch(second[0]) {
case L'?':
return test(first.substr(1), second.substr(1));
case L'*':
return test(first.substr(1), second) || test(first, second.substr(1));
default:
return (first[0] == second[0]) && test(first.substr(1), second.substr(1));
}
}
}