Skip to content

Commit

Permalink
backport changes from php7 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
iliaal committed Jun 23, 2016
1 parent 25d267d commit 7c3d4f9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ if test "$PHP_EXCEL" != "no"; then
-L$EXCEL_LIBDIR
])

PHP_CHECK_LIBRARY(xl,xlBookSetKeyA,
[
AC_DEFINE(HAVE_LIBXL_SETKEY,1,[ ])
],[],[])

if test `grep -c FILLPATTERN_HORSTRIPE $EXCEL_INCDIR/enum.h` -eq 1; then
AC_DEFINE(HAVE_LIBXL_243_PLUS,1,[ ])
fi
Expand Down
1 change: 1 addition & 0 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if (PHP_EXCEL != "no") {
EXTENSION("excel", "excel.c");
AC_DEFINE('HAVE_EXCELLIB', 1, 'Have LibXL library');
AC_DEFINE('HAVE_LIBXL_243_PLUS', 1, 'Have LibXL version 2.4.3 or later');
AC_DEFINE("HAVE_LIBXL_SETKEY", 1, "non-source libxl build");
AC_DEFINE("EXCEL_WITH_LIBXML", 1, "libxml support");
} else {
WARNING("excel not enabled; libraries and headers not found");
Expand Down
20 changes: 20 additions & 0 deletions excel.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ ZEND_DECLARE_MODULE_GLOBALS(excel)
static PHP_GINIT_FUNCTION(excel);

PHP_INI_BEGIN()
#if defined(HAVE_LIBXL_SETKEY)
STD_PHP_INI_ENTRY("excel.license_name", NULL, PHP_INI_ALL, OnUpdateString, ini_license_name, zend_excel_globals, excel_globals)
STD_PHP_INI_ENTRY("excel.license_key", NULL, PHP_INI_ALL, OnUpdateString, ini_license_key, zend_excel_globals, excel_globals)
#endif
STD_PHP_INI_ENTRY("excel.skip_empty", "0", PHP_INI_ALL, OnUpdateLong, ini_skip_empty, zend_excel_globals, excel_globals)
PHP_INI_END()

Expand Down Expand Up @@ -387,6 +389,19 @@ static wchar_t * _php_excel_to_wide(const char *string, size_t len, size_t *out_
#define EXCEL_METHOD(class_name, function_name) \
PHP_METHOD(Excel ## class_name, function_name)


/* {{{ proto bool ExcelBook::requiresKey()
true if license key is required. */
EXCEL_METHOD(Book, requiresKey)
{
#if defined(HAVE_LIBXL_SETKEY)
RETURN_BOOL(1);
#else
RETURN_BOOL(0);
#endif
}
/* }}} */

/* {{{ proto bool ExcelBook::load(string data)
Load Excel data string. */
EXCEL_METHOD(Book, load)
Expand Down Expand Up @@ -1240,6 +1255,7 @@ EXCEL_METHOD(Book, __construct)
RETURN_FALSE;
}
#endif
#if defined(HAVE_LIBXL_SETKEY)
if (!name_len) {
if (INI_STR("excel.license_name") && INI_STR("excel.license_key")) {
name = INI_STR("excel.license_name");
Expand All @@ -1252,6 +1268,7 @@ EXCEL_METHOD(Book, __construct)
#endif
}
}
#endif

BOOK_FROM_OBJECT(book, object);
#ifdef LIBXL_VERSION
Expand All @@ -1263,6 +1280,9 @@ EXCEL_METHOD(Book, __construct)
} else {
RETURN_FALSE;
}
#if !defined(HAVE_LIBXL_SETKEY)
return;
#endif
if (!name_len && !key_len) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/088.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool(true)
bool(false)
bool(false)
bool(false)
string(5) "=3+4"
string(1) ""
string(2) "3"
string(4) "=3+4"
string(0) ""
string(1) "3"
OK

0 comments on commit 7c3d4f9

Please sign in to comment.