@@ -3663,11 +3663,11 @@ PHP_FUNCTION(mb_convert_variables)
3663
3663
/* HTML numeric entities */
3664
3664
3665
3665
/* Convert PHP array to data structure required by mbfl_html_numeric_entity */
3666
- static uint32_t * make_conversion_map (HashTable * target_hash , int * convmap_size )
3666
+ static uint32_t * make_conversion_map (HashTable * target_hash , size_t * conversion_map_size )
3667
3667
{
3668
3668
zval * hash_entry ;
3669
3669
3670
- int n_elems = zend_hash_num_elements (target_hash );
3670
+ size_t n_elems = * conversion_map_size = zend_hash_num_elements (target_hash );
3671
3671
if (n_elems % 4 != 0 ) {
3672
3672
zend_argument_value_error (2 , "must have a multiple of 4 elements" );
3673
3673
return NULL ;
@@ -3680,13 +3680,12 @@ static uint32_t *make_conversion_map(HashTable *target_hash, int *convmap_size)
3680
3680
* mapelm ++ = zval_get_long (hash_entry );
3681
3681
} ZEND_HASH_FOREACH_END ();
3682
3682
3683
- * convmap_size = n_elems / 4 ;
3684
3683
return convmap ;
3685
3684
}
3686
3685
3687
- static bool html_numeric_entity_convert (uint32_t w , uint32_t * convmap , int mapsize , uint32_t * retval )
3686
+ static bool html_numeric_entity_convert (uint32_t w , uint32_t * convmap , size_t conversion_map_size , uint32_t * retval )
3688
3687
{
3689
- uint32_t * convmap_end = convmap + ( mapsize * 4 ) ;
3688
+ uint32_t * convmap_end = convmap + conversion_map_size ;
3690
3689
3691
3690
for (uint32_t * mapelm = convmap ; mapelm < convmap_end ; mapelm += 4 ) {
3692
3691
uint32_t lo_code = mapelm [0 ];
@@ -3706,7 +3705,7 @@ static bool html_numeric_entity_convert(uint32_t w, uint32_t *convmap, int mapsi
3706
3705
return false;
3707
3706
}
3708
3707
3709
- static zend_string * html_numeric_entity_encode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , int mapsize , bool hex )
3708
+ static zend_string * html_numeric_entity_encode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , size_t conversion_map_size , bool hex )
3710
3709
{
3711
3710
/* Each wchar which we get from decoding the input string may become up to
3712
3711
* 13 wchars when we convert it to an HTML entity */
@@ -3731,7 +3730,7 @@ static zend_string* html_numeric_entity_encode(zend_string *input, const mbfl_en
3731
3730
for (size_t i = 0 ; i < out_len ; i ++ ) {
3732
3731
uint32_t w = wchar_buf [i ];
3733
3732
3734
- if (html_numeric_entity_convert (w , convmap , mapsize , & w )) {
3733
+ if (html_numeric_entity_convert (w , convmap , conversion_map_size , & w )) {
3735
3734
* converted ++ = '&' ;
3736
3735
* converted ++ = '#' ;
3737
3736
if (hex ) {
@@ -3776,7 +3775,7 @@ static zend_string* html_numeric_entity_encode(zend_string *input, const mbfl_en
3776
3775
PHP_FUNCTION (mb_encode_numericentity )
3777
3776
{
3778
3777
zend_string * encoding = NULL , * str ;
3779
- int mapsize ;
3778
+ size_t conversion_map_size ;
3780
3779
HashTable * target_hash ;
3781
3780
bool is_hex = false;
3782
3781
@@ -3793,19 +3792,19 @@ PHP_FUNCTION(mb_encode_numericentity)
3793
3792
RETURN_THROWS ();
3794
3793
}
3795
3794
3796
- uint32_t * convmap = make_conversion_map (target_hash , & mapsize );
3795
+ uint32_t * convmap = make_conversion_map (target_hash , & conversion_map_size );
3797
3796
if (convmap == NULL ) {
3798
3797
RETURN_THROWS ();
3799
3798
}
3800
3799
3801
- RETVAL_STR (html_numeric_entity_encode (str , enc , convmap , mapsize , is_hex ));
3800
+ RETVAL_STR (html_numeric_entity_encode (str , enc , convmap , conversion_map_size , is_hex ));
3802
3801
efree (convmap );
3803
3802
}
3804
3803
/* }}} */
3805
3804
3806
- static bool html_numeric_entity_deconvert (uint32_t number , uint32_t * convmap , int mapsize , uint32_t * retval )
3805
+ static bool html_numeric_entity_deconvert (uint32_t number , uint32_t * convmap , size_t conversion_map_size , uint32_t * retval )
3807
3806
{
3808
- uint32_t * convmap_end = convmap + ( mapsize * 4 ) ;
3807
+ uint32_t * convmap_end = convmap + conversion_map_size ;
3809
3808
3810
3809
for (uint32_t * mapelm = convmap ; mapelm < convmap_end ; mapelm += 4 ) {
3811
3810
uint32_t lo_code = mapelm [0 ];
@@ -3826,7 +3825,7 @@ static bool html_numeric_entity_deconvert(uint32_t number, uint32_t *convmap, in
3826
3825
#define DEC_ENTITY_MAXLEN 12 /* For "&#" and 10 decimal digits */
3827
3826
#define HEX_ENTITY_MAXLEN 11 /* For "&#x" and 8 hexadecimal digits */
3828
3827
3829
- static zend_string * html_numeric_entity_decode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , int mapsize )
3828
+ static zend_string * html_numeric_entity_decode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , size_t conversion_map_size )
3830
3829
{
3831
3830
uint32_t wchar_buf [128 ], converted_buf [128 ];
3832
3831
@@ -3920,7 +3919,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
3920
3919
value = (value * 16 ) + 10 + (w - 'A' );
3921
3920
}
3922
3921
}
3923
- if (html_numeric_entity_deconvert (value , convmap , mapsize , converted )) {
3922
+ if (html_numeric_entity_deconvert (value , convmap , conversion_map_size , converted )) {
3924
3923
converted ++ ;
3925
3924
if (* p2 == ';' )
3926
3925
p2 ++ ;
@@ -3958,7 +3957,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
3958
3957
}
3959
3958
value = (value * 10 ) + (* p3 ++ - '0' );
3960
3959
}
3961
- if (html_numeric_entity_deconvert (value , convmap , mapsize , converted )) {
3960
+ if (html_numeric_entity_deconvert (value , convmap , conversion_map_size , converted )) {
3962
3961
converted ++ ;
3963
3962
if (* p2 == ';' )
3964
3963
p2 ++ ;
@@ -4008,7 +4007,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
4008
4007
PHP_FUNCTION (mb_decode_numericentity )
4009
4008
{
4010
4009
zend_string * encoding = NULL , * str ;
4011
- int mapsize ;
4010
+ size_t conversion_map_size ;
4012
4011
HashTable * target_hash ;
4013
4012
4014
4013
ZEND_PARSE_PARAMETERS_START (2 , 3 )
@@ -4023,12 +4022,12 @@ PHP_FUNCTION(mb_decode_numericentity)
4023
4022
RETURN_THROWS ();
4024
4023
}
4025
4024
4026
- uint32_t * convmap = make_conversion_map (target_hash , & mapsize );
4025
+ uint32_t * convmap = make_conversion_map (target_hash , & conversion_map_size );
4027
4026
if (convmap == NULL ) {
4028
4027
RETURN_THROWS ();
4029
4028
}
4030
4029
4031
- RETVAL_STR (html_numeric_entity_decode (str , enc , convmap , mapsize ));
4030
+ RETVAL_STR (html_numeric_entity_decode (str , enc , convmap , conversion_map_size ));
4032
4031
efree (convmap );
4033
4032
}
4034
4033
/* }}} */
0 commit comments