mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
Fix incorrect format string causing invalid export files
Zig requires alignment to be specified when specifying a fill character,
as otherwise digits specified after ':' are interpreted as part of the
field width.
The missing alignment specifier caused character codes < 0x10 to be
serialized incorrectly, producing an export file ncdu could not import.
For example, a character with code 1 would be serialized as '\u00 1'
instead of '\u0001'.
A directory of test files can be generated using:
mkdir test_files; i=1; while [ $i -le 255 ]; do c="$(printf "$(printf "\\\\x%02xZ" "$i")")"; c="${c%Z}"; touch "test_files/$c"; i=$((i+1)); done
This commit is contained in:
parent
d523a77fdc
commit
d6728bca95
1 changed files with 1 additions and 1 deletions
|
|
@ -96,7 +96,7 @@ fn writeJsonString(wr: anytype, s: []const u8) !void {
|
|||
0xC => try wr.writeAll("\\f"),
|
||||
'\\' => try wr.writeAll("\\\\"),
|
||||
'"' => try wr.writeAll("\\\""),
|
||||
0...7, 0xB, 0xE...0x1F, 127 => try wr.print("\\u00{x:02}", .{ch}),
|
||||
0...7, 0xB, 0xE...0x1F, 127 => try wr.print("\\u00{x:0>2}", .{ch}),
|
||||
else => try wr.writeByte(ch)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue