Skip to content

Commit ce82c48

Browse files
committed
ext/mbstring: Use bool where more appropriate instead of int
1 parent 3f64a7c commit ce82c48

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

ext/mbstring/mbstring.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,23 +1407,23 @@ PHP_FUNCTION(mb_detect_order)
14071407
}
14081408
/* }}} */
14091409

1410-
static inline int php_mb_check_code_point(zend_long cp)
1410+
static inline bool php_mb_check_code_point(zend_long cp)
14111411
{
14121412
if (cp < 0 || cp >= 0x110000) {
14131413
/* Out of Unicode range */
1414-
return 0;
1414+
return false;
14151415
}
14161416

14171417
if (cp >= 0xd800 && cp <= 0xdfff) {
14181418
/* Surrogate code-point. These are never valid on their own and we only allow a single
14191419
* substitute character. */
1420-
return 0;
1420+
return false;
14211421
}
14221422

14231423
/* As we do not know the target encoding of the conversion operation that is going to
14241424
* use the substitution character, we cannot check whether the codepoint is actually mapped
14251425
* in the given encoding at this point. Thus we have to accept everything. */
1426-
return 1;
1426+
return true;
14271427
}
14281428

14291429
/* {{{ Sets the current substitute_character or returns the current substitute_character */
@@ -5509,38 +5509,38 @@ static bool mb_check_str_encoding(zend_string *str, const mbfl_encoding *encodin
55095509
}
55105510
}
55115511

5512-
static int php_mb_check_encoding_recursive(HashTable *vars, const mbfl_encoding *encoding)
5512+
static bool php_mb_check_encoding_recursive(HashTable *vars, const mbfl_encoding *encoding)
55135513
{
55145514
zend_long idx;
55155515
zend_string *key;
55165516
zval *entry;
5517-
int valid = 1;
5517+
bool valid = true;
55185518

55195519
(void)(idx); /* Suppress spurious compiler warning that `idx` is not used */
55205520

55215521
if (GC_IS_RECURSIVE(vars)) {
55225522
php_error_docref(NULL, E_WARNING, "Cannot not handle circular references");
5523-
return 0;
5523+
return false;
55245524
}
55255525
GC_TRY_PROTECT_RECURSION(vars);
55265526
ZEND_HASH_FOREACH_KEY_VAL(vars, idx, key, entry) {
55275527
ZVAL_DEREF(entry);
55285528
if (key) {
55295529
if (!mb_check_str_encoding(key, encoding)) {
5530-
valid = 0;
5530+
valid = false;
55315531
break;
55325532
}
55335533
}
55345534
switch (Z_TYPE_P(entry)) {
55355535
case IS_STRING:
55365536
if (!mb_check_str_encoding(Z_STR_P(entry), encoding)) {
5537-
valid = 0;
5537+
valid = false;
55385538
break;
55395539
}
55405540
break;
55415541
case IS_ARRAY:
55425542
if (!php_mb_check_encoding_recursive(Z_ARRVAL_P(entry), encoding)) {
5543-
valid = 0;
5543+
valid = false;
55445544
break;
55455545
}
55465546
break;
@@ -5552,7 +5552,7 @@ static int php_mb_check_encoding_recursive(HashTable *vars, const mbfl_encoding
55525552
break;
55535553
default:
55545554
/* Other types are error. */
5555-
valid = 0;
5555+
valid = false;
55565556
break;
55575557
}
55585558
} ZEND_HASH_FOREACH_END();

0 commit comments

Comments
 (0)