added a non-wide ctypes.h

This commit is contained in:
Morten Delenk 2016-07-27 15:03:34 +02:00
parent 50e562782c
commit 1c3b33746e
No known key found for this signature in database
GPG key ID: 3F818D0F65DCB490
18 changed files with 209 additions and 0 deletions

35
ctype/_ctype.c Normal file
View file

@ -0,0 +1,35 @@
#include "_ctype.h"
int ascii_table[256] {
CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,
CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,
CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,
CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,
SPACE ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,
OPEN ,CLOSE ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,
NUMBER ,NUMBER ,NUMBER ,NUMBER ,NUMBER ,NUMBER ,NUMBER ,NUMBER ,
NUMBER ,NUMBER ,SYMBOL ,SYMBOL ,OPEN ,SYMBOL ,CLOSE ,SYMBOL ,
SYMBOL ,HEXNUM ,HEXNUM ,HEXNUM ,HEXNUM ,HEXNUM ,HEXNUM ,UPPER ,
UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,
UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,
UPPER ,UPPER ,UPPER ,OPEN ,SYMBOL ,CLOSE ,SYMBOL ,SYMBOL ,
SYMBOL ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,
LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,
LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,
LOWER ,LOWER ,LOWER ,OPEN ,SYMBOL ,CLOSE ,SYMBOL ,CONTROL,
CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,
CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,
CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,
CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,CONTROL,
SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,
SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,
SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,
SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,SYMBOL ,
UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,
UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,
UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,SYMBOL ,
UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,UPPER ,LOWER ,
LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,
LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,
LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,SYMBOL ,
LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER ,LOWER
};

9
ctype/_ctype.h Normal file
View file

@ -0,0 +1,9 @@
#define CONTROL 1
#define SYMBOL 2
#define UPPER 4
#define LOWER 8
#define NUMBER 16
#define OPEN 32|SYMBOL
#define CLOSE 64|SYMBOL
#define SPACE 128
#define HEXNUM 256|UPPER

6
ctype/isASCII.cpp Normal file
View file

@ -0,0 +1,6 @@
#include <ctype.h>
#include "_ctype.h"
extern "C" isascii(int c) {
assert(c<256);
return c >= 0 && c < 128;
}

7
ctype/isAlNum.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" int isalnum(int c) {
assert(c<256);
return ascii_table[c] & (UPPER|LOWER|NUMBER);
}

7
ctype/isAlpha.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" isalpha(int c) {
assert(c<256);
return ascii_table[c] & (UPPER|LOWER);
}

7
ctype/isBlank.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" isblank(int c) {
assert(c<256);
return (ascii_table[c] & SPACE) || (c=='\t');
}

7
ctype/isCntrl.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" iscntrl(int c) {
assert(c<256);
return ascii_table[c] & CONTROL;
}

7
ctype/isDigit.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" isdigit(int c) {
assert(c<256);
return ascii_table[c] & (NUMBER);
}

7
ctype/isLower.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" islower(int c) {
assert(c<256);
return ascii_table[c] & (LOWER);
}

11
ctype/isPrint.cpp Normal file
View file

@ -0,0 +1,11 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" isgraph(int c) {
assert(c<256);
return ascii_table[c] & (SYMBOL|UPPER|LOWER|NUMBER);
}
extern "C" isprint(int c) {
assert(c<256);
return ascii_table[c] & (SYMBOL|UPPER|LOWER|NUMBER|SPACE);
}

7
ctype/isPunct.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" int ispunct(int c) {
assert(c<256);
return ascii_table[c] & (SYMBOL);
}

7
ctype/isSpace.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" int isspace(int c) {
assert(c<256);
return ascii_table[c] & (SPACE);
}

7
ctype/isUpper.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" int isupper(int c) {
assert(c<256);
return ascii_table[c] & (UPPER);
}

7
ctype/isXDigit.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <ctype.h>
#include "_ctype.h"
#include <assert.h>
extern "C" int isxdigit(int c) {
assert(c<256);
return ascii_table[c] & (DIGIT|(HEXNUM^UPPER));
}

12
ctype/toCase.cpp Normal file
View file

@ -0,0 +1,12 @@
#include <ctype.h>
#include "_ctype.h"
extern "C" int toupper(int c) {
if(isupper(c))
return c;
return c+0x20;
}
extern "C" int tolower(int c) {
if(islower(c))
return c;
return c-0x20;
}

23
include/ctype.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef __CTYPE_H
#define __CTYPE_H
#ifdef __cplusplus
extern "C" {
#endif
int isalnum(int);
int isalpha(int);
int isascii(int);
int isblank(int);
int iscntrl(int);
int isdigit(int);
int islower(int);
int isgraph(int);
int isprint(int);
int ispunct(int);
int isspace(int);
int isupper(int);
int toupper(int);
int tolower(int);
#ifdef __cplusplus
}
#endif
#endif

25
include/limits.h Normal file
View file

@ -0,0 +1,25 @@
#define CHAR_BIT 8
#define SCHAR_MIN -128
#define SCHAR_MAX 127
#define UCHAR_MAX 255
#define CHAR_MIN -128
#define CHAR_MAX 127
#define MB_LEN_MAX 6
#define SHRT_MIN -32768
#define SHRT_MAX 32767
#define USHR_MAX 65535
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define LLONG_MIN -9223372036854775808lli
#define LLONG_MAX 9223372036854775807lli
#define ULLONG_MAX 18446744073709551615ulli
#ifdef __LP64
#define LONG_MIN LLONG_MIN
#define LONG_MAX LLONG_MAX
#define ULONG_MAX ULLONG_MAX
#else
#define LONG_MIN INT_MIN
#define LONG_MAX INT_MAX
#define ULONG_MAX UINT_MAX
#endif

18
include/signal.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef __SIGNAL_H
#define __SIGNAL_H
#ifdef __cplusplus
extern "C" {
#endif
#define SIG_DFL &__signal_h_sig_dfl
#define SIG_ERR &__signal_h_sig_err
#define SIG_IGN &__signal_h_sig_ign
#define SIGINT 1
#define SIGILL 2
#define SIGABRT 3
#define SIGFPE 4
#define SIGSEGV 5
#define SIGTERM 6
#ifdef __cplusplus
}
#endif
#endif