Rev 4206 | Rev 4213 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4206 | Rev 4208 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | 34 | ||
35 | #include <print.h> |
35 | #include <print.h> |
36 | #include <printf/printf_core.h> |
36 | #include <printf/printf_core.h> |
37 | #include <string.h> |
37 | #include <string.h> |
38 | #include <memstr.h> |
38 | #include <memstr.h> |
- | 39 | #include <errno.h> |
|
39 | 40 | ||
40 | typedef struct { |
41 | typedef struct { |
41 | size_t size; /* Total size of the buffer (in bytes) */ |
42 | size_t size; /* Total size of the buffer (in bytes) */ |
42 | size_t len; /* Number of already used bytes */ |
43 | size_t len; /* Number of already used bytes */ |
43 | char *dst; /* Destination */ |
44 | char *dst; /* Destination */ |
Line 84... | Line 85... | ||
84 | index_t index = 0; |
85 | index_t index = 0; |
85 | 86 | ||
86 | while (index < size) { |
87 | while (index < size) { |
87 | wchar_t uc = chr_decode(str, &index, size); |
88 | wchar_t uc = chr_decode(str, &index, size); |
88 | 89 | ||
89 | if (!chr_encode(uc, data->dst, &data->len, data->size - 1)) |
90 | if (chr_encode(uc, data->dst, &data->len, data->size - 1) != EOK) |
90 | break; |
91 | break; |
91 | } |
92 | } |
92 | 93 | ||
93 | /* Put trailing zero at end, but not count it |
94 | /* Put trailing zero at end, but not count it |
94 | * into data->len so it could be rewritten next time |
95 | * into data->len so it could be rewritten next time |
Line 144... | Line 145... | ||
144 | data->dst[data->size - 1] = 0; |
145 | data->dst[data->size - 1] = 0; |
145 | data->len = data->size; |
146 | data->len = data->size; |
146 | return ((int) size); |
147 | return ((int) size); |
147 | } |
148 | } |
148 | 149 | ||
149 | if (!chr_encode(str[index], data->dst, &data->len, data->size - 1)) |
150 | if (chr_encode(str[index], data->dst, &data->len, data->size - 1) != EOK) |
150 | break; |
151 | break; |
151 | 152 | ||
152 | index++; |
153 | index++; |
153 | } |
154 | } |
154 | 155 |