tokenizer: Use unsigned char
This commit is contained in:
parent
52ea737975
commit
0209fe6a51
1 changed files with 22 additions and 22 deletions
|
|
@ -30,7 +30,7 @@ struct apfl_tokenizer {
|
|||
NM_EOF,
|
||||
} next_mode;
|
||||
struct apfl_position pos_for_mapsto;
|
||||
char first_digit_for_negative_number;
|
||||
unsigned char first_digit_for_negative_number;
|
||||
|
||||
struct apfl_position position;
|
||||
struct apfl_position last_position;
|
||||
|
|
@ -96,7 +96,7 @@ apfl_tokenizer_get_error(apfl_tokenizer_ptr tokenizer)
|
|||
}
|
||||
|
||||
static enum read_result
|
||||
read_byte(apfl_tokenizer_ptr tokenizer, char *byte, bool need)
|
||||
read_byte(apfl_tokenizer_ptr tokenizer, unsigned char *byte, bool need)
|
||||
{
|
||||
if (tokenizer->buf_pos >= tokenizer->buf_len) {
|
||||
size_t len = BUFSIZE;
|
||||
|
|
@ -155,8 +155,8 @@ yield_simple_token(
|
|||
static enum apfl_parse_result comment(apfl_tokenizer_ptr);
|
||||
static enum apfl_parse_result colon(apfl_tokenizer_ptr);
|
||||
static enum apfl_parse_result string(apfl_tokenizer_ptr);
|
||||
static enum apfl_parse_result maybe_name(apfl_tokenizer_ptr, bool, char);
|
||||
static enum apfl_parse_result number(apfl_tokenizer_ptr, bool, struct apfl_position, char, bool);
|
||||
static enum apfl_parse_result maybe_name(apfl_tokenizer_ptr, bool, unsigned char);
|
||||
static enum apfl_parse_result number(apfl_tokenizer_ptr, bool, struct apfl_position, unsigned char, bool);
|
||||
|
||||
static bool
|
||||
is_control_byte(unsigned char byte)
|
||||
|
|
@ -183,7 +183,7 @@ apfl_tokenizer_next(apfl_tokenizer_ptr tokenizer, bool need)
|
|||
return APFL_PARSE_EOF;
|
||||
}
|
||||
|
||||
char byte;
|
||||
unsigned char byte;
|
||||
|
||||
for (;;) {
|
||||
switch (read_byte(tokenizer, &byte, need)) {
|
||||
|
|
@ -259,7 +259,7 @@ apfl_tokenizer_next(apfl_tokenizer_ptr tokenizer, bool need)
|
|||
static enum apfl_parse_result
|
||||
comment(apfl_tokenizer_ptr tokenizer)
|
||||
{
|
||||
char byte;
|
||||
unsigned char byte;
|
||||
|
||||
struct apfl_position pos = tokenizer->position;
|
||||
|
||||
|
|
@ -302,7 +302,7 @@ comment(apfl_tokenizer_ptr tokenizer)
|
|||
static enum apfl_parse_result
|
||||
colon(apfl_tokenizer_ptr tokenizer)
|
||||
{
|
||||
char byte;
|
||||
unsigned char byte;
|
||||
struct apfl_position pos = tokenizer->position;
|
||||
|
||||
switch (read_byte(tokenizer, &byte, true)) {
|
||||
|
|
@ -340,7 +340,7 @@ append_single_byte(
|
|||
}
|
||||
|
||||
static int
|
||||
unhex(char byte)
|
||||
unhex(unsigned char byte)
|
||||
{
|
||||
switch (byte) {
|
||||
case '0':
|
||||
|
|
@ -387,7 +387,7 @@ unhex(char byte)
|
|||
}
|
||||
|
||||
static int
|
||||
undec(char byte)
|
||||
undec(unsigned char byte)
|
||||
{
|
||||
switch (byte) {
|
||||
case '0':
|
||||
|
|
@ -416,7 +416,7 @@ undec(char byte)
|
|||
}
|
||||
|
||||
static int
|
||||
unoct(char byte)
|
||||
unoct(unsigned char byte)
|
||||
{
|
||||
switch (byte) {
|
||||
case '0':
|
||||
|
|
@ -441,7 +441,7 @@ unoct(char byte)
|
|||
}
|
||||
|
||||
static int
|
||||
unbin(char byte)
|
||||
unbin(unsigned char byte)
|
||||
{
|
||||
switch (byte) {
|
||||
case '0':
|
||||
|
|
@ -458,10 +458,10 @@ hex_escape(
|
|||
apfl_tokenizer_ptr tokenizer,
|
||||
struct apfl_string_builder *text
|
||||
) {
|
||||
char escaped_byte = 0;
|
||||
unsigned char escaped_byte = 0;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
char byte;
|
||||
unsigned char byte;
|
||||
|
||||
switch (read_byte(tokenizer, &byte, true)) {
|
||||
case RR_OK:
|
||||
|
|
@ -495,7 +495,7 @@ escape_sequence(apfl_tokenizer_ptr tokenizer, struct apfl_string_builder *text)
|
|||
{
|
||||
struct apfl_position pos = tokenizer->position;
|
||||
|
||||
char byte;
|
||||
unsigned char byte;
|
||||
|
||||
switch (read_byte(tokenizer, &byte, true)) {
|
||||
case RR_OK:
|
||||
|
|
@ -542,7 +542,7 @@ inner_string(apfl_tokenizer_ptr tokenizer, struct apfl_string_builder *text)
|
|||
{
|
||||
struct apfl_position pos = tokenizer->position;
|
||||
|
||||
char byte;
|
||||
unsigned char byte;
|
||||
|
||||
enum apfl_parse_result subresult;
|
||||
|
||||
|
|
@ -626,12 +626,12 @@ static enum apfl_parse_result
|
|||
maybe_name_inner(
|
||||
apfl_tokenizer_ptr tokenizer,
|
||||
bool need,
|
||||
char byte,
|
||||
unsigned char byte,
|
||||
struct apfl_string_builder *text
|
||||
) {
|
||||
struct apfl_position pos = tokenizer->position;
|
||||
struct apfl_position last_pos;
|
||||
char last_byte;
|
||||
unsigned char last_byte;
|
||||
|
||||
if (!apfl_string_builder_append_byte(text, byte)) {
|
||||
tokenizer->error = apfl_error_simple(APFL_ERR_MALLOC_FAILED);
|
||||
|
|
@ -726,7 +726,7 @@ maybe_name_inner(
|
|||
}
|
||||
|
||||
static enum apfl_parse_result
|
||||
maybe_name(apfl_tokenizer_ptr tokenizer, bool need, char first_byte)
|
||||
maybe_name(apfl_tokenizer_ptr tokenizer, bool need, unsigned char first_byte)
|
||||
{
|
||||
struct apfl_string_builder text = apfl_string_builder_init(tokenizer->allocator);
|
||||
|
||||
|
|
@ -758,10 +758,10 @@ non_decimal_number(
|
|||
struct apfl_position position,
|
||||
bool negative,
|
||||
int shift,
|
||||
int (*byte_to_digit)(char))
|
||||
int (*byte_to_digit)(unsigned char))
|
||||
{
|
||||
bool no_digits_yet = true;
|
||||
char byte;
|
||||
unsigned char byte;
|
||||
|
||||
uint64_t num = 0;
|
||||
|
||||
|
|
@ -843,7 +843,7 @@ number(
|
|||
apfl_tokenizer_ptr tokenizer,
|
||||
bool need,
|
||||
struct apfl_position position,
|
||||
char first_digit,
|
||||
unsigned char first_digit,
|
||||
bool negative
|
||||
) {
|
||||
double num = (double)undec(first_digit);
|
||||
|
|
@ -852,7 +852,7 @@ number(
|
|||
bool seen_dot = false;
|
||||
|
||||
for (;; first_iteration = false) {
|
||||
char byte;
|
||||
unsigned char byte;
|
||||
|
||||
switch (read_byte(tokenizer, &byte, need)) {
|
||||
case RR_OK:
|
||||
|
|
|
|||
Loading…
Reference in a new issue