Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/str.c

    r1772e6d r8e893ae  
    428428 *
    429429 * 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.
    437432 *
    438433 * @param s1 First string to compare.
    439434 * @param s2 Second string to compare.
    440435 *
    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.
    443438 *
    444439 */
     
    471466 *
    472467 * 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.
    483470 *
    484471 * @param s1      First string to compare.
     
    486473 * @param max_len Maximum number of characters to consider.
    487474 *
    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.
    490477 *
    491478 */
     
    521508        return 0;
    522509
    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;
    559510}
    560511
     
    11341085                c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 :
    11351086                    (c <= '9' ? c - '0' : 0xff)));
    1136                 if (c >= base) {
     1087                if (c > base) {
    11371088                        break;
    11381089                }
Note: See TracChangeset for help on using the changeset viewer.