mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-12 17:08:39 -09:00
Some fixes for building with Zig stage2
Building is currently broken on packed struct alignment issues. :/
This commit is contained in:
parent
f7e774ee6e
commit
1452b91032
3 changed files with 9 additions and 7 deletions
|
|
@ -120,7 +120,7 @@ test "parse" {
|
|||
// the match result is only used to construct the PatternList of the
|
||||
// subdirectory) and patterns without a sub-pointer (where the match result
|
||||
// determines whether the file/dir at this level should be included or not).
|
||||
fn PatternList(withsub: bool) type {
|
||||
fn PatternList(comptime withsub: bool) type {
|
||||
return struct {
|
||||
literals: std.HashMapUnmanaged(*const Pattern, Val, Ctx, 80) = .{},
|
||||
wild: std.ArrayListUnmanaged(*const Pattern) = .{},
|
||||
|
|
@ -150,7 +150,7 @@ fn PatternList(withsub: bool) type {
|
|||
var e = self.literals.getOrPut(main.allocator, pat) catch unreachable;
|
||||
if (!e.found_existing) {
|
||||
e.key_ptr.* = pat;
|
||||
e.value_ptr.* = .{};
|
||||
e.value_ptr.* = if (withsub) .{} else {};
|
||||
}
|
||||
if (!withsub and !pat.isdir and e.key_ptr.*.isdir) e.key_ptr.* = pat;
|
||||
if (withsub) {
|
||||
|
|
@ -165,14 +165,14 @@ fn PatternList(withsub: bool) type {
|
|||
if (self.literals.getKey(&.{ .pattern = name })) |p| ret = p.isdir;
|
||||
for (self.wild.items) |p| {
|
||||
if (ret == false) return ret;
|
||||
if (c.fnmatch(p.pattern, name, 0) == 0) ret = p.isdir;
|
||||
if (c.fnmatch(p.pattern.ptr, name.ptr, 0) == 0) ret = p.isdir;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
fn enter(self: *const Self, out: *Patterns, name: [:0]const u8) void {
|
||||
if (self.literals.get(&.{ .pattern = name })) |lst| for (lst.items) |sub| out.append(sub);
|
||||
for (self.wild.items) |p| if (c.fnmatch(p.pattern, name, 0) == 0) out.append(p.sub.?);
|
||||
for (self.wild.items) |p| if (c.fnmatch(p.pattern.ptr, name.ptr, 0) == 0) out.append(p.sub.?);
|
||||
}
|
||||
|
||||
fn deinit(self: *Self) void {
|
||||
|
|
|
|||
|
|
@ -261,7 +261,8 @@ fn tryReadArgsFile(path: [:0]const u8) void {
|
|||
defer f.close();
|
||||
|
||||
var arglist = std.ArrayList([:0]const u8).init(allocator);
|
||||
var rd = std.io.bufferedReader(f.reader()).reader();
|
||||
var rd_ = std.io.bufferedReader(f.reader());
|
||||
var rd = rd_.reader();
|
||||
var linebuf: [4096]u8 = undefined;
|
||||
|
||||
while (
|
||||
|
|
@ -379,7 +380,8 @@ fn spawnShell() void {
|
|||
fn readExcludeFile(path: [:0]const u8) !void {
|
||||
const f = try std.fs.cwd().openFileZ(path, .{});
|
||||
defer f.close();
|
||||
var rd = std.io.bufferedReader(f.reader()).reader();
|
||||
var rd_ = std.io.bufferedReader(f.reader());
|
||||
var rd = rd_.reader();
|
||||
var buf = std.ArrayList(u8).init(allocator);
|
||||
defer buf.deinit();
|
||||
while (true) {
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ pub fn move(y: u32, x: u32) void {
|
|||
// (Well, addchstr() does that, but not entirely sure I want to go that way.
|
||||
// Does that even work with UTF-8? Or do I really need to go wchar madness?)
|
||||
pub fn addstr(s: [:0]const u8) void {
|
||||
_ = c.addstr(s);
|
||||
_ = c.addstr(s.ptr);
|
||||
}
|
||||
|
||||
// Not to be used for strings that may end up >256 bytes.
|
||||
|
|
|
|||
Loading…
Reference in a new issue