authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-02-02 22:23:03+11:00
committergravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-02-20 09:09:06+11:00
log3f1c4306caf14274b60cfb2ff4b088a56d893e13
treece809e944aeae2c113051c5310560b8d49a745be
parentddeabc9aa7a465793ccbfd56dc29f04bf0d2854b

std.compress.zstandard: fix capitalisation of Zstandard


4 files changed, 23 insertions(+), 23 deletions(-)

lib/std/compress/zstandard.zig+1-1
...@@ -33,7 +33,7 @@ pub fn ZstandardStream(comptime ReaderType: type, comptime verify_checksum: bool...@@ -33,7 +33,7 @@ pub fn ZstandardStream(comptime ReaderType: type, comptime verify_checksum: bool
33 .skippable => return error.SkippableFrame,33 .skippable => return error.SkippableFrame,
34 .zstandard => {34 .zstandard => {
35 const frame_context = context: {35 const frame_context = context: {
36 const frame_header = try decompress.decodeZStandardHeader(source);36 const frame_header = try decompress.decodeZstandardHeader(source);
37 break :context try decompress.FrameContext.init(37 break :context try decompress.FrameContext.init(
38 frame_header,38 frame_header,
39 window_size_max,39 window_size_max,
lib/std/compress/zstandard/decode/block.zig+6-6
...@@ -580,7 +580,7 @@ pub const DecodeState = struct {...@@ -580,7 +580,7 @@ pub const DecodeState = struct {
580pub fn decodeBlock(580pub fn decodeBlock(
581 dest: []u8,581 dest: []u8,
582 src: []const u8,582 src: []const u8,
583 block_header: frame.ZStandard.Block.Header,583 block_header: frame.Zstandard.Block.Header,
584 decode_state: *DecodeState,584 decode_state: *DecodeState,
585 consumed_count: *usize,585 consumed_count: *usize,
586 written_count: usize,586 written_count: usize,
...@@ -668,7 +668,7 @@ pub fn decodeBlock(...@@ -668,7 +668,7 @@ pub fn decodeBlock(
668pub fn decodeBlockRingBuffer(668pub fn decodeBlockRingBuffer(
669 dest: *RingBuffer,669 dest: *RingBuffer,
670 src: []const u8,670 src: []const u8,
671 block_header: frame.ZStandard.Block.Header,671 block_header: frame.Zstandard.Block.Header,
672 decode_state: *DecodeState,672 decode_state: *DecodeState,
673 consumed_count: *usize,673 consumed_count: *usize,
674 block_size_max: usize,674 block_size_max: usize,
...@@ -758,7 +758,7 @@ pub fn decodeBlockRingBuffer(...@@ -758,7 +758,7 @@ pub fn decodeBlockRingBuffer(
758pub fn decodeBlockReader(758pub fn decodeBlockReader(
759 dest: *RingBuffer,759 dest: *RingBuffer,
760 source: anytype,760 source: anytype,
761 block_header: frame.ZStandard.Block.Header,761 block_header: frame.Zstandard.Block.Header,
762 decode_state: *DecodeState,762 decode_state: *DecodeState,
763 block_size_max: usize,763 block_size_max: usize,
764 literals_buffer: []u8,764 literals_buffer: []u8,
...@@ -825,9 +825,9 @@ pub fn decodeBlockReader(...@@ -825,9 +825,9 @@ pub fn decodeBlockReader(
825}825}
826826
827/// Decode the header of a block.827/// Decode the header of a block.
828pub fn decodeBlockHeader(src: *const [3]u8) frame.ZStandard.Block.Header {828pub fn decodeBlockHeader(src: *const [3]u8) frame.Zstandard.Block.Header {
829 const last_block = src[0] & 1 == 1;829 const last_block = src[0] & 1 == 1;
830 const block_type = @intToEnum(frame.ZStandard.Block.Type, (src[0] & 0b110) >> 1);830 const block_type = @intToEnum(frame.Zstandard.Block.Type, (src[0] & 0b110) >> 1);
831 const block_size = ((src[0] & 0b11111000) >> 3) + (@as(u21, src[1]) << 5) + (@as(u21, src[2]) << 13);831 const block_size = ((src[0] & 0b11111000) >> 3) + (@as(u21, src[1]) << 5) + (@as(u21, src[2]) << 13);
832 return .{832 return .{
833 .last_block = last_block,833 .last_block = last_block,
...@@ -840,7 +840,7 @@ pub fn decodeBlockHeader(src: *const [3]u8) frame.ZStandard.Block.Header {...@@ -840,7 +840,7 @@ pub fn decodeBlockHeader(src: *const [3]u8) frame.ZStandard.Block.Header {
840///840///
841/// Errors returned:841/// Errors returned:
842/// - `error.EndOfStream` if `src.len < 3`842/// - `error.EndOfStream` if `src.len < 3`
843pub fn decodeBlockHeaderSlice(src: []const u8) error{EndOfStream}!frame.ZStandard.Block.Header {843pub fn decodeBlockHeaderSlice(src: []const u8) error{EndOfStream}!frame.Zstandard.Block.Header {
844 if (src.len < 3) return error.EndOfStream;844 if (src.len < 3) return error.EndOfStream;
845 return decodeBlockHeader(src[0..3]);845 return decodeBlockHeader(src[0..3]);
846}846}
lib/std/compress/zstandard/decompress.zig+15-15
...@@ -41,7 +41,7 @@ pub fn decodeFrameType(source: anytype) error{ BadMagic, EndOfStream }!frame.Kin...@@ -41,7 +41,7 @@ pub fn decodeFrameType(source: anytype) error{ BadMagic, EndOfStream }!frame.Kin
41/// Errors returned:41/// Errors returned:
42/// - `error.BadMagic` if `magic` is not a valid magic number.42/// - `error.BadMagic` if `magic` is not a valid magic number.
43pub fn frameType(magic: u32) error{BadMagic}!frame.Kind {43pub fn frameType(magic: u32) error{BadMagic}!frame.Kind {
44 return if (magic == frame.ZStandard.magic_number)44 return if (magic == frame.Zstandard.magic_number)
45 .zstandard45 .zstandard
46 else if (isSkippableMagic(magic))46 else if (isSkippableMagic(magic))
47 .skippable47 .skippable
...@@ -79,7 +79,7 @@ pub fn decodeFrame(...@@ -79,7 +79,7 @@ pub fn decodeFrame(
79) !ReadWriteCount {79) !ReadWriteCount {
80 var fbs = std.io.fixedBufferStream(src);80 var fbs = std.io.fixedBufferStream(src);
81 return switch (try decodeFrameType(fbs.reader())) {81 return switch (try decodeFrameType(fbs.reader())) {
82 .zstandard => decodeZStandardFrame(dest, src, verify_checksum),82 .zstandard => decodeZstandardFrame(dest, src, verify_checksum),
83 .skippable => ReadWriteCount{83 .skippable => ReadWriteCount{
84 .read_count = try fbs.reader().readIntLittle(u32) + 8,84 .read_count = try fbs.reader().readIntLittle(u32) + 8,
85 .write_count = 0,85 .write_count = 0,
...@@ -126,7 +126,7 @@ pub fn decodeFrameAlloc(...@@ -126,7 +126,7 @@ pub fn decodeFrameAlloc(
126 const magic = try reader.readIntLittle(u32);126 const magic = try reader.readIntLittle(u32);
127 return switch (try frameType(magic)) {127 return switch (try frameType(magic)) {
128 .zstandard => .{128 .zstandard => .{
129 .zstandard = try decodeZStandardFrameAlloc(allocator, src, verify_checksum, window_size_max),129 .zstandard = try decodeZstandardFrameAlloc(allocator, src, verify_checksum, window_size_max),
130 },130 },
131 .skippable => .{131 .skippable => .{
132 .skippable = .{132 .skippable = .{
...@@ -166,17 +166,17 @@ const FrameError = error{...@@ -166,17 +166,17 @@ const FrameError = error{
166/// - `error.UnusedBitSet` if the unused bit of the frame header is set166/// - `error.UnusedBitSet` if the unused bit of the frame header is set
167/// - `error.EndOfStream` if `src` does not contain a complete frame167/// - `error.EndOfStream` if `src` does not contain a complete frame
168/// - an error in `block.Error` if there are errors decoding a block168/// - an error in `block.Error` if there are errors decoding a block
169pub fn decodeZStandardFrame(169pub fn decodeZstandardFrame(
170 dest: []u8,170 dest: []u8,
171 src: []const u8,171 src: []const u8,
172 verify_checksum: bool,172 verify_checksum: bool,
173) (error{ UnknownContentSizeUnsupported, ContentTooLarge } || FrameError)!ReadWriteCount {173) (error{ UnknownContentSizeUnsupported, ContentTooLarge } || FrameError)!ReadWriteCount {
174 assert(readInt(u32, src[0..4]) == frame.ZStandard.magic_number);174 assert(readInt(u32, src[0..4]) == frame.Zstandard.magic_number);
175 var consumed_count: usize = 4;175 var consumed_count: usize = 4;
176176
177 var fbs = std.io.fixedBufferStream(src[consumed_count..]);177 var fbs = std.io.fixedBufferStream(src[consumed_count..]);
178 var source = fbs.reader();178 var source = fbs.reader();
179 const frame_header = try decodeZStandardHeader(source);179 const frame_header = try decodeZstandardHeader(source);
180 consumed_count += fbs.pos;180 consumed_count += fbs.pos;
181181
182 if (frame_header.descriptor.dictionary_id_flag != 0) return error.DictionaryIdFlagUnsupported;182 if (frame_header.descriptor.dictionary_id_flag != 0) return error.DictionaryIdFlagUnsupported;
...@@ -218,7 +218,7 @@ pub const FrameContext = struct {...@@ -218,7 +218,7 @@ pub const FrameContext = struct {
218 /// - `error.WindowSizeUnknown` if the frame does not have a valid window size218 /// - `error.WindowSizeUnknown` if the frame does not have a valid window size
219 /// - `error.WindowTooLarge` if the window size is larger than219 /// - `error.WindowTooLarge` if the window size is larger than
220 pub fn init(220 pub fn init(
221 frame_header: frame.ZStandard.Header,221 frame_header: frame.Zstandard.Header,
222 window_size_max: usize,222 window_size_max: usize,
223 verify_checksum: bool,223 verify_checksum: bool,
224 ) Error!FrameContext {224 ) Error!FrameContext {
...@@ -241,7 +241,7 @@ pub const FrameContext = struct {...@@ -241,7 +241,7 @@ pub const FrameContext = struct {
241};241};
242242
243/// Decode a Zstandard from from `src` and return the decompressed bytes and the243/// Decode a Zstandard from from `src` and return the decompressed bytes and the
244/// number of bytes read; see `decodeZStandardFrame()`. `allocator` is used to244/// number of bytes read; see `decodeZstandardFrame()`. `allocator` is used to
245/// allocate both the returned slice and internal buffers used during decoding.245/// allocate both the returned slice and internal buffers used during decoding.
246/// The first four bytes of `src` must be the magic number for a Zstandard246/// The first four bytes of `src` must be the magic number for a Zstandard
247/// frame.247/// frame.
...@@ -259,20 +259,20 @@ pub const FrameContext = struct {...@@ -259,20 +259,20 @@ pub const FrameContext = struct {
259/// - `error.EndOfStream` if `src` does not contain a complete frame259/// - `error.EndOfStream` if `src` does not contain a complete frame
260/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory260/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory
261/// - an error in `block.Error` if there are errors decoding a block261/// - an error in `block.Error` if there are errors decoding a block
262pub fn decodeZStandardFrameAlloc(262pub fn decodeZstandardFrameAlloc(
263 allocator: Allocator,263 allocator: Allocator,
264 src: []const u8,264 src: []const u8,
265 verify_checksum: bool,265 verify_checksum: bool,
266 window_size_max: usize,266 window_size_max: usize,
267) (error{OutOfMemory} || FrameContext.Error || FrameError)!DecodeResult {267) (error{OutOfMemory} || FrameContext.Error || FrameError)!DecodeResult {
268 var result = std.ArrayList(u8).init(allocator);268 var result = std.ArrayList(u8).init(allocator);
269 assert(readInt(u32, src[0..4]) == frame.ZStandard.magic_number);269 assert(readInt(u32, src[0..4]) == frame.Zstandard.magic_number);
270 var consumed_count: usize = 4;270 var consumed_count: usize = 4;
271271
272 var frame_context = context: {272 var frame_context = context: {
273 var fbs = std.io.fixedBufferStream(src[consumed_count..]);273 var fbs = std.io.fixedBufferStream(src[consumed_count..]);
274 var source = fbs.reader();274 var source = fbs.reader();
275 const frame_header = try decodeZStandardHeader(source);275 const frame_header = try decodeZstandardHeader(source);
276 consumed_count += fbs.pos;276 consumed_count += fbs.pos;
277 break :context try FrameContext.init(frame_header, window_size_max, verify_checksum);277 break :context try FrameContext.init(frame_header, window_size_max, verify_checksum);
278 };278 };
...@@ -371,7 +371,7 @@ pub fn decodeSkippableHeader(src: *const [8]u8) frame.Skippable.Header {...@@ -371,7 +371,7 @@ pub fn decodeSkippableHeader(src: *const [8]u8) frame.Skippable.Header {
371371
372/// Returns the window size required to decompress a frame, or `null` if it372/// Returns the window size required to decompress a frame, or `null` if it
373/// cannot be determined (which indicates a malformed frame header).373/// cannot be determined (which indicates a malformed frame header).
374pub fn frameWindowSize(header: frame.ZStandard.Header) ?u64 {374pub fn frameWindowSize(header: frame.Zstandard.Header) ?u64 {
375 if (header.window_descriptor) |descriptor| {375 if (header.window_descriptor) |descriptor| {
376 const exponent = (descriptor & 0b11111000) >> 3;376 const exponent = (descriptor & 0b11111000) >> 3;
377 const mantissa = descriptor & 0b00000111;377 const mantissa = descriptor & 0b00000111;
...@@ -389,8 +389,8 @@ const InvalidBit = error{ UnusedBitSet, ReservedBitSet };...@@ -389,8 +389,8 @@ const InvalidBit = error{ UnusedBitSet, ReservedBitSet };
389/// - `error.UnusedBitSet` if the unused bits of the header are set389/// - `error.UnusedBitSet` if the unused bits of the header are set
390/// - `error.ReservedBitSet` if the reserved bits of the header are set390/// - `error.ReservedBitSet` if the reserved bits of the header are set
391/// - `error.EndOfStream` if `source` does not contain a complete header391/// - `error.EndOfStream` if `source` does not contain a complete header
392pub fn decodeZStandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)!frame.ZStandard.Header {392pub fn decodeZstandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)!frame.Zstandard.Header {
393 const descriptor = @bitCast(frame.ZStandard.Header.Descriptor, try source.readByte());393 const descriptor = @bitCast(frame.Zstandard.Header.Descriptor, try source.readByte());
394394
395 if (descriptor.unused) return error.UnusedBitSet;395 if (descriptor.unused) return error.UnusedBitSet;
396 if (descriptor.reserved) return error.ReservedBitSet;396 if (descriptor.reserved) return error.ReservedBitSet;
...@@ -414,7 +414,7 @@ pub fn decodeZStandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)...@@ -414,7 +414,7 @@ pub fn decodeZStandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)
414 if (field_size == 2) content_size.? += 256;414 if (field_size == 2) content_size.? += 256;
415 }415 }
416416
417 const header = frame.ZStandard.Header{417 const header = frame.Zstandard.Header{
418 .descriptor = descriptor,418 .descriptor = descriptor,
419 .window_descriptor = window_descriptor,419 .window_descriptor = window_descriptor,
420 .dictionary_id = dictionary_id,420 .dictionary_id = dictionary_id,
lib/std/compress/zstandard/types.zig+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1pub const frame = struct {1pub const frame = struct {
2 pub const Kind = enum { zstandard, skippable };2 pub const Kind = enum { zstandard, skippable };
33
4 pub const ZStandard = struct {4 pub const Zstandard = struct {
5 pub const magic_number = 0xFD2FB528;5 pub const magic_number = 0xFD2FB528;
66
7 header: Header,7 header: Header,