Changes in uspace/lib/c/generic/str.c [1772e6d:8e893ae] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
r1772e6d r8e893ae 428 428 * 429 429 * Do a char-by-char comparison of two NULL-terminated strings. 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. 430 * The strings are considered equal iff they consist of the same 431 * characters on the minimum of their lengths. 437 432 * 438 433 * @param s1 First string to compare. 439 434 * @param s2 Second string to compare. 440 435 * 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.436 * @return 0 if the strings are equal, -1 if first is smaller, 437 * 1 if second smaller. 443 438 * 444 439 */ … … 471 466 * 472 467 * Do a char-by-char comparison of two NULL-terminated strings. 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. 468 * The strings are considered equal iff they consist of the same 469 * characters on the minimum of their lengths and the length limit. 483 470 * 484 471 * @param s1 First string to compare. … … 486 473 * @param max_len Maximum number of characters to consider. 487 474 * 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.475 * @return 0 if the strings are equal, -1 if first is smaller, 476 * 1 if second smaller. 490 477 * 491 478 */ … … 521 508 return 0; 522 509 523 }524 525 /** Test whether p is a prefix of s.526 *527 * Do a char-by-char comparison of two NULL-terminated strings528 * and determine if p is a prefix of s.529 *530 * @param s The string in which to look531 * @param p The string to check if it is a prefix of s532 *533 * @return true iff p is prefix of s else false534 *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;559 510 } 560 511 … … 1134 1085 c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 : 1135 1086 (c <= '9' ? c - '0' : 0xff))); 1136 if (c > =base) {1087 if (c > base) { 1137 1088 break; 1138 1089 }
Note:
See TracChangeset
for help on using the changeset viewer.