Changeset 28a5ebd in mainline for uspace/dist/src/c/demos/edit/edit.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/dist/src/c/demos/edit/edit.c

    r4f663f3e r28a5ebd  
    147147static void pane_caret_display(void);
    148148
    149 static void insert_char(wchar_t c);
     149static void insert_char(char32_t c);
    150150static void delete_char_before(void);
    151151static void delete_char_after(void);
     
    630630        kbd_event_t *kev;
    631631        char *str;
    632         wchar_t buffer[INFNAME_MAX_LEN + 1];
     632        char32_t buffer[INFNAME_MAX_LEN + 1];
    633633        int max_len;
    634634        int nc;
     
    670670                                default:
    671671                                        if (kev->c >= 32 && nc < max_len) {
    672                                                 putwchar(kev->c);
     672                                                putuchar(kev->c);
    673673                                                console_flush(con);
    674674                                                buffer[nc++] = kev->c;
     
    696696{
    697697        FILE *f;
    698         wchar_t c;
     698        char32_t c;
    699699        char buf[BUF_SIZE];
    700700        int bcnt;
     
    847847        coord_t rbc, rec;
    848848        char row_buf[ROW_BUF_SIZE];
    849         wchar_t c;
     849        char32_t c;
    850850        size_t pos, size;
    851851        int s_column;
     
    10521052
    10531053/** Insert a character at caret position. */
    1054 static void insert_char(wchar_t c)
     1054static void insert_char(char32_t c)
    10551055{
    10561056        spt_t pt;
     
    12821282
    12831283/* Search operations */
    1284 static errno_t search_spt_producer(void *data, wchar_t *ret)
     1284static errno_t search_spt_producer(void *data, char32_t *ret)
    12851285{
    12861286        assert(data != NULL);
     
    12911291}
    12921292
    1293 static errno_t search_spt_reverse_producer(void *data, wchar_t *ret)
     1293static errno_t search_spt_reverse_producer(void *data, char32_t *ret)
    12941294{
    12951295        assert(data != NULL);
     
    15101510        char *str;
    15111511        size_t off;
    1512         wchar_t c;
     1512        char32_t c;
    15131513        errno_t rc;
    15141514
     
    16061606}
    16071607
    1608 static wchar_t get_first_wchar(const char *str)
     1608static char32_t get_first_wchar(const char *str)
    16091609{
    16101610        size_t offset = 0;
     
    16271627                return false;
    16281628
    1629         wchar_t first_char = get_first_wchar(ch);
     1629        char32_t first_char = get_first_wchar(ch);
    16301630        switch (first_char) {
    16311631        case ' ':
     
    16531653                return false;
    16541654
    1655         wchar_t first_char = get_first_wchar(ch);
     1655        char32_t first_char = get_first_wchar(ch);
    16561656        switch (first_char) {
    16571657        case ',':
Note: See TracChangeset for help on using the changeset viewer.