Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Any kind of contributions are welcome.

## Building GopherLua

GopherLua uses simple inlining tool for generate efficient codes. This tool requires python interpreter. Files name of which starts with `_` genarate files name of which does not starts with `_` . For instance, `_state.go` generate `state.go` . You do not edit generated sources.
GopherLua uses simple inlining tool for generate efficient codes. This tool requires python interpreter. Files name of which starts with `_` generate files name of which does not starts with `_` . For instance, `_state.go` generate `state.go` . You do not edit generated sources.
To generate sources, some make target is available.

```bash
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ Lua has an interpreter called ``lua`` . GopherLua has an interpreter called ``gl
----------------------------------------------------------------
How to Contribute
----------------------------------------------------------------
See `Guidlines for contributors <https://github.com/yuin/gopher-lua/tree/master/.github/CONTRIBUTING.md>`_ .
See `Guidelines for contributors <https://github.com/yuin/gopher-lua/tree/master/.github/CONTRIBUTING.md>`_ .

----------------------------------------------------------------
Libraries for GopherLua
Expand All @@ -868,7 +868,7 @@ Libraries for GopherLua
- `gluacrypto <https://github.com/tengattack/gluacrypto>`_ : A native Go implementation of crypto library for the GopherLua VM.
- `gluasql <https://github.com/tengattack/gluasql>`_ : A native Go implementation of SQL client for the GopherLua VM.
- `purr <https://github.com/leyafo/purr>`_ : A http mock testing tool.
- `vadv/gopher-lua-libs <https://github.com/vadv/gopher-lua-libs>`_ : Some usefull libraries for GopherLua VM.
- `vadv/gopher-lua-libs <https://github.com/vadv/gopher-lua-libs>`_ : Some useful libraries for GopherLua VM.
- `gluaperiphery <https://github.com/BixData/gluaperiphery>`_ : A periphery library for the GopherLua VM (GPIO, SPI, I2C, MMIO, and Serial peripheral I/O for Linux).
- `glua-async <https://github.com/CuberL/glua-async>`_ : An async/await implement for gopher-lua.
- `gopherlua-debugger <https://github.com/edolphin-ydf/gopherlua-debugger>`_ : A debugger for gopher-lua
Expand Down
2 changes: 1 addition & 1 deletion _lua5.1-tests/README
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This tarball contains the official test scripts for Lua 5.1.
Unlike Lua itself, these tests do not aim portability, small footprint,
or easy of use. (Their main goal is to try to crash Lua.) They are not
intended for general use. You are wellcome to use them, but expect to
intended for general use. You are welcome to use them, but expect to
have to "dirt your hands".

The tarball should expand in the following contents:
Expand Down
8 changes: 4 additions & 4 deletions _lua5.1-tests/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function pack(...) return arg end

print('testing C API')

-- testing allignment
-- testing alignment
a = T.d2s(12458954321123)
assert(string.len(a) == 8) -- sizeof(double)
assert(T.s2d(a) == 12458954321123)
Expand Down Expand Up @@ -315,7 +315,7 @@ collectgarbage()
assert(type(T.getref(a)) == 'table')


-- colect in cl the `val' of all collected userdata
-- collect in cl the `val' of all collected userdata
tt = {}
cl = {n=0}
A = nil; B = nil
Expand All @@ -333,15 +333,15 @@ F = function (x)
if A ~= nil then
assert(type(A) == "userdata")
assert(T.udataval(A) == B)
debug.getmetatable(A) -- just acess it
debug.getmetatable(A) -- just access it
end
A = x -- ressucita userdata
B = udval
return 1,2,3
end
tt.__gc = F

-- test whether udate collection frees memory in the right time
-- test whether update collection frees memory in the right time
do
collectgarbage();
collectgarbage();
Expand Down
2 changes: 1 addition & 1 deletion _lua5.1-tests/closure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ end
assert(a == 5^4)


