mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 04:49:08 +08:00
clean up list parsing logic and add clear warnings
This commit is contained in:
parent
051a6fd5b3
commit
13c95f16bf
@ -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
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <vcpkg/parse.h>
|
||||
|
||||
#include <vcpkg/base/util.h>
|
||||
#include <vcpkg/base/system.print.h>
|
||||
|
||||
namespace vcpkg::Parse
|
||||
{
|
||||
@ -58,26 +59,73 @@ namespace vcpkg::Parse
|
||||
|
||||
std::vector<std::string> out;
|
||||
|
||||
size_t cur = 0;
|
||||
do
|
||||
{
|
||||
auto pos = str.find(',', cur);
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
out.push_back(str.substr(cur));
|
||||
break;
|
||||
}
|
||||
out.push_back(str.substr(cur, pos - cur));
|
||||
auto iter = str.cbegin();
|
||||
|
||||
// skip comma and space
|
||||
++pos;
|
||||
while (is_whitespace(str[pos]))
|
||||
do {
|
||||
// Trim leading whitespace of each element
|
||||
while (iter != str.cend() && is_whitespace(*iter))
|
||||
{
|
||||
++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 == '[')
|
||||
{
|
||||
bracket_nesting = true;
|
||||
}
|
||||
else if (value == ']')
|
||||
{
|
||||
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)
|
||||
{
|
||||
System::print2( System::Color::warning,
|
||||
"Warning: empty element in list\n"
|
||||
"> '", str, "'\n"
|
||||
"> ", std::string(static_cast<int>(element_begin - str.cbegin()), ' '), "^\n"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
out.push_back({ element_begin, element_end });
|
||||
}
|
||||
|
||||
if (iter != str.cend())
|
||||
{
|
||||
//Not at the end, must be at a comma that needs to be stepped over
|
||||
++iter;
|
||||
|
||||
if (iter == str.end())
|
||||
{
|
||||
System::print2(System::Color::warning,
|
||||
"Warning: empty element in list\n"
|
||||
"> '", str, "'\n"
|
||||
"> ", std::string(str.length(), ' '), "^\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} while (iter != str.cend());
|
||||
|
||||
return out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user