@shd101wyy/yo 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/skills/yo-async-effects/SKILL.md +4 -4
- package/.github/skills/yo-async-effects/async-effects-recipes.md +34 -34
- package/.github/skills/yo-core-patterns/SKILL.md +1 -1
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +26 -26
- package/.github/skills/yo-project-workflow/SKILL.md +6 -3
- package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
- package/.github/skills/yo-syntax/SKILL.md +7 -6
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +73 -60
- package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
- package/README.md +10 -8
- package/out/cjs/index.cjs +456 -438
- package/out/cjs/yo-cli.cjs +576 -543
- package/out/cjs/yo-lsp.cjs +559 -532
- package/out/esm/index.mjs +281 -263
- package/out/types/src/formatter.d.ts +11 -0
- package/out/types/src/lsp/formatting.d.ts +2 -0
- package/out/types/src/tests/formatter.test.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/alg/hash.yo +13 -21
- package/std/allocator.yo +25 -40
- package/std/async.yo +3 -7
- package/std/build.yo +105 -151
- package/std/cli/arg_parser.yo +184 -169
- package/std/collections/array_list.yo +350 -314
- package/std/collections/btree_map.yo +142 -131
- package/std/collections/deque.yo +132 -128
- package/std/collections/hash_map.yo +542 -566
- package/std/collections/hash_set.yo +623 -687
- package/std/collections/linked_list.yo +275 -293
- package/std/collections/ordered_map.yo +113 -85
- package/std/collections/priority_queue.yo +73 -73
- package/std/crypto/md5.yo +191 -95
- package/std/crypto/random.yo +56 -64
- package/std/crypto/sha256.yo +151 -107
- package/std/encoding/base64.yo +87 -81
- package/std/encoding/hex.yo +43 -50
- package/std/encoding/html.yo +56 -81
- package/std/encoding/html_char_utils.yo +7 -13
- package/std/encoding/html_entities.yo +2248 -2253
- package/std/encoding/json.yo +316 -224
- package/std/encoding/punycode.yo +86 -116
- package/std/encoding/toml.yo +67 -66
- package/std/encoding/utf16.yo +37 -44
- package/std/env.yo +62 -91
- package/std/error.yo +7 -15
- package/std/fmt/display.yo +5 -9
- package/std/fmt/index.yo +8 -14
- package/std/fmt/to_string.yo +330 -315
- package/std/fmt/writer.yo +58 -87
- package/std/fs/dir.yo +83 -102
- package/std/fs/file.yo +147 -180
- package/std/fs/metadata.yo +45 -78
- package/std/fs/temp.yo +55 -65
- package/std/fs/types.yo +27 -40
- package/std/fs/walker.yo +53 -68
- package/std/gc.yo +5 -8
- package/std/glob.yo +30 -43
- package/std/http/client.yo +107 -120
- package/std/http/http.yo +106 -96
- package/std/http/index.yo +4 -6
- package/std/imm/list.yo +88 -93
- package/std/imm/map.yo +528 -464
- package/std/imm/set.yo +52 -57
- package/std/imm/sorted_map.yo +340 -286
- package/std/imm/sorted_set.yo +57 -63
- package/std/imm/string.yo +404 -345
- package/std/imm/vec.yo +173 -181
- package/std/io/reader.yo +3 -6
- package/std/io/writer.yo +4 -8
- package/std/libc/assert.yo +5 -9
- package/std/libc/ctype.yo +32 -22
- package/std/libc/dirent.yo +26 -25
- package/std/libc/errno.yo +164 -90
- package/std/libc/fcntl.yo +52 -45
- package/std/libc/float.yo +66 -44
- package/std/libc/limits.yo +42 -33
- package/std/libc/math.yo +53 -82
- package/std/libc/signal.yo +72 -47
- package/std/libc/stdatomic.yo +217 -188
- package/std/libc/stdint.yo +5 -29
- package/std/libc/stdio.yo +5 -29
- package/std/libc/stdlib.yo +32 -39
- package/std/libc/string.yo +5 -23
- package/std/libc/sys/stat.yo +58 -56
- package/std/libc/time.yo +5 -19
- package/std/libc/unistd.yo +5 -20
- package/std/libc/wctype.yo +6 -9
- package/std/libc/windows.yo +26 -30
- package/std/log.yo +41 -55
- package/std/net/addr.yo +102 -97
- package/std/net/dns.yo +27 -28
- package/std/net/errors.yo +50 -49
- package/std/net/tcp.yo +113 -124
- package/std/net/udp.yo +55 -66
- package/std/os/env.yo +35 -33
- package/std/os/signal.yo +15 -25
- package/std/path.yo +276 -311
- package/std/prelude.yo +6304 -4315
- package/std/process/command.yo +87 -103
- package/std/process/index.yo +12 -31
- package/std/regex/compiler.yo +196 -95
- package/std/regex/flags.yo +58 -39
- package/std/regex/index.yo +157 -173
- package/std/regex/match.yo +20 -31
- package/std/regex/node.yo +134 -152
- package/std/regex/parser.yo +283 -259
- package/std/regex/unicode.yo +172 -202
- package/std/regex/vm.yo +155 -171
- package/std/string/index.yo +5 -7
- package/std/string/rune.yo +45 -55
- package/std/string/string.yo +937 -964
- package/std/string/string_builder.yo +94 -104
- package/std/string/unicode.yo +46 -64
- package/std/sync/channel.yo +72 -73
- package/std/sync/cond.yo +31 -36
- package/std/sync/mutex.yo +30 -32
- package/std/sync/once.yo +13 -16
- package/std/sync/rwlock.yo +26 -31
- package/std/sync/waitgroup.yo +20 -25
- package/std/sys/advise.yo +16 -24
- package/std/sys/bufio/buf_reader.yo +77 -93
- package/std/sys/bufio/buf_writer.yo +52 -65
- package/std/sys/clock.yo +4 -9
- package/std/sys/constants.yo +77 -61
- package/std/sys/copy.yo +4 -10
- package/std/sys/dir.yo +26 -43
- package/std/sys/dns.yo +41 -61
- package/std/sys/errors.yo +95 -103
- package/std/sys/events.yo +45 -57
- package/std/sys/externs.yo +319 -267
- package/std/sys/fallocate.yo +7 -11
- package/std/sys/fcntl.yo +14 -22
- package/std/sys/file.yo +26 -40
- package/std/sys/future.yo +5 -8
- package/std/sys/iov.yo +12 -25
- package/std/sys/lock.yo +12 -13
- package/std/sys/mmap.yo +38 -43
- package/std/sys/path.yo +3 -8
- package/std/sys/perm.yo +7 -21
- package/std/sys/pipe.yo +5 -12
- package/std/sys/process.yo +23 -29
- package/std/sys/seek.yo +10 -12
- package/std/sys/signal.yo +7 -13
- package/std/sys/signals.yo +52 -35
- package/std/sys/socket.yo +63 -58
- package/std/sys/socketpair.yo +3 -6
- package/std/sys/sockinfo.yo +11 -20
- package/std/sys/statfs.yo +11 -34
- package/std/sys/statx.yo +25 -52
- package/std/sys/sysinfo.yo +15 -20
- package/std/sys/tcp.yo +62 -92
- package/std/sys/temp.yo +5 -9
- package/std/sys/time.yo +5 -15
- package/std/sys/timer.yo +6 -11
- package/std/sys/tty.yo +10 -18
- package/std/sys/udp.yo +22 -39
- package/std/sys/umask.yo +3 -6
- package/std/sys/unix.yo +33 -52
- package/std/testing/bench.yo +49 -52
- package/std/thread.yo +10 -15
- package/std/time/datetime.yo +105 -89
- package/std/time/duration.yo +43 -56
- package/std/time/instant.yo +13 -18
- package/std/time/sleep.yo +5 -9
- package/std/url/index.yo +184 -209
- package/std/worker.yo +6 -10
package/std/libc/stdio.yo
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
//! C11 `<stdio.h>` — standard I/O functions.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
c_include(
|
|
3
|
+
"<stdio.h>",
|
|
4
4
|
// Types
|
|
5
5
|
FILE : Type,
|
|
6
6
|
fpos_t : Type,
|
|
7
7
|
va_list : Type,
|
|
8
|
-
|
|
9
8
|
// Standard streams
|
|
10
9
|
stdin : *(FILE),
|
|
11
10
|
stdout : *(FILE),
|
|
12
11
|
stderr : *(FILE),
|
|
13
|
-
|
|
14
12
|
// File operations
|
|
15
13
|
fopen :
|
|
16
14
|
fn(filename : *(char), mode : *(char)) -> ?*(FILE),
|
|
@@ -24,7 +22,6 @@ c_include "<stdio.h>",
|
|
|
24
22
|
fn(stream : *(FILE), buffer : ?*(char)) -> unit,
|
|
25
23
|
setvbuf :
|
|
26
24
|
fn(stream : *(FILE), buffer : ?*(char), mode : int, size : usize) -> int,
|
|
27
|
-
|
|
28
25
|
// File positioning
|
|
29
26
|
fseek :
|
|
30
27
|
fn(stream : *(FILE), offset : int, whence : int) -> int,
|
|
@@ -36,7 +33,6 @@ c_include "<stdio.h>",
|
|
|
36
33
|
fn(stream : *(FILE), pos : *(fpos_t)) -> int,
|
|
37
34
|
fsetpos :
|
|
38
35
|
fn(stream : *(FILE), pos : *(fpos_t)) -> int,
|
|
39
|
-
|
|
40
36
|
// Character input/output
|
|
41
37
|
fgetc :
|
|
42
38
|
fn(stream : *(FILE)) -> int,
|
|
@@ -52,7 +48,6 @@ c_include "<stdio.h>",
|
|
|
52
48
|
fn(c : int) -> int,
|
|
53
49
|
ungetc :
|
|
54
50
|
fn(c : int, stream : *(FILE)) -> int,
|
|
55
|
-
|
|
56
51
|
// String input/output
|
|
57
52
|
fgets :
|
|
58
53
|
fn(s : *(char), n : int, stream : *(FILE)) -> ?*(char),
|
|
@@ -62,7 +57,6 @@ c_include "<stdio.h>",
|
|
|
62
57
|
fn(s : *(char), stream : *(FILE)) -> int,
|
|
63
58
|
puts :
|
|
64
59
|
fn(s : *(char)) -> int,
|
|
65
|
-
|
|
66
60
|
// Formatted input/output with variadic arguments
|
|
67
61
|
printf :
|
|
68
62
|
fn(format : *(char), ...) -> int,
|
|
@@ -72,7 +66,6 @@ c_include "<stdio.h>",
|
|
|
72
66
|
fn(s : *(char), format : *(char), ...) -> int,
|
|
73
67
|
snprintf :
|
|
74
68
|
fn(s : *(char), n : usize, format : *(char), ...) -> int,
|
|
75
|
-
|
|
76
69
|
vprintf :
|
|
77
70
|
fn(format : *(char), ap : va_list) -> int,
|
|
78
71
|
vfprintf :
|
|
@@ -81,27 +74,23 @@ c_include "<stdio.h>",
|
|
|
81
74
|
fn(s : *(char), format : *(char), ap : va_list) -> int,
|
|
82
75
|
vsnprintf :
|
|
83
76
|
fn(s : *(char), n : usize, format : *(char), ap : va_list) -> int,
|
|
84
|
-
|
|
85
77
|
scanf :
|
|
86
78
|
fn(format : *(char), ...) -> int,
|
|
87
79
|
fscanf :
|
|
88
80
|
fn(stream : *(FILE), format : *(char), ...) -> int,
|
|
89
81
|
sscanf :
|
|
90
82
|
fn(s : *(char), format : *(char), ...) -> int,
|
|
91
|
-
|
|
92
83
|
vscanf :
|
|
93
84
|
fn(format : *(char), ap : va_list) -> int,
|
|
94
85
|
vfscanf :
|
|
95
86
|
fn(stream : *(FILE), format : *(char), ap : va_list) -> int,
|
|
96
87
|
vsscanf :
|
|
97
88
|
fn(s : *(char), format : *(char), ap : va_list) -> int,
|
|
98
|
-
|
|
99
89
|
// Binary input/output
|
|
100
90
|
fread :
|
|
101
91
|
fn(ptr : *(void), size : usize, nmemb : usize, stream : *(FILE)) -> usize,
|
|
102
92
|
fwrite :
|
|
103
93
|
fn(ptr : *(void), size : usize, nmemb : usize, stream : *(FILE)) -> usize,
|
|
104
|
-
|
|
105
94
|
// File management
|
|
106
95
|
remove :
|
|
107
96
|
fn(filename : *(char)) -> int,
|
|
@@ -111,7 +100,6 @@ c_include "<stdio.h>",
|
|
|
111
100
|
fn() -> ?*(FILE),
|
|
112
101
|
tmpnam :
|
|
113
102
|
fn(s : ?*(char)) -> ?*(char),
|
|
114
|
-
|
|
115
103
|
// Error handling
|
|
116
104
|
feof :
|
|
117
105
|
fn(stream : *(FILE)) -> int,
|
|
@@ -121,7 +109,6 @@ c_include "<stdio.h>",
|
|
|
121
109
|
fn(stream : *(FILE)) -> unit,
|
|
122
110
|
perror :
|
|
123
111
|
fn(s : *(char)) -> unit,
|
|
124
|
-
|
|
125
112
|
// Constants
|
|
126
113
|
EOF : int,
|
|
127
114
|
BUFSIZ : int,
|
|
@@ -135,20 +122,17 @@ c_include "<stdio.h>",
|
|
|
135
122
|
_IOFBF : int,
|
|
136
123
|
_IOLBF : int,
|
|
137
124
|
_IONBF : int
|
|
138
|
-
;
|
|
139
|
-
|
|
125
|
+
);
|
|
140
126
|
// Export all stdio functionality
|
|
141
|
-
export
|
|
127
|
+
export(
|
|
142
128
|
// Types
|
|
143
129
|
FILE,
|
|
144
130
|
fpos_t,
|
|
145
131
|
va_list,
|
|
146
|
-
|
|
147
132
|
// Standard streams
|
|
148
133
|
stdin,
|
|
149
134
|
stdout,
|
|
150
135
|
stderr,
|
|
151
|
-
|
|
152
136
|
// File operations
|
|
153
137
|
fopen,
|
|
154
138
|
freopen,
|
|
@@ -156,14 +140,12 @@ export
|
|
|
156
140
|
fflush,
|
|
157
141
|
setbuf,
|
|
158
142
|
setvbuf,
|
|
159
|
-
|
|
160
143
|
// File positioning
|
|
161
144
|
fseek,
|
|
162
145
|
ftell,
|
|
163
146
|
rewind,
|
|
164
147
|
fgetpos,
|
|
165
148
|
fsetpos,
|
|
166
|
-
|
|
167
149
|
// Character input/output
|
|
168
150
|
fgetc,
|
|
169
151
|
getc,
|
|
@@ -172,13 +154,11 @@ export
|
|
|
172
154
|
putc,
|
|
173
155
|
putchar,
|
|
174
156
|
ungetc,
|
|
175
|
-
|
|
176
157
|
// String input/output
|
|
177
158
|
fgets,
|
|
178
159
|
gets,
|
|
179
160
|
fputs,
|
|
180
161
|
puts,
|
|
181
|
-
|
|
182
162
|
// Formatted input/output with variadic arguments
|
|
183
163
|
printf,
|
|
184
164
|
fprintf,
|
|
@@ -194,23 +174,19 @@ export
|
|
|
194
174
|
vscanf,
|
|
195
175
|
vfscanf,
|
|
196
176
|
vsscanf,
|
|
197
|
-
|
|
198
177
|
// Binary input/output
|
|
199
178
|
fread,
|
|
200
179
|
fwrite,
|
|
201
|
-
|
|
202
180
|
// File management
|
|
203
181
|
remove,
|
|
204
182
|
rename,
|
|
205
183
|
tmpfile,
|
|
206
184
|
tmpnam,
|
|
207
|
-
|
|
208
185
|
// Error handling
|
|
209
186
|
feof,
|
|
210
187
|
ferror,
|
|
211
188
|
clearerr,
|
|
212
189
|
perror,
|
|
213
|
-
|
|
214
190
|
// Constants
|
|
215
191
|
EOF,
|
|
216
192
|
BUFSIZ,
|
|
@@ -224,4 +200,4 @@ export
|
|
|
224
200
|
_IOFBF,
|
|
225
201
|
_IOLBF,
|
|
226
202
|
_IONBF
|
|
227
|
-
;
|
|
203
|
+
);
|
package/std/libc/stdlib.yo
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
//! C11 `<stdlib.h>` — general utility functions.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
c_include(
|
|
3
|
+
"<stdlib.h>",
|
|
4
4
|
// Types for div functions
|
|
5
5
|
div_t : Type,
|
|
6
6
|
ldiv_t : Type,
|
|
7
7
|
lldiv_t : Type,
|
|
8
8
|
wchar_t : Type,
|
|
9
|
-
|
|
10
9
|
// Program termination
|
|
11
10
|
exit :
|
|
12
11
|
fn(status : int) -> unit,
|
|
@@ -20,7 +19,6 @@ c_include "<stdlib.h>",
|
|
|
20
19
|
fn(func : (fn() -> unit)) -> int,
|
|
21
20
|
at_quick_exit :
|
|
22
21
|
fn(func : (fn() -> unit)) -> int,
|
|
23
|
-
|
|
24
22
|
// Memory management
|
|
25
23
|
malloc :
|
|
26
24
|
fn(size : usize) -> ?*(void),
|
|
@@ -32,7 +30,6 @@ c_include "<stdlib.h>",
|
|
|
32
30
|
fn(ptr : ?*(void)) -> unit,
|
|
33
31
|
aligned_alloc :
|
|
34
32
|
fn(alignment : usize, size : usize) -> ?*(void),
|
|
35
|
-
|
|
36
33
|
// String to number conversion
|
|
37
34
|
atof :
|
|
38
35
|
fn(nptr : *(char)) -> f64,
|
|
@@ -42,7 +39,6 @@ c_include "<stdlib.h>",
|
|
|
42
39
|
fn(nptr : *(char)) -> long,
|
|
43
40
|
atoll :
|
|
44
41
|
fn(nptr : *(char)) -> longlong,
|
|
45
|
-
|
|
46
42
|
strtol :
|
|
47
43
|
fn(nptr : *(char), endptr : ?*(?*(char)), base : int) -> long,
|
|
48
44
|
strtoll :
|
|
@@ -51,32 +47,36 @@ c_include "<stdlib.h>",
|
|
|
51
47
|
fn(nptr : *(char), endptr : ?*(?*(char)), base : int) -> ulong,
|
|
52
48
|
strtoull :
|
|
53
49
|
fn(nptr : *(char), endptr : ?*(?*(char)), base : int) -> ulonglong,
|
|
54
|
-
|
|
55
50
|
strtof :
|
|
56
51
|
fn(nptr : *(char), endptr : ?*(?*(char))) -> f32,
|
|
57
52
|
strtod :
|
|
58
53
|
fn(nptr : *(char), endptr : ?*(?*(char))) -> f64,
|
|
59
54
|
strtold :
|
|
60
55
|
fn(nptr : *(char), endptr : ?*(?*(char))) -> longdouble,
|
|
61
|
-
|
|
62
56
|
// Pseudo-random sequence generation
|
|
63
57
|
rand :
|
|
64
58
|
fn() -> int,
|
|
65
59
|
srand :
|
|
66
60
|
fn(seed : uint) -> unit,
|
|
67
|
-
|
|
68
61
|
// C11 - Thread-safe random functions
|
|
69
62
|
rand_r :
|
|
70
63
|
fn(seedp : *(uint)) -> int,
|
|
71
|
-
|
|
72
64
|
// Searching and sorting
|
|
73
65
|
bsearch :
|
|
74
|
-
fn(
|
|
75
|
-
|
|
66
|
+
fn(
|
|
67
|
+
key : *(void),
|
|
68
|
+
base : *(void),
|
|
69
|
+
nmemb : usize,
|
|
70
|
+
size : usize,
|
|
71
|
+
compar : (fn(a : *(void), b : *(void)) -> int)
|
|
72
|
+
) -> ?*(void),
|
|
76
73
|
qsort :
|
|
77
|
-
fn(
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
fn(
|
|
75
|
+
base : *(void),
|
|
76
|
+
nmemb : usize,
|
|
77
|
+
size : usize,
|
|
78
|
+
compar : (fn(a : *(void), b : *(void)) -> int)
|
|
79
|
+
) -> unit,
|
|
80
80
|
// Integer arithmetic
|
|
81
81
|
abs :
|
|
82
82
|
fn(j : int) -> int,
|
|
@@ -84,14 +84,12 @@ c_include "<stdlib.h>",
|
|
|
84
84
|
fn(j : long) -> long,
|
|
85
85
|
llabs :
|
|
86
86
|
fn(j : longlong) -> longlong,
|
|
87
|
-
|
|
88
87
|
div :
|
|
89
88
|
fn(numer : int, denom : int) -> div_t,
|
|
90
89
|
ldiv :
|
|
91
90
|
fn(numer : long, denom : long) -> ldiv_t,
|
|
92
91
|
lldiv :
|
|
93
92
|
fn(numer : longlong, denom : longlong) -> lldiv_t,
|
|
94
|
-
|
|
95
93
|
// Environment functions
|
|
96
94
|
getenv :
|
|
97
95
|
fn(name : *(char)) -> ?*(char),
|
|
@@ -99,11 +97,9 @@ c_include "<stdlib.h>",
|
|
|
99
97
|
fn(name : *(char), value : *(char), overwrite : int) -> int,
|
|
100
98
|
system :
|
|
101
99
|
fn(command : ?*(char)) -> int,
|
|
102
|
-
|
|
103
100
|
// C11 Annex K - Bounds-checking interfaces
|
|
104
101
|
getenv_s :
|
|
105
102
|
fn(len : ?*(usize), value : *(char), maxsize : usize, name : *(char)) -> int,
|
|
106
|
-
|
|
107
103
|
// Multibyte/wide character conversion
|
|
108
104
|
mblen :
|
|
109
105
|
fn(s : ?*(char), n : usize) -> int,
|
|
@@ -111,30 +107,36 @@ c_include "<stdlib.h>",
|
|
|
111
107
|
fn(pwc : ?*(wchar_t), s : ?*(char), n : usize) -> int,
|
|
112
108
|
wctomb :
|
|
113
109
|
fn(s : ?*(char), wc : wchar_t) -> int,
|
|
114
|
-
|
|
115
110
|
// Multibyte/wide string conversion
|
|
116
111
|
mbstowcs :
|
|
117
112
|
fn(dest : ?*(wchar_t), src : *(char), n : usize) -> usize,
|
|
118
113
|
wcstombs :
|
|
119
114
|
fn(dest : ?*(char), src : *(wchar_t), n : usize) -> usize,
|
|
120
|
-
|
|
121
115
|
// C11 Annex K - Safe multibyte functions
|
|
122
116
|
mbstowcs_s :
|
|
123
|
-
fn(
|
|
124
|
-
|
|
117
|
+
fn(
|
|
118
|
+
retval : ?*(usize),
|
|
119
|
+
dest : ?*(wchar_t),
|
|
120
|
+
destsz : usize,
|
|
121
|
+
src : *(char),
|
|
122
|
+
len : usize
|
|
123
|
+
) -> int,
|
|
125
124
|
wcstombs_s :
|
|
126
|
-
fn(
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
fn(
|
|
126
|
+
retval : ?*(usize),
|
|
127
|
+
dest : ?*(char),
|
|
128
|
+
destsz : usize,
|
|
129
|
+
src : *(wchar_t),
|
|
130
|
+
len : usize
|
|
131
|
+
) -> int,
|
|
129
132
|
// Constants
|
|
130
133
|
EXIT_SUCCESS : int,
|
|
131
134
|
EXIT_FAILURE : int,
|
|
132
135
|
RAND_MAX : int,
|
|
133
136
|
MB_CUR_MAX : int
|
|
134
|
-
;
|
|
135
|
-
|
|
137
|
+
);
|
|
136
138
|
// Export all stdlib functionality
|
|
137
|
-
export
|
|
139
|
+
export(
|
|
138
140
|
// Program termination
|
|
139
141
|
exit,
|
|
140
142
|
quick_exit,
|
|
@@ -142,14 +144,12 @@ export
|
|
|
142
144
|
abort,
|
|
143
145
|
atexit,
|
|
144
146
|
at_quick_exit,
|
|
145
|
-
|
|
146
147
|
// Memory management
|
|
147
148
|
malloc,
|
|
148
149
|
calloc,
|
|
149
150
|
realloc,
|
|
150
151
|
free,
|
|
151
152
|
aligned_alloc,
|
|
152
|
-
|
|
153
153
|
// String to number conversion
|
|
154
154
|
atof,
|
|
155
155
|
atoi,
|
|
@@ -162,16 +162,13 @@ export
|
|
|
162
162
|
strtof,
|
|
163
163
|
strtod,
|
|
164
164
|
strtold,
|
|
165
|
-
|
|
166
165
|
// Random number generation
|
|
167
166
|
rand,
|
|
168
167
|
srand,
|
|
169
168
|
rand_r,
|
|
170
|
-
|
|
171
169
|
// Searching and sorting
|
|
172
170
|
bsearch,
|
|
173
171
|
qsort,
|
|
174
|
-
|
|
175
172
|
// Integer arithmetic
|
|
176
173
|
abs,
|
|
177
174
|
labs,
|
|
@@ -179,13 +176,11 @@ export
|
|
|
179
176
|
div,
|
|
180
177
|
ldiv,
|
|
181
178
|
lldiv,
|
|
182
|
-
|
|
183
179
|
// Environment
|
|
184
180
|
getenv,
|
|
185
181
|
setenv,
|
|
186
182
|
system,
|
|
187
183
|
getenv_s,
|
|
188
|
-
|
|
189
184
|
// Multibyte/wide character
|
|
190
185
|
mblen,
|
|
191
186
|
mbtowc,
|
|
@@ -194,16 +189,14 @@ export
|
|
|
194
189
|
wcstombs,
|
|
195
190
|
mbstowcs_s,
|
|
196
191
|
wcstombs_s,
|
|
197
|
-
|
|
198
192
|
// Types
|
|
199
193
|
div_t,
|
|
200
194
|
ldiv_t,
|
|
201
195
|
lldiv_t,
|
|
202
196
|
wchar_t,
|
|
203
|
-
|
|
204
197
|
// Constants
|
|
205
198
|
EXIT_SUCCESS,
|
|
206
199
|
EXIT_FAILURE,
|
|
207
200
|
RAND_MAX,
|
|
208
201
|
MB_CUR_MAX
|
|
209
|
-
;
|
|
202
|
+
);
|
package/std/libc/string.yo
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//! C11 `<string.h>` — string and memory functions.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
c_include(
|
|
3
|
+
"<string.h>",
|
|
4
4
|
// Memory functions
|
|
5
5
|
memcpy :
|
|
6
6
|
fn(dest : *(void), src : *(void), n : usize) -> *(void),
|
|
@@ -12,19 +12,16 @@ c_include "<string.h>",
|
|
|
12
12
|
fn(s1 : *(void), s2 : *(void), n : usize) -> int,
|
|
13
13
|
memchr :
|
|
14
14
|
fn(s : *(void), c : int, n : usize) -> ?*(void),
|
|
15
|
-
|
|
16
15
|
// String copying functions
|
|
17
16
|
strcpy :
|
|
18
17
|
fn(dest : *(char), src : *(char)) -> *(char),
|
|
19
18
|
strncpy :
|
|
20
19
|
fn(dest : *(char), src : *(char), n : usize) -> *(char),
|
|
21
|
-
|
|
22
20
|
// String concatenation functions
|
|
23
21
|
strcat :
|
|
24
22
|
fn(dest : *(char), src : *(char)) -> *(char),
|
|
25
23
|
strncat :
|
|
26
24
|
fn(dest : *(char), src : *(char), n : usize) -> *(char),
|
|
27
|
-
|
|
28
25
|
// String comparison functions
|
|
29
26
|
strcmp :
|
|
30
27
|
fn(s1 : *(char), s2 : *(char)) -> int,
|
|
@@ -34,7 +31,6 @@ c_include "<string.h>",
|
|
|
34
31
|
fn(s1 : *(char), s2 : *(char)) -> int,
|
|
35
32
|
strxfrm :
|
|
36
33
|
fn(dest : *(char), src : *(char), n : usize) -> usize,
|
|
37
|
-
|
|
38
34
|
// String searching functions
|
|
39
35
|
strchr :
|
|
40
36
|
fn(s : *(char), c : int) -> ?*(char),
|
|
@@ -50,13 +46,11 @@ c_include "<string.h>",
|
|
|
50
46
|
fn(haystack : *(char), needle : *(char)) -> ?*(char),
|
|
51
47
|
strtok :
|
|
52
48
|
fn(s : ?*(char), delim : *(char)) -> ?*(char),
|
|
53
|
-
|
|
54
49
|
// String utility functions
|
|
55
50
|
strlen :
|
|
56
51
|
fn(s : *(char)) -> usize,
|
|
57
52
|
strerror :
|
|
58
53
|
fn(errnum : int) -> *(char),
|
|
59
|
-
|
|
60
54
|
// C11 Annex K - Bounds-checking interfaces (optional)
|
|
61
55
|
// These are safer versions of string functions
|
|
62
56
|
strcpy_s :
|
|
@@ -67,7 +61,6 @@ c_include "<string.h>",
|
|
|
67
61
|
fn(dest : *(char), destsz : usize, src : *(char)) -> int,
|
|
68
62
|
strncat_s :
|
|
69
63
|
fn(dest : *(char), destsz : usize, src : *(char), count : usize) -> int,
|
|
70
|
-
|
|
71
64
|
// C11 Annex K - Memory functions
|
|
72
65
|
memcpy_s :
|
|
73
66
|
fn(dest : *(void), destsz : usize, src : *(void), count : usize) -> int,
|
|
@@ -75,7 +68,6 @@ c_include "<string.h>",
|
|
|
75
68
|
fn(dest : *(void), destsz : usize, src : *(void), count : usize) -> int,
|
|
76
69
|
memset_s :
|
|
77
70
|
fn(s : *(void), smax : usize, c : int, n : usize) -> int,
|
|
78
|
-
|
|
79
71
|
// C11 - Additional string functions
|
|
80
72
|
strnlen_s :
|
|
81
73
|
fn(s : *(char), maxlen : usize) -> usize,
|
|
@@ -83,43 +75,36 @@ c_include "<string.h>",
|
|
|
83
75
|
fn(s : *(char), maxsize : usize, errnum : int) -> int,
|
|
84
76
|
strtok_s :
|
|
85
77
|
fn(s : ?*(char), delim : *(char), ptr : *(?*(char))) -> ?*(char),
|
|
86
|
-
|
|
87
78
|
// C11 - Duplicate string (POSIX, but commonly available)
|
|
88
79
|
strdup :
|
|
89
80
|
fn(s : *(char)) -> ?*(char),
|
|
90
81
|
strndup :
|
|
91
82
|
fn(s : *(char), n : usize) -> ?*(char),
|
|
92
|
-
|
|
93
83
|
// Case-insensitive comparison (POSIX, but commonly available)
|
|
94
84
|
strcasecmp :
|
|
95
85
|
fn(s1 : *(char), s2 : *(char)) -> int,
|
|
96
86
|
strncasecmp :
|
|
97
87
|
fn(s1 : *(char), s2 : *(char), n : usize) -> int
|
|
98
|
-
;
|
|
99
|
-
|
|
88
|
+
);
|
|
100
89
|
// Export all string functionality
|
|
101
|
-
export
|
|
90
|
+
export(
|
|
102
91
|
// Memory functions
|
|
103
92
|
memcpy,
|
|
104
93
|
memmove,
|
|
105
94
|
memset,
|
|
106
95
|
memcmp,
|
|
107
96
|
memchr,
|
|
108
|
-
|
|
109
97
|
// String copying
|
|
110
98
|
strcpy,
|
|
111
99
|
strncpy,
|
|
112
|
-
|
|
113
100
|
// String concatenation
|
|
114
101
|
strcat,
|
|
115
102
|
strncat,
|
|
116
|
-
|
|
117
103
|
// String comparison
|
|
118
104
|
strcmp,
|
|
119
105
|
strncmp,
|
|
120
106
|
strcoll,
|
|
121
107
|
strxfrm,
|
|
122
|
-
|
|
123
108
|
// String searching
|
|
124
109
|
strchr,
|
|
125
110
|
strrchr,
|
|
@@ -128,11 +113,9 @@ export
|
|
|
128
113
|
strpbrk,
|
|
129
114
|
strstr,
|
|
130
115
|
strtok,
|
|
131
|
-
|
|
132
116
|
// String utilities
|
|
133
117
|
strlen,
|
|
134
118
|
strerror,
|
|
135
|
-
|
|
136
119
|
// C11 Annex K - Safe functions
|
|
137
120
|
strcpy_s,
|
|
138
121
|
strncpy_s,
|
|
@@ -144,10 +127,9 @@ export
|
|
|
144
127
|
strnlen_s,
|
|
145
128
|
strerror_s,
|
|
146
129
|
strtok_s,
|
|
147
|
-
|
|
148
130
|
// Additional useful functions
|
|
149
131
|
strdup,
|
|
150
132
|
strndup,
|
|
151
133
|
strcasecmp,
|
|
152
134
|
strncasecmp
|
|
153
|
-
;
|
|
135
|
+
);
|
package/std/libc/sys/stat.yo
CHANGED
|
@@ -1,94 +1,100 @@
|
|
|
1
1
|
//! POSIX `<sys/stat.h>` — file status and mode operations.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
c_include(
|
|
3
|
+
"<sys/stat.h>",
|
|
4
4
|
// Types
|
|
5
5
|
mode_t : Type,
|
|
6
|
-
|
|
7
6
|
// The stat structure - platform specific layout
|
|
8
7
|
// Use helper functions to extract fields portably
|
|
9
8
|
// struct_stat : Type, // Can't use 'stat' as type name since it conflicts with function
|
|
10
|
-
|
|
11
9
|
// File status functions
|
|
12
10
|
stat :
|
|
13
|
-
(fn(pathname: *(char), statbuf: *(void)) -> int),
|
|
11
|
+
(fn(pathname : *(char), statbuf : *(void)) -> int),
|
|
14
12
|
fstat :
|
|
15
|
-
(fn(fd: int, statbuf: *(void)) -> int),
|
|
13
|
+
(fn(fd : int, statbuf : *(void)) -> int),
|
|
16
14
|
lstat :
|
|
17
|
-
(fn(pathname: *(char), statbuf: *(void)) -> int),
|
|
18
|
-
|
|
15
|
+
(fn(pathname : *(char), statbuf : *(void)) -> int),
|
|
19
16
|
// Directory creation
|
|
20
17
|
mkdir :
|
|
21
|
-
(fn(pathname: *(char), mode: mode_t) -> int),
|
|
22
|
-
|
|
18
|
+
(fn(pathname : *(char), mode : mode_t) -> int),
|
|
23
19
|
// File mode operations
|
|
24
20
|
chmod :
|
|
25
|
-
(fn(pathname: *(char), mode: mode_t) -> int),
|
|
21
|
+
(fn(pathname : *(char), mode : mode_t) -> int),
|
|
26
22
|
fchmod :
|
|
27
|
-
(fn(fd: int, mode: mode_t) -> int),
|
|
28
|
-
|
|
23
|
+
(fn(fd : int, mode : mode_t) -> int),
|
|
29
24
|
// File creation mask
|
|
30
25
|
umask :
|
|
31
|
-
(fn(mask: mode_t) -> mode_t),
|
|
32
|
-
|
|
26
|
+
(fn(mask : mode_t) -> mode_t),
|
|
33
27
|
// Create special files (POSIX)
|
|
34
28
|
mkfifo :
|
|
35
|
-
(fn(pathname: *(char), mode: mode_t) -> int),
|
|
36
|
-
|
|
29
|
+
(fn(pathname : *(char), mode : mode_t) -> int),
|
|
37
30
|
// File type macros (applied to st_mode)
|
|
38
31
|
// These are typically implemented as macros, but we expose the constants
|
|
39
|
-
S_IFMT : mode_t,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
S_IFMT : mode_t,
|
|
33
|
+
// Bit mask for the file type bit field
|
|
34
|
+
S_IFSOCK : mode_t,
|
|
35
|
+
// Socket
|
|
36
|
+
S_IFLNK : mode_t,
|
|
37
|
+
// Symbolic link
|
|
38
|
+
S_IFREG : mode_t,
|
|
39
|
+
// Regular file
|
|
40
|
+
S_IFBLK : mode_t,
|
|
41
|
+
// Block device
|
|
42
|
+
S_IFDIR : mode_t,
|
|
43
|
+
// Directory
|
|
44
|
+
S_IFCHR : mode_t,
|
|
45
|
+
// Character device
|
|
46
|
+
S_IFIFO : mode_t,
|
|
47
|
+
// FIFO
|
|
48
48
|
// File mode bits (permissions)
|
|
49
49
|
// Owner permissions
|
|
50
|
-
S_IRWXU : mode_t,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
S_IRWXU : mode_t,
|
|
51
|
+
// Owner has read, write, and execute permission
|
|
52
|
+
S_IRUSR : mode_t,
|
|
53
|
+
// Owner has read permission
|
|
54
|
+
S_IWUSR : mode_t,
|
|
55
|
+
// Owner has write permission
|
|
56
|
+
S_IXUSR : mode_t,
|
|
57
|
+
// Owner has execute permission
|
|
55
58
|
// Group permissions
|
|
56
|
-
S_IRWXG : mode_t,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
S_IRWXG : mode_t,
|
|
60
|
+
// Group has read, write, and execute permission
|
|
61
|
+
S_IRGRP : mode_t,
|
|
62
|
+
// Group has read permission
|
|
63
|
+
S_IWGRP : mode_t,
|
|
64
|
+
// Group has write permission
|
|
65
|
+
S_IXGRP : mode_t,
|
|
66
|
+
// Group has execute permission
|
|
61
67
|
// Others permissions
|
|
62
|
-
S_IRWXO : mode_t,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
S_IRWXO : mode_t,
|
|
69
|
+
// Others have read, write, and execute permission
|
|
70
|
+
S_IROTH : mode_t,
|
|
71
|
+
// Others have read permission
|
|
72
|
+
S_IWOTH : mode_t,
|
|
73
|
+
// Others have write permission
|
|
74
|
+
S_IXOTH : mode_t,
|
|
75
|
+
// Others have execute permission
|
|
67
76
|
// Special mode bits
|
|
68
|
-
S_ISUID : mode_t,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
S_ISUID : mode_t,
|
|
78
|
+
// Set-user-ID bit
|
|
79
|
+
S_ISGID : mode_t,
|
|
80
|
+
// Set-group-ID bit
|
|
81
|
+
S_ISVTX : mode_t // Sticky bit
|
|
82
|
+
);
|
|
73
83
|
// Export all sys/stat functionality
|
|
74
|
-
export
|
|
84
|
+
export(
|
|
75
85
|
// Types
|
|
76
86
|
mode_t,
|
|
77
|
-
|
|
78
87
|
// File status functions
|
|
79
88
|
stat,
|
|
80
89
|
fstat,
|
|
81
90
|
lstat,
|
|
82
|
-
|
|
83
91
|
// Directory creation
|
|
84
92
|
mkdir,
|
|
85
|
-
|
|
86
93
|
// File mode operations
|
|
87
94
|
chmod,
|
|
88
95
|
fchmod,
|
|
89
96
|
umask,
|
|
90
97
|
mkfifo,
|
|
91
|
-
|
|
92
98
|
// File type constants
|
|
93
99
|
S_IFMT,
|
|
94
100
|
S_IFSOCK,
|
|
@@ -98,27 +104,23 @@ export
|
|
|
98
104
|
S_IFDIR,
|
|
99
105
|
S_IFCHR,
|
|
100
106
|
S_IFIFO,
|
|
101
|
-
|
|
102
107
|
// Owner permissions
|
|
103
108
|
S_IRWXU,
|
|
104
109
|
S_IRUSR,
|
|
105
110
|
S_IWUSR,
|
|
106
111
|
S_IXUSR,
|
|
107
|
-
|
|
108
112
|
// Group permissions
|
|
109
113
|
S_IRWXG,
|
|
110
114
|
S_IRGRP,
|
|
111
115
|
S_IWGRP,
|
|
112
116
|
S_IXGRP,
|
|
113
|
-
|
|
114
117
|
// Others permissions
|
|
115
118
|
S_IRWXO,
|
|
116
119
|
S_IROTH,
|
|
117
120
|
S_IWOTH,
|
|
118
121
|
S_IXOTH,
|
|
119
|
-
|
|
120
122
|
// Special mode bits
|
|
121
123
|
S_ISUID,
|
|
122
124
|
S_ISGID,
|
|
123
125
|
S_ISVTX
|
|
124
|
-
;
|
|
126
|
+
);
|