Skip to content

Commit 07b006f

Browse files
committed
ext/mbstring: Use unsigned int where more appropriate instead of int
1 parent c6f5651 commit 07b006f

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
@@ -2457,9 +2457,9 @@ static size_t character_width(uint32_t c)
24572457
}
24582458

24592459
/* Do a binary search to see if we fall in any of the fullwidth ranges */
2460-
int lo = 0, hi = sizeof(mbfl_eaw_table) / sizeof(mbfl_eaw_table[0]);
2460+
unsigned int lo = 0, hi = sizeof(mbfl_eaw_table) / sizeof(mbfl_eaw_table[0]);
24612461
while (lo < hi) {
2462-
int probe = (lo + hi) / 2;
2462+
unsigned int probe = (lo + hi) / 2;
24632463
if (c < mbfl_eaw_table[probe].begin) {
24642464
hi = probe;
24652465
} else if (c > mbfl_eaw_table[probe].end) {
@@ -2533,7 +2533,7 @@ static zend_string* mb_trim_string(zend_string *input, zend_string *marker, cons
25332533
if (out_len <= to_skip) {
25342534
to_skip -= out_len;
25352535
} else {
2536-
for (int i = to_skip; i < out_len; i++) {
2536+
for (unsigned int i = to_skip; i < out_len; i++) {
25372537
uint32_t w = wchar_buf[i];
25382538
input_err |= (w == MBFL_BAD_INPUT);
25392539
remaining_width -= character_width(w);
@@ -2593,7 +2593,7 @@ static zend_string* mb_trim_string(zend_string *input, zend_string *marker, cons
25932593
if (out_len <= from) {
25942594
from -= out_len;
25952595
} else {
2596-
for (int i = from; i < out_len; i++) {
2596+
for (unsigned int i = from; i < out_len; i++) {
25972597
width -= character_width(wchar_buf[i]);
25982598
if (width < 0) {
25992599
enc->from_wchar(wchar_buf + from, i - from, &buf, true);
@@ -2794,8 +2794,8 @@ static void remove_non_encodings_from_elist(const mbfl_encoding **elist, size_t
27942794
/* mbstring supports some 'text encodings' which aren't really text encodings
27952795
* at all, but really 'byte encodings', like Base64, QPrint, and so on.
27962796
* These should never be returned by `mb_detect_encoding`. */
2797-
int shift = 0;
2798-
for (int i = 0; i < *size; i++) {
2797+
unsigned int shift = 0;
2798+
for (unsigned int i = 0; i < *size; i++) {
27992799
const mbfl_encoding *encoding = elist[i];
28002800
if (encoding->no_encoding <= mbfl_no_encoding_charset_min) {
28012801
shift++; /* Remove this encoding from the list */
@@ -4620,7 +4620,7 @@ MBSTRING_API bool php_mb_check_encoding(const char *input, size_t length, const
46204620
* buffer of 128 codepoints, convert and check just a few codepoints first */
46214621
size_t out_len = encoding->to_wchar(&in, &length, wchar_buf, 8, &state);
46224622
ZEND_ASSERT(out_len <= 8);
4623-
for (int i = 0; i < out_len; i++) {
4623+
for (unsigned int i = 0; i < out_len; i++) {
46244624
if (wchar_buf[i] == MBFL_BAD_INPUT) {
46254625
return false;
46264626
}
@@ -4629,7 +4629,7 @@ MBSTRING_API bool php_mb_check_encoding(const char *input, size_t length, const
46294629
while (length) {
46304630
out_len = encoding->to_wchar(&in, &length, wchar_buf, 128, &state);
46314631
ZEND_ASSERT(out_len <= 128);
4632-
for (int i = 0; i < out_len; i++) {
4632+
for (unsigned int i = 0; i < out_len; i++) {
46334633
if (wchar_buf[i] == MBFL_BAD_INPUT) {
46344634
return false;
46354635
}

0 commit comments

Comments
 (0)