From 40deaa176848765068c55ba22bab0902ed601adf Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Mon, 6 Dec 2021 11:50:27 -0800 Subject: [PATCH] [temporal] Sync parser change in PR1957 https://github.com/tc39/proposal-temporal/pull/1957 Resolve https://github.com/tc39/proposal-temporal/issues/1794 Bug: v8:11544 Change-Id: I50d406848e815b400d6e0cd14dee95589aac0647 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3318718 Reviewed-by: Shu-yu Guo Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/main@{#78263} --- src/temporal/temporal-parser.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/temporal/temporal-parser.cc b/src/temporal/temporal-parser.cc index ae99d48212..a4468b05d4 100644 --- a/src/temporal/temporal-parser.cc +++ b/src/temporal/temporal-parser.cc @@ -182,10 +182,20 @@ int32_t ScanFractionalPart(base::Vector str, int32_t s, int64_t* out) { // TimeFraction: FractionalPart SCAN_FORWARD(TimeFractionalPart, FractionalPart, int32_t) -// Fraction: DecimalSeparator TimeFractionalPart +// Fraction: DecimalSeparator FractionalPart // DecimalSeparator: one of , . template int32_t ScanFraction(base::Vector str, int32_t s, int32_t* out) { + if ((str.length() < (s + 2)) || (!IsDecimalSeparator(str[s]))) return 0; + int32_t len; + if ((len = ScanFractionalPart(str, s + 1, out)) == 0) return 0; + return len + 1; +} + +// TimeFraction: DecimalSeparator TimeFractionalPart +// DecimalSeparator: one of , . +template +int32_t ScanTimeFraction(base::Vector str, int32_t s, int32_t* out) { if ((str.length() < (s + 2)) || (!IsDecimalSeparator(str[s]))) return 0; int32_t len; if ((len = ScanTimeFractionalPart(str, s + 1, out)) == 0) return 0; @@ -193,12 +203,10 @@ int32_t ScanFraction(base::Vector str, int32_t s, int32_t* out) { } template -int32_t ScanFraction(base::Vector str, int32_t s, - ParsedISO8601Result* r) { - return ScanFraction(str, s, &(r->time_nanosecond)); +int32_t ScanTimeFraction(base::Vector str, int32_t s, + ParsedISO8601Result* r) { + return ScanTimeFraction(str, s, &(r->time_nanosecond)); } -// TimeFraction: Fraction -SCAN_FORWARD(TimeFraction, Fraction, ParsedISO8601Result) // TimeSpec: // TimeHour @@ -544,7 +552,6 @@ int32_t ScanTimeZoneUTCOffsetName(base::Vector str, int32_t s) { if ((len = ScanMinuteSecond(str, cur, &second)) == 0) return 0; cur += len; len = ScanFraction(str, cur, &fraction); - // TODO(ftang) Problem See Issue 1794 return cur + len - s; } else { if ((len = ScanMinuteSecond(str, cur, &minute)) == 0) { @@ -557,7 +564,6 @@ int32_t ScanTimeZoneUTCOffsetName(base::Vector str, int32_t s) { return cur - s; } cur += len; - // TODO(ftang) Problem See Issue 1794 len = ScanFraction(str, cur, &fraction); // Sign Hour MinuteSecond MinuteSecond [Fraction] return cur + len - s;