scc

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

commit d7511b681b42b4367cb5818a5d949010c5910980
parent 08c48f8d3da19e4f1a70e8da9bdef305002666de
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; +}