https://bugs.kde.org/show_bug.cgi?id=396057

            Bug ID: 396057
           Summary: Pascal-style RLE strings not working properly for
                    length 1, both JS and OSD
           Product: okteta
           Version: unspecified
          Platform: Gentoo Packages
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: Structures Tool
          Assignee: arichardson....@gmail.com
          Reporter: sa...@o2.pl
                CC: kosse...@kde.org
  Target Milestone: ---

The following simple test structure definition for recognizing Pascal-style
(run length ncoded) strings works only for strings longer than 1 byte, but for
lengths 1 and 0 shows that the string has length 0 while still containing the
previous content (sometimes with garbage characters at the beginning):

function init() {
        var obj = struct({
                len: uint16(),
                data: string("utf-8")
        });
        obj.byteOrder = "big-endian";
        obj.child("data").updateFunc = function() {
                this.maxByteCount = this.parent.len.value;
        };
        return obj;
}

Or the same expressed in the XML format:

<?xml version="1.0" encoding="UTF-8"?>
<data>
        <struct name="PascalString" byteOrder="big-endian">
                <primitive name="len" type="uint16" />
                <string name="data" encoding="utf-8" updateFunc="function() {
this.maxByteCount = this.parent.len.value; }">
        </struct>
</data>

Here's a sample data I select:

00 04 41 42 43 44 45 46 47 48    |..ABCDEFGH    |

In this case, it correctly contains only a 4-byte string, "ABCD" (4).
But when I change the data to this:

00 01 41 42 43 44 45 46 47 48    |..ABCDEFGH    |

it contains a 0-byte string which is not empty! "BCDEFGH\0" (0).
It seems like it doesn't update the content of the string buffer / pointer to
it, but updates the length to be 0 instead of 1.

A correct/expected behaviour should be a 1-byte string: "A" (1).
A 0-byte string should be a result when the length field in the data structure
is set to `00 00`, and the contents of the string should be empty in that case,
not contain the previously stored value: "" (0).

My version of Okteta is 0.12.5, which from some reason wasn't on the list. (KDE
version 4.14.3)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to