diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/SpecifiedLengthParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/SpecifiedLengthParsers.scala index a969ba8b6b..72afe0b496 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/SpecifiedLengthParsers.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/SpecifiedLengthParsers.scala @@ -85,7 +85,9 @@ sealed abstract class SpecifiedLengthParserBase(eParser: Parser, erd: RuntimeDat if (pState.processorStatus ne Success) return val finalEndPos0b = startingBitPos0b + nBits - captureValueLength(pState, ULong(startingBitPos0b), ULong(dis.bitPos0b)) + // if we haven't already set the value length, set it now + if (pState.infoset.valueLength.isEndUndef) + captureValueLength(pState, ULong(startingBitPos0b), ULong(dis.bitPos0b)) Assert.invariant(dis eq pState.dataInputStream) val bitsToSkip = finalEndPos0b - dis.bitPos0b diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/PrefixedTests.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/PrefixedTests.tdml index 82d201a360..295d536a6b 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/PrefixedTests.tdml +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/PrefixedTests.tdml @@ -17,14 +17,14 @@ --> + description="Section 12 - lengthKind=prefixed" xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:fn="http://www.w3.org/2005/xpath-functions" + xmlns:ex="http://example.com" + xmlns:tns="http://example.com" + xmlns:dfdlx="http://www.ogf.org/dfdl/dfdl-1.0/extensions" + defaultRoundTrip="onePass" xmlns:x="http://www.ogf.org/dfdl/dfdl-1.0/"> @@ -2314,10 +2314,31 @@ - + + + + + + + + + + + + + + + @@ -2423,8 +2444,10 @@ + + model="lengthKindPrefixed-2" + roundTrip="none"> 00 00 00 0B ABC @@ -2439,6 +2462,21 @@ + + + ABC + + + + + ABC + 3 + + + + + diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section12/lengthKind/TestLengthKindPrefixed.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section12/lengthKind/TestLengthKindPrefixed.scala index 99e0cf1c98..72286a3989 100644 --- a/daffodil-test/src/test/scala/org/apache/daffodil/section12/lengthKind/TestLengthKindPrefixed.scala +++ b/daffodil-test/src/test/scala/org/apache/daffodil/section12/lengthKind/TestLengthKindPrefixed.scala @@ -269,7 +269,12 @@ class TestLengthKindPrefixed { } // DAFFODIL-2658 - // @Test def test_pl_simpleValueLengthBytes_1() = { runner.runOneTest("pl_simpleValueLengthBytes_1")} + @Test def test_pl_simpleValueLengthBytes_1() = { + runner.runOneTest("pl_simpleValueLengthBytes_1") + } + @Test def test_pl_simpleValueLengthBytes_2() = { + runner.runOneTest("pl_simpleValueLengthBytes_2") + } @Test def test_pl_simpleContentLengthCharacters_1() = { runner.runOneTest("pl_simpleContentLengthCharacters_1")