Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 272f88f0 in mainline for uspace/lib/libc/generic/string.c


Ignore:
Timestamp:
2009-11-29T14:54:07Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
1352fc1, 1df977c
Parents:
a1622091 (diff), da2bd08 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge more command-line input improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/string.c

    ra1622091 r272f88f0  
    583583}
    584584
     585/** Convert string to wide string.
     586 *
     587 * Convert string @a src to wide string. The output is written to the
     588 * buffer specified by @a dest and @a size, which must have non-zero
     589 * size. The output will always be null-terminated.
     590 *
     591 * @param dest  Destination buffer.
     592 * @param dlen  Length of destination buffer (number of wchars).
     593 * @param src   Source string.
     594 */
     595void str_to_wstr(wchar_t *dest, size_t dlen, const char *src)
     596{
     597        size_t offset;
     598        size_t di;
     599        wchar_t c;
     600
     601        assert(dlen > 0);
     602
     603        offset = 0;
     604        di = 0;
     605
     606        do {
     607                if (di >= dlen - 1)
     608                        break;
     609
     610                c = str_decode(src, &offset, STR_NO_LIMIT);
     611                dest[di++] = c;
     612        } while (c != '\0');
     613
     614        dest[dlen - 1] = '\0';
     615}
     616
    585617/** Find first occurence of character in string.
    586618 *
Note: See TracChangeset for help on using the changeset viewer.