Skip to content
Open
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
15 changes: 15 additions & 0 deletions lib/libc/minimal/include/ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
return (int)((((unsigned)c|32u)-(unsigned)'a') < 26U);
}

static inline int isblank(int c)
{
return (int)((c == (int)' ') || (c == (int)'\t'));
}

static inline int isspace(int c)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd let the compiler do something cute if it likes, but express these in a direct fashion.

static inline int isspace (int c)
{
    return c == ' ' || ('\t' <= c && c <= '\r');
}

Similarly for the other functions. There's no reason to obscure what these functions do; having to check that there are 5 'blank' values between '\t' and '\r' is something the compiler should do, not us.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll prepend a commit for that, since it's technically not related to the bugfix.

Copy link
Member Author

Choose a reason for hiding this comment

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

I could also prepend a commit that would eliminate linter issues as well (and fix up the commit I added).

{
return (int)(c == (int)' ' || ((unsigned)c-(unsigned)'\t') < 5U);
Expand All @@ -45,6 +50,11 @@
return (int)(((unsigned)(a)-(unsigned)'0') < 10U);
}

static inline int islower(int c)
{
return (int)(((unsigned)(c) - (unsigned)'a') < 26U);

Check warning on line 55 in lib/libc/minimal/include/ctype.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

UNSPECIFIED_INT

lib/libc/minimal/include/ctype.h:55 Prefer 'unsigned int' to bare use of 'unsigned'

Check warning on line 55 in lib/libc/minimal/include/ctype.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

UNSPECIFIED_INT

lib/libc/minimal/include/ctype.h:55 Prefer 'unsigned int' to bare use of 'unsigned'

Check warning on line 55 in lib/libc/minimal/include/ctype.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

UNSPECIFIED_INT

lib/libc/minimal/include/ctype.h:55 Prefer 'unsigned int' to bare use of 'unsigned'

Check warning on line 55 in lib/libc/minimal/include/ctype.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

UNSPECIFIED_INT

lib/libc/minimal/include/ctype.h:55 Prefer 'unsigned int' to bare use of 'unsigned'

Check warning on line 55 in lib/libc/minimal/include/ctype.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

UNSPECIFIED_INT

lib/libc/minimal/include/ctype.h:55 Prefer 'unsigned int' to bare use of 'unsigned'

Check warning on line 55 in lib/libc/minimal/include/ctype.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

UNSPECIFIED_INT

lib/libc/minimal/include/ctype.h:55 Prefer 'unsigned int' to bare use of 'unsigned'
}

static inline int isxdigit(int a)
{
unsigned int ua = (unsigned int)a;
Expand All @@ -69,6 +79,11 @@
return (int)(isalpha(chr) || isdigit(chr));
}

static inline int ispunct(int c)
{
return (int)(isgraph(c) && !isalnum(c));
}

static inline int iscntrl(int c)
{
return (int)((((unsigned int)c) <= 31U) || (((unsigned int)c) == 127U));
Expand Down
Loading