Commit Graph

1112 Commits

Author SHA1 Message Date
Benjamin P. Jung
4cc5f4270d Merge pull request #14 from Enyby/patch-6
Fix for proper print OP_SETLIST additional opcode

Closes #7
2018-09-14 12:12:10 +02:00
Enyby
75fa98d13f Fix format float numbers
Fix bug: https://sourceforge.net/p/luaj/bugs/53/ if System support String.format or fallback to old way.
2018-09-14 02:16:42 +03:00
Enyby
a627a868d5 Fix build stack traceback in DebugLib #7
If create huge table with a lot items (> 28000) then additional op code for store `c` out of range of op codes and this loop crash.
This PR add case for OP_SETLIST for skip next op if in it stored `c`.
OP_SETLIST not AMode OP 
70cb74b4d6/src/core/org/luaj/vm2/Lua.java (L319)
70cb74b4d6/src/core/org/luaj/vm2/Lua.java (L335)
2018-09-14 02:13:21 +03:00
Enyby
f073919f64 Print any code 2018-09-14 02:09:43 +03:00
Enyby
27a1dcdd11 Fix gmatch for pass testsuites
Test suites from lua.org:
```
-- tests for gmatch
local a = 0
for i in string.gmatch('abcde', '()') do assert(i == a+1); a=i end
assert(a==6)

t = {n=0}
for w in string.gmatch("first second word", "%w+") do
      t.n=t.n+1; t[t.n] = w
end
assert(t[1] == "first" and t[2] == "second" and t[3] == "word")

t = {3, 6, 9}
for i in string.gmatch ("xuxx uu ppar r", "()(.)%2") do
  assert(i == table.remove(t, 1))
end
assert(#t == 0)

t = {}
for i,j in string.gmatch("13 14 10 = 11, 15= 16, 22=23", "(%d+)%s*=%s*(%d+)") do
  t[tonumber(i)] = tonumber(j)
end
a = 0
for k,v in pairs(t) do assert(k+1 == v+0); a=a+1 end
assert(a == 3)


-- tests for `%f' (`frontiers')

assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x")
assert(string.gsub("[[]] [][] [[[[", "%f[[].", "x") == "x[]] x]x] x[[[")
assert(string.gsub("01abc45de3", "%f[%d]", ".") == ".01abc.45de.3")
assert(string.gsub("01abc45 de3x", "%f[%D]%w", ".") == "01.bc45 de3.")
assert(string.gsub("function", "%f[\1-\255]%w", ".") == ".unction")
assert(string.gsub("function", "%f[^\1-\255]", ".") == "function.")

assert(string.find("a", "%f[a]") == 1)
assert(string.find("a", "%f[^%z]") == 1)
assert(string.find("a", "%f[^%l]") == 2)
assert(string.find("aba", "%f[a%z]") == 3)
assert(string.find("aba", "%f[%z]") == 4)
assert(not string.find("aba", "%f[%l%z]"))
assert(not string.find("aba", "%f[^%l%z]"))

local i, e = string.find(" alo aalo allo", "%f[%S].-%f[%s].-%f[%S]")
assert(i == 2 and e == 5)
local k = string.match(" alo aalo allo", "%f[%S](.-%f[%s].-%f[%S])")
assert(k == 'alo ')

local a = {1, 5, 9, 14, 17,}
for k in string.gmatch("alo alo th02 is 1hat", "()%f[%w%d]") do
  assert(table.remove(a, 1) == k)
