reformatted with zig fmt

This commit is contained in:
Squibid 2026-03-01 22:23:31 -05:00
parent e6a45f91b6
commit 6be66b6a71
Signed by: squibid
GPG key ID: BECE5684D3C4005D
32 changed files with 2108 additions and 2237 deletions

View file

@ -4,7 +4,7 @@ const std = @import("std");
const zlua = @import("zlua");
const Lua = @import("Lua.zig");
const Utils = @import("../Utils.zig");
const Utils = @import("../Utils.zig");
const gpa = std.heap.c_allocator;
@ -12,29 +12,29 @@ const gpa = std.heap.c_allocator;
/// ---@vararg string paths to join
/// ---@return string?
pub fn joinpath(L: *zlua.Lua) i32 {
const nargs: i32 = L.getTop();
if (nargs < 2) {
L.raiseErrorStr("Expected at least two paths to join", .{});
return 0;
}
var paths = std.ArrayList([:0]const u8).initCapacity(gpa, @intCast(nargs)) catch Utils.oomPanic();
defer paths.deinit(gpa);
var i: u8 = 1;
while (i <= nargs) : (i += 1) {
if (!L.isString(i)) {
L.raiseErrorStr("Expected string at argument %d", .{i});
return 0;
const nargs: i32 = L.getTop();
if (nargs < 2) {
L.raiseErrorStr("Expected at least two paths to join", .{});
return 0;
}
const partial_path = L.toString(i) catch unreachable;
paths.append(gpa, partial_path) catch Utils.oomPanic();
}
var paths = std.ArrayList([:0]const u8).initCapacity(gpa, @intCast(nargs)) catch Utils.oomPanic();
defer paths.deinit(gpa);
const final_path: []const u8 = std.fs.path.join(gpa, paths.items) catch Utils.oomPanic();
defer gpa.free(final_path);
var i: u8 = 1;
while (i <= nargs) : (i += 1) {
if (!L.isString(i)) {
L.raiseErrorStr("Expected string at argument %d", .{i});
return 0;
}
_ = L.pushString(final_path);
return 1;
const partial_path = L.toString(i) catch unreachable;
paths.append(gpa, partial_path) catch Utils.oomPanic();
}
const final_path: []const u8 = std.fs.path.join(gpa, paths.items) catch Utils.oomPanic();
defer gpa.free(final_path);
_ = L.pushString(final_path);
return 1;
}