mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
fmt: remove the prefixed module name of const names, that are in the same module (related #22183) (#22185)
This commit is contained in:
parent
234fb8e2b0
commit
008aaad999
284 changed files with 2539 additions and 2572 deletions
|
@ -12,8 +12,8 @@ fn C.tinfl_decompress_mem_to_heap(source_buf voidptr, source_buf_len usize, out_
|
|||
// NB: this is a low level api, a high level implementation like zlib/gzip should be preferred
|
||||
@[manualfree]
|
||||
pub fn compress(data []u8, flags int) ![]u8 {
|
||||
if u64(data.len) > compress.max_size {
|
||||
return error('data too large (${data.len} > ${compress.max_size})')
|
||||
if u64(data.len) > max_size {
|
||||
return error('data too large (${data.len} > ${max_size})')
|
||||
}
|
||||
mut out_len := usize(0)
|
||||
|
||||
|
@ -21,8 +21,8 @@ pub fn compress(data []u8, flags int) ![]u8 {
|
|||
if address == 0 {
|
||||
return error('compression failed')
|
||||
}
|
||||
if u64(out_len) > compress.max_size {
|
||||
return error('compressed data is too large (${out_len} > ${compress.max_size})')
|
||||
if u64(out_len) > max_size {
|
||||
return error('compressed data is too large (${out_len} > ${max_size})')
|
||||
}
|
||||
return unsafe { address.vbytes(int(out_len)) }
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ pub fn decompress(data []u8, flags int) ![]u8 {
|
|||
if address == 0 {
|
||||
return error('decompression failed')
|
||||
}
|
||||
if u64(out_len) > compress.max_size {
|
||||
return error('decompressed data is too large (${out_len} > ${compress.max_size})')
|
||||
if u64(out_len) > max_size {
|
||||
return error('decompressed data is too large (${out_len} > ${max_size})')
|
||||
}
|
||||
return unsafe { address.vbytes(int(out_len)) }
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ fn test_gzip() {
|
|||
uncompressed := 'Hello world!'
|
||||
compressed := compress(uncompressed.bytes())!
|
||||
first2 := compressed[0..2]
|
||||
assert first2 != deflate.gzip_magic_numbers
|
||||
assert first2 != gzip_magic_numbers
|
||||
decompressed := decompress(compressed)!
|
||||
assert decompressed == uncompressed.bytes()
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ pub mut:
|
|||
|
||||
// validate validates the header and returns its details if valid
|
||||
pub fn validate(data []u8, params DecompressParams) !GzipHeader {
|
||||
if data.len < gzip.min_header_length {
|
||||
if data.len < min_header_length {
|
||||
return error('data is too short, not gzip compressed?')
|
||||
} else if data[0] != 0x1f || data[1] != 0x8b {
|
||||
return error('wrong magic numbers, not gzip compressed?')
|
||||
|
@ -83,7 +83,7 @@ pub fn validate(data []u8, params DecompressParams) !GzipHeader {
|
|||
// correctly, so we dont accidently decompress something that belongs
|
||||
// to the header
|
||||
|
||||
if data[3] & gzip.reserved_bits > 0 {
|
||||
if data[3] & reserved_bits > 0 {
|
||||
// rfc 1952 2.3.1.2 Compliance
|
||||
// A compliant decompressor must give an error indication if any
|
||||
// reserved bit is non-zero, since such a bit could indicate the
|
||||
|
@ -92,12 +92,12 @@ pub fn validate(data []u8, params DecompressParams) !GzipHeader {
|
|||
return error('reserved flags are set, unsupported field detected')
|
||||
}
|
||||
|
||||
if data[3] & gzip.fextra > 0 {
|
||||
if data[3] & fextra > 0 {
|
||||
xlen := data[header.length]
|
||||
header.extra = data[header.length + 1..header.length + 1 + xlen]
|
||||
header.length += xlen + 1
|
||||
}
|
||||
if data[3] & gzip.fname > 0 {
|
||||
if data[3] & fname > 0 {
|
||||
// filename is zero-terminated, so skip until we hit a zero byte
|
||||
for header.length < data.len && data[header.length] != 0x00 {
|
||||
header.filename << data[header.length]
|
||||
|
@ -105,7 +105,7 @@ pub fn validate(data []u8, params DecompressParams) !GzipHeader {
|
|||
}
|
||||
header.length++
|
||||
}
|
||||
if data[3] & gzip.fcomment > 0 {
|
||||
if data[3] & fcomment > 0 {
|
||||
// comment is zero-terminated, so skip until we hit a zero byte
|
||||
for header.length < data.len && data[header.length] != 0x00 {
|
||||
header.comment << data[header.length]
|
||||
|
@ -113,7 +113,7 @@ pub fn validate(data []u8, params DecompressParams) !GzipHeader {
|
|||
}
|
||||
header.length++
|
||||
}
|
||||
if data[3] & gzip.fhcrc > 0 {
|
||||
if data[3] & fhcrc > 0 {
|
||||
if header.length + 12 > data.len {
|
||||
return error('data too short')
|
||||
}
|
||||
|
|
|
@ -431,10 +431,10 @@ pub:
|
|||
// extra decompression parameters can be set by `params`
|
||||
// Example: decompressed := zstd.decompress(b)!
|
||||
pub fn decompress(data []u8, params DecompressParams) ![]u8 {
|
||||
dst_capacity := C.ZSTD_getFrameContentSize(data.data, zstd.zstd_frame_header_size_max)
|
||||
if dst_capacity == zstd.zstd_content_size_unknown {
|
||||
dst_capacity := C.ZSTD_getFrameContentSize(data.data, zstd_frame_header_size_max)
|
||||
if dst_capacity == zstd_content_size_unknown {
|
||||
return error('The size cannot be determined, try use streaming mode to decompress data?')
|
||||
} else if dst_capacity == zstd.zstd_content_size_error {
|
||||
} else if dst_capacity == zstd_content_size_error {
|
||||
return error('An error occurred (e.g. invalid magic number, srcSize too small)')
|
||||
} else if dst_capacity == 0 {
|
||||
return error('The frame is valid but empty')
|
||||
|
@ -543,7 +543,7 @@ pub fn store_array[T](fname string, array []T, params CompressParams) ! {
|
|||
fout.close()
|
||||
}
|
||||
|
||||
mut buf_out := []u8{len: zstd.buf_out_size}
|
||||
mut buf_out := []u8{len: buf_out_size}
|
||||
mut input := &ZSTD_inBuffer{}
|
||||
mut output := &ZSTD_outBuffer{}
|
||||
mut remaining := usize(1)
|
||||
|
@ -554,7 +554,7 @@ pub fn store_array[T](fname string, array []T, params CompressParams) ! {
|
|||
input.size = 8
|
||||
input.pos = 0
|
||||
output.dst = buf_out.data
|
||||
output.size = zstd.buf_out_size
|
||||
output.size = buf_out_size
|
||||
output.pos = 0
|
||||
remaining = cctx.compress_stream2(output, input, .zstd_e_flush)
|
||||
check_zstd(remaining)!
|
||||
|
@ -564,12 +564,12 @@ pub fn store_array[T](fname string, array []T, params CompressParams) ! {
|
|||
input.size = usize(array.len * sizeof(T))
|
||||
input.pos = 0
|
||||
output.dst = buf_out.data
|
||||
output.size = zstd.buf_out_size
|
||||
output.size = buf_out_size
|
||||
output.pos = 0
|
||||
remaining = 1
|
||||
for remaining != 0 {
|
||||
output.dst = buf_out.data
|
||||
output.size = zstd.buf_out_size
|
||||
output.size = buf_out_size
|
||||
output.pos = 0
|
||||
remaining = cctx.compress_stream2(output, input, .zstd_e_end)
|
||||
check_zstd(remaining)!
|
||||
|
@ -587,7 +587,7 @@ pub fn load_array[T](fname string, params DecompressParams) ![]T {
|
|||
fin.close()
|
||||
}
|
||||
|
||||
mut buf_in := []u8{len: zstd.buf_in_size}
|
||||
mut buf_in := []u8{len: buf_in_size}
|
||||
mut len_buf := []u8{len: 8}
|
||||
mut input := &ZSTD_inBuffer{}
|
||||
mut output := &ZSTD_outBuffer{}
|
||||
|
|
|
@ -5,7 +5,7 @@ import os
|
|||
const samples_folder = os.join_path(os.dir(@FILE), 'samples')
|
||||
|
||||
fn s(fname string) string {
|
||||
return os.join_path(zstd.samples_folder, fname)
|
||||
return os.join_path(samples_folder, fname)
|
||||
}
|
||||
|
||||
fn test_zstd() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue