Skip to content

[modify] internal function 'isdigit' name to '_isdigit' #3764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/kservice.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void rt_show_version(void)
RTM_EXPORT(rt_show_version);

/* private function */
#define isdigit(c) ((unsigned)((c) - '0') < 10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里实现的 isdigit 宏使用了小写,可能会和 libc 中的函数符号重名。

作为一个宏来讲,一般情况下会使用大写来区分,经过测试,如果将该宏改为大写,也可以避免此条静态检查报错。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试改成大写也可以,是否改成大写?

#define _ISDIGIT(c) ((unsigned)((c) - '0') < 10)

#ifdef RT_PRINTF_LONGLONG
rt_inline int divide(long long *n, int base)
Expand Down Expand Up @@ -588,7 +588,7 @@ rt_inline int divide(long *n, int base)
rt_inline int skip_atoi(const char **s)
{
register int i = 0;
while (isdigit(**s))
while (_ISDIGIT(**s))
i = i * 10 + *((*s)++) - '0';

return i;
Expand Down Expand Up @@ -834,7 +834,7 @@ rt_int32_t rt_vsnprintf(char *buf,

/* get field width */
field_width = -1;
if (isdigit(*fmt)) field_width = skip_atoi(&fmt);
if (_ISDIGIT(*fmt)) field_width = skip_atoi(&fmt);
else if (*fmt == '*')
{
++ fmt;
Expand All @@ -853,7 +853,7 @@ rt_int32_t rt_vsnprintf(char *buf,
if (*fmt == '.')
{
++ fmt;
if (isdigit(*fmt)) precision = skip_atoi(&fmt);
if (_ISDIGIT(*fmt)) precision = skip_atoi(&fmt);
else if (*fmt == '*')
{
++ fmt;
Expand Down