mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
Rename error_offset to error_offset_within_token
Hopefully clarify the role of this variable.
This commit is contained in:
parent
ef8b5e4fa0
commit
896ef65f8c
4 changed files with 9 additions and 8 deletions
|
@ -634,7 +634,7 @@ static void test_tokenizer() {
|
|||
do_test(token.has_value());
|
||||
do_test(token->type == token_type_t::error);
|
||||
do_test(token->error == tokenizer_error_t::unterminated_escape);
|
||||
do_test(token->error_offset == 3);
|
||||
do_test(token->error_offset_within_token == 3);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -646,7 +646,7 @@ static void test_tokenizer() {
|
|||
do_test(token->type == token_type_t::error);
|
||||
do_test(token->error == tokenizer_error_t::closing_unopened_subshell);
|
||||
do_test(token->offset == 4);
|
||||
do_test(token->error_offset == 0);
|
||||
do_test(token->error_offset_within_token == 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -657,7 +657,7 @@ static void test_tokenizer() {
|
|||
do_test(token.has_value());
|
||||
do_test(token->type == token_type_t::error);
|
||||
do_test(token->error == tokenizer_error_t::unterminated_subshell);
|
||||
do_test(token->error_offset == 4);
|
||||
do_test(token->error_offset_within_token == 4);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -668,7 +668,7 @@ static void test_tokenizer() {
|
|||
do_test(token.has_value());
|
||||
do_test(token->type == token_type_t::error);
|
||||
do_test(token->error == tokenizer_error_t::unterminated_slice);
|
||||
do_test(token->error_offset == 4);
|
||||
do_test(token->error_offset_within_token == 4);
|
||||
}
|
||||
|
||||
// Test some redirection parsing.
|
||||
|
|
|
@ -694,8 +694,9 @@ void parse_ll_t::parse_error_failed_production(struct parse_stack_element_t &sta
|
|||
|
||||
void parse_ll_t::report_tokenizer_error(const tok_t &tok) {
|
||||
parse_error_code_t parse_error_code = parse_error_from_tokenizer_error(tok.error);
|
||||
this->parse_error_at_location(tok.offset, tok.length, tok.offset + tok.error_offset,
|
||||
parse_error_code, L"%ls", tokenizer_get_error_message(tok.error));
|
||||
this->parse_error_at_location(tok.offset, tok.length,
|
||||
tok.offset + tok.error_offset_within_token, parse_error_code,
|
||||
L"%ls", tokenizer_get_error_message(tok.error));
|
||||
}
|
||||
|
||||
void parse_ll_t::parse_error_unexpected_token(const wchar_t *expected, parse_token_t token) {
|
||||
|
|
|
@ -79,7 +79,7 @@ tok_t tokenizer_t::call_error(tokenizer_error_t error_type, const wchar_t *token
|
|||
result.offset = token_start - this->start;
|
||||
// If we are passed a token_length, then use it; otherwise infer it from the buffer.
|
||||
result.length = token_length ? *token_length : this->token_cursor - token_start;
|
||||
result.error_offset = error_loc - token_start;
|
||||
result.error_offset_within_token = error_loc - token_start;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ struct tok_t {
|
|||
|
||||
// If an error, this is the offset of the error within the token. A value of 0 means it occurred
|
||||
// at 'offset'.
|
||||
size_t error_offset{size_t(-1)};
|
||||
size_t error_offset_within_token{size_t(-1)};
|
||||
|
||||
// Construct from a token type.
|
||||
explicit tok_t(token_type_t type);
|
||||
|
|
Loading…
Reference in a new issue