Skip to content

Commit 3f64a7c

Browse files
committed
ext/mbstring: Use unsigned int where more appropriate instead of int
1 parent 7c1ec84 commit 3f64a7c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ext/mbstring/mbstring.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,9 +2494,9 @@ static size_t character_width(uint32_t c)
24942494
}
24952495

24962496
/* Do a binary search to see if we fall in any of the fullwidth ranges */
2497-
int lo = 0, hi = sizeof(mbfl_eaw_table) / sizeof(mbfl_eaw_table[0]);
2497+
unsigned int lo = 0, hi = sizeof(mbfl_eaw_table) / sizeof(mbfl_eaw_table[0]);
24982498
while (lo < hi) {
2499-
int probe = (lo + hi) / 2;
2499+
unsigned int probe = (lo + hi) / 2;
25002500
if (c < mbfl_eaw_table[probe].begin) {
25012501
hi = probe;
25022502
} else if (c > mbfl_eaw_table[probe].end) {
@@ -2570,7 +2570,7 @@ static zend_string* mb_trim_string(zend_string *input, zend_string *marker, cons
25702570
if (out_len <= to_skip) {
25712571
to_skip -= out_len;
25722572
} else {
2573-
for (int i = to_skip; i < out_len; i++) {
2573+
for (unsigned int i = to_skip; i < out_len; i++) {
25742574
uint32_t w = wchar_buf[i];
25752575
input_err |= (w == MBFL_BAD_INPUT);
25762576
remaining_width -= character_width(w);
@@ -2630,7 +2630,7 @@ static zend_string* mb_trim_string(zend_string *input, zend_string *marker, cons
26302630
if (out_len <= from) {
26312631
from -= out_len;
26322632
} else {
2633-
for (int i = from; i < out_len; i++) {
2633+
for (unsigned int i = from; i < out_len; i++) {
26342634
width -= character_width(wchar_buf[i]);
26352635
if (width < 0) {
26362636
enc->from_wchar(wchar_buf + from, i - from, &buf, true);
@@ -2831,8 +2831,8 @@ static void remove_non_encodings_from_elist(const mbfl_encoding **elist, size_t
28312831
/* mbstring supports some 'text encodings' which aren't really text encodings
28322832
* at all, but really 'byte encodings', like Base64, QPrint, and so on.
28332833
* These should never be returned by `mb_detect_encoding`. */
2834-
int shift = 0;
2835-
for (int i = 0; i < *size; i++) {
2834+
unsigned int shift = 0;
2835+
for (unsigned int i = 0; i < *size; i++) {
28362836
const mbfl_encoding *encoding = elist[i];
28372837
if (encoding->no_encoding <= mbfl_no_encoding_charset_min) {
28382838
shift++; /* Remove this encoding from the list */
@@ -4822,7 +4822,7 @@ MBSTRING_API bool php_mb_check_encoding(const char *input, size_t length, const
48224822
* buffer of 128 codepoints, convert and check just a few codepoints first */
48234823
size_t out_len = encoding->to_wchar(&in, &length, wchar_buf, 8, &state);
48244824
ZEND_ASSERT(out_len <= 8);
4825-
for (int i = 0; i < out_len; i++) {
4825+
for (unsigned int i = 0; i < out_len; i++) {
48264826
if (wchar_buf[i] == MBFL_BAD_INPUT) {
48274827
return false;
48284828
}
@@ -4831,7 +4831,7 @@ MBSTRING_API bool php_mb_check_encoding(const char *input, size_t length, const
48314831
while (length) {
48324832
out_len = encoding->to_wchar(&in, &length, wchar_buf, 128, &state);
48334833
ZEND_ASSERT(out_len <= 128);
4834-
for (int i = 0; i < out_len; i++) {
4834+
for (unsigned int i = 0; i < out_len; i++) {
48354835
if (wchar_buf[i] == MBFL_BAD_INPUT) {
48364836
return false;
48374837
}

0 commit comments

Comments
 (0)