php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #71091
Patch feature-support-php5-and-php7 revision 2016-03-07 16:01 UTC by nikitin dot dv27 at gmail dot com
Patch feature-support-php7 revision 2016-03-01 12:18 UTC by nikitin dot dv27 at gmail dot com

Patch feature-support-php5-and-php7 for stem Bug #71091

Patch version 2016-03-07 16:01 UTC

Return to Bug #71091 | Download this patch
This patch renders other patches obsolete

Obsolete patches:

Patch Revisions:

Developer: nikitin.dv27@gmail.com

diff --git a/stem.c b/stem.c
index f827f86..703a612 100644
--- a/stem.c
+++ b/stem.c
@@ -13,80 +13,96 @@ $Id$
 #include "config.h"
 #endif
 
+
 #include "php.h"
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_stem.h"
+#if PHP_MAJOR_VERSION == 7
+ZEND_BEGIN_ARG_INFO_EX(arginfo_stem_params, 0, 0, 1)
+	ZEND_ARG_INFO(0, string)
+	ZEND_ARG_INFO(0, lang)
+ZEND_END_ARG_INFO()
+
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_stem_params_lang_preset, 0, 0, 1)
+	ZEND_ARG_INFO(0, string)
+	ZEND_ARG_INFO(0, lang)
+ZEND_END_ARG_INFO()
+#else
+#define arginfo_stem_params NULL
+#define arginfo_stem_params_lang_preset NULL
+#endif
 
 /* {{{ stem_functions[]
 */
 zend_function_entry stem_functions[] = {
-	PHP_FE(stem,				NULL)
-	PHP_FE(stem_porter,			NULL)
+	PHP_FE(stem,				arginfo_stem_params)
+	PHP_FE(stem_porter,			arginfo_stem_params)
 	PHP_FE(stem_enabled,		NULL)
 
 	#if ENABLE_DANISH
-	PHP_FE(stem_danish,			NULL)
+	PHP_FE(stem_danish,			arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_DUTCH
-	PHP_FE(stem_dutch,			NULL)
+	PHP_FE(stem_dutch,			arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_ENGLISH
-	PHP_FE(stem_english,		NULL)
+	PHP_FE(stem_english,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_FINNISH
-	PHP_FE(stem_finnish,		NULL)
+	PHP_FE(stem_finnish,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_FRENCH
-	PHP_FE(stem_french,			NULL)
+	PHP_FE(stem_french,			arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_GERMAN
-	PHP_FE(stem_german,			NULL)
+	PHP_FE(stem_german,			arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_HUNGARIAN
-	PHP_FE(stem_hungarian,		NULL)
+	PHP_FE(stem_hungarian,		arginfo_stem_params_lang_preset)
 	#endif
 	
 	#if ENABLE_ITALIAN
-	PHP_FE(stem_italian,		NULL)
+	PHP_FE(stem_italian,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_NORWEGIAN
-	PHP_FE(stem_norwegian,		NULL)
+	PHP_FE(stem_norwegian,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_PORTUGUESE
-	PHP_FE(stem_portuguese,		NULL)
+	PHP_FE(stem_portuguese,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_ROMANIAN
-	PHP_FE(stem_romanian,		NULL)
+	PHP_FE(stem_romanian,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_RUSSIAN
-	PHP_FE(stem_russian,		NULL)
+	PHP_FE(stem_russian,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_RUSSIAN_UNICODE
-	PHP_FE(stem_russian_unicode,	NULL)
+	PHP_FE(stem_russian_unicode,	arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_SPANISH
-	PHP_FE(stem_spanish,		NULL)
+	PHP_FE(stem_spanish,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_SWEDISH
-	PHP_FE(stem_swedish,		NULL)
+	PHP_FE(stem_swedish,		arginfo_stem_params_lang_preset)
 	#endif
 
 	#if ENABLE_TURKISH_UNICODE
-	PHP_FE(stem_turkish_unicode,	NULL)
+	PHP_FE(stem_turkish_unicode,	arginfo_stem_params_lang_preset)
 	#endif
 
 	{NULL, NULL, NULL}	
@@ -209,17 +225,26 @@ void php_stem(INTERNAL_FUNCTION_PARAMETERS, long lang)
 	struct SN_env* (*create_env)(void);
 	void (*close_env)(struct SN_env*);
 	int (*stem)(struct SN_env*);
-
+#if PHP_MAJOR_VERSION == 7
+	const char* incoming;
+	size_t arglen;
+#else
 	char * incoming;
 	int arglen;
+#endif
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &incoming, &arglen, &lang) == FAILURE) {
+	if (zend_parse_parameters_ex(0, MIN(ZEND_NUM_ARGS(),2), "s|l", &incoming, &arglen, &lang) == FAILURE) {
 		return;
 	}
 
+
 	/* Empty string */
 	if (arglen <= 0) {
+#if PHP_MAJOR_VERSION == 7
+		RETURN_STRINGL(incoming, arglen);
+#else
 		RETURN_STRINGL(incoming, arglen, 1);
+#endif
 	}
 
 	switch (lang)
@@ -330,13 +355,20 @@ void php_stem(INTERNAL_FUNCTION_PARAMETERS, long lang)
 			RETURN_FALSE;
 	}
 
+
 	z = create_env();
+
 	SN_set_current(z, arglen, incoming);
+
 	php_strtolower(z->p, arglen);
+
 	stem(z);
 	z->p[z->l]= '\0';
-
-	RETVAL_STRINGL(z->p, z->l, 1);
+#if PHP_MAJOR_VERSION == 7
+	RETVAL_STRINGL(z->p,z->l);
+#else
+	RETVAL_STRINGL(z->p,z->l, 1);
+#endif
 	close_env(z);
 }
 /* }}} */
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 21:01:32 2024 UTC