[vcpkg] fix list parsing logic and add error messages

fix list parsing logic and add error messages
This commit is contained in:
Phil Christensen 2019-08-27 11:00:37 -07:00 committed by GitHub
commit 0eb7305102
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 120 additions and 21 deletions

View File

@ -3,7 +3,33 @@ Source: boost
Version: 1.70.0
Homepage: https://boost.org
Description: Peer-reviewed portable C++ source libraries
Build-Depends: boost-accumulators, boost-algorithm, boost-align, boost-any, boost-array, boost-asio, boost-assert, boost-assign, boost-atomic, boost-beast, boost-bimap, boost-bind, boost-callable-traits, boost-chrono, boost-circular-buffer, boost-compatibility, boost-compute, boost-concept-check, boost-config, boost-container, boost-container-hash, boost-context (!uwp), boost-contract (!arm), boost-conversion, boost-convert, boost-core, boost-coroutine (!uwp), boost-coroutine2, boost-crc, boost-date-time, boost-detail, boost-disjoint-sets, boost-dll, boost-dynamic-bitset, boost-endian, boost-exception, boost-fiber (windows), boost-filesystem (!uwp), boost-flyweight, boost-foreach, boost-format, boost-function, boost-functional, boost-function-types, boost-fusion, boost-geometry, boost-gil, boost-graph, boost-graph-parallel, boost-hana, boost-heap, boost-histogram, boost-hof, boost-icl, boost-integer, boost-interprocess, boost-intrusive, boost-io, boost-iostreams (!uwp), boost-iterator, boost-lambda, boost-lexical-cast, boost-locale (!uwp), boost-local-function, boost-lockfree, boost-log (!uwp), boost-logic, boost-math, boost-metaparse, boost-move, boost-mp11, boost-mpl, boost-msm, boost-multiprecision, boost-multi-array, boost-multi-index, boost-numeric-conversion, boost-interval, boost-odeint, boost-ublas, boost-safe-numerics, boost-optional, boost-outcome, boost-parameter, boost-parameter-python (windows), boost-phoenix, boost-polygon, boost-poly-collection, boost-pool, boost-predef, boost-preprocessor, boost-process, boost-program-options, boost-property-map, boost-property-tree, boost-proto, boost-ptr-container, boost-python (windows), boost-qvm, boost-random, boost-range, boost-ratio, boost-rational, boost-regex, boost-numeric-conversion, boost-interval, boost-odeint, boost-ublas, boost-safe-numerics, boost-scope-exit, boost-serialization, boost-signals2, boost-smart-ptr, boost-sort, boost-spirit, boost-stacktrace (!uwp), boost-statechart, boost-static-assert, boost-system, boost-test (!uwp), boost-thread (!arm), boost-throw-exception, boost-timer, boost-tokenizer, boost-tti, boost-tuple, boost-typeof, boost-type-erasure (!arm), boost-type-index, boost-type-traits, boost-units, boost-unordered, boost-utility, boost-uuid, boost-variant, boost-vmd, boost-wave (!uwp), boost-winapi, boost-xpressive, boost-yap
Build-Depends: boost-accumulators, boost-algorithm, boost-align, boost-any, boost-array,
boost-asio, boost-assert, boost-assign, boost-atomic, boost-beast, boost-bimap, boost-bind,
boost-callable-traits, boost-chrono, boost-circular-buffer, boost-compatibility,
boost-compute, boost-concept-check, boost-config, boost-container, boost-container-hash,
boost-context (!uwp), boost-contract (!arm), boost-conversion, boost-convert, boost-core,
boost-coroutine (!uwp), boost-coroutine2, boost-crc, boost-date-time, boost-detail,
boost-disjoint-sets, boost-dll, boost-dynamic-bitset, boost-endian, boost-exception,
boost-fiber (windows), boost-filesystem (!uwp), boost-flyweight, boost-foreach, boost-format,
boost-function, boost-functional, boost-function-types, boost-fusion, boost-geometry,
boost-gil, boost-graph, boost-graph-parallel, boost-hana, boost-heap, boost-histogram,
boost-hof, boost-icl, boost-integer, boost-interprocess, boost-intrusive, boost-io,
boost-iostreams (!uwp), boost-iterator, boost-lambda, boost-lexical-cast, boost-locale (!uwp),
boost-local-function, boost-lockfree, boost-log (!uwp), boost-logic, boost-math,
boost-metaparse, boost-move, boost-mp11, boost-mpl, boost-msm, boost-multiprecision,
boost-multi-array, boost-multi-index, boost-numeric-conversion, boost-interval, boost-odeint,
boost-ublas, boost-safe-numerics, boost-optional, boost-outcome, boost-parameter,
boost-parameter-python (windows), boost-phoenix, boost-polygon, boost-poly-collection,
boost-pool, boost-predef, boost-preprocessor, boost-process, boost-program-options,
boost-property-map, boost-property-tree, boost-proto, boost-ptr-container,
boost-python (windows), boost-qvm, boost-random, boost-range, boost-ratio, boost-rational,
boost-regex, boost-numeric-conversion, boost-interval, boost-odeint, boost-ublas,
boost-safe-numerics, boost-scope-exit, boost-serialization, boost-signals2, boost-smart-ptr,
boost-sort, boost-spirit, boost-stacktrace (!uwp), boost-statechart, boost-static-assert,
boost-system, boost-test (!uwp), boost-thread (!arm), boost-throw-exception, boost-timer,
boost-tokenizer, boost-tti, boost-tuple, boost-typeof, boost-type-erasure (!arm),
boost-type-index, boost-type-traits, boost-units, boost-unordered, boost-utility, boost-uuid,
boost-variant, boost-vmd, boost-wave (!uwp), boost-winapi, boost-xpressive, boost-yap
Feature: mpi
Description: Build with MPI support

