mbeckerle commented on a change in pull request #258: Adds bitawareness to left
over data dump
URL: https://github.com/apache/incubator-daffodil/pull/258#discussion_r299678392
##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -908,21 +911,36 @@ object Main extends Logging {
} else {
// not streaming, show left over data warning
val Dump = new DataDumper
- val curPositionInByte0b = inStream.inputSource.position
+ val firstByteBitArray = new Array[Byte](1)
+ val bitsAlreadyConsumed = loc.bitPos0b % 8
+ val firstByteString = if (bitsAlreadyConsumed != 0) {
+ val bitsToDisplay = 8 - bitsAlreadyConsumed
+ val pbp = inStream.inputSource.position + 1
+ inStream.fillByteArray(firstByteBitArray, bitsToDisplay,
finfo)
+ val fbs =
firstByteBitArray(0).toBinaryString.takeRight(8).reverse.padTo(8, '0').reverse
+ val bits = if (finfo.bitOrder ==
BitOrder.MostSignificantBitFirst) {
+ "x" * bitsAlreadyConsumed +
fbs.dropRight(bitsAlreadyConsumed)
+ } else {
+ fbs.takeRight(bitsToDisplay) + "x" *
bitsAlreadyConsumed
+ }
+ val dumpString = f"\nLeft over data (Hex) at byte $pbp
is: (0b$bits)"
Review comment:
This is I think where you change the message to indicate binary data and
emphasize the special first byte.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services