end
assert(#a == 0)
```
Code from lua:
https://www.lua.org/source/5.2/lstrlib.c.html
```
static int gmatch_aux (lua_State *L) {
  MatchState ms;
  size_t ls, lp;
  const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
  const char *p = lua_tolstring(L, lua_upvalueindex(2), &lp);
  const char *src;
  ms.L = L;
  ms.matchdepth = MAXCCALLS;
  ms.src_init = s;
  ms.src_end = s+ls;
  ms.p_end = p + lp;
  for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
       src <= ms.src_end;
       src++) {
    const char *e;
    ms.level = 0;
    lua_assert(ms.matchdepth == MAXCCALLS);
    if ((e = match(&ms, src, p)) != NULL) {
      lua_Integer newstart = e-s;
      if (e == src) newstart++;  /* empty match? go at least one position */
      lua_pushinteger(L, newstart);
      lua_replace(L, lua_upvalueindex(3));
      return push_captures(&ms, src, e);
    }
  }
  return 0;  /* not found */
}
```
On empty match need increase string offset.
2018-09-14 02:04:56 +03:00
Enyby
b459724103 Fix for proper print OP_SETLIST additional opcode #7 2018-09-14 01:59:35 +03:00
Benjamin P. Jung
3d22990e3c Migrate CVS project to Git
* Delete .svnignore and move stuff to .gitignore
* Add note to README to show that this is an inofficial fork as of now.
* Change file suffix of README file from .html to .md for better
  Github integration and readability
2018-09-13 11:56:02 +02:00
James Roseborough
194b776317 Add synchronization to CoerceJavaToLua.COERCIONS map. 2018-09-13 11:53:24 +02:00
James Roseborough
828e4be019 Fix JsePlatform.luaMain() to provide an "arg" table in the chunk's environment. 2018-09-13 11:53:00 +02:00
James Roseborough
ebe45e4a8a Add back sample code into distro. 2015-04-30 05:27:55 +00:00
James Roseborough
a55bf97064 Include new server classes in javadoc. 2015-04-29 15:26:30 +00:00
James Roseborough
08dfdf1434 Fix os.time() conversions for pm times. 2015-04-28 23:06:40 +00:00
James Roseborough
4c3d0f9cdd Revert change that removed default traceback in debug builds. 2015-04-23 03:25:30 +00:00
James Roseborough
cdc33ab5b6 Add test to detect class load order issues and fix load order bug in lua string class. 2015-04-21 14:19:18 +00:00
James Roseborough
5bab91f715 Update grammer spec link 2015-04-18 16:31:29 +00:00
James Roseborough
9bb16ded8f Update links to grammar specs 2015-04-18 16:30:09 +00:00
James Roseborough
c41c28d7ea Move online docs to http://luaj.org/luaj/3.0/api/ 2015-04-18 16:22:36 +00:00
James Roseborough
e7940fd3a2 Correct release not comment 2015-04-18 16:08:51 +00:00
James Roseborough
cdbb46f497 Extend ant build script to produce snapshot releases. 2015-04-18 05:45:14 +00:00
James Roseborough
e866bd45ed Extend reach of .cvsignore file 2015-04-17 03:05:51 +00:00
James Roseborough
b545646922 Add utilities and sample code to load luaj in custom class loader for strong sandboxing, and use of orphaned threads. 2015-04-17 02:59:50 +00:00
James Roseborough
70f7859cee Fix links in javadoc 2015-04-16 04:56:03 +00:00
James Roseborough
f3fb9a7fde Fix javadoc comments. 2015-04-15 05:07:43 +00:00
James Roseborough
ef008fca5e Improve links in javadoc comments. 2015-04-15 05:02:57 +00:00
James Roseborough
1cbe99d3c5 Remove unused code 2015-04-15 03:18:59 +00:00
James Roseborough
7f5d052faa Add samplesandboxed.lua script to demonstrate sandboxing in lua. 2015-04-11 23:36:48 +00:00
James Roseborough
b16c521f40 Fix message when disallowing plain setmetatable for non-tables. 2015-04-11 23:07:08 +00:00
James Roseborough
977353080c Turn off traceback by default. Use xpcall with debug.traceback instead. 2015-04-11 23:06:16 +00:00
James Roseborough
2c50d505eb Add SampleSandboxed.java sample code to illustrate sandboxing. 2015-04-06 05:18:52 +00:00
James Roseborough
57888814df Correct userdata usage in debug lib. 2015-04-05 21:02:10 +00:00
James Roseborough
878bf5ac78 Improve string lib factoring, javadoc on lib loading functions. 2015-04-05 16:19:13 +00:00
James Roseborough
591de13a46 Move hook function state to LuaThread.State class. 2015-03-22 16:54:56 +00:00
James Roseborough
450692d130 Add blank initializers to all Prototypes. 2015-03-22 16:54:12 +00:00
James Roseborough
d0e0fd4445 Add function to Print to print only stack. 2015-03-22 16:53:35 +00:00
James Roseborough
ba43e15e72 Add ReadOnlyTable and ReadWriteShadowTable, add sandboxing example code, make string metatable a real metatable. 2015-03-22 00:36:44 +00:00
James Roseborough
85381770a7 ix os.date("*t") to return hour in 24 hour format (fixes issue #45) 2015-03-18 16:16:13 +00:00
James Roseborough
87f19030cb Improve synchronization of debug library 2015-03-18 15:52:49 +00:00
James Roseborough
237c384d55 LuaScriptEngineFactory.getScriptEngine() now returns new instance of lua script engine for each call. 2015-03-18 15:07:56 +00:00
James Roseborough
cd9cdc496e Improve collection of orphaned coroutines when yielding from debug hook functions. 2015-03-18 03:16:05 +00:00
James Roseborough
31c13af7b4 Let os.getenv() return System.getenv() values first for JSE, then fall back to properties 2015-03-15 23:23:38 +00:00
James Roseborough
17ffcc6940 Fix aliasing issue for some multiple assignments from varargs return values 2015-03-15 23:23:06 +00:00
James Roseborough
4cf1dca264 Fix aliasing issue for some multiple assignments from varargs return values 2015-03-15 21:32:34 +00:00
James Roseborough
06a9ddbb88 Fix return value for table.remove() and table.insert() 2015-03-15 05:45:50 +00:00
James Roseborough
4c3bb1d709 Add test for balanced match on empty string. 2015-03-14 20:09:09 +00:00
James Roseborough
baccc39c74 Update comment to link to bug number. 2015-03-14 18:42:09 +00:00
James Roseborough
63e99c1500 List keyeq() and keyindex() methods as abstract on LuaTable.Entry. 2015-03-14 18:12:13 +00:00
James Roseborough
8c8c98fb00 Allow access to Java inner classes using lua field syntax. 2015-03-14 17:53:55 +00:00
James Roseborough
6bde11639c Let collectgarbage() behave as collectgarbage("collect") 2015-03-14 16:32:38 +00:00
James Roseborough
c8e4bea43d Improve string byte backing ownership, add gradle file, up version, improve build packaging rules. 2015-03-09 06:32:54 +00:00
James Roseborough
71500e7d8d Allow error() function to pass any lua object including non-strings. 2015-03-08 20:29:37 +00:00