diff options
| author | Phil Christensen <philc@microsoft.com> | 2019-08-26 16:39:38 -0700 |
|---|---|---|
| committer | Phil Christensen <philc@microsoft.com> | 2019-08-26 16:39:38 -0700 |
| commit | 8bae937e1725a85cb7829ad3113debbeef43674a (patch) | |
| tree | ede578ef1cdea5d764c096412ad57f299ddcf612 /toolsrc/src | |
| parent | 6d8e66ff4fe40ef0937e33e809287476e2c04ee5 (diff) | |
| download | vcpkg-8bae937e1725a85cb7829ad3113debbeef43674a.tar.gz vcpkg-8bae937e1725a85cb7829ad3113debbeef43674a.zip | |
avoid assembling error strings unless there is an error
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg/parse.cpp | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/toolsrc/src/vcpkg/parse.cpp b/toolsrc/src/vcpkg/parse.cpp index a3f4186fc..6015d9927 100644 --- a/toolsrc/src/vcpkg/parse.cpp +++ b/toolsrc/src/vcpkg/parse.cpp @@ -78,24 +78,28 @@ namespace vcpkg::Parse // do not support nested [] if (value == '[') { - Checks::check_exit(VCPKG_LINE_INFO, - !bracket_nesting, - "Lists do not support nested brackets, Did you forget a ']'?\n" - "> '%s'\n" - "> %s^\n", - str, - std::string(static_cast<int>(iter - str.cbegin()), ' ')); + if (bracket_nesting) + { + Checks::exit_with_message(VCPKG_LINE_INFO, + "Lists do not support nested brackets, Did you forget a ']'?\n" + "> '%s'\n" + "> %s^\n", + str, + std::string(static_cast<int>(iter - str.cbegin()), ' ')); + } bracket_nesting = true; } else if (value == ']') { - Checks::check_exit(VCPKG_LINE_INFO, - bracket_nesting, - "Found unmatched ']'. Did you forget a '['?\n" - "> '%s'\n" - "> %s^\n", - str, - std::string(static_cast<int>(iter - str.cbegin()), ' ')); + if (!bracket_nesting) + { + Checks::exit_with_message(VCPKG_LINE_INFO, + "Found unmatched ']'. Did you forget a '['?\n" + "> '%s'\n" + "> %s^\n", + str, + std::string(static_cast<int>(iter - str.cbegin()), ' ')); + } bracket_nesting = false; } @@ -109,14 +113,15 @@ namespace vcpkg::Parse } } - Checks::check_exit(VCPKG_LINE_INFO, - element_begin != element_end, - "Empty element in list\n" - "> '%s'\n" - "> %s^\n", - str, - std::string(static_cast<int>(element_begin - str.cbegin()), ' ')); - + if (element_begin == element_end) + { + Checks::exit_with_message(VCPKG_LINE_INFO, + "Empty element in list\n" + "> '%s'\n" + "> %s^\n", + str, + std::string(static_cast<int>(element_begin - str.cbegin()), ' ')); + } out.push_back({element_begin, element_end}); if (iter != str.cend()) @@ -126,13 +131,15 @@ namespace vcpkg::Parse // Not at the end, must be at a comma that needs to be stepped over ++iter; - Checks::check_exit(VCPKG_LINE_INFO, - iter != str.end(), - "Empty element in list\n" - "> '%s'\n" - "> %s^\n", - str, - std::string(str.length(), ' ')); + if (iter == str.end()) + { + Checks::exit_with_message(VCPKG_LINE_INFO, + "Empty element in list\n" + "> '%s'\n" + "> %s^\n", + str, + std::string(str.length(), ' ')); + } } } while (iter != str.cend()); |
