Changeset 8e893ae in mainline for uspace/lib/c/generic/str.c


Ignore:
Timestamp:
2012-04-07T17:49:43Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c7afcba7
Parents:
a4a0f1d
Message:

avoid comparison with 0 if the type is unsigned

File:
1 edited

Legend:

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

    ra4a0f1d r8e893ae  
    4646#include <mem.h>
    4747#include <str.h>
     48
     49/** Check the condition if wchar_t is signed */
     50#ifdef WCHAR_IS_UNSIGNED
     51        #define WCHAR_SIGNED_CHECK(cond)  (true)
     52#else
     53        #define WCHAR_SIGNED_CHECK(cond)  (cond)
     54#endif
    4855
    4956/** Byte mask consisting of lowest @n bits (out of 8) */
     
    399406bool ascii_check(wchar_t ch)
    400407{
    401         if ((ch >= 0) && (ch <= 127))
     408        if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))
    402409                return true;
    403410       
     
    412419bool chr_check(wchar_t ch)
    413420{
    414         if ((ch >= 0) && (ch <= 1114111))
     421        if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))
    415422                return true;
    416423       
     
    513520 * @param count Size of the destination buffer (must be > 0).
    514521 * @param src   Source string.
     522 *
    515523 */
    516524void str_cpy(char *dest, size_t size, const char *src)
     
    545553 * @param src   Source string.
    546554 * @param n     Maximum number of bytes to read from @a src.
     555 *
    547556 */
    548557void str_ncpy(char *dest, size_t size, const char *src, size_t n)
Note: See TracChangeset for help on using the changeset viewer.