mbeckerle commented on code in PR #1587:
URL: https://github.com/apache/daffodil/pull/1587#discussion_r2503627644
##########
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/ConvertTextStandardNumberParser.scala:
##########
@@ -192,43 +192,13 @@ case class ConvertTextStandardNumberParser(
val pos = new ParsePosition(0)
val icuNum: JNumber = df.parse(strToParse, pos) match {
case null => {
- val infNaN: JDouble =
- if (df.isDecimalPatternMatchRequired) {
- // ICU failed to parse. But there is a bug in ICU4J
(ICU-22303) that if there is
- // a decimal in the pattern and we've set that decimal to be
required (due to
- // strict mode), then it will fail to parse Inf/NaN
representations. As a
- // workaround, we clone the DecimalFormat, disable requiring
the decimal, and
- // reparse. We only accept successful Inf/NaN parses
though--everything else is
- // considered a parse error since it meant the decimal point
was missing or
- // wasn't either inf/nan or a valid number. If ICU fixes this
bug, we should
- // remove this infNan variable and its use, as it is likely
pretty expensive to
- // clone, change a setting, and reparse. Fortunately, it is
only in the error
- // case of strict parsing so should be rare.
- pos.setIndex(0)
- val newDF = df.clone().asInstanceOf[DecimalFormat]
- newDF.setDecimalPatternMatchRequired(false)
- newDF.parse(strToParse, pos) match {
- case d: JDouble => {
- Assert.invariant(d.isNaN || d.isInfinite)
- d
- }
- case _ => null
- }
- } else {
- null
- }
-
- if (infNaN != null) {
- infNaN
- } else {
- PE(
- start,
- "Unable to parse %s from text: %s",
- context.optPrimType.get.globalQName,
- str
- )
- return
- }
+ PE(
Review Comment:
I was surprised to see that this code doesn't have to deal with
textStandardInfinityRep nor textStandardNaNRep.
This code needs a one-line comment as to where those are handled.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]