Skip to content

Commit 3c311c9

Browse files
committed
ext/mbstring: Use bool where more appropriate instead of int
1 parent 07b006f commit 3c311c9

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
@@ -1403,23 +1403,23 @@ PHP_FUNCTION(mb_detect_order)
14031403
}
14041404
/* }}} */
14051405

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

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

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

14251425
/* {{{ Sets the current substitute_character or returns the current substitute_character */
@@ -5296,38 +5296,38 @@ static bool mb_check_str_encoding(zend_string *str, const mbfl_encoding *encodin
52965296
}
52975297
}
52985298

5299-
static int php_mb_check_encoding_recursive(HashTable *vars, const mbfl_encoding *encoding)
5299+
static bool php_mb_check_encoding_recursive(HashTable *vars, const mbfl_encoding *encoding)
53005300
{
53015301
zend_long idx;
53025302
zend_string *key;
53035303
zval *entry;
5304-
int valid = 1;
5304+
bool valid = true;
53055305

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

53085308
if (GC_IS_RECURSIVE(vars)) {
53095309
php_error_docref(NULL, E_WARNING, "Cannot not handle circular references");
5310-
return 0;
5310+
return false;
53115311
}
53125312
GC_TRY_PROTECT_RECURSION(vars);
53135313
ZEND_HASH_FOREACH_KEY_VAL(vars, idx, key, entry) {
53145314
ZVAL_DEREF(entry);
53155315
if (key) {
53165316
if (!mb_check_str_encoding(key, encoding)) {
5317-
valid = 0;
5317+
valid = false;
53185318
break;
53195319
}
53205320
}
53215321
switch (Z_TYPE_P(entry)) {
53225322
case IS_STRING:
53235323
if (!mb_check_str_encoding(Z_STR_P(entry), encoding)) {
5324-
valid = 0;
5324+
valid = false;
53255325
break;
53265326
}
53275327
break;
53285328
case IS_ARRAY:
53295329
if (!php_mb_check_encoding_recursive(Z_ARRVAL_P(entry), encoding)) {
5330-
valid = 0;
5330+
valid = false;
53315331
break;
53325332
}
53335333
break;
@@ -5339,7 +5339,7 @@ static int php_mb_check_encoding_recursive(HashTable *vars, const mbfl_encoding
53395339
break;
53405340
default:
53415341
/* Other types are error. */
5342-
valid = 0;
5342+
valid = false;
53435343
break;
53445344
}
53455345
} ZEND_HASH_FOREACH_END();

0 commit comments

Comments
 (0)