Changeset f2b8cdc in mainline for uspace/lib/libc/generic/io/vprintf.c


Ignore:
Timestamp:
2009-04-04T22:04:28Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b27eb71
Parents:
4527fb5
Message:

Copy printf with Unicode support to userspace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/io/vprintf.c

    r4527fb5 rf2b8cdc  
    4242static atomic_t printf_futex = FUTEX_INITIALIZER;
    4343
    44 static int vprintf_write(const char *str, size_t count, void *unused)
     44static int vprintf_str_write(const char *str, size_t size, void *data)
    4545{
    46         return write_stdout(str, count);
     46        size_t offset = 0;
     47        size_t prev;
     48        count_t chars = 0;
     49       
     50        while (offset < size) {
     51                prev = offset;
     52                str_decode(str, &offset, size);
     53                write_stdout(str + prev, offset - prev);
     54                chars++;
     55        }
     56       
     57        return chars;
    4758}
     59
     60static int vprintf_wstr_write(const wchar_t *str, size_t size, void *data)
     61{
     62        size_t offset = 0;
     63        size_t boff;
     64        count_t chars = 0;
     65        char buf[4];
     66       
     67        while (offset < size) {
     68                boff = 0;
     69                chr_encode(str[chars], buf, &boff, 4);
     70                write_stdout(buf, boff);
     71                chars++;
     72                offset += sizeof(wchar_t);
     73        }
     74       
     75        return chars;
     76}
     77
    4878
    4979/** Print formatted text.
     
    5585{
    5686        struct printf_spec ps = {
    57                 (int (*)(void *, size_t, void *)) vprintf_write,
     87                vprintf_str_write,
     88                vprintf_wstr_write,
    5889                 NULL
    5990        };
Note: See TracChangeset for help on using the changeset viewer.