Skip to content
Snippets Groups Projects
Commit 1452b910 authored by Yorhel's avatar Yorhel
Browse files

Some fixes for building with Zig stage2

Building is currently broken on packed struct alignment issues. :/
parent f7e774ee
No related branches found
No related tags found
No related merge requests found
...@@ -120,7 +120,7 @@ test "parse" { ...@@ -120,7 +120,7 @@ test "parse" {
// the match result is only used to construct the PatternList of the // the match result is only used to construct the PatternList of the
// subdirectory) and patterns without a sub-pointer (where the match result // subdirectory) and patterns without a sub-pointer (where the match result
// determines whether the file/dir at this level should be included or not). // 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 { return struct {
literals: std.HashMapUnmanaged(*const Pattern, Val, Ctx, 80) = .{}, literals: std.HashMapUnmanaged(*const Pattern, Val, Ctx, 80) = .{},
wild: std.ArrayListUnmanaged(*const Pattern) = .{}, wild: std.ArrayListUnmanaged(*const Pattern) = .{},
...@@ -150,7 +150,7 @@ fn PatternList(withsub: bool) type { ...@@ -150,7 +150,7 @@ fn PatternList(withsub: bool) type {
var e = self.literals.getOrPut(main.allocator, pat) catch unreachable; var e = self.literals.getOrPut(main.allocator, pat) catch unreachable;
if (!e.found_existing) { if (!e.found_existing) {
e.key_ptr.* = pat; 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 and !pat.isdir and e.key_ptr.*.isdir) e.key_ptr.* = pat;
if (withsub) { if (withsub) {
...@@ -165,14 +165,14 @@ fn PatternList(withsub: bool) type { ...@@ -165,14 +165,14 @@ fn PatternList(withsub: bool) type {
if (self.literals.getKey(&.{ .pattern = name })) |p| ret = p.isdir; if (self.literals.getKey(&.{ .pattern = name })) |p| ret = p.isdir;
for (self.wild.items) |p| { for (self.wild.items) |p| {
if (ret == false) return ret; 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; return ret;
} }
fn enter(self: *const Self, out: *Patterns, name: [:0]const u8) void { 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); 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 { fn deinit(self: *Self) void {
......
...@@ -261,7 +261,8 @@ fn tryReadArgsFile(path: [:0]const u8) void { ...@@ -261,7 +261,8 @@ fn tryReadArgsFile(path: [:0]const u8) void {
defer f.close(); defer f.close();
var arglist = std.ArrayList([:0]const u8).init(allocator); 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; var linebuf: [4096]u8 = undefined;
while ( while (
...@@ -379,7 +380,8 @@ fn spawnShell() void { ...@@ -379,7 +380,8 @@ fn spawnShell() void {
fn readExcludeFile(path: [:0]const u8) !void { fn readExcludeFile(path: [:0]const u8) !void {
const f = try std.fs.cwd().openFileZ(path, .{}); const f = try std.fs.cwd().openFileZ(path, .{});
defer f.close(); 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); var buf = std.ArrayList(u8).init(allocator);
defer buf.deinit(); defer buf.deinit();
while (true) { while (true) {
......
...@@ -395,7 +395,7 @@ pub fn move(y: u32, x: u32) void { ...@@ -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. // (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?) // Does that even work with UTF-8? Or do I really need to go wchar madness?)
pub fn addstr(s: [:0]const u8) void { 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. // Not to be used for strings that may end up >256 bytes.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment