compiled newlib, need to hook up the system calls
This commit is contained in:
38
rocklibc/src/ctype/isalnum.c
Normal file
38
rocklibc/src/ctype/isalnum.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* isalnum( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isalnum( int c )
|
||||
{
|
||||
return ( isdigit( c ) || isalpha( c ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isalnum( 'a' ) );
|
||||
TESTCASE( isalnum( 'z' ) );
|
||||
TESTCASE( isalnum( 'A' ) );
|
||||
TESTCASE( isalnum( 'Z' ) );
|
||||
TESTCASE( isalnum( '0' ) );
|
||||
TESTCASE( isalnum( '9' ) );
|
||||
TESTCASE( ! isalnum( ' ' ) );
|
||||
TESTCASE( ! isalnum( '\n' ) );
|
||||
TESTCASE( ! isalnum( '@' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
34
rocklibc/src/ctype/isalpha.c
Normal file
34
rocklibc/src/ctype/isalpha.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* isalpha( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isalpha( int c )
|
||||
{
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_ALPHA );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isalpha( 'a' ) );
|
||||
TESTCASE( isalpha( 'z' ) );
|
||||
TESTCASE( ! isalpha( ' ' ) );
|
||||
TESTCASE( ! isalpha( '1' ) );
|
||||
TESTCASE( ! isalpha( '@' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
35
rocklibc/src/ctype/isblank.c
Normal file
35
rocklibc/src/ctype/isblank.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* isblank( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isblank( int c )
|
||||
{
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_BLANK );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isblank( ' ' ) );
|
||||
TESTCASE( isblank( '\t' ) );
|
||||
TESTCASE( ! isblank( '\v' ) );
|
||||
TESTCASE( ! isblank( '\r' ) );
|
||||
TESTCASE( ! isblank( 'x' ) );
|
||||
TESTCASE( ! isblank( '@' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
33
rocklibc/src/ctype/iscntrl.c
Normal file
33
rocklibc/src/ctype/iscntrl.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* iscntrl( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int iscntrl( int c )
|
||||
{
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_CNTRL );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( iscntrl( '\a' ) );
|
||||
TESTCASE( iscntrl( '\b' ) );
|
||||
TESTCASE( iscntrl( '\n' ) );
|
||||
TESTCASE( ! iscntrl( ' ' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
34
rocklibc/src/ctype/isdigit.c
Normal file
34
rocklibc/src/ctype/isdigit.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* isdigit( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isdigit( int c )
|
||||
{
|
||||
return ( c >= _PDCLIB_lc_ctype->digits_low && c <= _PDCLIB_lc_ctype->digits_high );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isdigit( '0' ) );
|
||||
TESTCASE( isdigit( '9' ) );
|
||||
TESTCASE( ! isdigit( ' ' ) );
|
||||
TESTCASE( ! isdigit( 'a' ) );
|
||||
TESTCASE( ! isdigit( '@' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
37
rocklibc/src/ctype/isgraph.c
Normal file
37
rocklibc/src/ctype/isgraph.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/* isgraph( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isgraph( int c )
|
||||
{
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_GRAPH );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isgraph( 'a' ) );
|
||||
TESTCASE( isgraph( 'z' ) );
|
||||
TESTCASE( isgraph( 'A' ) );
|
||||
TESTCASE( isgraph( 'Z' ) );
|
||||
TESTCASE( isgraph( '@' ) );
|
||||
TESTCASE( ! isgraph( '\t' ) );
|
||||
TESTCASE( ! isgraph( '\0' ) );
|
||||
TESTCASE( ! isgraph( ' ' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
35
rocklibc/src/ctype/islower.c
Normal file
35
rocklibc/src/ctype/islower.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* islower( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int islower( int c )
|
||||
{
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_LOWER );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( islower( 'a' ) );
|
||||
TESTCASE( islower( 'z' ) );
|
||||
TESTCASE( ! islower( 'A' ) );
|
||||
TESTCASE( ! islower( 'Z' ) );
|
||||
TESTCASE( ! islower( ' ' ) );
|
||||
TESTCASE( ! islower( '@' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
38
rocklibc/src/ctype/isprint.c
Normal file
38
rocklibc/src/ctype/isprint.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* isprint( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isprint( int c )
|
||||
{
|
||||
/* FIXME: Space as of current locale charset, not source charset. */
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_GRAPH ) || ( c == ' ' );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isprint( 'a' ) );
|
||||
TESTCASE( isprint( 'z' ) );
|
||||
TESTCASE( isprint( 'A' ) );
|
||||
TESTCASE( isprint( 'Z' ) );
|
||||
TESTCASE( isprint( '@' ) );
|
||||
TESTCASE( ! isprint( '\t' ) );
|
||||
TESTCASE( ! isprint( '\0' ) );
|
||||
TESTCASE( isprint( ' ' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
38
rocklibc/src/ctype/ispunct.c
Normal file
38
rocklibc/src/ctype/ispunct.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* ispunct( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int ispunct( int c )
|
||||
{
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_PUNCT );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( ! ispunct( 'a' ) );
|
||||
TESTCASE( ! ispunct( 'z' ) );
|
||||
TESTCASE( ! ispunct( 'A' ) );
|
||||
TESTCASE( ! ispunct( 'Z' ) );
|
||||
TESTCASE( ispunct( '@' ) );
|
||||
TESTCASE( ispunct( '.' ) );
|
||||
TESTCASE( ! ispunct( '\t' ) );
|
||||
TESTCASE( ! ispunct( '\0' ) );
|
||||
TESTCASE( ! ispunct( ' ' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
36
rocklibc/src/ctype/isspace.c
Normal file
36
rocklibc/src/ctype/isspace.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* isspace( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isspace( int c )
|
||||
{
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_SPACE );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isspace( ' ' ) );
|
||||
TESTCASE( isspace( '\f' ) );
|
||||
TESTCASE( isspace( '\n' ) );
|
||||
TESTCASE( isspace( '\r' ) );
|
||||
TESTCASE( isspace( '\t' ) );
|
||||
TESTCASE( isspace( '\v' ) );
|
||||
TESTCASE( ! isspace( 'a' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
35
rocklibc/src/ctype/isupper.c
Normal file
35
rocklibc/src/ctype/isupper.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* isupper( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isupper( int c )
|
||||
{
|
||||
return ( _PDCLIB_lc_ctype->entry[c].flags & _PDCLIB_CTYPE_UPPER );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isupper( 'A' ) );
|
||||
TESTCASE( isupper( 'Z' ) );
|
||||
TESTCASE( ! isupper( 'a' ) );
|
||||
TESTCASE( ! isupper( 'z' ) );
|
||||
TESTCASE( ! isupper( ' ' ) );
|
||||
TESTCASE( ! isupper( '@' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
42
rocklibc/src/ctype/isxdigit.c
Normal file
42
rocklibc/src/ctype/isxdigit.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/* isxdigit( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int isxdigit( int c )
|
||||
{
|
||||
return ( isdigit( c ) ||
|
||||
( c >= _PDCLIB_lc_ctype->Xdigits_low && c <= _PDCLIB_lc_ctype->Xdigits_high ) ||
|
||||
( c >= _PDCLIB_lc_ctype->xdigits_low && c <= _PDCLIB_lc_ctype->xdigits_high )
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( isxdigit( '0' ) );
|
||||
TESTCASE( isxdigit( '9' ) );
|
||||
TESTCASE( isxdigit( 'a' ) );
|
||||
TESTCASE( isxdigit( 'f' ) );
|
||||
TESTCASE( ! isxdigit( 'g' ) );
|
||||
TESTCASE( isxdigit( 'A' ) );
|
||||
TESTCASE( isxdigit( 'F' ) );
|
||||
TESTCASE( ! isxdigit( 'G' ) );
|
||||
TESTCASE( ! isxdigit( '@' ) );
|
||||
TESTCASE( ! isxdigit( ' ' ) );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
35
rocklibc/src/ctype/tolower.c
Normal file
35
rocklibc/src/ctype/tolower.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* tolower( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int tolower( int c )
|
||||
{
|
||||
return _PDCLIB_lc_ctype->entry[c].lower;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( tolower( 'A' ) == 'a' );
|
||||
TESTCASE( tolower( 'Z' ) == 'z' );
|
||||
TESTCASE( tolower( 'a' ) == 'a' );
|
||||
TESTCASE( tolower( 'z' ) == 'z' );
|
||||
TESTCASE( tolower( '@' ) == '@' );
|
||||
TESTCASE( tolower( '[' ) == '[' );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
35
rocklibc/src/ctype/toupper.c
Normal file
35
rocklibc/src/ctype/toupper.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* toupper( int )
|
||||
|
||||
This file is part of the Public Domain C Library (PDCLib).
|
||||
Permission is granted to use, modify, and / or redistribute at will.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef REGTEST
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
int toupper( int c )
|
||||
{
|
||||
return _PDCLIB_lc_ctype->entry[c].upper;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include "_PDCLIB_test.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
TESTCASE( toupper( 'a' ) == 'A' );
|
||||
TESTCASE( toupper( 'z' ) == 'Z' );
|
||||
TESTCASE( toupper( 'A' ) == 'A' );
|
||||
TESTCASE( toupper( 'Z' ) == 'Z' );
|
||||
TESTCASE( toupper( '@' ) == '@' );
|
||||
TESTCASE( toupper( '[' ) == '[' );
|
||||
return TEST_RESULTS;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user