mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Let flatecut accept a degenerate Huffman tree
This commit is contained in:
1 parent
52261e7528
commit
0cc17985db
7 files changed
+132
-3
No files matched your search
@@ -232,6 +232,7 @@ var deflateGlobals struct {
|
||||
func stateDeflate(line string) (stateFunc, error) {
|
||||
g := &deflateGlobals
|
||||
const (
|
||||
cmdB = "bytes "
|
||||
cmdBNC = "blockNoCompression "
|
||||
cmdBFH = "blockFixedHuffman "
|
||||
)
|
||||
@@ -240,6 +241,18 @@ func stateDeflate(line string) (stateFunc, error) {
|
||||
|
||||
retState := stateFunc(nil)
|
||||
switch {
|
||||
case strings.HasPrefix(line, cmdB):
|
||||
s := line[len(cmdB):]
|
||||
for s != "" {
|
||||
x, ok := uint32(0), false
|
||||
x, s, ok = parseHex(s)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("bad stateDeflate command: %q", line)
|
||||
}
|
||||
out = append(out, uint8(x))
|
||||
}
|
||||
return stateDeflate, nil
|
||||
|
||||
case strings.HasPrefix(line, cmdBNC):
|
||||
s = line[len(cmdBNC):]
|
||||
retState = stateDeflateNoCompression
|
||||
|
||||
Reference in new issue
Block a user