View File

@ -1,13 +1,16 @@
Source: cpprestsdk
Version: 2.10.14-1
Build-Depends: openssl (!uwp&!windows), boost-system (!uwp&!windows), boost-date-time (!uwp&!windows), boost-regex (!uwp&!windows), boost-thread (!uwp&!windows), boost-filesystem (!uwp&!windows), boost-random (!uwp&!windows), boost-chrono (!uwp&!windows), boost-asio (!uwp&!windows)
Build-Depends: openssl (!uwp&!windows), boost-system (!uwp&!windows),
boost-date-time (!uwp&!windows), boost-regex (!uwp&!windows), boost-thread (!uwp&!windows),
boost-filesystem (!uwp&!windows), boost-random (!uwp&!windows), boost-chrono (!uwp&!windows),
boost-asio (!uwp&!windows)
Homepage: https://github.com/Microsoft/cpprestsdk
Description: C++11 JSON, REST, and OAuth library
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Default-Features: default-features
Feature: default-features
Build-Depends: cpprestsdk[brotli] (windows), cpprestsdk[core], cpprestsdk[compression], cpprestsdk[websockets]
Build-Depends: cpprestsdk[brotli] (windows), cpprestsdk[core,compression,websockets]
Description: Features installed by default
Feature: compression
@ -15,9 +18,9 @@ Build-Depends: zlib
Description: HTTP Compression support
Feature: websockets
Build-Depends: cpprestsdk[core], cpprestsdk[compression], websocketpp (!uwp), openssl (!uwp), boost-system (!uwp), boost-date-time (!uwp), boost-regex (!uwp)
Build-Depends: cpprestsdk[core,compression], websocketpp (!uwp), openssl (!uwp), boost-system (!uwp), boost-date-time (!uwp), boost-regex (!uwp)
Description: Websockets support
Feature: brotli
Build-Depends: cpprestsdk[core], cpprestsdk[compression], brotli
Build-Depends: cpprestsdk[core,compression], brotli
Description: Brotli compression support

View File

@ -1 +1 @@
"2019.08.16"
"2019.08.23"

View File

@ -2,6 +2,7 @@
#include <vcpkg/parse.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>
namespace vcpkg::Parse
@ -44,6 +45,8 @@ namespace vcpkg::Parse
return nullptr;
}
static bool is_whitespace(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\r'; }
std::vector<std::string> parse_comma_list(const std::string& str)
{
if (str.empty())
@ -53,26 +56,93 @@ namespace vcpkg::Parse
std::vector<std::string> out;
size_t cur = 0;
auto iter = str.cbegin();
do
{
auto pos = str.find(',', cur);
if (pos == std::string::npos)
// Trim leading whitespace of each element
while (iter != str.cend() && is_whitespace(*iter))
{
out.push_back(str.substr(cur));
break;
}
out.push_back(str.substr(cur, pos - cur));
// skip comma and space
++pos;
while (str[pos] == ' ')
{
++pos;
++iter;
}
cur = pos;
} while (cur != std::string::npos);
// Allow commas inside of [].
bool bracket_nesting = false;
auto element_begin = iter;
auto element_end = iter;
while (iter != str.cend() && (*iter != ',' || bracket_nesting))
{
char value = *iter;
// do not support nested []
if (value == '[')
{
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 == ']')
{
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;
}
++iter;
// Trim ending whitespace
if (!is_whitespace(value))
{
// Update element_end after iter is incremented so it will be one past.
element_end = iter;
}
}
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())
{
Checks::check_exit(VCPKG_LINE_INFO, *iter == ',', "Internal parsing error - expected comma");
// Not at the end, must be at a comma that needs to be stepped over
++iter;
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());
return out;
}