mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Add a writer1.length method.
This commit is contained in:
1 parent
e9df25d599
commit
d30d4c3dad
3 files changed
+16
-4
No files matched your search
@@ -171,12 +171,20 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
|||||||
if pp == parenthesesMandatory {
|
if pp == parenthesesMandatory {
|
||||||
b.writeb('(')
|
b.writeb('(')
|
||||||
}
|
}
|
||||||
b.writes("(uint64_t)(")
|
|
||||||
x := n.LHS().Expr().LHS().Expr()
|
x := n.LHS().Expr().LHS().Expr()
|
||||||
if err := g.writeExpr(b, x, rp, parenthesesMandatory, depth); err != nil {
|
if typ := x.MType(); typ.Decorator() == 0 && typ.Name().Key() == t.KeyWriter1 {
|
||||||
return err
|
// TODO: don't hard-code dst.
|
||||||
|
const wName = "dst"
|
||||||
|
b.printf("(uint64_t)(%swptr_%s - %swstart_%s)", bPrefix, wName, bPrefix, wName)
|
||||||
|
} else {
|
||||||
|
b.writes("(uint64_t)(")
|
||||||
|
if err := g.writeExpr(b, x, rp, parenthesesMandatory, depth); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b.writes(".len)")
|
||||||
}
|
}
|
||||||
b.writes(".len)")
|
|
||||||
if pp == parenthesesMandatory {
|
if pp == parenthesesMandatory {
|
||||||
b.writeb(')')
|
b.writeb(')')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1314,6 +1314,8 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
v_distance += ((v_bits) & ((1 << (v_table_entry_n_bits)) - 1));
|
v_distance += ((v_bits) & ((1 << (v_table_entry_n_bits)) - 1));
|
||||||
v_bits >>= v_table_entry_n_bits;
|
v_bits >>= v_table_entry_n_bits;
|
||||||
v_n_bits -= v_table_entry_n_bits;
|
v_n_bits -= v_table_entry_n_bits;
|
||||||
|
if (((uint64_t)(v_distance)) > ((uint64_t)(b_wptr_dst - b_wstart_dst))) {
|
||||||
|
}
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT(8);
|
PUFFS_COROUTINE_SUSPENSION_POINT(8);
|
||||||
{
|
{
|
||||||
self->private_impl.c_decode_huffman[0].scratch =
|
self->private_impl.c_decode_huffman[0].scratch =
|
||||||
|
|||||||
@@ -341,6 +341,8 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
|||||||
// TODO: copy_history32 should also take some notion of how much of dst
|
// TODO: copy_history32 should also take some notion of how much of dst
|
||||||
// is valid. When copying from a distance greater than that, we also
|
// is valid. When copying from a distance greater than that, we also
|
||||||
// need to keep a sliding window of previous history.
|
// need to keep a sliding window of previous history.
|
||||||
|
if (distance as u64) > in.dst.length() {
|
||||||
|
}
|
||||||
in.dst.copy_history32?(distance:distance, length:length)
|
in.dst.copy_history32?(distance:distance, length:length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user