@@ -1319,41 +1319,42 @@ PHP_FUNCTION(mb_http_input)
13191319 char * type = NULL ;
13201320 size_t type_len = 0 , n ;
13211321 const mbfl_encoding * * entry ;
1322+ const mbfl_encoding * encoding ;
13221323
13231324 ZEND_PARSE_PARAMETERS_START (0 , 1 )
13241325 Z_PARAM_OPTIONAL
13251326 Z_PARAM_STRING (type , type_len )
13261327 ZEND_PARSE_PARAMETERS_END ();
13271328
13281329 if (type == NULL ) {
1329- RETVAL_STRING ( MBSTRG (http_input_identify ) -> name );
1330+ encoding = MBSTRG (http_input_identify );
13301331 } else {
13311332 switch (* type ) {
13321333 case 'G' :
13331334 case 'g' :
1334- RETVAL_STRING ( MBSTRG (http_input_identify_get ) -> name );
1335+ encoding = MBSTRG (http_input_identify_get );
13351336 break ;
13361337 case 'P' :
13371338 case 'p' :
1338- RETVAL_STRING ( MBSTRG (http_input_identify_post ) -> name );
1339+ encoding = MBSTRG (http_input_identify_post );
13391340 break ;
13401341 case 'C' :
13411342 case 'c' :
1342- RETVAL_STRING ( MBSTRG (http_input_identify_cookie ) -> name );
1343+ encoding = MBSTRG (http_input_identify_cookie );
13431344 break ;
13441345 case 'S' :
13451346 case 's' :
1346- RETVAL_STRING ( MBSTRG (http_input_identify_string ) -> name );
1347+ encoding = MBSTRG (http_input_identify_string );
13471348 break ;
13481349 case 'I' :
13491350 case 'i' :
13501351 entry = MBSTRG (http_input_list );
13511352 n = MBSTRG (http_input_list_size );
13521353 array_init (return_value );
1353- for (int i = 0 ; i < n ; i ++ , entry ++ ) {
1354+ for (size_t i = 0 ; i < n ; i ++ , entry ++ ) {
13541355 add_next_index_string (return_value , (* entry )-> name );
13551356 }
1356- break ;
1357+ return ;
13571358 case 'L' :
13581359 case 'l' :
13591360 entry = MBSTRG (http_input_list );
@@ -1362,24 +1363,31 @@ PHP_FUNCTION(mb_http_input)
13621363 // TODO should return empty string?
13631364 RETURN_FALSE ;
13641365 }
1366+ // TODO Use smart_str instead.
13651367 mbfl_string result ;
13661368 mbfl_memory_device device ;
13671369 mbfl_memory_device_init (& device , n * 12 , 0 );
1368- for (int i = 0 ; i < n ; i ++ , entry ++ ) {
1370+ for (size_t i = 0 ; i < n ; i ++ , entry ++ ) {
13691371 mbfl_memory_device_strcat (& device , (* entry )-> name );
13701372 mbfl_memory_device_output (',' , & device );
13711373 }
13721374 mbfl_memory_device_unput (& device ); /* Remove trailing comma */
13731375 mbfl_memory_device_result (& device , & result );
13741376 RETVAL_STRINGL ((const char * )result .val , result .len );
13751377 mbfl_string_clear (& result );
1376- break ;
1378+ return ;
13771379 default :
13781380 // TODO ValueError
1379- RETVAL_STRING ( MBSTRG (http_input_identify ) -> name );
1381+ encoding = MBSTRG (http_input_identify );
13801382 break ;
13811383 }
13821384 }
1385+
1386+ if (encoding ) {
1387+ RETURN_STRING (encoding -> name );
1388+ } else {
1389+ RETURN_FALSE ;
1390+ }
13831391}
13841392/* }}} */
13851393
0 commit comments