@@ -4676,8 +4676,10 @@ PHP_FUNCTION(mb_get_info)
4676
4676
size_t n ;
4677
4677
char * name ;
4678
4678
zval row ;
4679
- const mbfl_language * lang = mbfl_no2language (MBSTRG (language ));
4680
4679
const mbfl_encoding * * entry ;
4680
+ const mbfl_language * lang = mbfl_no2language (MBSTRG (language ));
4681
+
4682
+ ZEND_ASSERT (lang );
4681
4683
4682
4684
ZEND_PARSE_PARAMETERS_START (0 , 1 )
4683
4685
Z_PARAM_OPTIONAL
@@ -4695,29 +4697,32 @@ PHP_FUNCTION(mb_get_info)
4695
4697
if (MBSTRG (current_http_output_encoding )) {
4696
4698
add_assoc_string (return_value , "http_output" , (char * )MBSTRG (current_http_output_encoding )-> name );
4697
4699
}
4698
- if (( name = ( char * ) zend_ini_string ( "mbstring.http_output_conv_mimetypes" , sizeof ( "mbstring.http_output_conv_mimetypes" ) - 1 , 0 )) != NULL ) {
4699
- add_assoc_string (return_value , "http_output_conv_mimetypes" , name );
4700
- }
4701
- if ( lang != NULL ) {
4702
- if (( name = ( char * ) mbfl_no_encoding2name ( lang -> mail_charset )) != NULL ) {
4703
- add_assoc_string ( return_value , " mail_charset" , name );
4704
- }
4705
- if (( name = ( char * ) mbfl_no_encoding2name ( lang -> mail_header_encoding )) != NULL ) {
4706
- add_assoc_string ( return_value , " mail_header_encoding" , name );
4707
- }
4708
- if (( name = ( char * ) mbfl_no_encoding2name ( lang -> mail_body_encoding )) != NULL ) {
4709
- add_assoc_string ( return_value , " mail_body_encoding" , name );
4710
- }
4711
- }
4700
+
4701
+ add_assoc_str (return_value , "http_output_conv_mimetypes" ,
4702
+ zend_ini_str ( "mbstring.http_output_conv_mimetypes" , sizeof ( "mbstring.http_output_conv_mimetypes" ) - 1 , 0 )
4703
+ );
4704
+
4705
+ name = ( char * ) mbfl_no_encoding2name ( lang -> mail_charset );
4706
+ add_assoc_string ( return_value , "mail_charset" , name );
4707
+
4708
+ name = ( char * ) mbfl_no_encoding2name ( lang -> mail_header_encoding );
4709
+ add_assoc_string ( return_value , "mail_header_encoding" , name );
4710
+
4711
+ name = ( char * ) mbfl_no_encoding2name ( lang -> mail_body_encoding );
4712
+ add_assoc_string ( return_value , "mail_body_encoding" , name );
4713
+
4712
4714
add_assoc_long (return_value , "illegal_chars" , MBSTRG (illegalchars ));
4715
+
4713
4716
if (MBSTRG (encoding_translation )) {
4714
4717
add_assoc_string (return_value , "encoding_translation" , "On" );
4715
4718
} else {
4716
4719
add_assoc_string (return_value , "encoding_translation" , "Off" );
4717
4720
}
4718
- if ((name = (char * )mbfl_no_language2name (MBSTRG (language ))) != NULL ) {
4719
- add_assoc_string (return_value , "language" , name );
4720
- }
4721
+
4722
+ name = (char * )mbfl_no_language2name (MBSTRG (language ));
4723
+ add_assoc_string (return_value , "language" , name );
4724
+
4725
+ // TODO Seems to always have one entry at least?
4721
4726
n = MBSTRG (current_detect_order_list_size );
4722
4727
entry = MBSTRG (current_detect_order_list );
4723
4728
if (n > 0 ) {
@@ -4744,46 +4749,46 @@ PHP_FUNCTION(mb_get_info)
4744
4749
add_assoc_string (return_value , "strict_detection" , "Off" );
4745
4750
}
4746
4751
} else if (zend_string_equals_literal_ci (type , "internal_encoding" )) {
4747
- if (MBSTRG (current_internal_encoding )) {
4748
- RETVAL_STRING ((char * )MBSTRG (current_internal_encoding )-> name );
4749
- }
4752
+ ZEND_ASSERT (MBSTRG (current_internal_encoding ));
4753
+ RETURN_STRING ((char * )MBSTRG (current_internal_encoding )-> name );
4750
4754
} else if (zend_string_equals_literal_ci (type , "http_input" )) {
4751
4755
if (MBSTRG (http_input_identify )) {
4752
- RETVAL_STRING ((char * )MBSTRG (http_input_identify )-> name );
4756
+ RETURN_STRING ((char * )MBSTRG (http_input_identify )-> name );
4753
4757
}
4758
+ RETURN_NULL ();
4754
4759
} else if (zend_string_equals_literal_ci (type , "http_output" )) {
4755
- if (MBSTRG (current_http_output_encoding )) {
4756
- RETVAL_STRING ((char * )MBSTRG (current_http_output_encoding )-> name );
4757
- }
4760
+ ZEND_ASSERT (MBSTRG (current_http_output_encoding ));
4761
+ RETURN_STRING ((char * )MBSTRG (current_http_output_encoding )-> name );
4758
4762
} else if (zend_string_equals_literal_ci (type , "http_output_conv_mimetypes" )) {
4759
- if ((name = (char * )zend_ini_string ("mbstring.http_output_conv_mimetypes" , sizeof ("mbstring.http_output_conv_mimetypes" ) - 1 , 0 )) != NULL ) {
4760
- RETVAL_STRING (name );
4761
- }
4763
+ RETURN_STR (
4764
+ zend_ini_str (
4765
+ "mbstring.http_output_conv_mimetypes" ,
4766
+ sizeof ("mbstring.http_output_conv_mimetypes" ) - 1 ,
4767
+ false
4768
+ )
4769
+ );
4762
4770
} else if (zend_string_equals_literal_ci (type , "mail_charset" )) {
4763
- if (lang != NULL && (name = (char * )mbfl_no_encoding2name (lang -> mail_charset )) != NULL ) {
4764
- RETVAL_STRING (name );
4765
- }
4771
+ name = (char * )mbfl_no_encoding2name (lang -> mail_charset );
4772
+ RETURN_STRING (name );
4766
4773
} else if (zend_string_equals_literal_ci (type , "mail_header_encoding" )) {
4767
- if (lang != NULL && (name = (char * )mbfl_no_encoding2name (lang -> mail_header_encoding )) != NULL ) {
4768
- RETVAL_STRING (name );
4769
- }
4774
+ name = (char * )mbfl_no_encoding2name (lang -> mail_header_encoding );
4775
+ RETURN_STRING (name );
4770
4776
} else if (zend_string_equals_literal_ci (type , "mail_body_encoding" )) {
4771
- if (lang != NULL && (name = (char * )mbfl_no_encoding2name (lang -> mail_body_encoding )) != NULL ) {
4772
- RETVAL_STRING (name );
4773
- }
4777
+ name = (char * )mbfl_no_encoding2name (lang -> mail_body_encoding );
4778
+ RETURN_STRING (name );
4774
4779
} else if (zend_string_equals_literal_ci (type , "illegal_chars" )) {
4775
- RETVAL_LONG (MBSTRG (illegalchars ));
4780
+ RETURN_LONG (MBSTRG (illegalchars ));
4776
4781
} else if (zend_string_equals_literal_ci (type , "encoding_translation" )) {
4777
4782
if (MBSTRG (encoding_translation )) {
4778
- RETVAL_STRING ("On" );
4783
+ RETURN_STRING ("On" );
4779
4784
} else {
4780
- RETVAL_STRING ("Off" );
4785
+ RETURN_STRING ("Off" );
4781
4786
}
4782
4787
} else if (zend_string_equals_literal_ci (type , "language" )) {
4783
- if ((name = (char * )mbfl_no_language2name (MBSTRG (language ))) != NULL ) {
4784
- RETVAL_STRING (name );
4785
- }
4788
+ name = (char * )mbfl_no_language2name (MBSTRG (language ));
4789
+ RETURN_STRING (name );
4786
4790
} else if (zend_string_equals_literal_ci (type , "detect_order" )) {
4791
+ // TODO Seems to always have one entry at least?
4787
4792
n = MBSTRG (current_detect_order_list_size );
4788
4793
entry = MBSTRG (current_detect_order_list );
4789
4794
if (n > 0 ) {
@@ -4796,22 +4801,22 @@ PHP_FUNCTION(mb_get_info)
4796
4801
}
4797
4802
} else if (zend_string_equals_literal_ci (type , "substitute_character" )) {
4798
4803
if (MBSTRG (current_filter_illegal_mode ) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE ) {
4799
- RETVAL_STRING ("none" );
4804
+ RETURN_STRING ("none" );
4800
4805
} else if (MBSTRG (current_filter_illegal_mode ) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG ) {
4801
- RETVAL_STRING ("long" );
4806
+ RETURN_STRING ("long" );
4802
4807
} else if (MBSTRG (current_filter_illegal_mode ) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY ) {
4803
- RETVAL_STRING ("entity" );
4808
+ RETURN_STRING ("entity" );
4804
4809
} else {
4805
- RETVAL_LONG (MBSTRG (current_filter_illegal_substchar ));
4810
+ RETURN_LONG (MBSTRG (current_filter_illegal_substchar ));
4806
4811
}
4807
4812
} else if (zend_string_equals_literal_ci (type , "strict_detection" )) {
4808
4813
if (MBSTRG (strict_detection )) {
4809
- RETVAL_STRING ("On" );
4814
+ RETURN_STRING ("On" );
4810
4815
} else {
4811
- RETVAL_STRING ("Off" );
4816
+ RETURN_STRING ("Off" );
4812
4817
}
4813
4818
} else {
4814
- // TODO Convert to ValueError
4819
+ php_error_docref ( NULL , E_WARNING , "argument #1 ($type) must be a valid type" );
4815
4820
RETURN_FALSE ;
4816
4821
}
4817
4822
}
0 commit comments