-- access to locals of collected corroutines
-- access to locals of collected coroutines
--[[
local C = {}; setmetatable(C, {__mode = "kv"})
local x = coroutine.wrap (function ()
Expand Down
2 changes: 1 addition & 1 deletion _lua5.1-tests/db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ t[1] = "'error'"
checktraceback(co, t)


-- test acessing line numbers of a coroutine from a resume inside
-- test accessing line numbers of a coroutine from a resume inside
-- a C function (this is a known bug in Lua 5.0)

local function g(x)
Expand Down
2 changes: 1 addition & 1 deletion _lua5.1-tests/gc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ do
assert(getmetatable(o) == tt)
-- create new objects during GC
local a = 'xuxu'..(10+3)..'joao', {}
___Glob = o -- ressurect object!
___Glob = o -- resurrect object!
newproxy(o) -- creates a new one with same metatable
print(">>> closing state " .. "<<<\n")
end
Expand Down
2 changes: 1 addition & 1 deletion _lua5.1-tests/locals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ if rawget(_G, "querytab") then
local t = querytab(a)

for k,_ in pairs(a) do a[k] = nil end
collectgarbage() -- restore GC and collect dead fiels in `a'
collectgarbage() -- restore GC and collect dead fields in `a'
for i=0,t-1 do
local k = querytab(a, i)
assert(k == nil or type(k) == 'number' or k == 'alo')
Expand Down
2 changes: 1 addition & 1 deletion _lua5.1-tests/math.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ stat(a)

a = nil

-- testing implicit convertions
-- testing implicit conversions

local a,b = '10', '20'
assert(a*b == 200 and a+b == 30 and a-b == -10 and a/b == 0.5 and -b == -20)
Expand Down
4 changes: 2 additions & 2 deletions _lua5.1-tests/pm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ a,b = string.find('alo', '')
assert(a == 1 and b == 0)
a,b = string.find('a\0o a\0o a\0o', 'a', 1) -- first position
assert(a == 1 and b == 1)
a,b = string.find('a\0o a\0o a\0o', 'a\0o', 2) -- starts in the midle
a,b = string.find('a\0o a\0o a\0o', 'a\0o', 2) -- starts in the middle
assert(a == 5 and b == 7)
a,b = string.find('a\0o a\0o a\0o', 'a\0o', 9) -- starts in the midle
a,b = string.find('a\0o a\0o a\0o', 'a\0o', 9) -- starts in the middle
assert(a == 9 and b == 11)
a,b = string.find('a\0a\0a\0a\0\0ab', '\0ab', 2); -- finds at the end
assert(a == 9 and b == 11);
Expand Down
2 changes: 1 addition & 1 deletion _state.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ func (ls *LState) frameFuncName(fr *callFrame) (string, bool) {
if ls.Parent == nil {
return "main chunk", true
} else {
return "corountine", true
return "coroutine", true
}
}
if !frame.Fn.IsG {
Expand Down
2 changes: 1 addition & 1 deletion compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ func patchCode(context *funcContext) { // {{{
}
}

// bulk move optimization(reducing op dipatch costs)
// bulk move optimization(reducing op dispatch costs)
if curop == OP_MOVE {
moven++
} else {
Expand Down
8 changes: 4 additions & 4 deletions iolib.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func ioInput(L *LState) int {
}

}
L.ArgError(1, "string or file expedted, but got "+L.Get(1).Type().String())
L.ArgError(1, "string or file expected, but got "+L.Get(1).Type().String())
return 0
}

Expand Down Expand Up @@ -613,7 +613,7 @@ func ioLines(L *LState) int {
return 1
}

var ioOpenOpions = []string{"r", "rb", "w", "wb", "a", "ab", "r+", "rb+", "w+", "wb+", "a+", "ab+"}
var ioOpenOptions = []string{"r", "rb", "w", "wb", "a", "ab", "r+", "rb+", "w+", "wb+", "a+", "ab+"}

func ioOpenFile(L *LState) int {
path := L.CheckString(1)
Expand All @@ -624,7 +624,7 @@ func ioOpenFile(L *LState) int {
perm := 0600
writable := true
readable := true
switch ioOpenOpions[L.CheckOption(2, ioOpenOpions)] {
switch ioOpenOptions[L.CheckOption(2, ioOpenOptions)] {
case "r", "rb":
mode = os.O_RDONLY
writable = false
Expand Down Expand Up @@ -735,7 +735,7 @@ func ioOutput(L *LState) int {
}

}
L.ArgError(1, "string or file expedted, but got "+L.Get(1).Type().String())
L.ArgError(1, "string or file expected, but got "+L.Get(1).Type().String())
return 0
}

Expand Down
12 changes: 6 additions & 6 deletions parse/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,23 +510,23 @@ func dump(node interface{}, level int, s string) string {
case reflect.Ptr:
vt := rv.Elem()
tt := rt.Elem()
indicies := []int{}
indices := []int{}
for i := 0; i < tt.NumField(); i++ {
if strings.Index(tt.Field(i).Name, "Base") > -1 {
continue
}
indicies = append(indicies, i)
indices = append(indices, i)
}
switch {
case len(indicies) == 0:
case len(indices) == 0:
return strings.Repeat(s, level) + "<empty>"
case len(indicies) == 1 && isInlineDumpNode(vt.Field(indicies[0])):
for _, i := range indicies {
case len(indices) == 1 && isInlineDumpNode(vt.Field(indices[0])):
for _, i := range indices {
buf = append(buf, strings.Repeat(s, level)+"- Node$"+tt.Name()+": "+dump(vt.Field(i).Interface(), 0, s))
}
default:
buf = append(buf, strings.Repeat(s, level)+"- Node$"+tt.Name())
for _, i := range indicies {
for _, i := range indices {
if isInlineDumpNode(vt.Field(i)) {
inf := dump(vt.Field(i).Interface(), 0, s)
buf = append(buf, strings.Repeat(s, level+1)+tt.Field(i).Name+": "+inf)
Expand Down
2 changes: 1 addition & 1 deletion parse/parser.go.y
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ stat:
$$ = &ast.AssignStmt{Lhs: $1, Rhs: $3}
$$.SetLine($1[0].Line())
} |
/* 'stat = functioncal' causes a reduce/reduce conflict */
/* 'stat = functioncall' causes a reduce/reduce conflict */
prefixexp {
if _, ok := $1.(*ast.FuncCallExpr); !ok {
yylex.(*Lexer).Error("parse error")
Expand Down
2 changes: 1 addition & 1 deletion pm/pm.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (e *Error) Error() string {
type MatchData struct {
// captured positions
// layout
// xxxx xxxx xxxx xxx0 : caputured positions
// xxxx xxxx xxxx xxx0 : captured positions
// xxxx xxxx xxxx xxx1 : position captured positions
captures []uint32
}
Expand Down
12 changes: 6 additions & 6 deletions script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ func testScriptDir(t *testing.T, tests []string, directory string) {
}
}

var numActiveUserDatas int32 = 0
var numActiveUserData int32 = 0

type finalizerStub struct{ x byte }

func allocFinalizerUserData(L *LState) int {
ud := L.NewUserData()
atomic.AddInt32(&numActiveUserDatas, 1)
atomic.AddInt32(&numActiveUserData, 1)
a := finalizerStub{}
ud.Value = &a
runtime.SetFinalizer(&a, func(aa *finalizerStub) {
atomic.AddInt32(&numActiveUserDatas, -1)
atomic.AddInt32(&numActiveUserData, -1)
})
L.Push(ud)
return 1
Expand All @@ -106,11 +106,11 @@ func sleep(L *LState) int {
}

func countFinalizers(L *LState) int {
L.Push(LNumber(numActiveUserDatas))
L.Push(LNumber(numActiveUserData))
return 1
}

// TestLocalVarFree verifies that tables and user user datas which are no longer referenced by the lua script are
// TestLocalVarFree verifies that tables and user data which are no longer referenced by the lua script are
// correctly gc-ed. There was a bug in gopher lua where local vars were not being gc-ed in all circumstances.
func TestLocalVarFree(t *testing.T) {
s := `
Expand All @@ -127,7 +127,7 @@ func TestLocalVarFree(t *testing.T) {
end
sleep(100)
end
error("user datas not finalized after 100 gcs")
error("user data not finalized after 100 gcs")
`
L := NewState()
L.SetGlobal("allocFinalizer", L.NewFunction(allocFinalizerUserData))
Expand Down
2 changes: 1 addition & 1 deletion state.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ func (ls *LState) frameFuncName(fr *callFrame) (string, bool) {
if ls.Parent == nil {
return "main chunk", true
} else {
return "corountine", true
return "coroutine", true
}
}
if !frame.Fn.IsG {
Expand Down
4 changes: 2 additions & 2 deletions state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func TestContextCancel(t *testing.T) {
errorIfFalse(t, strings.Contains(err.Error(), "context canceled"), "execution must be canceled")
}

func TestContextWithCroutine(t *testing.T) {
func TestContextWithCoroutine(t *testing.T) {
L := NewState()
defer L.Close()
ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -469,7 +469,7 @@ func TestPCallAfterFail(t *testing.T) {
})
L.Push(changeError)
err := L.PCall(0, 0, nil)
errorIfFalse(t, strings.Contains(err.Error(), "A New Error"), "error not propogated correctly")
errorIfFalse(t, strings.Contains(err.Error(), "A New Error"), "error not propagated correctly")
}

func TestRegistryFixedOverflow(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions stringlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ func strGsub(L *LState) int {
}

type replaceInfo struct {
Indicies []int
String string
Indices []int
String string
}

func checkCaptureIndex(L *LState, m *pm.MatchData, idx int) {
Expand Down Expand Up @@ -205,9 +205,9 @@ func strGsubDoReplace(str string, info []replaceInfo) string {
buf := []byte(str)
for _, replace := range info {
oldlen := len(buf)
b1 := append([]byte(""), buf[0:offset+replace.Indicies[0]]...)
b1 := append([]byte(""), buf[0:offset+replace.Indices[0]]...)
b2 := []byte("")
index2 := offset + replace.Indicies[1]
index2 := offset + replace.Indices[1]
if index2 <= len(buf) {
b2 = append(b2, buf[index2:len(buf)]...)
}
Expand Down