~martin-decky/helenos/rcu

« back to all changes in this revision

Viewing changes to kernel/generic/src/lib/str.c

MergeĀ mainlineĀ changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
#include <debug.h>
112
112
#include <macros.h>
113
113
 
 
114
/** Check the condition if wchar_t is signed */
 
115
#ifdef WCHAR_IS_UNSIGNED
 
116
        #define WCHAR_SIGNED_CHECK(cond)  (true)
 
117
#else
 
118
        #define WCHAR_SIGNED_CHECK(cond)  (cond)
 
119
#endif
 
120
 
114
121
/** Byte mask consisting of lowest @n bits (out of 8) */
115
122
#define LO_MASK_8(n)  ((uint8_t) ((1 << (n)) - 1))
116
123
 
205
212
 * @param size   Size of the output buffer (in bytes).
206
213
 *
207
214
 * @return EOK if the character was encoded successfully, EOVERFLOW if there
208
 
 *         was not enough space in the output buffer or EINVAL if the character
209
 
 *         code was invalid.
 
215
 *         was not enough space in the output buffer or EINVAL if the character
 
216
 *         code was invalid.
210
217
 */
211
 
int chr_encode(wchar_t ch, char *str, size_t *offset, size_t size)
 
218
int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t size)
212
219
{
213
220
        if (*offset >= size)
214
221
                return EOVERFLOW;
426
433
 */
427
434
bool ascii_check(wchar_t ch)
428
435
{
429
 
        if ((ch >= 0) && (ch <= 127))
 
436
        if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))
430
437
                return true;
431
438
        
432
439
        return false;
439
446
 */
440
447
bool chr_check(wchar_t ch)
441
448
{
442
 
        if ((ch >= 0) && (ch <= 1114111))
 
449
        if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))
443
450
                return true;
444
451
        
445
452
        return false;
892
899
 * @return EOK if conversion was successful.
893
900
 *
894
901
 */
895
 
int str_uint64(const char *nptr, char **endptr, unsigned int base,
 
902
int str_uint64_t(const char *nptr, char **endptr, unsigned int base,
896
903
    bool strict, uint64_t *result)
897
904
{
898
905
        ASSERT(result != NULL);