1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* [ʞ] ord.c - integer converter
* ~ lexi hale <lexi@hale.su>
* © AGPLv3
* * ord has no dependencies except for libc.
* ? ord converts integers to ascii characters
* and back. written because the only fucking
* way to do this in shell is FUCKING PRINTF.
* $ cc ord.c -o ord [-D_IO=(LIBC|POSIX)]
* - the flag D_IO will instruct ord.c whether
* to use POSIX io primitives (write and read)
* instead of libc primitives (printf). if
* you're on a UNIX system, POSIX primitives
* will be used by default, but you can block
* them with LIBC or force them with POSIX.
* if you are on a POSIX- compliant system,
................................................................................
* you *should* use POSIX IO, for improved
* performance and safety.
TODO: take full advantage of write(2) by storing
output in single string & making single
write call */
#if (defined(__unix__) && _IO != LIBC) || (_IO == POSIX)
# define _POSIX_IO
#endif
#ifdef _POSIX_IO
# include <unistd.h>
# define say(x) (write(2, (x), (sizeof (x))))
# define print(sz,x) (write(1, (x), (sz)))
# define forposix(x) x
# define forlibc(x)
#else
# include <stdio.h>
# define say(x) (fprintf(stderr, (x)))
# define print(x) (printf("%s",(x)))
# define forposix(x)
# define forlibc(x) x
#endif
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* [ʞ] ord.c - integer converter
* ~ lexi hale <lexi@hale.su>
* © AGPLv3
* * ord has no dependencies except for libc.
* ? ord converts integers to ascii characters
* and back. written because the only fucking
* way to do this in shell is FUCKING PRINTF.
* $ cc ord.c -o ord [-D_(POSIX|LIBC)_IO]
* - the flag D_IO will instruct ord.c whether
* to use POSIX io primitives (write and read)
* instead of libc primitives (printf). if
* you're on a UNIX system, POSIX primitives
* will be used by default, but you can block
* them with LIBC or force them with POSIX.
* if you are on a POSIX- compliant system,
................................................................................
* you *should* use POSIX IO, for improved
* performance and safety.
TODO: take full advantage of write(2) by storing
output in single string & making single
write call */
#if (defined(__unix__) && !defined(_POSIX_IO)) && !defined(_LIBC_IO)
# define _POSIX_IO
#endif
#ifdef _POSIX_IO
# include <unistd.h>
# define say(x) (write(2, (x), (sizeof (x))))
# define print(sz,x) (write(1, (x), (sz)))
# define forposix(x) x
# define forlibc(x)
#else
# include <stdio.h>
# define say(x) (fprintf(stderr, (x)))
# define print(sz,x) (printf("%s",(x)))
# define forposix(x)
# define forlibc(x) x
#endif
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
|