diff options
Diffstat (limited to 'ext/gettext')
-rw-r--r-- | ext/gettext/gettext.c | 84 | ||||
-rw-r--r-- | ext/gettext/gettext.dsp | 113 | ||||
-rw-r--r-- | ext/gettext/php_gettext.h | 5 | ||||
-rw-r--r-- | ext/gettext/tests/gettext_ngettext-wrongparams.phpt | 2 |
4 files changed, 47 insertions, 157 deletions
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c index f55ccdb315..44e8a354a7 100644 --- a/ext/gettext/gettext.c +++ b/ext/gettext/gettext.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ @@ -127,7 +127,7 @@ zend_module_entry php_gettext_module_entry = { NULL, NULL, PHP_MINFO(php_gettext), - NO_VERSION_YET, + PHP_GETTEXT_VERSION, STANDARD_MODULE_PROPERTIES }; @@ -139,14 +139,14 @@ ZEND_GET_MODULE(php_gettext) #define PHP_GETTEXT_MAX_MSGID_LENGTH 4096 #define PHP_GETTEXT_DOMAIN_LENGTH_CHECK \ - if (domain_len > PHP_GETTEXT_MAX_DOMAIN_LENGTH) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "domain passed too long"); \ + if (UNEXPECTED(domain_len > PHP_GETTEXT_MAX_DOMAIN_LENGTH)) { \ + php_error_docref(NULL, E_WARNING, "domain passed too long"); \ RETURN_FALSE; \ } #define PHP_GETTEXT_LENGTH_CHECK(check_name, check_len) \ - if (check_len > PHP_GETTEXT_MAX_MSGID_LENGTH) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s passed too long", check_name); \ + if (UNEXPECTED(check_len > PHP_GETTEXT_MAX_MSGID_LENGTH)) { \ + php_error_docref(NULL, E_WARNING, "%s passed too long", check_name); \ RETURN_FALSE; \ } @@ -162,9 +162,9 @@ PHP_MINFO_FUNCTION(php_gettext) PHP_NAMED_FUNCTION(zif_textdomain) { char *domain, *domain_name, *retval; - int domain_len; + size_t domain_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &domain, &domain_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &domain, &domain_len) == FAILURE) { return; } @@ -178,7 +178,7 @@ PHP_NAMED_FUNCTION(zif_textdomain) retval = textdomain(domain_name); - RETURN_STRING(retval, 1); + RETURN_STRING(retval); } /* }}} */ @@ -186,17 +186,17 @@ PHP_NAMED_FUNCTION(zif_textdomain) Return the translation of msgid for the current domain, or msgid unaltered if a translation does not exist */ PHP_NAMED_FUNCTION(zif_gettext) { - char *msgid, *msgstr; - int msgid_len; + char *msgstr; + zend_string *msgid; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &msgid, &msgid_len) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(msgid) + ZEND_PARSE_PARAMETERS_END(); - PHP_GETTEXT_LENGTH_CHECK("msgid", msgid_len) - msgstr = gettext(msgid); + PHP_GETTEXT_LENGTH_CHECK("msgid", ZSTR_LEN(msgid)) + msgstr = gettext(ZSTR_VAL(msgid)); - RETURN_STRING(msgstr, 1); + RETURN_STRING(msgstr); } /* }}} */ @@ -205,9 +205,9 @@ PHP_NAMED_FUNCTION(zif_gettext) PHP_NAMED_FUNCTION(zif_dgettext) { char *domain, *msgid, *msgstr; - int domain_len, msgid_len; + size_t domain_len, msgid_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &domain, &domain_len, &msgid, &msgid_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &domain, &domain_len, &msgid, &msgid_len) == FAILURE) { return; } @@ -216,7 +216,7 @@ PHP_NAMED_FUNCTION(zif_dgettext) msgstr = dgettext(domain, msgid); - RETURN_STRING(msgstr, 1); + RETURN_STRING(msgstr); } /* }}} */ @@ -225,10 +225,10 @@ PHP_NAMED_FUNCTION(zif_dgettext) PHP_NAMED_FUNCTION(zif_dcgettext) { char *domain, *msgid, *msgstr; - int domain_len, msgid_len; - long category; + size_t domain_len, msgid_len; + zend_long category; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &domain, &domain_len, &msgid, &msgid_len, &category) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssl", &domain, &domain_len, &msgid, &msgid_len, &category) == FAILURE) { return; } @@ -237,7 +237,7 @@ PHP_NAMED_FUNCTION(zif_dcgettext) msgstr = dcgettext(domain, msgid, category); - RETURN_STRING(msgstr, 1); + RETURN_STRING(msgstr); } /* }}} */ @@ -246,10 +246,10 @@ PHP_NAMED_FUNCTION(zif_dcgettext) PHP_NAMED_FUNCTION(zif_bindtextdomain) { char *domain, *dir; - int domain_len, dir_len; + size_t domain_len, dir_len; char *retval, dir_name[MAXPATHLEN]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &domain, &domain_len, &dir, &dir_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &domain, &domain_len, &dir, &dir_len) == FAILURE) { return; } @@ -270,7 +270,7 @@ PHP_NAMED_FUNCTION(zif_bindtextdomain) retval = bindtextdomain(domain, dir_name); - RETURN_STRING(retval, 1); + RETURN_STRING(retval); } /* }}} */ @@ -280,10 +280,10 @@ PHP_NAMED_FUNCTION(zif_bindtextdomain) PHP_NAMED_FUNCTION(zif_ngettext) { char *msgid1, *msgid2, *msgstr; - int msgid1_len, msgid2_len; - long count; + size_t msgid1_len, msgid2_len; + zend_long count; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssl", &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) { return; } @@ -292,7 +292,7 @@ PHP_NAMED_FUNCTION(zif_ngettext) msgstr = ngettext(msgid1, msgid2, count); if (msgstr) { - RETVAL_STRING(msgstr, 1); + RETVAL_STRING(msgstr); } } /* }}} */ @@ -304,10 +304,10 @@ PHP_NAMED_FUNCTION(zif_ngettext) PHP_NAMED_FUNCTION(zif_dngettext) { char *domain, *msgid1, *msgid2, *msgstr = NULL; - int domain_len, msgid1_len, msgid2_len; - long count; + size_t domain_len, msgid1_len, msgid2_len; + zend_long count; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssl", &domain, &domain_len, + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sssl", &domain, &domain_len, &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) { return; } @@ -318,7 +318,7 @@ PHP_NAMED_FUNCTION(zif_dngettext) msgstr = dngettext(domain, msgid1, msgid2, count); if (msgstr) { - RETVAL_STRING(msgstr, 1); + RETVAL_STRING(msgstr); } } /* }}} */ @@ -330,12 +330,12 @@ PHP_NAMED_FUNCTION(zif_dngettext) PHP_NAMED_FUNCTION(zif_dcngettext) { char *domain, *msgid1, *msgid2, *msgstr = NULL; - int domain_len, msgid1_len, msgid2_len; - long count, category; + size_t domain_len, msgid1_len, msgid2_len; + zend_long count, category; RETVAL_FALSE; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssll", &domain, &domain_len, + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sssll", &domain, &domain_len, &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count, &category) == FAILURE) { return; } @@ -347,7 +347,7 @@ PHP_NAMED_FUNCTION(zif_dcngettext) msgstr = dcngettext(domain, msgid1, msgid2, count, category); if (msgstr) { - RETVAL_STRING(msgstr, 1); + RETVAL_STRING(msgstr); } } /* }}} */ @@ -360,9 +360,9 @@ PHP_NAMED_FUNCTION(zif_dcngettext) PHP_NAMED_FUNCTION(zif_bind_textdomain_codeset) { char *domain, *codeset, *retval = NULL; - int domain_len, codeset_len; + size_t domain_len, codeset_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &domain, &domain_len, &codeset, &codeset_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &domain, &domain_len, &codeset, &codeset_len) == FAILURE) { return; } @@ -373,7 +373,7 @@ PHP_NAMED_FUNCTION(zif_bind_textdomain_codeset) if (!retval) { RETURN_FALSE; } - RETURN_STRING(retval, 1); + RETURN_STRING(retval); } /* }}} */ #endif diff --git a/ext/gettext/gettext.dsp b/ext/gettext/gettext.dsp deleted file mode 100644 index 79ea194854..0000000000 --- a/ext/gettext/gettext.dsp +++ /dev/null @@ -1,113 +0,0 @@ -# Microsoft Developer Studio Project File - Name="gettext" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=gettext - Win32 Release_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "gettext.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "gettext.mak" CFG="gettext - Win32 Release_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "gettext - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "gettext - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "gettext - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_GETTEXT" /D ZTS=1 /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GETTEXT_EXPORTS" /D "COMPILE_DL_GETTEXT" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LIBINTL=1 /D HAVE_BIND_TEXTDOMAIN_CODESET=1 /D HAVE_NGETTEXT=1 /D HAVE_DNGETTEXT=1 /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_gettext.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
-# ADD LINK32 php5ts.lib libintl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_gettext.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
-
-!ELSEIF "$(CFG)" == "gettext - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MSSQL_EXPORTS" /D "COMPILE_DL_GETTEXT" /D ZTS=1 /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D HAVE_NGETTEXT=1 /D HAVE_DNGETTEXT=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GETTEXT_EXPORTS" /D "COMPILE_DL_GETTEXT" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LIBINTL=1 /D HAVE_BIND_TEXTDOMAIN_CODESET=1 /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386 /out:"../../Debug_TS/php_gettext.dll" /libpath:"..\..\Debug_TS"
-# ADD LINK32 php5ts_debug.lib libintl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /debug /machine:I386 /out:"../../Debug_TS/php_gettext.dll" /libpath:"..\..\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "gettext - Win32 Release_TS"
-# Name "gettext - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\gettext.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_gettext.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/ext/gettext/php_gettext.h b/ext/gettext/php_gettext.h index 1191b3f0a2..5bde94f2a3 100644 --- a/ext/gettext/php_gettext.h +++ b/ext/gettext/php_gettext.h @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ @@ -26,6 +26,9 @@ extern zend_module_entry php_gettext_module_entry; #define gettext_module_ptr &php_gettext_module_entry +#include "php_version.h" +#define PHP_GETTEXT_VERSION PHP_VERSION + PHP_MINFO_FUNCTION(php_gettext); PHP_NAMED_FUNCTION(zif_textdomain); diff --git a/ext/gettext/tests/gettext_ngettext-wrongparams.phpt b/ext/gettext/tests/gettext_ngettext-wrongparams.phpt index 9003aefcfe..f73e133026 100644 --- a/ext/gettext/tests/gettext_ngettext-wrongparams.phpt +++ b/ext/gettext/tests/gettext_ngettext-wrongparams.phpt @@ -21,7 +21,7 @@ Warning: ngettext() expects parameter 1 to be string, array given in %s on line Warning: ngettext() expects parameter 2 to be string, array given in %s on line 3 -Warning: ngettext() expects parameter 3 to be long, array given in %s on line 4 +Warning: ngettext() expects parameter 3 to be integer, array given in %s on line 4 Warning: ngettext() expects exactly 3 parameters, 0 given in %s on line 5 |