diff --git a/ent/dict.go b/ent/dict.go index bf5033d..547a628 100644 --- a/ent/dict.go +++ b/ent/dict.go @@ -187,8 +187,16 @@ func (d *Dict) syncBaselines() { c.baseline = c.New() } + if e.Value == nil || len(e.Value) == 0 { + Debug.Printf("syncBaselines skipping entry with key %s: value is empty", e.Key) + continue + } + d.br.SetSource(e.Value) Debug.Printf("syncBaselines has new baseline for class %v", c) - c.baseline.Read(d.br) + if err := c.baseline.Read(d.br); err != nil { + Debug.Printf("syncBaselines failed to read a baseline: %v", err) + continue + } } } diff --git a/ent/entity.go b/ent/entity.go index c648685..6599a98 100644 --- a/ent/entity.go +++ b/ent/entity.go @@ -18,6 +18,9 @@ func (e *Entity) Read(br bit.Reader) error { fp := newFieldPath() for fn := walk(htree, br); fn != nil; fn = walk(htree, br) { + if err := br.Err(); err != nil { + return fmt.Errorf("unable to read entity: reader error: %v", err) + } fn(fp, br) } Debug.Printf("fieldpath %s", fp.pathString()) diff --git a/ent/huff.go b/ent/huff.go index 70a1e65..d16c4fc 100644 --- a/ent/huff.go +++ b/ent/huff.go @@ -181,15 +181,12 @@ var hlist = nodeList{ }) }}, lNode{"NonTopoComplex", 36, 76, func(fp *fieldPath, br bit.Reader) { - panic("not implemented: NonTopoComplex") - // for i := 0; i < len(fp.index); i++ { - // fp.replaceAll(func(i int) int { - // if bit.ReadBool(br) { - // return i + bit.ReadVarInt(br) - // } - // return i - // }) - // } + fp.replaceAll(func(i int) int { + if bit.ReadBool(br) { + return i + int(bit.ReadZigZag32(br)) + } + return i + }) }}, lNode{"PushOneLeftDeltaZeroRightZero", 5, 35, func(fp *fieldPath, br bit.Reader) { fp.push(0) @@ -202,7 +199,13 @@ var hlist = nodeList{ fp.add(1) }}, lNode{"PopNAndNonTopographical", 35, 1, func(fp *fieldPath, br bit.Reader) { - panic("not implemented: PopNAndNonTopographical") + fp.last -= int(bit.ReadUBitVarFP(br)) + fp.replaceAll(func(i int) int { + if bit.ReadBool(br) { + return i + int(bit.ReadZigZag32(br)) + } + return i + }) }}, // all the other operations have weights of 0 in clarity, which makes no @@ -250,7 +253,8 @@ var hlist = nodeList{ panic("not implemented: PushThreeLeftDeltaZero") }}, lNode{"PushTwoPack5LeftDeltaZero", 14, 1, func(fp *fieldPath, br bit.Reader) { - panic("not implemented: PushTwoPack5LeftDeltaZero") + fp.push(int(br.ReadBits(5))) + fp.push(int(br.ReadBits(5))) }}, lNode{"PushTwoLeftDeltaZero", 13, 1, func(fp *fieldPath, br bit.Reader) { panic("not implemented: PushTwoLeftDeltaZero")