aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/Paragraphs.cpp
diff options
context:
space:
mode:
authorTobias Kohlbau <tobias@kohlbau.de>2017-03-31 01:05:21 +0200
committerAlexander Karatarakis <alkarata@microsoft.com>2017-04-03 14:12:06 -0700
commitb992a05a5979f4a13e2f51a90c34f99847278030 (patch)
tree1a6f383e3f8c3803de948ace6bb1ff5986d1e72d /toolsrc/src/Paragraphs.cpp
parent23887e920822599e04a87bff0d03733b309dce98 (diff)
downloadvcpkg-b992a05a5979f4a13e2f51a90c34f99847278030.tar.gz
vcpkg-b992a05a5979f4a13e2f51a90c34f99847278030.zip
adds line comments for CONTROL
Adds line comments denoted by # within CONTROL files. For the moment a comment must be start with # and is valid until the end of the line. It's not possible to add a comment at the end of usable lines. Signed-off-by: Tobias Kohlbau <tobias@kohlbau.de>
Diffstat (limited to 'toolsrc/src/Paragraphs.cpp')
-rw-r--r--toolsrc/src/Paragraphs.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp
index aebe3d1f8..898fc6460 100644
--- a/toolsrc/src/Paragraphs.cpp
+++ b/toolsrc/src/Paragraphs.cpp
@@ -32,6 +32,16 @@ namespace vcpkg::Paragraphs
}
}
+ void skip_comment(char& ch)
+ {
+ while (ch != '\r')
+ next(ch);
+ if (ch == '\r')
+ next(ch);
+ if (ch == '\n')
+ next(ch);
+ }
+
void skip_spaces(char& ch)
{
while (ch == ' ' || ch == '\t')
@@ -45,6 +55,11 @@ namespace vcpkg::Paragraphs
|| (ch >= '0' && ch <= '9');
}
+ static bool is_comment(char ch)
+ {
+ return (ch == '#');
+ }
+
static bool is_lineend(char ch)
{
return ch == '\r' || ch == '\n' || ch == 0;
@@ -68,7 +83,7 @@ namespace vcpkg::Paragraphs
if (ch == '\n')
next(ch);
- if (is_alphanum(ch))
+ if (is_alphanum(ch) || is_comment(ch))
{
// Line begins a new field.
return;
@@ -115,6 +130,12 @@ namespace vcpkg::Paragraphs
std::string fieldvalue;
do
{
+ if (is_comment(ch))
+ {
+ skip_comment(ch);
+ continue;
+ }
+
get_fieldname(ch, fieldname);
auto it = fields.find(fieldname);