misc/ustring.c

C code posted
created at 06 Sep 19:01

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* ==================== handle argv ==================== */

#define ustring_delete_range_p(/*UString **/ ustr, /*UChar **/ from, /*UChar **/ to) \
ustring_delete_len(ustr, from - ustr->ptr, to - from)

#define ustring_subreplace_len_p(/*UString **/ ustr, /*UChar **/ from, /*UChar **/ to, /*UChar **/ what, /*size_t*/ len) \
ustring_subreplace_len(ustr, what, len, from - ustr->ptr, to - from)

static int hexadecimal_digit(UChar c)
{
    if (c >= U_0 && c <= U_9) { // '0' .. '9'
        return (c - U_0);
    }
    if (c >= U_A && c <= U_F) { // 'A' .. 'F'
        return (c - (U_A - 10));
    }
    if (c >= U_a && c <= U_f) { // 'a' .. 'f'
        return (c - (U_a - 10));
    }

    return -1;
}
722 Bytes in 2 ms with coderay