Skip to content

Commit be83b6c

Browse files
authored
fix(spanner): Do not compare iterators from different containers (#15665)
* fix(spanner): Do not compare iterators from different containers, fixes #15234
1 parent 41b9672 commit be83b6c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

google/cloud/spanner/interval.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -345,22 +345,22 @@ StatusOr<Interval> Interval::ParseISO8601Interval(absl::string_view str) {
345345
Interval intvl;
346346
absl::string_view s = str;
347347

348+
bool negated = !absl::ConsumePrefix(&s, "+") && absl::ConsumePrefix(&s, "-");
349+
if (!absl::ConsumePrefix(&s, "P")) {
350+
return SyntaxError(str, s, GCP_ERROR_INFO());
351+
}
352+
348353
auto const* units = std::begin(kISO8601DateUnitFactories);
349354
auto const* units_end = std::end(kISO8601DateUnitFactories);
350355
enum { kValue, kUnit, kNothing } expecting = kValue;
351-
bool negated = false;
356+
bool seen_time_designator = false;
352357

353358
for (;;) {
354-
if (units == std::begin(kISO8601DateUnitFactories)) {
355-
negated = !absl::ConsumePrefix(&s, "+") && absl::ConsumePrefix(&s, "-");
356-
if (!absl::ConsumePrefix(&s, "P")) break;
357-
}
358-
if (units_end == std::end(kISO8601DateUnitFactories)) {
359-
if (absl::ConsumePrefix(&s, "T")) {
360-
units = std::begin(kISO8601TimeUnitFactories);
361-
units_end = std::end(kISO8601TimeUnitFactories);
362-
expecting = kValue;
363-
}
359+
if (!seen_time_designator && absl::ConsumePrefix(&s, "T")) {
360+
units = std::begin(kISO8601TimeUnitFactories);
361+
units_end = std::end(kISO8601TimeUnitFactories);
362+
expecting = kValue;
363+
seen_time_designator = true;
364364
}
365365
if (units == units_end) break;
366366
double vf;

0 commit comments

Comments
 (0)