Changes in uspace/lib/c/generic/str.c [8e893ae:1772e6d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
r8e893ae r1772e6d 428 428 * 429 429 * Do a char-by-char comparison of two NULL-terminated strings. 430 * The strings are considered equal iff they consist of the same 431 * characters on the minimum of their lengths. 430 * The strings are considered equal iff their length is equal 431 * and both strings consist of the same sequence of characters. 432 * 433 * A string S1 is less than another string S2 if it has a character with 434 * lower value at the first character position where the strings differ. 435 * If the strings differ in length, the shorter one is treated as if 436 * padded by characters with a value of zero. 432 437 * 433 438 * @param s1 First string to compare. 434 439 * @param s2 Second string to compare. 435 440 * 436 * @return 0 if the strings are equal, -1 if first is smaller,437 * 1 if second smaller.441 * @return 0 if the strings are equal, -1 if the first is less than the second, 442 * 1 if the second is less than the first. 438 443 * 439 444 */ … … 466 471 * 467 472 * Do a char-by-char comparison of two NULL-terminated strings. 468 * The strings are considered equal iff they consist of the same 469 * characters on the minimum of their lengths and the length limit. 473 * The strings are considered equal iff 474 * min(str_length(s1), max_len) == min(str_length(s2), max_len) 475 * and both strings consist of the same sequence of characters, 476 * up to max_len characters. 477 * 478 * A string S1 is less than another string S2 if it has a character with 479 * lower value at the first character position where the strings differ. 480 * If the strings differ in length, the shorter one is treated as if 481 * padded by characters with a value of zero. Only the first max_len 482 * characters are considered. 470 483 * 471 484 * @param s1 First string to compare. … … 473 486 * @param max_len Maximum number of characters to consider. 474 487 * 475 * @return 0 if the strings are equal, -1 if first is smaller,476 * 1 if second smaller.488 * @return 0 if the strings are equal, -1 if the first is less than the second, 489 * 1 if the second is less than the first. 477 490 * 478 491 */ … … 508 521 return 0; 509 522 523 } 524 525 /** Test whether p is a prefix of s. 526 * 527 * Do a char-by-char comparison of two NULL-terminated strings 528 * and determine if p is a prefix of s. 529 * 530 * @param s The string in which to look 531 * @param p The string to check if it is a prefix of s 532 * 533 * @return true iff p is prefix of s else false 534 * 535 */ 536 bool str_test_prefix(const char *s, const char *p) 537 { 538 wchar_t c1 = 0; 539 wchar_t c2 = 0; 540 541 size_t off1 = 0; 542 size_t off2 = 0; 543 544 while (true) { 545 c1 = str_decode(s, &off1, STR_NO_LIMIT); 546 c2 = str_decode(p, &off2, STR_NO_LIMIT); 547 548 if (c2 == 0) 549 return true; 550 551 if (c1 != c2) 552 return false; 553 554 if (c1 == 0) 555 break; 556 } 557 558 return false; 510 559 } 511 560 … … 1085 1134 c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 : 1086 1135 (c <= '9' ? c - '0' : 0xff))); 1087 if (c > base) {1136 if (c >= base) { 1088 1137 break; 1089 1138 }
Note:
See TracChangeset
for help on using the changeset viewer.