Skip to content

Commit 2189811

Browse files
author
dweiller
committed
std.compress.zstandard: fix capitalisation of Zstandard
1 parent ce048af commit 2189811

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

lib/std/compress/zstandard.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ pub const DecodeState = struct {
580580
pub 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(
668668
pub 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(
758758
pub 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.
828-
pub fn decodeBlockHeader(src: *const [3]u8) frame.ZStandard.Block.Header {
828+
pub 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`
843-
pub fn decodeBlockHeaderSlice(src: []const u8) error{EndOfStream}!frame.ZStandard.Block.Header {
843+
pub 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
Original file line numberDiff line numberDiff line change
@@ -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.
4343
pub 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
169-
pub fn decodeZStandardFrame(
169+
pub 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
262-
pub fn decodeZStandardFrameAlloc(
262+
pub 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).
374-
pub fn frameWindowSize(header: frame.ZStandard.Header) ?u64 {
374+
pub 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
392-
pub fn decodeZStandardHeader(source: anytype) (error{EndOfStream} || InvalidBit)!frame.ZStandard.Header {
393-
const descriptor = @bitCast(frame.ZStandard.Header.Descriptor, try source.readByte());
392+
pub 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
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub 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,

0 commit comments

Comments
 (0)