Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/src/stdio.c

    r163e34c r694ca3d6  
    232232 * @return The number of written characters.
    233233 */
    234 static errno_t _dprintf_str_write(const char *str, size_t size, void *fd)
     234static int _dprintf_str_write(const char *str, size_t size, void *fd)
    235235{
    236236        const int fildes = *(int *) fd;
    237237        size_t wr;
    238         return vfs_write(fildes, &posix_pos[fildes], str, size, &wr);
     238        if (failed(vfs_write(fildes, &posix_pos[fildes], str, size, &wr)))
     239                return -1;
     240        return str_nlength(str, wr);
     241}
     242
     243/**
     244 * Write wide string to the opened file.
     245 *
     246 * @param str String to be written.
     247 * @param size Size of the string (in bytes).
     248 * @param fd File descriptor of the opened file.
     249 * @return The number of written characters.
     250 */
     251static int _dprintf_wstr_write(const char32_t *str, size_t size, void *fd)
     252{
     253        size_t offset = 0;
     254        size_t chars = 0;
     255        size_t sz;
     256        char buf[4];
     257
     258        while (offset < size) {
     259                sz = 0;
     260                if (chr_encode(str[chars], buf, &sz, sizeof(buf)) != EOK) {
     261                        break;
     262                }
     263
     264                const int fildes = *(int *) fd;
     265                size_t nwr;
     266                if (vfs_write(fildes, &posix_pos[fildes], buf, sz, &nwr) != EOK)
     267                        break;
     268
     269                chars++;
     270                offset += sizeof(char32_t);
     271        }
     272
     273        return chars;
    239274}
    240275
     
    250285{
    251286        printf_spec_t spec = {
    252                 .write = _dprintf_str_write,
     287                .str_write = _dprintf_str_write,
     288                .wstr_write = _dprintf_wstr_write,
    253289                .data = &fildes
    254290        };
Note: See TracChangeset for help on using the changeset viewer.