Changeset d4a3ee5 in mainline for uspace/lib/libc/generic/string.c
- Timestamp:
- 2009-06-03T19:12:51Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b267ee6
- Parents:
- e1ab30f8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/string.c
re1ab30f8 rd4a3ee5 139 139 * 140 140 * @return EOK if the character was encoded successfully, EOVERFLOW if there 141 * 142 * 141 * was not enough space in the output buffer or EINVAL if the character 142 * code was invalid. 143 143 */ 144 144 int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t size) … … 244 244 * 245 245 */ 246 size_t str_lsize(const char *str, count_t max_len)247 { 248 count_t len = 0;246 size_t str_lsize(const char *str, size_t max_len) 247 { 248 size_t len = 0; 249 249 size_t offset = 0; 250 250 … … 272 272 * 273 273 */ 274 size_t wstr_lsize(const wchar_t *str, count_t max_len)274 size_t wstr_lsize(const wchar_t *str, size_t max_len) 275 275 { 276 276 return (wstr_nlength(str, max_len * sizeof(wchar_t)) * sizeof(wchar_t)); … … 284 284 * 285 285 */ 286 count_t str_length(const char *str)287 { 288 count_t len = 0;286 size_t str_length(const char *str) 287 { 288 size_t len = 0; 289 289 size_t offset = 0; 290 290 … … 302 302 * 303 303 */ 304 count_t wstr_length(const wchar_t *wstr)305 { 306 count_t len = 0;304 size_t wstr_length(const wchar_t *wstr) 305 { 306 size_t len = 0; 307 307 308 308 while (*wstr++ != 0) … … 320 320 * 321 321 */ 322 count_t str_nlength(const char *str, size_t size)323 { 324 count_t len = 0;322 size_t str_nlength(const char *str, size_t size) 323 { 324 size_t len = 0; 325 325 size_t offset = 0; 326 326 … … 339 339 * 340 340 */ 341 count_t wstr_nlength(const wchar_t *str, size_t size)342 { 343 count_t len = 0;344 count_t limit = ALIGN_DOWN(size, sizeof(wchar_t));345 count_t offset = 0;341 size_t wstr_nlength(const wchar_t *str, size_t size) 342 { 343 size_t len = 0; 344 size_t limit = ALIGN_DOWN(size, sizeof(wchar_t)); 345 size_t offset = 0; 346 346 347 347 while ((offset < limit) && (*str++ != 0)) { … … 431 431 * 432 432 */ 433 int str_lcmp(const char *s1, const char *s2, count_t max_len)433 int str_lcmp(const char *s1, const char *s2, size_t max_len) 434 434 { 435 435 wchar_t c1 = 0; … … 439 439 size_t off2 = 0; 440 440 441 count_t len = 0;441 size_t len = 0; 442 442 443 443 while (true) { … … 569 569 570 570 wchar_t ch; 571 count_t src_idx = 0;571 size_t src_idx = 0; 572 572 size_t dst_off = 0; 573 573 … … 617 617 size_t off = 0; 618 618 size_t last = 0; 619 c har *res = NULL;619 const char *res = NULL; 620 620 621 621 while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) { … … 642 642 * 643 643 */ 644 bool wstr_linsert(wchar_t *str, wchar_t ch, count_t pos, count_t max_pos)645 { 646 count_t len = wstr_length(str);644 bool wstr_linsert(wchar_t *str, wchar_t ch, size_t pos, size_t max_pos) 645 { 646 size_t len = wstr_length(str); 647 647 648 648 if ((pos > len) || (pos + 1 > max_pos)) 649 649 return false; 650 650 651 count_t i;651 size_t i; 652 652 for (i = len; i + 1 > pos; i--) 653 653 str[i + 1] = str[i]; … … 670 670 * 671 671 */ 672 bool wstr_remove(wchar_t *str, count_t pos)673 { 674 count_t len = wstr_length(str);672 bool wstr_remove(wchar_t *str, size_t pos) 673 { 674 size_t len = wstr_length(str); 675 675 676 676 if (pos >= len) 677 677 return false; 678 678 679 count_t i;679 size_t i; 680 680 for (i = pos + 1; i <= len; i++) 681 681 str[i - 1] = str[i];
Note:
See TracChangeset
for help on using the changeset viewer.