Skip to content

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

@cfriedt

Description

@cfriedt

Describe the bug

The minimal libc is missing isblank() (C99), islower() (C89), and ispunct() (C89).

Regression

  • This is a regression.

Steps to reproduce

  1. apply the following diff
diff --git a/samples/hello_world/src/main.c b/samples/hello_world/src/main.c
index c550ab461cb..d0f1f87de30 100644
--- a/samples/hello_world/src/main.c
+++ b/samples/hello_world/src/main.c
@@ -4,11 +4,12 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
+#include <ctype.h>
 #include <stdio.h>
 
 int main(void)
 {
        printf("Hello World! %s\n", CONFIG_BOARD_TARGET);
 
-       return 0;
+       return isblank('x') || islower('X') || ispunct('x');
 }
  1. west build -p auto -b qemu_riscv64 samples/hello_world -- -DCONFIG_MINIMAL_LIBC=y -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
  2. See error

Relevant log output

ZEPHYR_BASE/samples/hello_world/src/main.c:14:16: error: implicit declaration of function 'isblank' [-Werror=implicit-function-declaration]
   14 |         return isblank('x') || islower('X') || ispunct('x');
      |                ^~~~~~~
ZEPHYR_BASE/samples/hello_world/src/main.c:14:32: error: implicit declaration of function 'islower'; did you mean 'tolower'? [-Werror=implicit-function-declaration]
   14 |         return isblank('x') || islower('X') || ispunct('x');
      |                                ^~~~~~~
      |                                tolower
ZEPHYR_BASE/samples/hello_world/src/main.c:14:48: error: implicit declaration of function 'ispunct' [-Werror=implicit-function-declaration]
   14 |         return isblank('x') || islower('X') || ispunct('x');
      |                                                ^~~~

Impact

Major – Severely degrades functionality; workaround is difficult or unavailable.

Environment

  • OS: any
  • Toolchain: Zephyr SDK v0.17.4
  • Commit SHA or Version used: v4.3.0

Additional Context

Blocks #97400 (in terms of testing), #55186

Metadata

Metadata

Assignees

Labels

area: C LibraryC Standard Libraryarea: Minimal libcMinimal C Standard LibrarybugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions