@@ -3667,11 +3667,11 @@ PHP_FUNCTION(mb_convert_variables)
3667
3667
/* HTML numeric entities */
3668
3668
3669
3669
/* Convert PHP array to data structure required by mbfl_html_numeric_entity */
3670
- static uint32_t * make_conversion_map (HashTable * target_hash , int * convmap_size )
3670
+ static uint32_t * make_conversion_map (HashTable * target_hash , size_t * conversion_map_size )
3671
3671
{
3672
3672
zval * hash_entry ;
3673
3673
3674
- int n_elems = zend_hash_num_elements (target_hash );
3674
+ size_t n_elems = * conversion_map_size = zend_hash_num_elements (target_hash );
3675
3675
if (n_elems % 4 != 0 ) {
3676
3676
zend_argument_value_error (2 , "must have a multiple of 4 elements" );
3677
3677
return NULL ;
@@ -3684,13 +3684,12 @@ static uint32_t *make_conversion_map(HashTable *target_hash, int *convmap_size)
3684
3684
* mapelm ++ = zval_get_long (hash_entry );
3685
3685
} ZEND_HASH_FOREACH_END ();
3686
3686
3687
- * convmap_size = n_elems / 4 ;
3688
3687
return convmap ;
3689
3688
}
3690
3689
3691
- static bool html_numeric_entity_convert (uint32_t w , uint32_t * convmap , int mapsize , uint32_t * retval )
3690
+ static bool html_numeric_entity_convert (uint32_t w , uint32_t * convmap , size_t conversion_map_size , uint32_t * retval )
3692
3691
{
3693
- uint32_t * convmap_end = convmap + ( mapsize * 4 ) ;
3692
+ uint32_t * convmap_end = convmap + conversion_map_size ;
3694
3693
3695
3694
for (uint32_t * mapelm = convmap ; mapelm < convmap_end ; mapelm += 4 ) {
3696
3695
uint32_t lo_code = mapelm [0 ];
@@ -3710,7 +3709,7 @@ static bool html_numeric_entity_convert(uint32_t w, uint32_t *convmap, int mapsi
3710
3709
return false;
3711
3710
}
3712
3711
3713
- static zend_string * html_numeric_entity_encode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , int mapsize , bool hex )
3712
+ static zend_string * html_numeric_entity_encode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , size_t conversion_map_size , bool hex )
3714
3713
{
3715
3714
/* Each wchar which we get from decoding the input string may become up to
3716
3715
* 13 wchars when we convert it to an HTML entity */
@@ -3735,7 +3734,7 @@ static zend_string* html_numeric_entity_encode(zend_string *input, const mbfl_en
3735
3734
for (size_t i = 0 ; i < out_len ; i ++ ) {
3736
3735
uint32_t w = wchar_buf [i ];
3737
3736
3738
- if (html_numeric_entity_convert (w , convmap , mapsize , & w )) {
3737
+ if (html_numeric_entity_convert (w , convmap , conversion_map_size , & w )) {
3739
3738
* converted ++ = '&' ;
3740
3739
* converted ++ = '#' ;
3741
3740
if (hex ) {
@@ -3780,7 +3779,7 @@ static zend_string* html_numeric_entity_encode(zend_string *input, const mbfl_en
3780
3779
PHP_FUNCTION (mb_encode_numericentity )
3781
3780
{
3782
3781
zend_string * encoding = NULL , * str ;
3783
- int mapsize ;
3782
+ size_t conversion_map_size ;
3784
3783
HashTable * target_hash ;
3785
3784
bool is_hex = false;
3786
3785
@@ -3797,19 +3796,19 @@ PHP_FUNCTION(mb_encode_numericentity)
3797
3796
RETURN_THROWS ();
3798
3797
}
3799
3798
3800
- uint32_t * convmap = make_conversion_map (target_hash , & mapsize );
3799
+ uint32_t * convmap = make_conversion_map (target_hash , & conversion_map_size );
3801
3800
if (convmap == NULL ) {
3802
3801
RETURN_THROWS ();
3803
3802
}
3804
3803
3805
- RETVAL_STR (html_numeric_entity_encode (str , enc , convmap , mapsize , is_hex ));
3804
+ RETVAL_STR (html_numeric_entity_encode (str , enc , convmap , conversion_map_size , is_hex ));
3806
3805
efree (convmap );
3807
3806
}
3808
3807
/* }}} */
3809
3808
3810
- static bool html_numeric_entity_deconvert (uint32_t number , uint32_t * convmap , int mapsize , uint32_t * retval )
3809
+ static bool html_numeric_entity_deconvert (uint32_t number , uint32_t * convmap , size_t conversion_map_size , uint32_t * retval )
3811
3810
{
3812
- uint32_t * convmap_end = convmap + ( mapsize * 4 ) ;
3811
+ uint32_t * convmap_end = convmap + conversion_map_size ;
3813
3812
3814
3813
for (uint32_t * mapelm = convmap ; mapelm < convmap_end ; mapelm += 4 ) {
3815
3814
uint32_t lo_code = mapelm [0 ];
@@ -3830,7 +3829,7 @@ static bool html_numeric_entity_deconvert(uint32_t number, uint32_t *convmap, in
3830
3829
#define DEC_ENTITY_MAXLEN 12 /* For "&#" and 10 decimal digits */
3831
3830
#define HEX_ENTITY_MAXLEN 11 /* For "&#x" and 8 hexadecimal digits */
3832
3831
3833
- static zend_string * html_numeric_entity_decode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , int mapsize )
3832
+ static zend_string * html_numeric_entity_decode (zend_string * input , const mbfl_encoding * encoding , uint32_t * convmap , size_t conversion_map_size )
3834
3833
{
3835
3834
uint32_t wchar_buf [128 ], converted_buf [128 ];
3836
3835
@@ -3924,7 +3923,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
3924
3923
value = (value * 16 ) + 10 + (w - 'A' );
3925
3924
}
3926
3925
}
3927
- if (html_numeric_entity_deconvert (value , convmap , mapsize , converted )) {
3926
+ if (html_numeric_entity_deconvert (value , convmap , conversion_map_size , converted )) {
3928
3927
converted ++ ;
3929
3928
if (* p2 == ';' )
3930
3929
p2 ++ ;
@@ -3962,7 +3961,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
3962
3961
}
3963
3962
value = (value * 10 ) + (* p3 ++ - '0' );
3964
3963
}
3965
- if (html_numeric_entity_deconvert (value , convmap , mapsize , converted )) {
3964
+ if (html_numeric_entity_deconvert (value , convmap , conversion_map_size , converted )) {
3966
3965
converted ++ ;
3967
3966
if (* p2 == ';' )
3968
3967
p2 ++ ;
@@ -4012,7 +4011,7 @@ static zend_string* html_numeric_entity_decode(zend_string *input, const mbfl_en
4012
4011
PHP_FUNCTION (mb_decode_numericentity )
4013
4012
{
4014
4013
zend_string * encoding = NULL , * str ;
4015
- int mapsize ;
4014
+ size_t conversion_map_size ;
4016
4015
HashTable * target_hash ;
4017
4016
4018
4017
ZEND_PARSE_PARAMETERS_START (2 , 3 )
@@ -4027,12 +4026,12 @@ PHP_FUNCTION(mb_decode_numericentity)
4027
4026
RETURN_THROWS ();
4028
4027
}
4029
4028
4030
- uint32_t * convmap = make_conversion_map (target_hash , & mapsize );
4029
+ uint32_t * convmap = make_conversion_map (target_hash , & conversion_map_size );
4031
4030
if (convmap == NULL ) {
4032
4031
RETURN_THROWS ();
4033
4032
}
4034
4033
4035
- RETVAL_STR (html_numeric_entity_decode (str , enc , convmap , mapsize ));
4034
+ RETVAL_STR (html_numeric_entity_decode (str , enc , convmap , conversion_map_size ));
4036
4035
efree (convmap );
4037
4036
}
4038
4037
/* }}} */
0 commit comments