From 801e6b84901c76dbeaebe756397909b0db1ee947 Mon Sep 17 00:00:00 2001 From: Kshitij Bansal Date: Fri, 16 May 2014 13:41:31 -0400 Subject: [PATCH] minor improvements (fixes) to did-you-mean suggestions --- src/options/base_options_handlers.h | 10 ++++++++-- src/options/options_template.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/options/base_options_handlers.h b/src/options/base_options_handlers.h index 3779f75c1..15813a774 100644 --- a/src/options/base_options_handlers.h +++ b/src/options/base_options_handlers.h @@ -100,7 +100,8 @@ inline InputLanguage stringToInputLanguage(std::string option, std::string optar Unreachable(); } -inline std::string suggestTags(char const* const* validTags, std::string inputTag) +inline std::string suggestTags(char const* const* validTags, std::string inputTag, + char const* const* additionalTags = NULL) { DidYouMean didYouMean; @@ -108,6 +109,11 @@ inline std::string suggestTags(char const* const* validTags, std::string inputTa for(size_t i = 0; (opt = validTags[i]) != NULL; ++i) { didYouMean.addWord(validTags[i]); } + if(additionalTags != NULL) { + for(size_t i = 0; (opt = additionalTags[i]) != NULL; ++i) { + didYouMean.addWord(additionalTags[i]); + } + } return didYouMean.getMatchAsString(inputTag); } @@ -130,7 +136,7 @@ inline void addDebugTag(std::string option, std::string optarg, SmtEngine* smt) !Configuration::isTraceTag(optarg.c_str())) { throw OptionException(std::string("debug tag ") + optarg + std::string(" not available.") + - suggestTags(Configuration::getDebugTags(), optarg) ); + suggestTags(Configuration::getDebugTags(), optarg, Configuration::getTraceTags()) ); } } else if(! Configuration::isDebugBuild()) { throw OptionException("debug tags not available in non-debug builds"); diff --git a/src/options/options_template.cpp b/src/options/options_template.cpp index a16e7f899..39deb285a 100644 --- a/src/options/options_template.cpp +++ b/src/options/options_template.cpp @@ -570,7 +570,7 @@ std::string Options::suggestCommandLineOptions(const std::string& optionName) th didYouMean.addWord(std::string("--") + cmdlineOptions[i].name); } - return didYouMean.getMatchAsString(optionName); + return didYouMean.getMatchAsString(optionName.substr(0, optionName.find('='))); } static const char* smtOptions[] = { -- 2.30.2