diff --git a/libc/Makefile b/libc/Makefile index f85516f2..101f5b3f 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -22,6 +22,7 @@ aux/c++.o \ aux/op-new.o \ ctype/isalnum.o \ ctype/isalpha.o \ +ctype/isascii.o \ ctype/isblank.o \ ctype/iscntrl.o \ ctype/isdigit.o \ diff --git a/libc/ctype/isascii.cpp b/libc/ctype/isascii.cpp new file mode 100644 index 00000000..95fcabbd --- /dev/null +++ b/libc/ctype/isascii.cpp @@ -0,0 +1,30 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2014. + + This file is part of the Sortix C Library. + + The Sortix C Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + The Sortix C Library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with the Sortix C Library. If not, see . + + ctype/isascii.cpp + Returns whether the character is an ascii character. + +*******************************************************************************/ + +#include + +extern "C" int isascii(int c) +{ + return 0 <= c && c < 128 ? 1 : 0; +} diff --git a/libc/include/ctype.h b/libc/include/ctype.h index c9f7ecec..a7dd2dd1 100644 --- a/libc/include/ctype.h +++ b/libc/include/ctype.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2014. This file is part of the Sortix C Library. @@ -22,30 +22,51 @@ *******************************************************************************/ -/* TODO: POSIX-1.2008 compliance is only partial */ - -#ifndef _CTYPE_H -#define _CTYPE_H 1 +#ifndef INCLUDE_CTYPE_H +#define INCLUDE_CTYPE_H #include __BEGIN_DECLS -/* TODO: Declare locale_t and the *_t functions here */ +#ifndef __locale_t_defined +#define __locale_t_defined +/* TODO: figure out what this does and typedef it properly. This is just a + temporary assignment. */ +typedef int __locale_t; +typedef __locale_t locale_t; +#endif + int isalnum(int c); +/* TODO: isalnum_l */ int isalpha(int c); +/* TODO: isalpha_l */ +int isascii(int c); +/* TODO: isascii_l */ int isblank(int c); +/* TODO: isblank_l */ int iscntrl(int c); +/* TODO: iscntrl_l */ int isdigit(int c); +/* TODO: isdigit_l */ int isgraph(int c); +/* TODO: isgraph_l */ int islower(int c); +/* TODO: islower_l */ int isprint(int c); +/* TODO: isprint_l */ int ispunct(int c); +/* TODO: ispunct_l */ int isspace(int c); +/* TODO: isspace_l */ int isupper(int c); +/* TODO: isupper_l */ int isxdigit(int c); +/* TODO: isxdigit_l */ int tolower(int c); +/* TODO: tolower_l */ int toupper(int c); +/* TODO: toupper_l */ __END_DECLS