Rename "!=" to "<>"; "!" now only shows impurity

This commit is contained in:
Nigel Tao committed 2019-03-02 14:51:32 +11:00
1 parent f8d02cfb16
commit ef7aa0d980
11 files changed
+82 -83

No files matched your search

+2 -1
View File
@@ -21,6 +21,7 @@
- Spun `std/zlib` out of `std/flate`.
- Let the `std/zlib` decoder ignore checksums.
- Renamed `std/flate` to `std/deflate`.
- Renamed `!=` to `<>`; `!` is now only for impure functions.
- Renamed `~+` to `~mod+`; added `~mod-`, `~sat+` and `~sat-`.
- Removed `&^`.
- Renamed `$(etc)` to `[etc]`.
@@ -67,4 +68,4 @@
---
Updated on February 2019.
Updated on March 2019.
+1 -1
View File
@@ -164,7 +164,7 @@ var opStrings = [...]string{
t.IDXBinaryTildeModMinus: " ~mod- ",
t.IDXBinaryTildeSatPlus: " ~sat+ ",
t.IDXBinaryTildeSatMinus: " ~sat- ",
t.IDXBinaryNotEq: " != ",
t.IDXBinaryNotEq: " <> ",
t.IDXBinaryLessThan: " < ",
t.IDXBinaryLessEq: " <= ",
t.IDXBinaryEqEq: " == ",
+2 -2
View File
@@ -86,7 +86,7 @@ func TestCheck(tt *testing.T) {
while:label p == q,
pre true,
inv true,
post p != q,
post p <> q,
{
// Redundant, but shows the labeled jump syntax.
continue:label
@@ -191,7 +191,7 @@ func TestConstValues(tt *testing.T) {
"i = 10 | 3": 11,
"i = 10 ^ 3": 9,
"b = 10 != 3": 1,
"b = 10 <> 3": 1,
"b = 10 < 3": 0,
"b = 10 <= 3": 0,
"b = 10 == 3": 0,
+3 -5
View File
@@ -659,7 +659,7 @@ var builtInsByID = [nBuiltInIDs]string{
IDTildeSatPlus: "~sat+",
IDTildeSatMinus: "~sat-",
IDNotEq: "!=",
IDNotEq: "<>",
IDLessThan: "<",
IDLessEq: "<=",
IDEqEq: "==",
@@ -954,6 +954,7 @@ var squiggles = [256]ID{
'}': IDCloseCurly,
',': IDComma,
'!': IDExclam,
'?': IDQuestion,
':': IDColon,
';': IDSemicolon,
@@ -975,10 +976,6 @@ var lexers = [256][]suffixLexer{
{".", IDDotDot},
{"", IDDot},
},
'!': {
{"=", IDNotEq},
{"", IDExclam},
},
'&': {
{"=", IDAmpEq},
{"", IDAmp},
@@ -1020,6 +1017,7 @@ var lexers = [256][]suffixLexer{
{"<=", IDShiftLEq},
{"<", IDShiftL},
{"=", IDLessEq},
{">", IDNotEq},
{"", IDLessThan},
},
'>': {
+10 -10
View File
@@ -259,14 +259,14 @@ pri func decoder.decode_uncompressed?(dst base.io_writer, src base.io_reader) {
// TODO: make this "if" into a function invariant?
//
// Ditto for decode_huffman_slow and decode_huffman_fast.
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
return "#internal error: inconsistent n_bits"
}
this.n_bits = 0
this.bits = 0
length = args.src.read_u32le?()
if (length.low_bits(n:16) + length.high_bits(n:16)) != 0xFFFF {
if (length.low_bits(n:16) + length.high_bits(n:16)) <> 0xFFFF {
return "#inconsistent stored block length"
}
length = length.low_bits(n:16)
@@ -414,7 +414,7 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
}
// For H-CL, there should be no redirections and all symbols should be
// literals.
if (table_entry >> 24) != 0x80 {
if (table_entry >> 24) <> 0x80 {
return "#internal error: inconsistent Huffman decoder state"
}
table_entry = (table_entry >> 8) & 0xFF
@@ -477,7 +477,7 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
}
}
if i != (n_lit + n_dist) {
if i <> (n_lit + n_dist) {
return "#bad Huffman code length count"
}
if this.code_lengths[256] == 0 {
@@ -588,7 +588,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
remaining -= counts[i] as base.u32
i += 1
}
if remaining != 0 {
if remaining <> 0 {
// TODO: when is a degenerate Huffman table valid?
return "#bad Huffman code (under-subscribed)"
}
@@ -649,7 +649,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
if i < args.n_codes0 {
return "#internal error: inconsistent Huffman decoder state"
}
if this.code_lengths[i] != 0 {
if this.code_lengths[i] <> 0 {
if offsets[this.code_lengths[i] & 15] >= 320 {
return "#internal error: inconsistent Huffman decoder state"
}
@@ -668,7 +668,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
while true,
inv n_symbols <= 288,
{
if counts[min_cl] != 0 {
if counts[min_cl] <> 0 {
break
}
if min_cl >= 9 {
@@ -680,7 +680,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
while true,
inv n_symbols <= 288,
{
if counts[max_cl] != 0 {
if counts[max_cl] <> 0 {
break
}
if max_cl <= 1 {
@@ -709,7 +709,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
// - this.huffs[0][0b01111] = 0x80000305 (literal, symbols[8]=0x03, code_length=5)
// - this.huffs[0][0b11111] = 0x80001805 (literal, symbols[9]=0x18, code_length=5)
i = 0
if (n_symbols != (offsets[max_cl] as base.u32)) or (n_symbols != (offsets[15] as base.u32)) {
if (n_symbols <> (offsets[max_cl] as base.u32)) or (n_symbols <> (offsets[15] as base.u32)) {
return "#internal error: inconsistent Huffman decoder state"
}
if (args.n_codes0 + (symbols[0] as base.u32)) >= 320 {
@@ -753,7 +753,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
redirect_key = (key >> cl) & 511
key = key.low_bits(n:cl)
if prev_redirect_key != redirect_key {
if prev_redirect_key <> redirect_key {
prev_redirect_key = redirect_key
// Calculate the number of bits needed for the 2nd level table.
+13 -13
View File
@@ -34,7 +34,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
var hlen base.u32[..0x7FFF]
var hdist base.u32
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
return "#internal error: inconsistent n_bits"
}
@@ -97,18 +97,18 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
bits >>= table_entry_n_bits
n_bits -= table_entry_n_bits
if (table_entry >> 31) != 0 {
if (table_entry >> 31) <> 0 {
// Literal.
args.dst.write_fast_u8!(x:((table_entry >> 8) & 0xFF) as base.u8)
continue:loop
} else if (table_entry >> 30) != 0 {
} else if (table_entry >> 30) <> 0 {
// No-op; code continues past the if-else chain.
assert args.src.available() >= 8
} else if (table_entry >> 29) != 0 {
} else if (table_entry >> 29) <> 0 {
// End of block.
this.end_of_block = true
break:loop
} else if (table_entry >> 28) != 0 {
} else if (table_entry >> 28) <> 0 {
// Redirect.
// Ensure that we have at least 15 bits of input.
@@ -139,19 +139,19 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
bits >>= table_entry_n_bits
n_bits -= table_entry_n_bits
if (table_entry >> 31) != 0 {
if (table_entry >> 31) <> 0 {
// Literal.
args.dst.write_fast_u8!(x:((table_entry >> 8) & 0xFF) as base.u8)
continue:loop
} else if (table_entry >> 30) != 0 {
} else if (table_entry >> 30) <> 0 {
// No-op; code continues past the if-else chain.
} else if (table_entry >> 29) != 0 {
} else if (table_entry >> 29) <> 0 {
// End of block.
this.end_of_block = true
break:loop
} else if (table_entry >> 28) != 0 {
} else if (table_entry >> 28) <> 0 {
return "#internal error: inconsistent Huffman decoder state"
} else if (table_entry >> 27) != 0 {
} else if (table_entry >> 27) <> 0 {
return "#bad Huffman code"
} else {
return "#internal error: inconsistent Huffman decoder state"
@@ -160,7 +160,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
// Once again, redundant but explicit assertions.
assert args.src.available() >= 8
} else if (table_entry >> 27) != 0 {
} else if (table_entry >> 27) <> 0 {
return "#bad Huffman code"
} else {
return "#internal error: inconsistent Huffman decoder state"
@@ -257,7 +257,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
}
// For H-D, all symbols should be base_number + extra_bits.
if (table_entry >> 24) != 0x40 {
if (table_entry >> 24) <> 0x40 {
if (table_entry >> 24) == 0x08 {
return "#bad Huffman code"
}
@@ -396,7 +396,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
this.bits = bits & (((1 as base.u32) << n_bits) - 1)
this.n_bits = n_bits
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) <> 0) {
return "#internal error: inconsistent n_bits"
}
}
+13 -13
View File
@@ -38,7 +38,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
// decode_huffman_*.wuffs files as small as possible, while retaining both
// correctness and performance.
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
return "#internal error: inconsistent n_bits"
}
@@ -64,17 +64,17 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
n_bits += 8
}
if (table_entry >> 31) != 0 {
if (table_entry >> 31) <> 0 {
// Literal.
args.dst.write_u8?(x:((table_entry >> 8) & 0xFF) as base.u8)
continue:loop
} else if (table_entry >> 30) != 0 {
} else if (table_entry >> 30) <> 0 {
// No-op; code continues past the if-else chain.
} else if (table_entry >> 29) != 0 {
} else if (table_entry >> 29) <> 0 {
// End of block.
this.end_of_block = true
break:loop
} else if (table_entry >> 28) != 0 {
} else if (table_entry >> 28) <> 0 {
// Redirect.
redir_top = (table_entry >> 8) & 0xFFFF
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
@@ -96,25 +96,25 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
n_bits += 8
}
if (table_entry >> 31) != 0 {
if (table_entry >> 31) <> 0 {
// Literal.
args.dst.write_u8?(x:((table_entry >> 8) & 0xFF) as base.u8)
continue:loop
} else if (table_entry >> 30) != 0 {
} else if (table_entry >> 30) <> 0 {
// No-op; code continues past the if-else chain.
} else if (table_entry >> 29) != 0 {
} else if (table_entry >> 29) <> 0 {
// End of block.
this.end_of_block = true
break:loop
} else if (table_entry >> 28) != 0 {
} else if (table_entry >> 28) <> 0 {
return "#internal error: inconsistent Huffman decoder state"
} else if (table_entry >> 27) != 0 {
} else if (table_entry >> 27) <> 0 {
return "#bad Huffman code"
} else {
return "#internal error: inconsistent Huffman decoder state"
}
} else if (table_entry >> 27) != 0 {
} else if (table_entry >> 27) <> 0 {
return "#bad Huffman code"
} else {
return "#internal error: inconsistent Huffman decoder state"
@@ -180,7 +180,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
}
// For H-D, all symbols should be base_number + extra_bits.
if (table_entry >> 24) != 0x40 {
if (table_entry >> 24) <> 0x40 {
if (table_entry >> 24) == 0x08 {
return "#bad Huffman code"
}
@@ -287,7 +287,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
this.bits = bits
this.n_bits = n_bits
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
return "#internal error: inconsistent n_bits"
}
}
+22 -22
View File
@@ -146,7 +146,7 @@ pub func decoder.decode_image_config?(dst nptr base.image_config, src base.io_re
(this.frame_rect_x1 == this.width) and
(this.frame_rect_y1 == this.height)
if args.dst != nullptr {
if args.dst <> nullptr {
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY magic pixfmt constant.
args.dst.set!(
@@ -217,7 +217,7 @@ pub func decoder.decode_frame_config?(dst nptr base.frame_config, src base.io_re
if not this.end_of_data {
if this.call_sequence == 0 {
this.decode_image_config?(dst:nullptr, src:args.src)
} else if this.call_sequence != 1 {
} else if this.call_sequence <> 1 {
if this.call_sequence == 2 {
this.skip_frame?(src:args.src)
}
@@ -236,7 +236,7 @@ pub func decoder.decode_frame_config?(dst nptr base.frame_config, src base.io_re
blend = 2 // 2 is WUFFS_BASE__ANIMATION_BLEND__OPAQUE.
}
if args.dst != nullptr {
if args.dst <> nullptr {
args.dst.update!(bounds:this.util.make_rect_ie_u32(
min_incl_x:this.frame_rect_x0.min(x:this.width),
min_incl_y:this.frame_rect_y0.min(x:this.height),
@@ -258,7 +258,7 @@ pri func decoder.skip_frame?(src base.io_reader) {
// Skip the optional Local Color Table, 3 bytes (RGB) per entry.
flags = args.src.read_u8?()
if (flags & 0x80) != 0 {
if (flags & 0x80) <> 0 {
args.src.skip?(n:(3 as base.u32) << (1 + (flags & 0x07)))
}
// Skip the literal width.
@@ -272,7 +272,7 @@ pri func decoder.skip_frame?(src base.io_reader) {
// TODO: honor args.opts.
pub func decoder.decode_frame?(dst ptr base.pixel_buffer, src base.io_reader, workbuf slice base.u8, opts nptr base.decode_frame_options) {
if this.call_sequence != 2 {
if this.call_sequence <> 2 {
this.decode_frame_config?(dst:nullptr, src:args.src)
}
this.decode_id_part1?(dst:args.dst, src:args.src)
@@ -298,7 +298,7 @@ pri func decoder.decode_up_to_id_part1?(src base.io_reader) {
if not this.restarted {
this.frame_config_io_position = args.src.position()
} else if this.frame_config_io_position != args.src.position() {
} else if this.frame_config_io_position <> args.src.position() {
return base."#bad restart"
} else {
this.restarted = false
@@ -331,8 +331,8 @@ pri func decoder.decode_header?(src base.io_reader) {
c[i] = args.src.read_u8?()
i += 1
}
if (c[0] != 0x47) or (c[1] != 0x49) or (c[2] != 0x46) or (c[3] != 0x38) or
((c[4] != 0x37) and (c[4] != 0x39)) or (c[5] != 0x61) {
if (c[0] <> 0x47) or (c[1] <> 0x49) or (c[2] <> 0x46) or (c[3] <> 0x38) or
((c[4] <> 0x37) and (c[4] <> 0x39)) or (c[5] <> 0x61) {
return "#bad header"
}
}
@@ -353,7 +353,7 @@ pri func decoder.decode_lsd?(src base.io_reader) {
args.src.skip?(n:2)
// Read the optional Global Color Table.
if (flags & 0x80) != 0 {
if (flags & 0x80) <> 0 {
num_palette_entries = (1 as base.u32) << (1 + (flags & 0x07))
i = 0
while i < num_palette_entries {
@@ -444,7 +444,7 @@ pri func decoder.decode_ae?(src base.io_reader) {
// as per:
// - http://www.vurdalakov.net/misc/gif/animexts-looping-application-extension
// - http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension
if block_size != 11 {
if block_size <> 11 {
args.src.skip?(n:block_size as base.u32)
break
}
@@ -453,8 +453,8 @@ pri func decoder.decode_ae?(src base.io_reader) {
block_size = 0 // Re-purpose the block_size variable as a counter.
while block_size < 11 {
c = args.src.read_u8?()
not_animexts = not_animexts or (c != animexts1dot0[block_size])
not_netscape = not_netscape or (c != netscape2dot0[block_size])
not_animexts = not_animexts or (c <> animexts1dot0[block_size])
not_netscape = not_netscape or (c <> netscape2dot0[block_size])
block_size += 1
}
if not_animexts and not_netscape {
@@ -464,12 +464,12 @@ pri func decoder.decode_ae?(src base.io_reader) {
// Those 11 bytes should be followed by 0x03, 0x01 and then the loop
// count.
block_size = args.src.read_u8?()
if block_size != 3 {
if block_size <> 3 {
args.src.skip?(n:block_size as base.u32)
break
}
c = args.src.read_u8?()
if c != 0x01 {
if c <> 0x01 {
args.src.skip?(n:2)
break
}
@@ -505,12 +505,12 @@ pri func decoder.decode_gc?(src base.io_reader) {
return "#bad graphic control"
}
c = args.src.read_u8?()
if c != 4 {
if c <> 4 {
return "#bad graphic control"
}
flags = args.src.read_u8?()
this.gc_has_transparent_index = (flags & 0x01) != 0
this.gc_has_transparent_index = (flags & 0x01) <> 0
// Convert the disposal method from GIF's wire format to Wuffs constants.
//
@@ -536,7 +536,7 @@ pri func decoder.decode_gc?(src base.io_reader) {
this.gc_transparent_index = args.src.read_u8?()
c = args.src.read_u8?()
if c != 0 {
if c <> 0 {
return "#bad graphic control"
}
this.seen_graphic_control = true
@@ -584,7 +584,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
var lw base.u8
flags = args.src.read_u8?()
if (flags & 0x40) != 0 {
if (flags & 0x40) <> 0 {
this.interlace = 4
} else {
this.interlace = 0
@@ -592,7 +592,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
// Read the optional Local Color Table.
this.which_palette = 1
if (flags & 0x80) != 0 {
if (flags & 0x80) <> 0 {
num_palette_entries = (1 as base.u32) << (1 + (flags & 0x07))
i = 0
while i < num_palette_entries {
@@ -762,8 +762,8 @@ pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader,
this.compressed_wi = 0
if (this.dst_y < this.frame_rect_y1) and
(this.frame_rect_x0 != this.frame_rect_x1) and
(this.frame_rect_y0 != this.frame_rect_y1) {
(this.frame_rect_x0 <> this.frame_rect_x1) and
(this.frame_rect_y0 <> this.frame_rect_y1) {
return base."#not enough data"
}
}
@@ -856,7 +856,7 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
continue
}
if src_ri != args.src.length() {
if src_ri <> args.src.length() {
return "#internal error: inconsistent ri/wi"
}
break
+9 -9
View File
@@ -54,15 +54,15 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
// Read the header.
c = args.src.read_u8?()
if c != 0x1F {
if c <> 0x1F {
return "#bad header"
}
c = args.src.read_u8?()
if c != 0x8B {
if c <> 0x8B {
return "#bad header"
}
c = args.src.read_u8?()
if c != 0x08 {
if c <> 0x08 {
return "#bad compression method"
}
flags = args.src.read_u8?()
@@ -70,7 +70,7 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
args.src.skip?(n:6)
// Handle FEXTRA.
if (flags & 0x04) != 0 {
if (flags & 0x04) <> 0 {
xlen = args.src.read_u16le?()
args.src.skip?(n:xlen as base.u32)
}
@@ -80,7 +80,7 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
// TODO: API for returning the header's FNAME field. This might require
// converting ISO 8859-1 to UTF-8. We may also want to cap the UTF-8
// filename length to NAME_MAX, which is 255.
if (flags & 0x08) != 0 {
if (flags & 0x08) <> 0 {
while true {
c = args.src.read_u8?()
if c == 0 {
@@ -90,7 +90,7 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
}
// Handle FCOMMENT.
if (flags & 0x10) != 0 {
if (flags & 0x10) <> 0 {
while true {
c = args.src.read_u8?()
if c == 0 {
@@ -100,12 +100,12 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
}
// Handle FHCRC.
if (flags & 0x02) != 0 {
if (flags & 0x02) <> 0 {
args.src.skip?(n:2)
}
// Reserved flags bits must be zero.
if (flags & 0xE0) != 0 {
if (flags & 0xE0) <> 0 {
return "#bad encoding flags"
}
@@ -125,7 +125,7 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
checksum_want = args.src.read_u32le?()
decoded_length_want = args.src.read_u32le?()
if (not this.ignore_checksum) and
((checksum_got != checksum_want) or (decoded_length_got != decoded_length_want)) {
((checksum_got <> checksum_want) or (decoded_length_got <> decoded_length_want)) {
return "#bad checksum"
}
}
+3 -3
View File
@@ -204,7 +204,7 @@ pri func decoder.read_from!(src base.io_reader) {
lm1_a = (this.lm1s[prev_code] ~mod+ 1) & 4095
this.lm1s[save_code] = lm1_a
if (lm1_a % 8) != 0 {
if (lm1_a % 8) <> 0 {
this.prefixes[save_code] = this.prefixes[prev_code]
this.suffixes[save_code] = this.suffixes[prev_code]
this.suffixes[save_code][lm1_a % 8] = code as base.u8
@@ -277,7 +277,7 @@ pri func decoder.read_from!(src base.io_reader) {
lm1_b = (this.lm1s[prev_code] ~mod+ 1) & 4095
this.lm1s[save_code] = lm1_b
if (lm1_b % 8) != 0 {
if (lm1_b % 8) <> 0 {
this.prefixes[save_code] = this.prefixes[prev_code]
this.suffixes[save_code] = this.suffixes[prev_code]
this.suffixes[save_code][lm1_b % 8] = first_byte
@@ -310,7 +310,7 @@ pri func decoder.read_from!(src base.io_reader) {
// Rewind args.src, if we're not in "$short read" and we've read too many
// bits.
if this.read_from_return_value != 2 {
if this.read_from_return_value <> 2 {
while n_bits >= 8 {
n_bits -= 8
if args.src.can_undo_byte() {
+4 -4
View File
@@ -51,16 +51,16 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
var checksum_want base.u32
x = args.src.read_u16be?()
if ((x >> 8) & 0x0F) != 0x08 {
if ((x >> 8) & 0x0F) <> 0x08 {
return "#bad compression method"
}
if (x >> 12) > 0x07 {
return "#bad compression window size"
}
if (x & 0x20) != 0 {
if (x & 0x20) <> 0 {
return "#TODO: unsupported preset dictionary"
}
if (x % 31) != 0 {
if (x % 31) <> 0 {
return "#bad parity check"
}
@@ -77,7 +77,7 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
yield? status
}
checksum_want = args.src.read_u32be?()
if (not this.ignore_checksum) and (checksum_got != checksum_want) {
if (not this.ignore_checksum) and (checksum_got <> checksum_want) {
return "#bad checksum"
}
}