Skip to content

Commit 66733bb

Browse files
committed
ext/standard/scanf: refactor CharInSet()
1 parent a9b3e7f commit 66733bb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

ext/standard/scanf.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ typedef zend_long (*int_string_formater)(const char*, char**, int);
107107
* Declarations for functions used only in this file.
108108
*/
109109
static char *BuildCharSet(CharSet *cset, char *format);
110-
static int CharInSet(CharSet *cset, int ch);
110+
static bool CharInSet(const CharSet *cset, char c);
111111
static void ReleaseCharSet(CharSet *cset);
112112
static inline void scan_set_error_return(bool assignToVariables, zval *return_value);
113113

@@ -230,22 +230,22 @@ static char * BuildCharSet(CharSet *cset, char *format)
230230
*
231231
*----------------------------------------------------------------------
232232
*/
233-
static int CharInSet(CharSet *cset, int c)
233+
static bool CharInSet(const CharSet *cset, char c)
234234
{
235-
char ch = (char) c;
236-
int i, match = 0;
235+
int i;
236+
bool match = false;
237237

238238
for (i = 0; i < cset->nchars; i++) {
239-
if (cset->chars[i] == ch) {
240-
match = 1;
239+
if (cset->chars[i] == c) {
240+
match = true;
241241
break;
242242
}
243243
}
244244
if (!match) {
245245
for (i = 0; i < cset->nranges; i++) {
246-
if ((cset->ranges[i].start <= ch)
247-
&& (ch <= cset->ranges[i].end)) {
248-
match = 1;
246+
if ((cset->ranges[i].start <= c)
247+
&& (c <= cset->ranges[i].end)) {
248+
match = true;
249249
break;
250250
}
251251
}
@@ -861,7 +861,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
861861
format = BuildCharSet(&cset, format);
862862
while (*end != '\0') {
863863
sch = *end;
864-
if (!CharInSet(&cset, (int)sch)) {
864+
if (!CharInSet(&cset, sch)) {
865865
break;
866866
}
867867
end++;

0 commit comments

Comments
 (0)