Changeset 08e103d4 in mainline for uspace/dist/src


Ignore:
Timestamp:
2019-02-05T18:26:05Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
1d2f85e
Parents:
d066259
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-05 16:16:55)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-05 18:26:05)
Message:

Use clearer naming for string length functions

This and the following commit change the names of functions, as well as
their documentation, to use unambiguous terms "bytes" and "code points"
instead of ambiguous terms "size", "length", and "characters".

Location:
uspace/dist/src/c/demos
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/dist/src/c/demos/edit/edit.c

    rd066259 r08e103d4  
    637637        asprintf(&str, "%s: %s", prompt, init_value);
    638638        status_display(str);
    639         console_set_pos(con, 1 + str_length(str), scr_rows - 1);
     639        console_set_pos(con, 1 + str_code_points(str), scr_rows - 1);
    640640        free(str);
    641641
    642642        console_set_style(con, STYLE_INVERTED);
    643643
    644         max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_length(prompt));
     644        max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_code_points(prompt));
    645645        str_to_wstr(buffer, max_len + 1, init_value);
    646         nc = wstr_length(buffer);
     646        nc = wstr_code_points(buffer);
    647647        done = false;
    648648
     
    747747        do {
    748748                sheet_copy_out(doc.sh, &sp, epos, buf, BUF_SIZE, &bep);
    749                 bytes = str_size(buf);
     749                bytes = str_bytes(buf);
    750750
    751751                n_written = fwrite(buf, 1, bytes, f);
     
    783783                sheet_copy_out(doc.sh, &sp, epos, &buf[bpos], buf_size - bpos,
    784784                    &bep);
    785                 bytes = str_size(&buf[bpos]);
     785                bytes = str_bytes(&buf[bpos]);
    786786                bpos += bytes;
    787787                sp = bep;
     
    893893
    894894                console_set_pos(con, 0, i);
    895                 size = str_size(row_buf);
     895                size = str_bytes(row_buf);
    896896                pos = 0;
    897897                s_column = pane.sh_column;
     
    10121012                /* Compute position where we overwrite with '..\0' */
    10131013                if (fnw >= nextra + 2) {
    1014                         p = fname + str_lsize(fname, fnw - nextra - 2);
     1014                        p = fname + str_lbytes(fname, fnw - nextra - 2);
    10151015                } else {
    10161016                        p = fname;
     
    16091609{
    16101610        size_t offset = 0;
    1611         return str_decode(str, &offset, str_size(str));
     1611        return str_decode(str, &offset, str_bytes(str));
    16121612}
    16131613
  • uspace/dist/src/c/demos/edit/search.c

    rd066259 r08e103d4  
    5555        }
    5656
    57         search->pattern_length = wstr_length(p);
     57        search->pattern_length = wstr_code_points(p);
    5858
    5959        if (reverse) {
  • uspace/dist/src/c/demos/edit/sheet.c

    rd066259 r08e103d4  
    107107        char *newp;
    108108
    109         sz = str_size(str);
     109        sz = str_bytes(str);
    110110        if (sh->text_size + sz > sh->dbuf_size) {
    111111                /* Enlarge data buffer. */
  • uspace/dist/src/c/demos/tetris/screen.c

    rd066259 r08e103d4  
    321321void scr_msg(char *s, bool set)
    322322{
    323         int l = str_size(s);
     323        int l = str_bytes(s);
    324324
    325325        moveto(Rows - 2, ((Cols - l) >> 1) - 1);
  • uspace/dist/src/c/demos/tetris/tetris.c

    rd066259 r08e103d4  
    270270                        break;
    271271                case 'k':
    272                         if (str_size(keys = optarg) != 6)
     272                        if (str_bytes(keys = optarg) != 6)
    273273                                usage();
    274274                        break;
Note: See TracChangeset for help on using the changeset viewer.