Declare ext/iconv constants in stubs (#8714)

This commit is contained in:
Máté Kocsis 2022-06-06 14:16:47 +02:00 committed by GitHub
parent e7d482d896
commit 7e6301cd31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 29 deletions

View File

@ -47,6 +47,32 @@
#include "zend_smart_str.h"
#include "ext/standard/base64.h"
#include "ext/standard/quot_print.h"
#ifdef PHP_ICONV_IMPL
#define PHP_ICONV_IMPL_VALUE PHP_ICONV_IMPL
#elif HAVE_LIBICONV
#define PHP_ICONV_IMPL_VALUE "libiconv"
#else
#define PHP_ICONV_IMPL_VALUE "unknown"
#endif
char *get_iconv_version(void) {
char *version = "unknown";
#ifdef HAVE_LIBICONV
static char buf[16];
snprintf(buf, sizeof(buf), "%d.%d", _libiconv_version >> 8, _libiconv_version & 0xff);
version = buf;
#elif HAVE_GLIBC_ICONV
version = (char *) gnu_get_libc_version();
#endif
return version;
}
#define PHP_ICONV_MIME_DECODE_STRICT (1<<0)
#define PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR (1<<1)
#include "iconv_arginfo.h"
#define _php_iconv_memequal(a, b, c) \
@ -104,9 +130,6 @@ typedef enum _php_iconv_enc_scheme_t {
} php_iconv_enc_scheme_t;
/* }}} */
#define PHP_ICONV_MIME_DECODE_STRICT (1<<0)
#define PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR (1<<1)
/* {{{ prototypes */
static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, iconv_t cd);
static php_iconv_err_t _php_iconv_appendc(smart_str *d, const char c, iconv_t cd);
@ -186,37 +209,14 @@ PHP_INI_END()
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(miconv)
{
char *version = "unknown";
REGISTER_INI_ENTRIES();
#ifdef HAVE_LIBICONV
{
static char buf[16];
snprintf(buf, sizeof(buf), "%d.%d",
_libiconv_version >> 8, _libiconv_version & 0xff);
version = buf;
}
#elif HAVE_GLIBC_ICONV
version = (char *)gnu_get_libc_version();
#endif
#ifdef PHP_ICONV_IMPL
REGISTER_STRING_CONSTANT("ICONV_IMPL", PHP_ICONV_IMPL, CONST_CS | CONST_PERSISTENT);
#elif HAVE_LIBICONV
REGISTER_STRING_CONSTANT("ICONV_IMPL", "libiconv", CONST_CS | CONST_PERSISTENT);
#else
REGISTER_STRING_CONSTANT("ICONV_IMPL", "unknown", CONST_CS | CONST_PERSISTENT);
#endif
REGISTER_STRING_CONSTANT("ICONV_VERSION", version, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ICONV_MIME_DECODE_STRICT", PHP_ICONV_MIME_DECODE_STRICT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ICONV_MIME_DECODE_CONTINUE_ON_ERROR", PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR, CONST_CS | CONST_PERSISTENT);
if (php_iconv_stream_filter_register_factory() != PHP_ICONV_ERR_SUCCESS) {
return FAILURE;
}
register_iconv_symbols(module_number);
php_output_handler_alias_register(ZEND_STRL("ob_iconv_handler"), php_iconv_output_handler_init);
php_output_handler_conflict_register(ZEND_STRL("ob_iconv_handler"), php_iconv_output_conflict);

View File

@ -2,6 +2,27 @@
/** @generate-class-entries */
/**
* @var string
* @cname PHP_ICONV_IMPL_VALUE
*/
const ICONV_IMPL = UNKNOWN;
/**
* @var string
* @cname get_iconv_version()
*/
const ICONV_VERSION = UNKNOWN;
/**
* @var int
* @cname PHP_ICONV_MIME_DECODE_STRICT
*/
const ICONV_MIME_DECODE_STRICT = UNKNOWN;
/**
* @var int
* @cname PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR
*/
const ICONV_MIME_DECODE_CONTINUE_ON_ERROR = UNKNOWN;
function iconv_strlen(string $string, ?string $encoding = null): int|false {}
/** @refcount 1 */

View File

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: c7198f92b39f7a15d242a74ed5f42036f858da2e */
* Stub hash: 3df53b4f973d99fe56dd3b95128ab9b49027376a */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strlen, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
@ -85,3 +85,11 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(iconv_get_encoding, arginfo_iconv_get_encoding)
ZEND_FE_END
};
static void register_iconv_symbols(int module_number)
{
REGISTER_STRING_CONSTANT("ICONV_IMPL", PHP_ICONV_IMPL_VALUE, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("ICONV_VERSION", get_iconv_version(), CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ICONV_MIME_DECODE_STRICT", PHP_ICONV_MIME_DECODE_STRICT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ICONV_MIME_DECODE_CONTINUE_ON_ERROR", PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR, CONST_CS | CONST_PERSISTENT);
}