Skip to content

Commit 0465a59

Browse files
committed
Fix formatting
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
1 parent 9312588 commit 0465a59

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/stack.zig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,18 @@ const Lua = @import("lua.zig").Lua;
4242
/// storage uses heap allocation via TString*, so pointers remain valid after copy.
4343
fn fixStrBufPointers(buf: State.StrBuf) State.StrBuf {
4444
var fixed_buf = buf;
45-
45+
4646
// Only fix pointers for stack-allocated buffers
4747
if (fixed_buf.storage == null) {
4848
// Calculate how far into the original buffer the current position was
4949
const p_offset = @intFromPtr(buf.p) - @intFromPtr(&buf.buffer);
5050
// Adjust pointer to point into the new buffer at the same relative offset
5151
fixed_buf.p = @ptrFromInt(@intFromPtr(&fixed_buf.buffer) + p_offset);
5252
}
53-
53+
5454
return fixed_buf;
5555
}
5656

57-
5857
/// Counts how many Lua stack slots are needed for the given type.
5958
///
6059
/// This is typically 1 for most types, but there are edge cases:
@@ -311,7 +310,6 @@ pub fn pushResult(lua: Lua, result: anytype) c_int {
311310
return pushResult(lua, payload);
312311
}
313312

314-
315313
// Handle tuple results by pushing each element individually
316314
if (result_info == .@"struct" and result_info.@"struct".is_tuple) {
317315
inline for (0..result_info.@"struct".fields.len) |i| {

src/tests.zig

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,6 @@ test "StrBuf integration with Table operations" {
18251825
try expectEq(lua.top(), 0);
18261826
}
18271827

1828-
18291828
// Define a Zig function that builds and returns StrBuf by pointer
18301829
fn makeMsg(l: *Lua, name: []const u8, value: i32) !Lua.StrBuf {
18311830
var buf: Lua.StrBuf = undefined;
@@ -1863,7 +1862,7 @@ fn makeMsgTuple(l: *Lua, name: []const u8, value: i32) !struct { Lua.StrBuf, i32
18631862
buf.addLString(name);
18641863
buf.addString(" = ");
18651864
try buf.add(value);
1866-
1865+
18671866
return .{ buf, value * 2 };
18681867
}
18691868

@@ -1880,7 +1879,7 @@ test "StrBuf returned in tuple from Zig functions" {
18801879

18811880
// Call function that returns tuple (StrBuf, i32)
18821881
const result = try lua.eval("return makeTuple('test', 21)", .{}, struct { []const u8, i32 });
1883-
1882+
18841883
const expected_str = "Tuple: test = 21";
18851884
try expectEq(std.mem.startsWith(u8, result[0], expected_str), true);
18861885
try expectEq(result[1], 42);
@@ -1890,18 +1889,18 @@ test "StrBuf returned in tuple from Zig functions" {
18901889
fn makeLargeMsg(l: *Lua, count: i32) !Lua.StrBuf {
18911890
var buf: Lua.StrBuf = undefined;
18921891
buf.init(l);
1893-
1892+
18941893
// Build a string longer than LUA_BUFFERSIZE (512 bytes) to force dynamic allocation
18951894
buf.addString("Large message: ");
1896-
1895+
18971896
// Add enough content to exceed buffer size
18981897
var i: i32 = 0;
18991898
while (i < count) : (i += 1) {
19001899
buf.addString("This is a repeated string to exceed buffer size! ");
19011900
try buf.add(i);
19021901
buf.addString(" ");
19031902
}
1904-
1903+
19051904
return buf;
19061905
}
19071906

@@ -1915,12 +1914,12 @@ test "StrBuf with dynamic allocation returned from Zig functions" {
19151914
// Test with enough iterations to exceed 512 bytes
19161915
// Each iteration adds ~50+ bytes, so 15 iterations should exceed 512 bytes
19171916
const result = try lua.eval("return makeLarge(15)", .{}, []const u8);
1918-
1917+
19191918
// Verify the result starts correctly and is reasonably long
19201919
try expectEq(std.mem.startsWith(u8, result, "Large message: This is a repeated string"), true);
19211920
try expectEq(result.len > 512, true); // Should be longer than buffer size
1922-
1921+
19231922
// Verify it contains content from both early and late iterations
1924-
try expectEq(std.mem.indexOf(u8, result, "0 ") != null, true); // First iteration
1923+
try expectEq(std.mem.indexOf(u8, result, "0 ") != null, true); // First iteration
19251924
try expectEq(std.mem.indexOf(u8, result, "14 ") != null, true); // Last iteration
19261925
}

0 commit comments

Comments
 (0)