@@ -2743,26 +2743,21 @@ PHP_FUNCTION(imagefilledpolygon)
2743
2743
/* }}} */
2744
2744
2745
2745
/* {{{ php_find_gd_font */
2746
- static gdFontPtr php_find_gd_font (zval * zfont )
2746
+ static gdFontPtr php_find_gd_font (zend_object * font_obj , zend_long font_int )
2747
2747
{
2748
- if (( Z_TYPE_P ( zfont ) == IS_OBJECT ) && instanceof_function ( Z_OBJCE_P ( zfont ), gd_font_ce ) ) {
2749
- return php_gd_font_object_from_zend_object (Z_OBJ_P ( zfont ) )-> font ;
2748
+ if (font_obj ) {
2749
+ return php_gd_font_object_from_zend_object (font_obj )-> font ;
2750
2750
}
2751
2751
2752
- if (Z_TYPE_P (zfont ) != IS_LONG ) {
2753
- /* In practice, type checks should prevent us from reaching here. */
2754
- return gdFontTiny ;
2755
- }
2756
-
2757
- switch (Z_LVAL_P (zfont )) {
2752
+ switch (font_int ) {
2758
2753
case 1 : return gdFontTiny ;
2759
2754
case 2 : return gdFontSmall ;
2760
2755
case 3 : return gdFontMediumBold ;
2761
2756
case 4 : return gdFontLarge ;
2762
2757
case 5 : return gdFontGiant ;
2763
2758
}
2764
2759
2765
- return ( Z_LVAL_P ( zfont ) < 1 ) ? gdFontTiny : gdFontGiant ;
2760
+ return font_int < 1 ? gdFontTiny : gdFontGiant ;
2766
2761
}
2767
2762
/* }}} */
2768
2763
@@ -2772,14 +2767,15 @@ static gdFontPtr php_find_gd_font(zval *zfont)
2772
2767
*/
2773
2768
static void php_imagefontsize (INTERNAL_FUNCTION_PARAMETERS , int arg )
2774
2769
{
2775
- zval * zfont ;
2770
+ zend_object * font_obj ;
2771
+ zend_long font_int ;
2776
2772
gdFontPtr font ;
2777
2773
2778
- if ( zend_parse_parameters ( ZEND_NUM_ARGS (), "z" , & zfont ) == FAILURE ) {
2779
- RETURN_THROWS ();
2780
- }
2774
+ ZEND_PARSE_PARAMETERS_START ( 1 , 1 )
2775
+ Z_PARAM_OBJ_OF_CLASS_OR_LONG ( font_obj , gd_font_ce , font_int )
2776
+ ZEND_PARSE_PARAMETERS_END ();
2781
2777
2782
- font = php_find_gd_font (zfont );
2778
+ font = php_find_gd_font (font_obj , font_int );
2783
2779
RETURN_LONG (arg ? font -> h : font -> w );
2784
2780
}
2785
2781
/* }}} */
@@ -2839,12 +2835,18 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
2839
2835
gdImagePtr im ;
2840
2836
int ch = 0 , col , x , y , i , l = 0 ;
2841
2837
unsigned char * str = NULL ;
2842
- zval * zfont ;
2838
+ zend_object * font_obj ;
2839
+ zend_long font_int ;
2843
2840
gdFontPtr font ;
2844
2841
2845
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "Ozllsl" , & IM , gd_image_ce , & zfont , & X , & Y , & C , & C_len , & COL ) == FAILURE ) {
2846
- RETURN_THROWS ();
2847
- }
2842
+ ZEND_PARSE_PARAMETERS_START (6 , 6 )
2843
+ Z_PARAM_OBJECT_OF_CLASS (IM , gd_image_ce )
2844
+ Z_PARAM_OBJ_OF_CLASS_OR_LONG (font_obj , gd_font_ce , font_int )
2845
+ Z_PARAM_LONG (X )
2846
+ Z_PARAM_LONG (Y )
2847
+ Z_PARAM_STRING (C , C_len )
2848
+ Z_PARAM_LONG (COL )
2849
+ ZEND_PARSE_PARAMETERS_END ();
2848
2850
2849
2851
im = php_gd_libgdimageptr_from_zval_p (IM );
2850
2852
@@ -2860,7 +2862,7 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
2860
2862
y = Y ;
2861
2863
x = X ;
2862
2864
2863
- font = php_find_gd_font (zfont );
2865
+ font = php_find_gd_font (font_obj , font_int );
2864
2866
2865
2867
switch (mode ) {
2866
2868
case 0 :
0 commit comments