mike-mcgann commented on code in PR #988:
URL: https://github.com/apache/daffodil/pull/988#discussion_r1140185407
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/Parser.scala:
##########
@@ -65,7 +66,27 @@ sealed trait Parser extends Processor {
pstate.setFailed(new ParseError(One(sfl), One(dataLoc), s, args: _*))
}
- def PENotEnoughBits(pstate: PState, neededBits: Long, remainingBits:
MaybeULong) = {
+ def PENotEnoughBits(pstate: PState, neededBits: Long, source:
InputSourceDataInputStream): Unit = {
+ val remainingLimitedBits = {
+ if (source.bitLimit0b.isEmpty) MaybeULong.Nope
+ else {
+ val lim = source.bitLimit0b.get
+ Assert.invariant(lim >= 0)
+ val nBits = lim - source.bitPos0b
+ MaybeULong(nBits)
+ }
+ }
+
+ val remainingBits = {
+ if (source.hasReachedEndOfData) {
+ val bitsAvailable = source.knownBytesAvailable * 8
Review Comment:
Updated and I added an additional test for this condition
##########
daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala:
##########
@@ -129,23 +129,14 @@ final class InputSourceDataInputStream private (val
inputSource: InputSource)
def hasReachedEndOfData: Boolean = inputSource.hasReachedEndOfData
/**
- * The number of bits remaining if known. If a limit has not been set,
- * returns Nope. If a limit has been set, the number of bits available
- * until the limit as long as the end of data has not been seen. If the
- * end of data has been seen, the smaller value of the remaining bits
- * in the limit and the remaining bits in the data stream.
+ * Return the number of currently available bytes.
+ *
+ * This should not be used to determine the length of the data, as more bytes
+ * may become available in the future. This should really only be used for
+ * debug purposes.
Review Comment:
Updated
--
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]