Skip to content

Conversation

@cfriedt
Copy link
Member

@cfriedt cfriedt commented Nov 15, 2025

Add the functions below to the minimal libc ctype.h since they are missing, and are required as of C89 (C99 for isblank())

  • isblank()
  • islower()
  • ispunct()

Fixes #99452

Add the functions below to the minimal libc ctype.h since they are
missing, and are required as of C89 (C99 for `isblank()`)

* `isblank()`
* `islower()`
* `ispunct()`

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
@cfriedt cfriedt force-pushed the add-missing-ctype-functions-to-minimal-libc branch from 32d89a3 to 2960508 Compare November 15, 2025 22:06
@cfriedt cfriedt added bug The issue is a bug, or the PR is fixing a bug area: Minimal libc Minimal C Standard Library labels Nov 15, 2025
@sonarqubecloud
Copy link

@cfriedt
Copy link
Member Author

cfriedt commented Nov 15, 2025

  • Added Compliance: False Positive because the coding style follows what is currently in the file

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
Contributor

@keith-packard keith-packard left a comment

Choose a reason for hiding this comment

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

Please express these directly rather than using arithmetic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: C Library C Standard Library area: Minimal libc Minimal C Standard Library bug The issue is a bug, or the PR is fixing a bug Compliance: False Positive

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libc: minimal: missing ctype.h functions isblank(), islower(), and ispunct()

4 participants