show endianess better

This commit is contained in:
Motiejus Jakštys 2022-07-06 12:38:56 +03:00
parent f2570529d7
commit 4e9f609131

View File

@ -30,7 +30,7 @@ const Info = struct {
size_file: []const u8,
bytes_file: os.off_t,
version: meta.fieldInfo(Header, .version).field_type,
endian: meta.fieldInfo(Header, .endian).field_type,
endian: []const u8,
ptr_size: meta.fieldInfo(Header, .ptr_size).field_type,
getgr_bufsize: meta.fieldInfo(Header, .getgr_bufsize).field_type,
getpw_bufsize: meta.fieldInfo(Header, .getpw_bufsize).field_type,
@ -106,8 +106,8 @@ fn execute(
defer file.close();
const db = file.db;
var scratch: [16]u8 = undefined;
const buf = fmt.bufPrint(scratch[0..], "{:.2}", .{
var file_size_scratch: [16]u8 = undefined;
const buf = fmt.bufPrint(file_size_scratch[0..], "{:.2}", .{
fmt.fmtIntSizeBin(@intCast(u64, file_size_bytes)),
}) catch unreachable;
@ -116,7 +116,7 @@ fn execute(
.size_file = buf,
.bytes_file = file_size_bytes,
.version = db.header.version,
.endian = db.header.endian,
.endian = @tagName(db.header.endian),
.ptr_size = db.header.ptr_size,
.getgr_bufsize = db.header.getgr_bufsize,
.getpw_bufsize = db.header.getpw_bufsize,
@ -131,8 +131,8 @@ fn execute(
\\Version: {[version]d}
\\Endian: {[endian]s}
\\Pointer size: {[ptr_size]} bytes
\\getgr buffer size: {[getgr_bufsize]d}B
\\getpw buffer size: {[getpw_bufsize]d}B
\\getgr buffer size: {[getgr_bufsize]d}
\\getpw buffer size: {[getpw_bufsize]d}
\\Users: {[users]d}
\\Groups: {[groups]d}
\\Shells: {[shells]d}
@ -147,7 +147,7 @@ fn execute(
inline for (meta.fields(DB.DBNumbers)) |field| {
const length = @field(lengths, field.name);
const size = fmt.bufPrint(scratch[0..], "{:.0}", .{
const size = fmt.bufPrint(file_size_scratch[0..], "{:.0}", .{
fmt.fmtIntSizeBin(@intCast(u64, length << section_length_bits)),
}) catch unreachable;