Add isascii(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2014-04-02 17:56:48 +02:00
parent bcf0720a59
commit 7f7fd66039
3 changed files with 58 additions and 6 deletions

View File

@ -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 \

30
libc/ctype/isascii.cpp Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
ctype/isascii.cpp
Returns whether the character is an ascii character.
*******************************************************************************/
#include <ctype.h>
extern "C" int isascii(int c)
{
return 0 <= c && c < 128 ? 1 : 0;
}

View File

@ -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 <sys/cdefs.h>
__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