Skip to content

Commit b93287d

Browse files
committed
Change some [*:0] to [:0]
There are a few cases where we can use a [:0] instead of a [*:0] to be less restrictive.
1 parent 6ed2b7c commit b93287d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/lib.zig

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,12 +1497,14 @@ pub const Lua = struct {
14971497

14981498
/// Push a formatted string onto the stack and return a pointer to the string
14991499
/// See https://www.lua.org/manual/5.4/manual.html#lua_pushfstring
1500-
pub fn pushFString(lua: *Lua, fmt: [:0]const u8, args: anytype) [*:0]const u8 {
1501-
return @call(
1500+
pub fn pushFString(lua: *Lua, fmt: [:0]const u8, args: anytype) [:0]const u8 {
1501+
const ptr = @call(
15021502
.auto,
15031503
if (lang == .luau) c.lua_pushfstringL else c.lua_pushfstring,
15041504
.{ lua.state, fmt.ptr } ++ args,
15051505
);
1506+
const l = lua.rawLen(-1);
1507+
return ptr[0..l :0];
15061508
}
15071509

15081510
/// Pushes the global environment onto the stack
@@ -2375,8 +2377,8 @@ pub const Lua = struct {
23752377

23762378
/// Raises an error reporting a problem with argument `arg` of the C function that called it
23772379
/// See https://www.lua.org/manual/5.4/manual.html#luaL_argerror
2378-
pub fn argError(lua: *Lua, arg: i32, extra_msg: [*:0]const u8) noreturn {
2379-
_ = c.luaL_argerror(lua.state, arg, extra_msg);
2380+
pub fn argError(lua: *Lua, arg: i32, extra_msg: [:0]const u8) noreturn {
2381+
_ = c.luaL_argerror(lua.state, arg, extra_msg.ptr);
23802382
unreachable;
23812383
}
23822384

@@ -2445,8 +2447,8 @@ pub const Lua = struct {
24452447
/// Grows the stack size to top + `size` elements, raising an error if the stack cannot grow to that size
24462448
/// `msg` is an additional text to go into the error message
24472449
/// See https://www.lua.org/manual/5.4/manual.html#luaL_checkstack
2448-
pub fn checkStackErr(lua: *Lua, size: i32, msg: ?[*:0]const u8) void {
2449-
c.luaL_checkstack(lua.state, size, msg);
2450+
pub fn checkStackErr(lua: *Lua, size: i32, msg: ?[:0]const u8) void {
2451+
c.luaL_checkstack(lua.state, size, if (msg) |m| m.ptr else null);
24502452
}
24512453

24522454
/// Checks whether the function argument `arg` is a string and returns the string

0 commit comments

Comments
 (0)