diff options
author | Simon Tatham <anakin@pobox.com> | 2017-05-18 07:14:27 +0100 |
---|---|---|
committer | Simon Tatham <anakin@pobox.com> | 2017-05-18 07:16:21 +0100 |
commit | 39faf94ea2fa54f6791641142ad03e7e4f884a69 (patch) | |
tree | 371ff51b465294d4529437be4cdaab7944ed5a20 /fake-lib.c | |
parent | 3b3a5fd6bf7a3542ab8e8701c93c3d0f505c722f (diff) | |
download | wix-on-linux-39faf94ea2fa54f6791641142ad03e7e4f884a69.tar.gz wix-on-linux-39faf94ea2fa54f6791641142ad03e7e4f884a69.tar.bz2 wix-on-linux-39faf94ea2fa54f6791641142ad03e7e4f884a69.zip |
Move the char16 functions into their own file.
This completes the removal of the monolithic fake-lib.[ch].
Diffstat (limited to 'fake-lib.c')
-rw-r--r-- | fake-lib.c | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/fake-lib.c b/fake-lib.c deleted file mode 100644 index e2bc364..0000000 --- a/fake-lib.c +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <stdint.h> | ||
4 | #include <stdbool.h> | ||
5 | #include <stdarg.h> | ||
6 | #include <string.h> | ||
7 | #include <uchar.h> | ||
8 | #include <err.h> | ||
9 | |||
10 | #include "memory.h" | ||
11 | #include "fake-lib.h" | ||
12 | |||
13 | char *ascii(const char16_t *wstr, bool translate_slashes) | ||
14 | { | ||
15 | size_t len = 0; | ||
16 | for (const char16_t *wp = wstr; *wp; wp++) | ||
17 | len++; | ||
18 | char *ret = malloc(len + 1); | ||
19 | char *p = ret; | ||
20 | for (const char16_t *wp = wstr; *wp; wp++) | ||
21 | *p++ = (*wp == '\\' && translate_slashes ? '/' : | ||
22 | *wp < 0x80 ? *wp : | ||
23 | '?'); | ||
24 | *p = '\0'; | ||
25 | return ret; | ||
26 | } | ||
27 | |||
28 | void c16cpy(char16_t *out, uint32_t *outsize, char *s) | ||
29 | { | ||
30 | uint32_t retlen = 0; | ||
31 | while (retlen < *outsize) { | ||
32 | char16_t c = (out[retlen] = (unsigned char)*s++); | ||
33 | if (!c) | ||
34 | break; | ||
35 | retlen++; | ||
36 | } | ||
37 | *outsize = retlen; | ||
38 | } | ||