mirror of
https://github.com/php-win-ext/php-lua.git
synced 2026-03-26 01:52:11 +01:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3d6dca1a0 | ||
|
|
f177b21ff1 | ||
|
|
c7d9844cf1 | ||
|
|
12c53f28eb | ||
|
|
86cb62e0b8 | ||
|
|
dc226c345d | ||
|
|
2d23b565e5 | ||
|
|
6a2bf0e8af | ||
|
|
230a8af900 | ||
|
|
468203ce7c | ||
|
|
aaf49be301 | ||
|
|
1bd4adf039 | ||
|
|
18e2bb493d | ||
|
|
0b28ef4f55 | ||
|
|
d3323aa9fe | ||
|
|
f6a2f09b19 | ||
|
|
6c2a37f99c | ||
|
|
50d32564d2 |
28
.travis.yml
28
.travis.yml
@@ -1,21 +1,23 @@
|
||||
language: php
|
||||
language: php
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- liblua5.2-dev
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
- 5.5
|
||||
- 5.4
|
||||
- 5.3
|
||||
- 5.3.3
|
||||
- 7.0
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y libjson0-dev libjson0 php5-cli php5-dev liblua5.2-dev
|
||||
notifications:
|
||||
email: false
|
||||
irc: "irc.efnet.org#php.yaf"
|
||||
|
||||
env:
|
||||
- REPORT_EXIT_STATUS=1 NO_INTERACTION=1
|
||||
|
||||
#Compile
|
||||
before_script:
|
||||
# Compile PHP
|
||||
- ./travis/compile.sh
|
||||
|
||||
script:
|
||||
- ./travis/build_check.sh
|
||||
|
||||
# Run PHPs run-tests.php
|
||||
script: TEST_PHP_ARGS="--show-diff" make test
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
"Lua is a powerful, fast, light-weight, embeddable scripting language."
|
||||
# PHP Lua
|
||||
[](https://travis-ci.org/laruence/php-lua)
|
||||
|
||||
This extension embeds the lua interpreter and offers an OO-API to lua variables and functions.
|
||||
|
||||
"Lua is a powerful, fast, light-weight, embeddable scripting language."
|
||||
@@ -3,6 +3,8 @@ PHP_ARG_WITH(lua, for lua support,
|
||||
[ --with-lua=[DIR] Include php lua support])
|
||||
PHP_ARG_WITH(lua-version, to specify a custom lua version, [ --with-lua-version=[VERSION]] Use the specified lua version.)
|
||||
|
||||
PHP_ARG_WITH(lua-version, to specify a custom lua version, [ --with-lua-version=[VERSION]] Use the specified lua version.)
|
||||
|
||||
if test "$PHP_LUA" != "no"; then
|
||||
if test -r $PHP_LUA/include/lua.h; then
|
||||
LUA_INCLUDE_DIR=$PHP_LUA/include
|
||||
@@ -15,6 +17,12 @@ if test "$PHP_LUA" != "no"; then
|
||||
break
|
||||
fi
|
||||
|
||||
if test -r $i/include/lua.h; then
|
||||
LUA_INCLUDE_DIR=$i/include
|
||||
AC_MSG_RESULT(found in $i)
|
||||
break
|
||||
fi
|
||||
|
||||
if test "$PHP_LUA_VERSION" != "yes"; then
|
||||
if test -r $i/include/lua$PHP_LUA_VERSION/lua.h; then
|
||||
LUA_INCLUDE_DIR=$i/include/lua$PHP_LUA_VERSION
|
||||
|
||||
30
lua.c
30
lua.c
@@ -436,31 +436,37 @@ int php_lua_send_zval_to_lua(lua_State *L, zval *val) /* {{{ */ {
|
||||
zval_add_ref(val);
|
||||
add_next_index_zval(callbacks, val);
|
||||
} else {
|
||||
zval *v;
|
||||
zval *v;
|
||||
ulong longkey;
|
||||
zend_string *key;
|
||||
zval zkey;
|
||||
zval zkey;
|
||||
|
||||
HashTable *ht = HASH_OF(val);
|
||||
if (++ht->u.v.nApplyCount > 1) {
|
||||
php_error_docref(NULL, E_ERROR, "recursion found");
|
||||
--ht->u.v.nApplyCount;
|
||||
break;
|
||||
if (ZEND_HASH_APPLY_PROTECTION(ht)) {
|
||||
ZEND_HASH_INC_APPLY_COUNT(ht);
|
||||
if (ZEND_HASH_GET_APPLY_COUNT(ht) > 1) {
|
||||
php_error_docref(NULL, E_ERROR, "recursion found");
|
||||
ZEND_HASH_DEC_APPLY_COUNT(ht);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, v) {
|
||||
if (Z_TYPE_P(v) == IS_STRING) {
|
||||
ZEND_HASH_FOREACH_KEY_VAL_IND(ht, longkey, key, v) {
|
||||
if (key) {
|
||||
ZVAL_STR(&zkey, key);
|
||||
}
|
||||
if (Z_TYPE_P(v) == IS_LONG) {
|
||||
ZVAL_LONG(&zkey, Z_LVAL_P(v));
|
||||
} else {
|
||||
ZVAL_LONG(&zkey, longkey);
|
||||
}
|
||||
php_lua_send_zval_to_lua(L, &zkey);
|
||||
php_lua_send_zval_to_lua(L, v);
|
||||
lua_settable(L, -3);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
--ht->u.v.nApplyCount;
|
||||
if (ZEND_HASH_APPLY_PROTECTION(ht)) {
|
||||
ZEND_HASH_DEC_APPLY_COUNT(ht);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
34
package.xml
34
package.xml
@@ -23,17 +23,11 @@
|
||||
<email>msaraujo@php.net</email>
|
||||
<active>yes</active>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Helmut Januschka</name>
|
||||
<user>hjanuschka</user>
|
||||
<email>helmut@januschka.com</email>
|
||||
<active>yes</active>
|
||||
</developer>
|
||||
<date>2015-10-27</date>
|
||||
<time>11:12:27</time>
|
||||
<date>2016-04-11</date>
|
||||
<time>10:50:27</time>
|
||||
<version>
|
||||
<release>2.0.0</release>
|
||||
<api>2.0.0</api>
|
||||
<release>2.0.1</release>
|
||||
<api>2.0.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
@@ -41,7 +35,7 @@
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP</license>
|
||||
<notes>
|
||||
- Release lua for PHP7
|
||||
- Fixed bug #71997 (One-Dimensional arrays cause segmentation faults)
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
@@ -69,6 +63,7 @@
|
||||
<file name="012.phpt" role="test" />
|
||||
<file name="013.phpt" role="test" />
|
||||
<file name="bug65097.phpt" role="test" />
|
||||
<file name="bug71997.phpt" role="test" />
|
||||
</dir>
|
||||
</dir>
|
||||
</contents>
|
||||
@@ -85,6 +80,22 @@
|
||||
<providesextension>lua</providesextension>
|
||||
<extsrcrelease />
|
||||
<changelog>
|
||||
<release>
|
||||
<date>2016-04-11</date>
|
||||
<version>
|
||||
<release>2.0.1</release>
|
||||
<api>2.0.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Fixed bug #71997 (One-Dimensional arrays cause segmentation faults)
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<date>2015-10-27</date>
|
||||
<version>
|
||||
@@ -100,7 +111,6 @@
|
||||
- Release lua for PHP7
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<date>2012-10-23</date>
|
||||
<version>
|
||||
|
||||
@@ -48,7 +48,7 @@ extern zend_module_entry lua_module_entry;
|
||||
#define LUA_G(v) (lua_globals.v)
|
||||
#endif
|
||||
|
||||
#define PHP_LUA_VERSION "2.0.0"
|
||||
#define PHP_LUA_VERSION "2.0.1"
|
||||
|
||||
struct _php_lua_object {
|
||||
lua_State *L;
|
||||
|
||||
22
tests/bug71997.phpt
Normal file
22
tests/bug71997.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Bug #71997 (One-Dimensional arrays cause segmentation faults)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("lua")) print "skip lua extension missing";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$mylua = new \lua();
|
||||
$mylua->eval(<<<CODE
|
||||
function nicefunction(args)
|
||||
print(args[1])
|
||||
return args[1]
|
||||
end
|
||||
CODE
|
||||
);
|
||||
|
||||
echo $mylua->call("nicefunction", array(array('hello', 'world')));
|
||||
?>
|
||||
done
|
||||
--EXPECT--
|
||||
worldworlddone
|
||||
@@ -1,14 +1,2 @@
|
||||
phpize
|
||||
|
||||
./configure --with-lua-version=5.2
|
||||
make
|
||||
EX=$?;
|
||||
if [ $EX != 0 ];
|
||||
then
|
||||
echo "compile failed";
|
||||
exit $EX;
|
||||
fi;
|
||||
|
||||
|
||||
|
||||
exit $EX;
|
||||
#!/bin/sh
|
||||
phpize && ./configure --with-lua-version=5.2 && make
|
||||
|
||||
Reference in New Issue
Block a user