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
3333 .skippable => return error.SkippableFrame,
3434 .zstandard => {
3535 const frame_context = context: {
36 const frame_header = try decompress.decodeZStandardHeader(source);
36 const frame_header = try decompress.decodeZstandardHeader(source);
3737 break :context try decompress.FrameContext.init(
3838 frame_header,
3939 window_size_max,
lib/std/compress/zstandard/decode/block.zig+6-6
......@@ -580,7 +580,7 @@ pub const DecodeState = struct {
580580pub fn decodeBlock(
581581 dest: []u8,
582582 src: []const u8,
583 block_header: frame.ZStandard.Block.Header,
583 block_header: frame.Zstandard.Block.Header,
584584 decode_state: *DecodeState,
585585 consumed_count: *usize,
586586 written_count: usize,
......@@ -668,7 +668,7 @@ pub fn decodeBlock(
668668pub fn decodeBlockRingBuffer(
669669 dest: *RingBuffer,
670670 src: []const u8,
671 block_header: frame.ZStandard.Block.Header,
671 block_header: frame.Zstandard.Block.Header,
672672 decode_state: *DecodeState,
673673 consumed_count: *usize,
674674 block_size_max: usize,
......@@ -758,7 +758,7 @@ pub fn decodeBlockRingBuffer(
758758pub fn decodeBlockReader(
759759 dest: *RingBuffer,
760760 source: anytype,
761 block_header: frame.ZStandard.Block.Header,
761 block_header: frame.Zstandard.Block.Header,
762762 decode_state: *DecodeState,
763763 block_size_max: usize,
764764 literals_buffer: []u8,
......@@ -825,9 +825,9 @@ pub fn decodeBlockReader(
825825}
826826
827827/// 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 {
829829 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);
831831 const block_size = ((src[0] & 0b11111000) >> 3) + (@as(u21, src[1]) << 5) + (@as(u21, src[2]) << 13);
832832 return .{
833833 .last_block = last_block,
......@@ -840,7 +840,7 @@ pub fn decodeBlockHeader(src: *const [3]u8) frame.ZStandard.Block.Header {
840840///
841841/// Errors returned:
842842/// - `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 {
844844 if (src.len < 3) return error.EndOfStream;
845845 return decodeBlockHeader(src[0..3]);
846846}
lib/std/compress/zstandard/decompress.zig+15-15
......@@ -41,7 +41,7 @@ pub fn decodeFrameType(source: anytype) error{ BadMagic, EndOfStream }!frame.Kin
4141/// Errors returned:
4242/// - `error.BadMagic` if `magic` is not a valid magic number.
4343pub fn frameType(magic: u32) error{BadMagic}!frame.Kind {
44 return if (magic == frame.ZStandard.magic_number)
44 return if (magic == frame.Zstandard.magic_number)
4545 .zstandard
4646 else if (isSkippableMagic(magic))
4747 .skippable
......@@ -79,7 +79,7 @@ pub fn decodeFrame(
7979) !ReadWriteCount {
8080 var fbs = std.io.fixedBufferStream(src);
8181 return switch (try decodeFrameType(fbs.reader())) {
82 .zstandard => decodeZStandardFrame(dest, src, verify_checksum),
82 .zstandard => decodeZstandardFrame(dest, src, verify_checksum),
8383 .skippable => ReadWriteCount{
8484 .read_count = try fbs.reader().readIntLittle(u32) + 8,
8585 .write_count = 0,
......@@ -126,7 +126,7 @@ pub fn decodeFrameAlloc(
126126 const magic = try reader.readIntLittle(u32);
127127 return switch (try frameType(magic)) {
128128 .zstandard => .{
129 .zstandard = try decodeZStandardFrameAlloc(allocator, src, verify_checksum, window_size_max),
129 .zstandard = try decodeZstandardFrameAlloc(allocator, src, verify_checksum, window_size_max),
130130 },
131131 .skippable => .{
132132 .skippable = .{
......@@ -166,17 +166,17 @@ const FrameError = error{
166166/// - `error.UnusedBitSet` if the unused bit of the frame header is set
167167/// - `error.EndOfStream` if `src` does not contain a complete frame
168168/// - an error in `block.Error` if there are errors decoding a block
169pub fn decodeZStandardFrame(
169pub fn decodeZstandardFrame(
170170 dest: []u8,
171171 src: []const u8,
172172 verify_checksum: bool,
173173) (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);
175175 var consumed_count: usize = 4;
176176
177177 var fbs = std.io.fixedBufferStream(src[consumed_count..]);
178178 var source = fbs.reader();
179 const frame_header = try decodeZStandardHeader(source);
179 const frame_header = try decodeZstandardHeader(source);
180180 consumed_count += fbs.pos;
181181
182182 if (frame_header.descriptor.dictionary_id_flag != 0) return error.DictionaryIdFlagUnsupported;
......@@ -218,7 +218,7 @@ pub const FrameContext = struct {
218218 /// - `error.WindowSizeUnknown` if the frame does not have a valid window size
219219 /// - `error.WindowTooLarge` if the window size is larger than
220220 pub fn init(
221 frame_header: frame.ZStandard.Header,
221 frame_header: frame.Zstandard.Header,
222222 window_size_max: usize,
223223 verify_checksum: bool,
224224 ) Error!FrameContext {
......@@ -241,7 +241,7 @@ pub const FrameContext = struct {
241241};
242242
243243/// Decode a Zstandard from from `src` and return the decompressed bytes and the
244/// number of bytes read; see `decodeZStandardFrame()`. `allocator` is used to
244/// number of bytes read; see `decodeZstandardFrame()`. `allocator` is used to
245245/// allocate both the returned slice and internal buffers used during decoding.
246246/// The first four bytes of `src` must be the magic number for a Zstandard
247247/// frame.
......@@ -259,20 +259,20 @@ pub const FrameContext = struct {
259259/// - `error.EndOfStream` if `src` does not contain a complete frame
260260/// - `error.OutOfMemory` if `allocator` cannot allocate enough memory
261261/// - an error in `block.Error` if there are errors decoding a block
262pub fn decodeZStandardFrameAlloc(
262pub fn decodeZstandardFrameAlloc(
263263 allocator: Allocator,
264264 src: []const u8,
265265 verify_checksum: bool,
266266 window_size_max: usize,
267267) (error{OutOfMemory} || FrameContext.Error || FrameError)!DecodeResult {
268268 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);
270270 var consumed_count: usize = 4;
271271
272272 var frame_context = context: {
273273 var fbs = std.io.fixedBufferStream(src[consumed_count..]);
274274 var source = fbs.reader();
275 const frame_header = try decodeZStandardHeader(source);
275 const frame_header = try decodeZstandardHeader(source);
276276 consumed_count += fbs.pos;
277277 break :context try FrameContext.init(frame_header, window_size_max, verify_checksum);
278278 };
......@@ -371,7 +371,7 @@ pub fn decodeSkippableHeader(src: *const [8]u8) frame.Skippable.Header {
371371
372372/// Returns the window size required to decompress a frame, or `null` if it
373373/// 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 {
375375 if (header.window_descriptor) |descriptor| {
376376 const exponent = (descriptor & 0b11111000) >> 3;
377377 const mantissa = descriptor & 0b00000111;
......@@ -389,8 +389,8 @@ const InvalidBit = error{ UnusedBitSet, ReservedBitSet };
389389/// - `error.UnusedBitSet` if the unused bits of the header are set
390390/// - `error.ReservedBitSet` if the reserved bits of the header are set
391391/// - `error.EndOfStream` if `source` does not contain a complete header
392pub fn decodeZStandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)!frame.ZStandard.Header {
393 const descriptor = @bitCast(frame.ZStandard.Header.Descriptor, try source.readByte());
392pub fn decodeZstandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)!frame.Zstandard.Header {
393 const descriptor = @bitCast(frame.Zstandard.Header.Descriptor, try source.readByte());
394394
395395 if (descriptor.unused) return error.UnusedBitSet;
396396 if (descriptor.reserved) return error.ReservedBitSet;
......@@ -414,7 +414,7 @@ pub fn decodeZStandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)
414414 if (field_size == 2) content_size.? += 256;
415415 }
416416
417 const header = frame.ZStandard.Header{
417 const header = frame.Zstandard.Header{
418418 .descriptor = descriptor,
419419 .window_descriptor = window_descriptor,
420420 .dictionary_id = dictionary_id,
lib/std/compress/zstandard/types.zig+1-1
......@@ -1,7 +1,7 @@
11pub const frame = struct {
22 pub const Kind = enum { zstandard, skippable };
33
4 pub const ZStandard = struct {
4 pub const Zstandard = struct {
55 pub const magic_number = 0xFD2FB528;
66
77 header: Header,