Error/warning reporting improvements.

- Don't suggest matches when given an empty string or a single, non-alpha
  character.
- Also fixed the parser to be a bit less confusing when it encounters an
  unexpected EOF.
This commit is contained in:
Matt Pharr
2011-09-23 15:51:23 -07:00
parent b3d3e8987b
commit d261105a86
2 changed files with 25 additions and 9 deletions

View File

@@ -344,6 +344,10 @@ StringEditDistance(const std::string &str1, const std::string &str2, int maxDist
std::vector<std::string>
MatchStrings(const std::string &str, const std::vector<std::string> &options) {
if (str.size() == 0 || (str.size() == 1 && !isalpha(str[0])))
// don't even try...
return std::vector<std::string>();
const int maxDelta = 2;
std::vector<std::string> matches[maxDelta+1];