Ignore:
Timestamp:
Feb 17, 2001, 3:03:14 PM (25 years ago)
Author:
umoeller
Message:

Updates to XML.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/stringh.c

    r23 r38  
    8282    else
    8383        return (0);
     84}
     85
     86/*
     87 *@@ strhcmp:
     88 *      better strcmp. This doesn't crash if any of the
     89 *      string pointers are NULL, but returns a proper
     90 *      value then.
     91 *
     92 *      Besides, this is guaranteed to only return -1, 0,
     93 *      or +1, while strcmp can return any positive or
     94 *      negative value.
     95 *
     96 *@@added V0.9.9 (2001-02-16) [umoeller]
     97 */
     98
     99int strhcmp(const char *p1, const char *p2)
     100{
     101    if (p1 && p2)
     102    {
     103        int i = strcmp(p1, p2);
     104        if (i < 0) return (-1);
     105        if (i > 0) return (+1);
     106    }
     107    else if (p1)
     108        // but p2 is NULL: p1 greater than p2 then
     109        return (+1);
     110    else if (p2)
     111        // but p1 is NULL: p1 less than p2 then
     112        return (-1);
     113
     114    // return 0 if strcmp returned 0 above or both strings are NULL
     115    return (0);
    84116}
    85117
Note: See TracChangeset for help on using the changeset viewer.