Show actual enchant version if possible

As of libenchant 1.6.0 there is enchant_get_version()[1], so we use it,
if available, to show the actual enchant version in the PHP info.  We
also drop the fake ENCHANT_VERSION_STRING altogether, but stick with
showing version 1.5.x if at least HAVE_ENCHANT_BROKER_SET_PARAM is
defined.

Future scope: we may consider requiring enchant 1.6.0 (or later), since
this has been released in April 2010, and likely is available
everywhere.

[1] <https://www.abisource.com/projects/enchant/>
This commit is contained in:
Christoph M. Becker 2019-06-27 13:04:49 +02:00
parent e7446c1b2d
commit 218c18530a
3 changed files with 11 additions and 4 deletions

View File

@ -11,10 +11,16 @@ if test "$PHP_ENCHANT" != "no"; then
AC_DEFINE(HAVE_ENCHANT, 1, [ ])
PHP_CHECK_LIBRARY(enchant, enchant_get_version,
[
AC_DEFINE(HAVE_ENCHANT_GET_VERSION, 1, [ ])
], [ ], [
$ENCHANT_LIBS
])
PHP_CHECK_LIBRARY(enchant, enchant_broker_set_param,
[
AC_DEFINE(HAVE_ENCHANT_BROKER_SET_PARAM, 1, [ ])
AC_DEFINE(ENCHANT_VERSION_STRING, "1.5.x", [ ])
], [ ], [
$ENCHANT_LIBS
])

View File

@ -8,6 +8,7 @@ if (PHP_ENCHANT == "yes") {
CHECK_LIB("libenchant.lib", "enchant", PHP_ENCHANT) ) {
EXTENSION("enchant", "enchant.c");
AC_DEFINE('HAVE_ENCHANT', 1, 'Have Enchant support', false);
AC_DEFINE('HAVE_ENCHANT_GET_VERSION', 1);
AC_DEFINE('HAVE_ENCHANT_BROKER_SET_PARAM', 1);
ADD_FLAG("CFLAG_ENCHANT", "/D _WIN32");
} else {

View File

@ -315,10 +315,10 @@ PHP_MINFO_FUNCTION(enchant)
pbroker = enchant_broker_init();
php_info_print_table_start();
php_info_print_table_row(2, "enchant support", "enabled");
#ifdef ENCHANT_VERSION_STRING
php_info_print_table_row(2, "Libenchant Version", ENCHANT_VERSION_STRING);
#ifdef HAVE_ENCHANT_GET_VERSION
php_info_print_table_row(2, "Libenchant Version", enchant_get_version());
#elif defined(HAVE_ENCHANT_BROKER_SET_PARAM)
php_info_print_table_row(2, "Libenchant Version", "1.5.0 or later");
php_info_print_table_row(2, "Libenchant Version", "1.5.x");
#endif
php_info_print_table_end();