scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 368a6a533e6414844d59e85f3aaca0d99bc54713
parent 1f90172f8e7790879ee606e450ec84d0d638062a
Author: Quentin Rameau <quinq@fifth.space>
Date:   Fri, 28 Dec 2018 23:52:44 +0100

[libc] Add toascii

We already have isascii() and to* is reserved namespace so let's
add it.

Diffstat:
Minclude/ctype.h | 1+
Msrc/libc/ctype/Makefile | 1+
Asrc/libc/ctype/toascii.c | 8++++++++
3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/ctype.h b/include/ctype.h @@ -41,5 +41,6 @@ extern const unsigned char __ctype[]; #define isxdigit(c) ((__ctype+1)[c] & (_D|_X)) #define isascii(c) ((unsigned)(c)<=0x7f) +#define toascii(c) ((unsigned)(c)&0x7f) #endif diff --git a/src/libc/ctype/Makefile b/src/libc/ctype/Makefile @@ -17,6 +17,7 @@ OBJS = ctype.o\ isspace.o\ isupper.o\ isxdigit.o\ + toascii.o\ tolower.o\ toupper.o\ diff --git a/src/libc/ctype/toascii.c b/src/libc/ctype/toascii.c @@ -0,0 +1,8 @@ +#include <ctype.h> +#undef toascii + +int +toascii(int c) +{ + return c & 0x7f; +}