Lines Matching +full:4 +full:- +full:ch
1 /* SPDX-License-Identifier: GPL-2.0 */
31 io->fd = fd; in io__init()
32 io->buf_len = buf_len; in io__init()
33 io->buf = buf; in io__init()
34 io->end = buf; in io__init()
35 io->data = buf; in io__init()
36 io->eof = false; in io__init()
42 char *ptr = io->data; in io__get_char()
44 if (io->eof) in io__get_char()
45 return -1; in io__get_char()
47 if (ptr == io->end) { in io__get_char()
48 ssize_t n = read(io->fd, io->buf, io->buf_len); in io__get_char()
51 io->eof = true; in io__get_char()
52 return -1; in io__get_char()
54 ptr = &io->buf[0]; in io__get_char()
55 io->end = &io->buf[n]; in io__get_char()
57 io->data = ptr + 1; in io__get_char()
62 * first character isn't hexadecimal returns -2, io->eof returns -1, otherwise
63 * returns the character after the hexadecimal value which may be -1 for eof.
64 * If the read value is larger than a u64 the high-order bits will be dropped.
72 int ch = io__get_char(io); in io__get_hex() local
74 if (ch < 0) in io__get_hex()
75 return ch; in io__get_hex()
76 if (ch >= '0' && ch <= '9') in io__get_hex()
77 *hex = (*hex << 4) | (ch - '0'); in io__get_hex()
78 else if (ch >= 'a' && ch <= 'f') in io__get_hex()
79 *hex = (*hex << 4) | (ch - 'a' + 10); in io__get_hex()
80 else if (ch >= 'A' && ch <= 'F') in io__get_hex()
81 *hex = (*hex << 4) | (ch - 'A' + 10); in io__get_hex()
83 return -2; in io__get_hex()
85 return ch; in io__get_hex()
91 * isn't a decimal returns -2, io->eof returns -1, otherwise returns the
92 * character after the decimal value which may be -1 for eof. If the read value
93 * is larger than a u64 the high-order bits will be dropped.
101 int ch = io__get_char(io); in io__get_dec() local
103 if (ch < 0) in io__get_dec()
104 return ch; in io__get_dec()
105 if (ch >= '0' && ch <= '9') in io__get_dec()
106 *dec = (*dec * 10) + ch - '0'; in io__get_dec()
108 return -2; in io__get_dec()
110 return ch; in io__get_dec()