Skip to content

Commit 945b458

Browse files
committed
Upload project files
1 parent 50b6408 commit 945b458

13 files changed

Lines changed: 776 additions & 13 deletions

File tree

_prelude.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#define STDC_RESTRICT __restrict
4+
5+
#ifdef __cplusplus
6+
# define STDC_BEGIN_HEADER extern "C" {
7+
# define STDC_END_HEADER }
8+
#else
9+
# define STDC_BEGIN_HEADER
10+
# define STDC_END_HEADER
11+
#endif

ce-dummy.c

Lines changed: 0 additions & 5 deletions
This file was deleted.

ce-dummy.h

Lines changed: 0 additions & 3 deletions
This file was deleted.

ctype.c

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#include <ctype.h>
2+
#include <stddef.h>
3+
4+
// using https://koor.fr/C/cctype/Index.wp for ascii code
5+
6+
int isalnum(int c) {
7+
if (c <= 'z' && c >= 'a') {
8+
return 1;
9+
}
10+
if (c <= 'Z' && c >= 'A') {
11+
return 1;
12+
}
13+
if (c <= '9' && c >= '0') {
14+
return 1;
15+
}
16+
return 0;
17+
}
18+
19+
int isalpha(int c) {
20+
if (c <= 'z' && c >= 'a') {
21+
return 1;
22+
}
23+
if (c <= 'Z' && c >= 'A') {
24+
return 1;
25+
}
26+
return 0;
27+
}
28+
29+
int isblank(int c) {
30+
if (c == ' ' || c == '\t') {
31+
return 1;
32+
}
33+
return 0;
34+
}
35+
36+
int iscntrl(int c) {
37+
if (c < 0x1f || c == 0x7f) {
38+
return 1;
39+
}
40+
return 0;
41+
}
42+
43+
int isdigit(int c) {
44+
if (c <= '9' && c >= '0') {
45+
return 1;
46+
}
47+
return 0;
48+
}
49+
50+
int isgraph(int c) {
51+
if (c >= 0x21 && c <= 0x7f) {
52+
return 1;
53+
}
54+
return 0;
55+
}
56+
57+
int islower(int c) {
58+
59+
if (c >= 'a' && c <= 'z') {
60+
return 1;
61+
}
62+
return 0;
63+
}
64+
65+
int isprint(int c) {
66+
if (c >= 0x20 && c <= 0x7f) {
67+
return 1;
68+
}
69+
return 0;
70+
}
71+
72+
int ispunct(int c) {
73+
char const punctuation[] = "!\"#$%&'()*+,-./:;<=>?@ [\\]^_`{|}~";
74+
75+
for (size_t i = 0; i < sizeof(punctuation); i++) {
76+
if (punctuation[i] == c) {
77+
return 1;
78+
}
79+
}
80+
81+
return 0;
82+
}
83+
84+
int isspace(int c) {
85+
if (c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\v') {
86+
return 1;
87+
} else {
88+
return 0;
89+
}
90+
}
91+
92+
int isupper(int c) {
93+
if (c >= 'A' && c <= 'Z') {
94+
return 1;
95+
}
96+
return 0;
97+
}
98+
99+
int isxdigit(int c) {
100+
if (isdigit(c)) {
101+
return 1;
102+
}
103+
if (c <= 'F' && c >= 'A') {
104+
return 1;
105+
}
106+
if (c <= 'f' && c >= 'a') {
107+
return 1;
108+
}
109+
return 0;
110+
}
111+
112+
int tolower(int c) {
113+
if (c >= 'A' && c <= 'Z') {
114+
c -= 'A';
115+
c += 'a';
116+
}
117+
118+
return c;
119+
}
120+
121+
int toupper(int c) {
122+
if (c >= 'a' && c <= 'z') {
123+
c -= 'a';
124+
c += 'A';
125+
}
126+
return c;
127+
}

ctype.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#pragma once
2+
3+
#include "_prelude.h"
4+
5+
STDC_BEGIN_HEADER
6+
7+
/* --- 7.4 Character - handling --------------------------------------------- */
8+
9+
/* --- 7.4.1 Character classification - Copying functions ------------------- */
10+
11+
int isalnum(int c);
12+
13+
int isalpha(int c);
14+
15+
int isblank(int c);
16+
17+
int iscntrl(int c);
18+
19+
int isdigit(int c);
20+
21+
int isgraph(int c);
22+
23+
int islower(int c);
24+
25+
int isprint(int c);
26+
27+
int ispunct(int c);
28+
29+
int isspace(int c);
30+
31+
int isupper(int c);
32+
33+
int isxdigit(int c);
34+
35+
int tolower(int c);
36+
37+
int toupper(int c);
38+
39+
STDC_END_HEADER

endian.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include "_prelude.h"
4+
5+
STDC_BEGIN_HEADER
6+
7+
#define __LITTLE_ENDIAN 1234
8+
#define __BIG_ENDIAN 4321
9+
#define __BYTE_ORDER __LITTLE_ENDIAN
10+
11+
STDC_END_HEADER

host/manifest.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://schemas.cute.engineering/stable/cutekit.manifest.component.v1",
3+
"id": "ce-libc-host",
4+
"type": "lib",
5+
"description": "Placeholder for the host stdc library",
6+
"enableIf": {
7+
"host": [
8+
true
9+
]
10+
},
11+
"provides": [
12+
"stdc"
13+
]
14+
}

manifest.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
{
22
"$schema": "https://schemas.cute.engineering/stable/cutekit.manifest.component.v1",
3-
"id": "ce-dummy",
3+
"id": "ce-libc",
44
"type": "lib",
5-
"description": "Cute Engineering Dummy Library",
5+
"description": "The ISO C standard library, ISO/IEC 9899",
66
"props": {
77
"cpp-root-include": true
8-
}
8+
},
9+
"enableIf": {
10+
"host": [
11+
false
12+
]
13+
},
14+
"provides": [
15+
"stdc-ansi"
16+
]
917
}

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# 👷 Cute Engineering Dummy Library
1+
# 👷 Cute Engineering Libc
22

3-
A library to be used as a template for new libraries.
3+
The ISO C standard library, ISO/IEC 9899

0 commit comments

Comments
 (0)