Skip to content

Commit

Permalink
feat: rename gSub -> globalSub
Browse files Browse the repository at this point in the history
  • Loading branch information
natecraddock committed Feb 18, 2023
1 parent 5505a3e commit b6dec0d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/ziglua-5.1/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,7 @@ pub const Lua = struct {
/// Creates a copy of string `str`, replacing any occurrence of the string `pat` with the string `rep`
/// Pushes the resulting string on the stack and returns it.
/// See https://www.lua.org/manual/5.1/manual.html#luaL_gsub
/// TODO: rename to globalSub
pub fn gSub(lua: *Lua, str: [:0]const u8, pat: [:0]const u8, rep: [:0]const u8) [:0]const u8 {
pub fn globalSub(lua: *Lua, str: [:0]const u8, pat: [:0]const u8, rep: [:0]const u8) [:0]const u8 {
return std.mem.span(c.luaL_gsub(lua.state, str.ptr, pat.ptr, rep.ptr));
}

Expand Down
4 changes: 2 additions & 2 deletions src/ziglua-5.1/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -995,11 +995,11 @@ test "checkOption" {
try expectEqualStrings("bad argument #1 to '?' (invalid option 'unknown')", try lua.toBytes(-1));
}

test "gSub" {
test "globalSub" {
var lua = try Lua.init(testing.allocator);
defer lua.deinit();

_ = lua.gSub("-gity -!", "-", "zig");
_ = lua.globalSub("-gity -!", "-", "zig");
try expectEqualStrings("ziggity zig!", try lua.toBytes(-1));
}

Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.2/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ pub const Lua = struct {

/// Creates a copy of string `str`, replacing any occurrence of the string `pat` with the string `rep`
/// Pushes the resulting string on the stack and returns it.
pub fn gSub(lua: *Lua, str: [:0]const u8, pat: [:0]const u8, rep: [:0]const u8) [:0]const u8 {
pub fn globalSub(lua: *Lua, str: [:0]const u8, pat: [:0]const u8, rep: [:0]const u8) [:0]const u8 {
return std.mem.span(c.luaL_gsub(lua.state, str.ptr, pat.ptr, rep.ptr));
}

Expand Down
4 changes: 2 additions & 2 deletions src/ziglua-5.2/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1211,11 +1211,11 @@ test "checkOption" {
try expectEqualStrings("bad argument #1 to '?' (invalid option 'unknown')", try lua.toBytes(-1));
}

test "gSub" {
test "globalSub" {
var lua = try Lua.init(testing.allocator);
defer lua.deinit();

_ = lua.gSub("-gity -!", "-", "zig");
_ = lua.globalSub("-gity -!", "-", "zig");
try expectEqualStrings("ziggity zig!", try lua.toBytes(-1));
}

Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.3/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ pub const Lua = struct {

/// Creates a copy of string `str`, replacing any occurrence of the string `pat` with the string `rep`
/// Pushes the resulting string on the stack and returns it.
pub fn gSub(lua: *Lua, str: [:0]const u8, pat: [:0]const u8, rep: [:0]const u8) [:0]const u8 {
pub fn globalSub(lua: *Lua, str: [:0]const u8, pat: [:0]const u8, rep: [:0]const u8) [:0]const u8 {
return std.mem.span(c.luaL_gsub(lua.state, str.ptr, pat.ptr, rep.ptr));
}

Expand Down
4 changes: 2 additions & 2 deletions src/ziglua-5.3/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1240,11 +1240,11 @@ test "checkOption" {
try expectEqualStrings("bad argument #1 to '?' (invalid option 'unknown')", try lua.toBytes(-1));
}

test "gSub" {
test "globalSub" {
var lua = try Lua.init(testing.allocator);
defer lua.deinit();

_ = lua.gSub("-gity -!", "-", "zig");
_ = lua.globalSub("-gity -!", "-", "zig");
try expectEqualStrings("ziggity zig!", try lua.toBytes(-1));
}

Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.4/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ pub const Lua = struct {

/// Creates a copy of string `str`, replacing any occurrence of the string `pat` with the string `rep`
/// Pushes the resulting string on the stack and returns it.
pub fn gSub(lua: *Lua, str: [:0]const u8, pat: [:0]const u8, rep: [:0]const u8) [:0]const u8 {
pub fn globalSub(lua: *Lua, str: [:0]const u8, pat: [:0]const u8, rep: [:0]const u8) [:0]const u8 {
return std.mem.span(c.luaL_gsub(lua.state, str.ptr, pat.ptr, rep.ptr));
}

Expand Down
4 changes: 2 additions & 2 deletions src/ziglua-5.4/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1321,11 +1321,11 @@ test "checkOption" {
try expectEqualStrings("bad argument #1 to '?' (invalid option 'unknown')", try lua.toBytes(-1));
}

test "gSub" {
test "globalSub" {
var lua = try Lua.init(testing.allocator);
defer lua.deinit();

_ = lua.gSub("-gity -!", "-", "zig");
_ = lua.globalSub("-gity -!", "-", "zig");
try expectEqualStrings("ziggity zig!", try lua.toBytes(-1));
}

Expand Down

0 comments on commit b6dec0d

Please sign in to comment.