Skip to content

Commit

Permalink
libutils: isoc: implement tolower(), isdigit() and isxdigit()
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Acked-by: Joakim Bech <[email protected]>
  • Loading branch information
jforissier committed May 4, 2018
1 parent fb30caf commit d815ab4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
12 changes: 12 additions & 0 deletions lib/libutils/isoc/isdigit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (c) 2018, Linaro Limited
*/
#include <ctype.h>

int __builtin_isdigit(int c)
{
if (c >= '0' && c <= '9')
return 1;
return 0;
}
16 changes: 16 additions & 0 deletions lib/libutils/isoc/isxdigit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (c) 2018, Linaro Limited
*/
#include <ctype.h>

int __builtin_isxdigit(int c)
{
if (isdigit(c))
return 1;
if (c >= 'A' && c <= 'F')
return 1;
if (c >= 'a' && c <= 'f')
return 1;
return 0;
}
10 changes: 5 additions & 5 deletions lib/libutils/isoc/sub.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ cflags-bget_malloc.c-y += -Wno-sign-compare -Wno-cast-align
ifeq ($(sm),core)
cflags-remove-bget_malloc.c-y += $(cflags_kasan)
endif
srcs-y += isdigit.c
srcs-y += isxdigit.c
srcs-y += malloc_lock.c

srcs-y += snprintf.c

srcs-y += stack_check.c
srcs-y += qsort.c
cflags-qsort.c-y += -Wno-inline
cflags-remove-qsort.c-y += -Wcast-align

srcs-y += snprintf.c
srcs-y += stack_check.c
srcs-y += strdup.c
srcs-y += strndup.c
srcs-y += tolower.c

subdirs-y += newlib
subdirs-$(arch_arm) += arch/$(ARCH)
12 changes: 12 additions & 0 deletions lib/libutils/isoc/tolower.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (c) 2015, Linaro Limited
*/
#include <ctype.h>

int __builtin_tolower(int c)
{
if (c >= 'A' && c <= 'Z')
return c - 'A' + 'a';
return c;
}

0 comments on commit d815ab4

Please sign in to comment.