Changeset 28a5ebd in mainline for kernel/generic/src/printf
- Timestamp:
- 2020-06-18T15:39:50Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce52c333
- Parents:
- 4f663f3e
- Location:
- kernel/generic/src/printf
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/printf/printf_core.c
r4f663f3e r28a5ebd 139 139 * 140 140 */ 141 static int printf_wputnchars(const wchar_t *buf, size_t size,141 static int printf_wputnchars(const char32_t *buf, size_t size, 142 142 printf_spec_t *ps) 143 143 { … … 185 185 * 186 186 */ 187 static int printf_put wchar(const wchar_t ch, printf_spec_t *ps)187 static int printf_putuchar(const char32_t ch, printf_spec_t *ps) 188 188 { 189 189 if (!chr_check(ch)) 190 190 return ps->str_write((void *) &invalch, 1, ps->data); 191 191 192 return ps->wstr_write(&ch, sizeof( wchar_t), ps->data);192 return ps->wstr_write(&ch, sizeof(char32_t), ps->data); 193 193 } 194 194 … … 240 240 * 241 241 */ 242 static int print_wchar(const wchar_t ch, int width, uint32_t flags, printf_spec_t *ps)242 static int print_wchar(const char32_t ch, int width, uint32_t flags, printf_spec_t *ps) 243 243 { 244 244 size_t counter = 0; … … 254 254 } 255 255 256 if (printf_put wchar(ch, ps) > 0)256 if (printf_putuchar(ch, ps) > 0) 257 257 counter++; 258 258 … … 326 326 * @return Number of wide characters printed, negative value on failure. 327 327 */ 328 static int print_wstr( wchar_t *str, int width, unsigned int precision,328 static int print_wstr(char32_t *str, int width, unsigned int precision, 329 329 uint32_t flags, printf_spec_t *ps) 330 330 { … … 576 576 * - "l" Signed or unsigned long int.@n 577 577 * If conversion is "c", the character is wint_t (wide character).@n 578 * If conversion is "s", the string is wchar_t * (widestring).@n578 * If conversion is "s", the string is char32_t * (UTF-32 string).@n 579 579 * - "ll" Signed or unsigned long long int.@n 580 580 * - "z" Signed or unsigned ssize_t or site_t.@n … … 630 630 while (true) { 631 631 i = nxt; 632 wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT);632 char32_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT); 633 633 634 634 if (uc == 0) … … 789 789 case 's': 790 790 if (qualifier == PrintfQualifierLong) 791 retval = print_wstr(va_arg(ap, wchar_t *), width, precision, flags, ps);791 retval = print_wstr(va_arg(ap, char32_t *), width, precision, flags, ps); 792 792 else 793 793 retval = print_str(va_arg(ap, char *), width, precision, flags, ps); -
kernel/generic/src/printf/vprintf.c
r4f663f3e r28a5ebd 47 47 48 48 while (offset < size) { 49 put wchar(str_decode(str, &offset, size));49 putuchar(str_decode(str, &offset, size)); 50 50 chars++; 51 51 } … … 54 54 } 55 55 56 static int vprintf_wstr_write(const wchar_t *str, size_t size, void *data)56 static int vprintf_wstr_write(const char32_t *str, size_t size, void *data) 57 57 { 58 58 size_t offset = 0; … … 60 60 61 61 while (offset < size) { 62 put wchar(str[chars]);62 putuchar(str[chars]); 63 63 chars++; 64 offset += sizeof( wchar_t);64 offset += sizeof(char32_t); 65 65 } 66 66 … … 72 72 size_t offset = 0; 73 73 size_t chars = 0; 74 wchar_t uc;74 char32_t uc; 75 75 76 76 while ((uc = str_decode(str, &offset, STR_NO_LIMIT)) != 0) { 77 put wchar(uc);77 putuchar(uc); 78 78 chars++; 79 79 } 80 80 81 put wchar('\n');81 putuchar('\n'); 82 82 return chars; 83 83 } -
kernel/generic/src/printf/vsnprintf.c
r4f663f3e r28a5ebd 88 88 89 89 while (index < size) { 90 wchar_t uc = str_decode(str, &index, size);90 char32_t uc = str_decode(str, &index, size); 91 91 92 92 if (chr_encode(uc, data->dst, &data->len, data->size - 1) != EOK) … … 133 133 * 134 134 */ 135 static int vsnprintf_wstr_write(const wchar_t *str, size_t size, vsnprintf_data_t *data)135 static int vsnprintf_wstr_write(const char32_t *str, size_t size, vsnprintf_data_t *data) 136 136 { 137 137 size_t index = 0; 138 138 139 while (index < (size / sizeof( wchar_t))) {139 while (index < (size / sizeof(char32_t))) { 140 140 size_t left = data->size - data->len; 141 141 … … 177 177 printf_spec_t ps = { 178 178 (int (*) (const char *, size_t, void *)) vsnprintf_str_write, 179 (int (*) (const wchar_t *, size_t, void *)) vsnprintf_wstr_write,179 (int (*) (const char32_t *, size_t, void *)) vsnprintf_wstr_write, 180 180 &data 181 181 };
Note:
See TracChangeset
for help on using the changeset viewer.