@@ -1319,41 +1319,42 @@ PHP_FUNCTION(mb_http_input)
1319
1319
char * type = NULL ;
1320
1320
size_t type_len = 0 , n ;
1321
1321
const mbfl_encoding * * entry ;
1322
+ const mbfl_encoding * encoding ;
1322
1323
1323
1324
ZEND_PARSE_PARAMETERS_START (0 , 1 )
1324
1325
Z_PARAM_OPTIONAL
1325
1326
Z_PARAM_STRING (type , type_len )
1326
1327
ZEND_PARSE_PARAMETERS_END ();
1327
1328
1328
1329
if (type == NULL ) {
1329
- RETVAL_STRING ( MBSTRG (http_input_identify ) -> name );
1330
+ encoding = MBSTRG (http_input_identify );
1330
1331
} else {
1331
1332
switch (* type ) {
1332
1333
case 'G' :
1333
1334
case 'g' :
1334
- RETVAL_STRING ( MBSTRG (http_input_identify_get ) -> name );
1335
+ encoding = MBSTRG (http_input_identify_get );
1335
1336
break ;
1336
1337
case 'P' :
1337
1338
case 'p' :
1338
- RETVAL_STRING ( MBSTRG (http_input_identify_post ) -> name );
1339
+ encoding = MBSTRG (http_input_identify_post );
1339
1340
break ;
1340
1341
case 'C' :
1341
1342
case 'c' :
1342
- RETVAL_STRING ( MBSTRG (http_input_identify_cookie ) -> name );
1343
+ encoding = MBSTRG (http_input_identify_cookie );
1343
1344
break ;
1344
1345
case 'S' :
1345
1346
case 's' :
1346
- RETVAL_STRING ( MBSTRG (http_input_identify_string ) -> name );
1347
+ encoding = MBSTRG (http_input_identify_string );
1347
1348
break ;
1348
1349
case 'I' :
1349
1350
case 'i' :
1350
1351
entry = MBSTRG (http_input_list );
1351
1352
n = MBSTRG (http_input_list_size );
1352
1353
array_init (return_value );
1353
- for (int i = 0 ; i < n ; i ++ , entry ++ ) {
1354
+ for (size_t i = 0 ; i < n ; i ++ , entry ++ ) {
1354
1355
add_next_index_string (return_value , (* entry )-> name );
1355
1356
}
1356
- break ;
1357
+ return ;
1357
1358
case 'L' :
1358
1359
case 'l' :
1359
1360
entry = MBSTRG (http_input_list );
@@ -1362,24 +1363,31 @@ PHP_FUNCTION(mb_http_input)
1362
1363
// TODO should return empty string?
1363
1364
RETURN_FALSE ;
1364
1365
}
1366
+ // TODO Use smart_str instead.
1365
1367
mbfl_string result ;
1366
1368
mbfl_memory_device device ;
1367
1369
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 ++ ) {
1369
1371
mbfl_memory_device_strcat (& device , (* entry )-> name );
1370
1372
mbfl_memory_device_output (',' , & device );
1371
1373
}
1372
1374
mbfl_memory_device_unput (& device ); /* Remove trailing comma */
1373
1375
mbfl_memory_device_result (& device , & result );
1374
1376
RETVAL_STRINGL ((const char * )result .val , result .len );
1375
1377
mbfl_string_clear (& result );
1376
- break ;
1378
+ return ;
1377
1379
default :
1378
1380
// TODO ValueError
1379
- RETVAL_STRING ( MBSTRG (http_input_identify ) -> name );
1381
+ encoding = MBSTRG (http_input_identify );
1380
1382
break ;
1381
1383
}
1382
1384
}
1385
+
1386
+ if (encoding ) {
1387
+ RETURN_STRING (encoding -> name );
1388
+ } else {
1389
+ RETURN_FALSE ;
1390
+ }
1383
1391
}
1384
1392
/* }}} */
1385
1393
0 commit comments