Skip to content

Commit

Permalink
Change some [*:0] to [:0]
Browse files Browse the repository at this point in the history
There are a few cases where we can use a [:0] instead of a [*:0] to be
less restrictive.
  • Loading branch information
natecraddock committed Mar 20, 2024
1 parent 6ed2b7c commit b93287d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1497,12 +1497,14 @@ pub const Lua = struct {

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

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

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

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

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

0 comments on commit b93287d

Please sign in to comment.