diff options
author | Mike Pall <mike> | 2017-01-17 11:37:28 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2017-01-17 11:37:28 +0100 |
commit | c1981676907cedde9ffe2bbdfb28d2f786ff69d9 (patch) | |
tree | 08fec89b79040b758cc4473163a5e40dbe355799 /src/lib_table.c | |
parent | ed4ce98ac1471a1d8a4f50486adb29771dcab9f2 (diff) | |
download | luajit-c1981676907cedde9ffe2bbdfb28d2f786ff69d9.tar.gz luajit-c1981676907cedde9ffe2bbdfb28d2f786ff69d9.tar.bz2 luajit-c1981676907cedde9ffe2bbdfb28d2f786ff69d9.zip |
Add some more extensions from Lua 5.2/5.3.
Contributed by François Perrad.
Diffstat (limited to 'src/lib_table.c')
-rw-r--r-- | src/lib_table.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib_table.c b/src/lib_table.c index f9a3693d..0204f25d 100644 --- a/src/lib_table.c +++ b/src/lib_table.c | |||
@@ -129,6 +129,26 @@ LJLIB_LUA(table_remove) /* | |||
129 | end | 129 | end |
130 | */ | 130 | */ |
131 | 131 | ||
132 | LJLIB_LUA(table_move) /* | ||
133 | function(a1, f, e, t, a2) | ||
134 | CHECK_tab(a1) | ||
135 | CHECK_int(f) | ||
136 | CHECK_int(e) | ||
137 | CHECK_int(t) | ||
138 | if a2 == nil then a2 = a1 end | ||
139 | CHECK_tab(a2) | ||
140 | if e >= f then | ||
141 | local d = t - f | ||
142 | if t > e or t <= f or a2 ~= a1 then | ||
143 | for i=f,e do a2[i+d] = a1[i] end | ||
144 | else | ||
145 | for i=e,f,-1 do a2[i+d] = a1[i] end | ||
146 | end | ||
147 | end | ||
148 | return a2 | ||
149 | end | ||
150 | */ | ||
151 | |||
132 | LJLIB_CF(table_concat) LJLIB_REC(.) | 152 | LJLIB_CF(table_concat) LJLIB_REC(.) |
133 | { | 153 | { |
134 | GCtab *t = lj_lib_checktab(L, 1); | 154 | GCtab *t = lj_lib_checktab(L, 1); |