@@ -3864,11 +3864,11 @@ PHP_FUNCTION(mb_convert_variables)
3864
3864
/* HTML numeric entities */
3865
3865
3866
3866
/* Convert PHP array to data structure required by mbfl_html_numeric_entity */
3867
- static uint32_t * make_conversion_map (HashTable * target_hash , int * convmap_size )
3867
+ static uint32_t * make_conversion_map (HashTable * target_hash , size_t * conversion_map_size )
3868
3868
{
3869
3869
zval * hash_entry ;
3870
3870
3871
- int n_elems = zend_hash_num_elements (target_hash );
3871
+ size_t n_elems = * conversion_map_size = zend_hash_num_elements (target_hash );
3872
3872
if (n_elems % 4 != 0 ) {
3873
3873
zend_argument_value_error (2 , "must have a multiple of 4 elements" );
3874
3874
return NULL ;
@@ -3881,13 +3881,12 @@ static uint32_t *make_conversion_map(HashTable *target_hash, int *convmap_size)
3881
3881
* mapelm ++ = zval_get_long (hash_entry );
3882
3882
} ZEND_HASH_FOREACH_END ();
3883
3883
3884
- * convmap_size = n_elems / 4 ;
3885
3884
return convmap ;
3886
3885
}
3887
3886
3888
- static bool html_numeric_entity_convert (uint32_t w , uint32_t * convmap , int mapsize , uint32_t * retval )
3887
+ static bool html_numeric_entity_convert (uint32_t w , uint32_t * convmap , size_t conversion_map_size , uint32_t * retval )
3889
3888
{
3890
- uint32_t * convmap_end = convmap + ( mapsize * 4 ) ;
3889
+ uint32_t * convmap_end = convmap + conversion_map_size ;
3891
3890
3892
3891
for (uint32_t * mapelm = convmap ; mapelm < convmap_end ; mapelm += 4 ) {
3893
3892
uint32_t lo_code = mapelm [0 ];
@@ -3907,7 +3906,7 @@ static bool html_numeric_entity_convert(uint32_t w, uint32_t *convmap, int mapsi
3907
3906
return false;
3908
3907
}
3909
3908
3910
- static zend_string * html_numeric_entity_encode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , int mapsize , bool hex )
3909
+ static zend_string * html_numeric_entity_encode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , size_t conversion_map_size , bool hex )
3911
3910
{
3912
3911
/* Each wchar which we get from decoding the input string may become up to
3913
3912
* 13 wchars when we convert it to an HTML entity */
@@ -3932,7 +3931,7 @@ static zend_string* html_numeric_entity_encode(zend_string *input, const mbfl_en
3932
3931
for (size_t i = 0 ; i < out_len ; i ++ ) {
3933
3932
uint32_t w = wchar_buf [i ];
3934
3933
3935
- if (html_numeric_entity_convert (w , convmap , mapsize , & w )) {
3934
+ if (html_numeric_entity_convert (w , convmap , conversion_map_size , & w )) {
3936
3935
* converted ++ = '&' ;
3937
3936
* converted ++ = '#' ;
3938
3937
if (hex ) {
@@ -3977,7 +3976,7 @@ static zend_string* html_numeric_entity_encode(zend_string *input, const mbfl_en
3977
3976
PHP_FUNCTION (mb_encode_numericentity )
3978
3977
{
3979
3978
zend_string * encoding = NULL , * str ;
3980
- int mapsize ;
3979
+ size_t conversion_map_size ;
3981
3980
HashTable * target_hash ;
3982
3981
bool is_hex = false;
3983
3982
@@ -3994,19 +3993,19 @@ PHP_FUNCTION(mb_encode_numericentity)
3994
3993
RETURN_THROWS ();
3995
3994
}
3996
3995
3997
- uint32_t * convmap = make_conversion_map (target_hash , & mapsize );
3996
+ uint32_t * convmap = make_conversion_map (target_hash , & conversion_map_size );
3998
3997
if (convmap == NULL ) {
3999
3998
RETURN_THROWS ();
4000
3999
}
4001
4000
4002
- RETVAL_STR (html_numeric_entity_encode (str , enc , convmap , mapsize , is_hex ));
4001
+ RETVAL_STR (html_numeric_entity_encode (str , enc , convmap , conversion_map_size , is_hex ));
4003
4002
efree (convmap );
4004
4003
}
4005
4004
/* }}} */
4006
4005
4007
- static bool html_numeric_entity_deconvert (uint32_t number , uint32_t * convmap , int mapsize , uint32_t * retval )
4006
+ static bool html_numeric_entity_deconvert (uint32_t number , uint32_t * convmap , size_t conversion_map_size , uint32_t * retval )
4008
4007
{
4009
- uint32_t * convmap_end = convmap + ( mapsize * 4 ) ;
4008
+ uint32_t * convmap_end = convmap + conversion_map_size ;
4010
4009
4011
4010
for (uint32_t * mapelm = convmap ; mapelm < convmap_end ; mapelm += 4 ) {
4012
4011
uint32_t lo_code = mapelm [0 ];
@@ -4027,7 +4026,7 @@ static bool html_numeric_entity_deconvert(uint32_t number, uint32_t *convmap, in
4027
4026
#define DEC_ENTITY_MAXLEN 12 /* For "&#" and 10 decimal digits */
4028
4027
#define HEX_ENTITY_MAXLEN 11 /* For "&#x" and 8 hexadecimal digits */
4029
4028
4030
- static zend_string * html_numeric_entity_decode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , int mapsize )
4029
+ static zend_string * html_numeric_entity_decode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , size_t conversion_map_size )
4031
4030
{
4032
4031
uint32_t wchar_buf [128 ], converted_buf [128 ];
4033
4032
@@ -4121,7 +4120,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
4121
4120
value = (value * 16 ) + 10 + (w - 'A' );
4122
4121
}
4123
4122
}
4124
- if (html_numeric_entity_deconvert (value , convmap , mapsize , converted )) {
4123
+ if (html_numeric_entity_deconvert (value , convmap , conversion_map_size , converted )) {
4125
4124
converted ++ ;
4126
4125
if (* p2 == ';' )
4127
4126
p2 ++ ;
@@ -4159,7 +4158,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
4159
4158
}
4160
4159
value = (value * 10 ) + (* p3 ++ - '0' );
4161
4160
}
4162
- if (html_numeric_entity_deconvert (value , convmap , mapsize , converted )) {
4161
+ if (html_numeric_entity_deconvert (value , convmap , conversion_map_size , converted )) {
4163
4162
converted ++ ;
4164
4163
if (* p2 == ';' )
4165
4164
p2 ++ ;
@@ -4209,7 +4208,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
4209
4208
PHP_FUNCTION (mb_decode_numericentity )
4210
4209
{
4211
4210
zend_string * encoding = NULL , * str ;
4212
- int mapsize ;
4211
+ size_t conversion_map_size ;
4213
4212
HashTable * target_hash ;
4214
4213
4215
4214
ZEND_PARSE_PARAMETERS_START (2 , 3 )
@@ -4224,12 +4223,12 @@ PHP_FUNCTION(mb_decode_numericentity)
4224
4223
RETURN_THROWS ();
4225
4224
}
4226
4225
4227
- uint32_t * convmap = make_conversion_map (target_hash , & mapsize );
4226
+ uint32_t * convmap = make_conversion_map (target_hash , & conversion_map_size );
4228
4227
if (convmap == NULL ) {
4229
4228
RETURN_THROWS ();
4230
4229
}
4231
4230
4232
- RETVAL_STR (html_numeric_entity_decode (str , enc , convmap , mapsize ));
4231
+ RETVAL_STR (html_numeric_entity_decode (str , enc , convmap , conversion_map_size ));
4233
4232
efree (convmap );
4234
4233
}
4235
4234
/* }}} */
0 commit comments