Changeset b67c7d64 in mainline
- Timestamp:
- 2009-11-30T19:51:29Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e866806
- Parents:
- 0f06dbc
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/input.c
r0f06dbc rb67c7d64 134 134 static char *tinput_get_str(tinput_t *ti) 135 135 { 136 char *str; 137 138 str = malloc(STR_BOUNDS(ti->nc) + 1); 139 if (str == NULL) 140 return NULL; 141 142 wstr_to_str(str, STR_BOUNDS(ti->nc) + 1, ti->buffer); 143 144 return str; 136 return wstr_to_astr(ti->buffer); 145 137 } 146 138 -
uspace/app/edit/edit.c
r0f06dbc rb67c7d64 391 391 392 392 buffer[nc] = '\0'; 393 394 str = malloc(STR_BOUNDS(wstr_length(buffer)) + 1); 395 if (str == NULL) 396 return NULL; 397 398 wstr_to_str(str, STR_BOUNDS(wstr_length(buffer)) + 1, buffer); 393 str = wstr_to_astr(buffer); 399 394 400 395 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); -
uspace/lib/libc/generic/string.c
r0f06dbc rb67c7d64 579 579 } 580 580 581 /** Convert wide string to new string. 582 * 583 * Convert wide string @a src to string. Space for the new string is allocated 584 * on the heap. 585 * 586 * @param src Source wide string. 587 * @return New string. 588 */ 589 char *wstr_to_astr(const wchar_t *src) 590 { 591 char dbuf[STR_BOUNDS(1)]; 592 char *str; 593 wchar_t ch; 594 595 size_t src_idx; 596 size_t dest_off; 597 size_t dest_size; 598 599 /* Compute size of encoded string. */ 600 601 src_idx = 0; 602 dest_size = 0; 603 604 while ((ch = src[src_idx++]) != 0) { 605 dest_off = 0; 606 if (chr_encode(ch, dbuf, &dest_off, STR_BOUNDS(1)) != EOK) 607 break; 608 dest_size += dest_off; 609 } 610 611 str = malloc(dest_size + 1); 612 if (str == NULL) 613 return NULL; 614 615 /* Encode string. */ 616 617 src_idx = 0; 618 dest_off = 0; 619 620 while ((ch = src[src_idx++]) != 0) { 621 if (chr_encode(ch, str, &dest_off, dest_size) != EOK) 622 break; 623 } 624 625 str[dest_size] = '\0'; 626 return str; 627 } 628 629 581 630 /** Convert string to wide string. 582 631 * -
uspace/lib/libc/include/string.h
r0f06dbc rb67c7d64 74 74 75 75 extern void wstr_to_str(char *dest, size_t size, const wchar_t *src); 76 extern char *wstr_to_astr(const wchar_t *src); 76 77 extern void str_to_wstr(wchar_t *dest, size_t dlen, const char *src); 77 78
Note:
See TracChangeset
for help on using the changeset viewer.