diff options
author | Remi Collet <fedora@famillecollet.com> | 2015-03-28 12:05:47 +0100 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2015-03-28 12:05:47 +0100 |
commit | 4decaf547f0082b4bfb32e4caeec4530729a3e48 (patch) | |
tree | f319d67a658abcdd0421573536e3e45bb277c8e5 | |
parent | 711b87589b1a83f076d35b9ede5048ddc02d61be (diff) |
php-pecl-termbox: add fix for PHP 7
-rw-r--r-- | php-pecl-termbox.spec | 29 | ||||
-rw-r--r-- | termbox-php7.patch | 145 |
2 files changed, 167 insertions, 7 deletions
diff --git a/php-pecl-termbox.spec b/php-pecl-termbox.spec index 6e97532..7f0cec9 100644 --- a/php-pecl-termbox.spec +++ b/php-pecl-termbox.spec @@ -2,7 +2,7 @@ # # Copyright (c) 2014-2015 Remi Collet # License: CC-BY-SA -# http://creativecommons.org/licenses/by-sa/3.0/ +# http://creativecommons.org/licenses/by-sa/4.0/ # # Please, preserve the changelog entries # @@ -23,12 +23,15 @@ Summary: A termbox wrapper for PHP Name: %{?scl_prefix}php-pecl-%{pecl_name} Version: 0.1.2 -Release: 1%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}.1 +Release: 2%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} License: ASL 2.0 Group: Development/Languages URL: http://pecl.php.net/package/%{pecl_name} Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz +# Upstream patch +Patch0: %{pecl_name}-php7.patch + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: termbox-devel BuildRequires: %{?scl_prefix}php-devel @@ -36,8 +39,6 @@ BuildRequires: %{?scl_prefix}php-pear # For tests BuildRequires: %{?scl_prefix}php-mbstring -Requires(post): %{__pecl} -Requires(postun): %{__pecl} Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} Requires: %{?scl_prefix}php(api) = %{php_core_api} %{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}} @@ -88,6 +89,8 @@ sed -e '/role="test"/d' -i package.xml cd NTS +%patch0 -p1 -b .php7 + # Sanity check, really often broken extver=$(sed -n '/#define PHP_TERMBOX_VERSION/{s/.* "//;s/".*$//;p}' php_termbox.h) if test "x${extver}" != "x%{version}"; then @@ -147,12 +150,20 @@ do install -Dpm 644 NTS/$i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i done -%post -%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : +# when pear installed alone, after us +%triggerin -- %{?scl_prefix}php-pear +if [ -x %{__pecl} ] ; then + %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : +fi +# posttrans as pear can be installed after us +%posttrans +if [ -x %{__pecl} ] ; then + %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : +fi %postun -if [ $1 -eq 0 ] ; then +if [ $1 -eq 0 -a -x %{__pecl} ] ; then %{pecl_uninstall} %{pecl_name} >/dev/null || : fi @@ -211,6 +222,10 @@ rm -rf %{buildroot} %changelog +* Sat Mar 28 2015 Remi Collet <remi@fedoraproject.org> - 0.1.2-2 +- add fix for PHP 7 +- drop runtime dependency on pear, new scriptlets + * Wed Dec 24 2014 Remi Collet <remi@fedoraproject.org> - 0.1.2-1.1 - Fedora 21 SCL mass rebuild diff --git a/termbox-php7.patch b/termbox-php7.patch new file mode 100644 index 0000000..2eb0608 --- /dev/null +++ b/termbox-php7.patch @@ -0,0 +1,145 @@ +From 02a7c1c0a05614bd42e9d624aeda3be90d476f3a Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@php.net> +Date: Sat, 28 Mar 2015 11:56:23 +0100 +Subject: [PATCH] PHP 7 compatibility + +--- + php_termbox.h | 10 ++++++++++ + termbox.c | 30 +++++++++++++++++------------- + 2 files changed, 27 insertions(+), 13 deletions(-) + +diff --git a/php_termbox.h b/php_termbox.h +index 179dcd3..c21ac75 100644 +--- a/php_termbox.h ++++ b/php_termbox.h +@@ -89,6 +89,16 @@ PHP_FUNCTION(termbox_last_error); + #define TERMBOX_G(v) (termbox_globals.v) + #endif + ++#if PHP_MAJOR_VERSION < 7 ++typedef long zend_long; ++typedef int strsize; ++#define TERMBOX_RETSTRL(a,l) RETURN_STRINGL(a,l,1) ++#else ++typedef size_t strsize; ++#define TSRMLS_CC ++#define TERMBOX_RETSTRL(a,l) RETURN_STRINGL(a,l) ++#endif ++ + #endif /* PHP_TERMBOX_H */ + + /* +diff --git a/termbox.c b/termbox.c +index 0b51b0f..575b5dd 100644 +--- a/termbox.c ++++ b/termbox.c +@@ -149,8 +149,7 @@ PHP_MINIT_FUNCTION(termbox) + ZEND_INIT_MODULE_GLOBALS(termbox, _termbox_init_globals, NULL); + + /** Register constants */ +- #define PHP_TERMBOX_CONSTANT(NAME) \ +- zend_register_long_constant(#NAME, sizeof(#NAME), NAME, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC); ++ #define PHP_TERMBOX_CONSTANT(NAME) REGISTER_LONG_CONSTANT(#NAME, NAME, CONST_CS | CONST_PERSISTENT); + #include "constants.h" + #undef PHP_TERMBOX_CONSTANT + return SUCCESS; +@@ -262,7 +261,8 @@ PHP_FUNCTION(termbox_clear) + initialized yet. */ + PHP_FUNCTION(termbox_set_clear_attributes) + { +- long fg, bg; ++ zend_long fg, bg; ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &fg, &bg) == FAILURE) { + return; + } +@@ -292,7 +292,8 @@ PHP_FUNCTION(termbox_present) + Cursor is hidden by default. Return FALSE if not initialized yet. */ + PHP_FUNCTION(termbox_set_cursor) + { +- long x, y; ++ zend_long x, y; ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &x, &y) == FAILURE) { + return; + } +@@ -307,7 +308,8 @@ PHP_FUNCTION(termbox_set_cursor) + position. Return FALSE if not initialized yet. */ + PHP_FUNCTION(termbox_change_cell) + { +- long x, y, ch, fg, bg; ++ zend_long x, y, ch, fg, bg; ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllll", &x, &y, &ch, &fg, &bg) == FAILURE) { + return; + } +@@ -322,7 +324,8 @@ PHP_FUNCTION(termbox_change_cell) + if not yet initialized. */ + PHP_FUNCTION(termbox_set_input_mode) + { +- long mode; ++ zend_long mode; ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + return; + } +@@ -354,7 +357,8 @@ PHP_FUNCTION(termbox_get_input_mode) { + yet initialized. */ + PHP_FUNCTION(termbox_set_output_mode) + { +- long mode; ++ zend_long mode; ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + return; + } +@@ -398,7 +402,7 @@ static void _termbox_event_to_php_array(struct tb_event *event, zval *event_arr) + NULL. If an error occurrs, return FALSE. */ + PHP_FUNCTION(termbox_peek_event) + { +- long timeout_ms; ++ zend_long timeout_ms; + struct tb_event event; + int rc; + +@@ -449,7 +453,7 @@ PHP_FUNCTION(termbox_poll_event) + PHP_FUNCTION(termbox_utf8_char_to_unicode) + { + char *str; +- int str_len; ++ strsize str_len; + uint32_t unicode_int; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { +@@ -470,7 +474,7 @@ PHP_FUNCTION(termbox_utf8_unicode_to_char) + { + char str[7]; + int str_len; +- long unicode; ++ zend_long unicode; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &unicode) == FAILURE) { + return; +@@ -483,7 +487,7 @@ PHP_FUNCTION(termbox_utf8_unicode_to_char) + str_len = 0; + } + +- RETURN_STRINGL(str, str_len, 1); ++ TERMBOX_RETSTRL(str, str_len); + } + /* }}} */ + +@@ -493,8 +497,8 @@ PHP_FUNCTION(termbox_utf8_unicode_to_char) + PHP_FUNCTION(termbox_print) + { + char *str; +- int str_len; +- long x, y, fg, bg; ++ strsize str_len; ++ zend_long x, y, fg, bg; + uint32_t unicode; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sllll", &str, &str_len, &x, &y, &fg, &bg) == FAILURE) { +-- +2.1.4 + |