Changeset 28a5ebd in mainline for uspace/app/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/app/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;
     
    850850        coord_t rbc, rec;
    851851        char row_buf[ROW_BUF_SIZE];
    852         wchar_t c;
     852        char32_t c;
    853853        size_t pos, size;
    854854        int s_column;
     
    10551055
    10561056/** Insert a character at caret position. */
    1057 static void insert_char(wchar_t c)
     1057static void insert_char(char32_t c)
    10581058{
    10591059        spt_t pt;
     
    12851285
    12861286/* Search operations */
    1287 static errno_t search_spt_producer(void *data, wchar_t *ret)
     1287static errno_t search_spt_producer(void *data, char32_t *ret)
    12881288{
    12891289        assert(data != NULL);
     
    12941294}
    12951295
    1296 static errno_t search_spt_reverse_producer(void *data, wchar_t *ret)
     1296static errno_t search_spt_reverse_producer(void *data, char32_t *ret)
    12971297{
    12981298        assert(data != NULL);
     
    15131513        char *str;
    15141514        size_t off;
    1515         wchar_t c;
     1515        char32_t c;
    15161516        errno_t rc;
    15171517
     
    16091609}
    16101610
    1611 static wchar_t get_first_wchar(const char *str)
     1611static char32_t get_first_wchar(const char *str)
    16121612{
    16131613        size_t offset = 0;
     
    16301630                return false;
    16311631
    1632         wchar_t first_char = get_first_wchar(ch);
     1632        char32_t first_char = get_first_wchar(ch);
    16331633        switch (first_char) {
    16341634        case ' ':
     
    16561656                return false;
    16571657
    1658         wchar_t first_char = get_first_wchar(ch);
     1658        char32_t first_char = get_first_wchar(ch);
    16591659        switch (first_char) {
    16601660        case ',':
Note: See TracChangeset for help on using the changeset viewer.