Changeset 28a5ebd in mainline for uspace/app/kio/kio.c


Ignore:
Timestamp:
2020-06-18T15:39:50Z (4 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ce52c333
Parents:
4f663f3e
Message:

Use char32_t instead of wchat_t to represent UTF-32 strings

The intention of the native HelenOS string API has been always to
support Unicode in the UTF-8 and UTF-32 encodings as the sole character
representations and ignore the obsolete mess of older single-byte and
multibyte character encodings. Before C11, the wchar_t type has been
slightly misused for the purpose of the UTF-32 strings. The newer
char32_t type is obviously a much more suitable option. The standard
defines char32_t as uint_least32_t, thus we can take the liberty to fix
it to uint32_t.

To maintain compatilibity with the C Standard, the putwchar(wchar_t)
functions has been replaced by our custom putuchar(char32_t) functions
where appropriate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/kio/kio.c

    r4f663f3e r28a5ebd  
    5656        link_t link;
    5757        size_t length;
    58         wchar_t *data;
     58        char32_t *data;
    5959} item_t;
    6060
     
    6262
    6363/* Pointer to kio area */
    64 static wchar_t *kio = (wchar_t *) AS_AREA_ANY;
     64static char32_t *kio = (char32_t *) AS_AREA_ANY;
    6565static size_t kio_length;
    6666
     
    7777 *
    7878 */
    79 static void producer(size_t length, wchar_t *data)
     79static void producer(size_t length, char32_t *data)
    8080{
    8181        item_t *item = (item_t *) malloc(sizeof(item_t));
     
    8383                return;
    8484
    85         size_t sz = sizeof(wchar_t) * length;
    86         wchar_t *buf = (wchar_t *) malloc(sz);
     85        size_t sz = sizeof(char32_t) * length;
     86        char32_t *buf = (char32_t *) malloc(sz);
    8787        if (buf == NULL) {
    8888                free(item);
     
    121121
    122122                for (size_t i = 0; i < item->length; i++)
    123                         putwchar(item->data[i]);
     123                        putuchar(item->data[i]);
    124124
    125125                if (log != NULL) {
    126126                        for (size_t i = 0; i < item->length; i++)
    127                                 fputwc(item->data[i], log);
     127                                fputuc(item->data[i], log);
    128128
    129129                        fflush(log);
     
    202202
    203203        size_t size = pages * PAGE_SIZE;
    204         kio_length = size / sizeof(wchar_t);
     204        kio_length = size / sizeof(char32_t);
    205205
    206206        rc = physmem_map(faddr, pages, AS_AREA_READ | AS_AREA_CACHEABLE,
Note: See TracChangeset for help on using the changeset viewer.