Skip to content

Commit d0d4200

Browse files
authored
packagespec: fix warning on vcpkg::Located::operator ==() (microsoft#1711)
There was an comparison of identical operands.
1 parent 5f31f35 commit d0d4200

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

include/vcpkg/packagespec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ namespace vcpkg
112112

113113
friend bool operator==(const Located& lhs, const Located& rhs)
114114
{
115-
return lhs.loc.row == rhs.loc.row && rhs.loc.column == rhs.loc.column && lhs.value == rhs.value;
115+
return lhs.loc.row == rhs.loc.row && lhs.loc.column == rhs.loc.column && lhs.value == rhs.value;
116116
}
117117
friend bool operator!=(const Located& lhs, const Located& rhs) { return !(lhs == rhs); }
118118
};

src/vcpkg-test/specifier.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
270270
"zlib[feature]:x64-uwp", AllowFeatures::Yes, ParseExplicitTriplet::Allow, AllowPlatformSpec::Yes)
271271
.value_or_exit(VCPKG_LINE_INFO);
272272
REQUIRE(spec.name.value == "zlib");
273-
SourceLoc feature_loc{{}, {}, 0, 5};
273+
SourceLoc feature_loc{{}, {}, 0, 6};
274274
REQUIRE(spec.features.value_or_exit(VCPKG_LINE_INFO) ==
275275
std::vector<Located<std::string>>{Located<std::string>(feature_loc, "feature")});
276276
REQUIRE(spec.triplet.value_or_exit(VCPKG_LINE_INFO).value == "x64-uwp");
@@ -301,9 +301,9 @@ TEST_CASE ("specifier parsing", "[specifier]")
301301
"zlib[0, 1,2]", AllowFeatures::Yes, ParseExplicitTriplet::Allow, AllowPlatformSpec::Yes)
302302
.value_or_exit(VCPKG_LINE_INFO);
303303
REQUIRE(spec.name.value == "zlib");
304-
SourceLoc zero_loc{{}, {}, 0, 5};
305-
SourceLoc one_loc{{}, {}, 0, 8};
306-
SourceLoc two_loc{{}, {}, 0, 10};
304+
SourceLoc zero_loc{{}, {}, 0, 6};
305+
SourceLoc one_loc{{}, {}, 0, 9};
306+
SourceLoc two_loc{{}, {}, 0, 11};
307307
REQUIRE(spec.features.value_or_exit(VCPKG_LINE_INFO) ==
308308
std::vector<Located<std::string>>{Located<std::string>{zero_loc, "0"},
309309
Located<std::string>{one_loc, "1"},
@@ -317,7 +317,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
317317
auto spec = vcpkg::parse_qualified_specifier(
318318
"zlib[*]", AllowFeatures::Yes, ParseExplicitTriplet::Allow, AllowPlatformSpec::Yes)
319319
.value_or_exit(VCPKG_LINE_INFO);
320-
SourceLoc star_loc{{}, {}, 0, 5};
320+
SourceLoc star_loc{{}, {}, 0, 6};
321321
REQUIRE(spec.name.value == "zlib");
322322
REQUIRE(spec.features.value_or_exit(VCPKG_LINE_INFO) ==
323323
std::vector<Located<std::string>>{Located<std::string>{star_loc, "*"}});

src/vcpkg/base/parse.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ namespace vcpkg
99
{
1010
static void advance_rowcol(char32_t ch, int& row, int& column)
1111
{
12-
if (row == 0 && column == 0)
12+
if (row == 0)
1313
{
14+
if (column != 0)
15+
{
16+
++column;
17+
}
18+
1419
return;
1520
}
16-
else if (row == 0 || column == 0)
17-
{
18-
Checks::unreachable(VCPKG_LINE_INFO);
19-
}
2021

2122
if (ch == '\t')
2223
{

src/vcpkg/packagespec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ namespace vcpkg
218218
AllowPlatformSpec allow_platform_spec)
219219
{
220220
// there is no origin because this function is used for user inputs
221-
auto parser = ParserBase(input, nullopt, {0, 0});
221+
auto parser = ParserBase(input, nullopt, {0, 1});
222222
auto maybe_pqs = parse_qualified_specifier(parser, allow_features, parse_explicit_triplet, allow_platform_spec);
223223
if (!parser.at_eof())
224224
{

0 commit comments

Comments
 (0)