Simplify the logic for parsing bool.
This commit is contained in:
1 parent
d4016b310d
commit
e33e77595f
1 file changed
+3
-8
@@ -1315,11 +1315,8 @@ static inline bool
|
|||||||
m_core_fscan_bool (bool *ptr, FILE *f)
|
m_core_fscan_bool (bool *ptr, FILE *f)
|
||||||
{
|
{
|
||||||
char c = fgetc(f);
|
char c = fgetc(f);
|
||||||
if (c == '0' || c == '1') {
|
*ptr = (c == '1');
|
||||||
*ptr = (c == '1');
|
return (c == '0' || c == '1');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define M_FSCAN_DEFAULT_TYPE_DEF(name, type, format) \
|
#define M_FSCAN_DEFAULT_TYPE_DEF(name, type, format) \
|
||||||
@@ -1386,11 +1383,9 @@ static inline bool
|
|||||||
m_core_parse_bool (bool *ptr, const char str[], const char **endptr)
|
m_core_parse_bool (bool *ptr, const char str[], const char **endptr)
|
||||||
{
|
{
|
||||||
char c = *str++;
|
char c = *str++;
|
||||||
if (c != '0' && c != '1')
|
|
||||||
return false;
|
|
||||||
*ptr = (c == '1');
|
*ptr = (c == '1');
|
||||||
if (endptr != NULL) *endptr = str;
|
if (endptr != NULL) *endptr = str;
|
||||||
return true;
|
return (c == '0' || c == '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
#define M_PARSE_DEFAULT_TYPE_DEF(name, type, parse_func, extra_arg) \
|
#define M_PARSE_DEFAULT_TYPE_DEF(name, type, parse_func, extra_arg) \
|
||||||
|
|||||||
Reference in new issue
Block a user