mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Make tok_last_type return an enum token_type instead of int
This commit is contained in:
parent
6c70ed79ae
commit
cbe615224d
7 changed files with 35 additions and 14 deletions
|
@ -170,6 +170,10 @@ static void write_part(const wchar_t *begin,
|
|||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1915,6 +1915,11 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, completion_
|
|||
end_loop=1;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tok_get_pos(&tok) >= (long)pos)
|
||||
|
|
|
@ -381,6 +381,11 @@ static void job_or_process_extent(const wchar_t *buff,
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ The fish parser. Contains functions for parsing and evaluating code.
|
|||
/**
|
||||
Error message for Posix-style assignment
|
||||
*/
|
||||
#define COMMAND_ASSIGN_ERR_MSG _( L"Unknown command '%ls'. Did you mean 'set %ls %ls'? For information on assigning values to variables, see the help section on the set command by typing 'help set'.")
|
||||
#define COMMAND_ASSIGN_ERR_MSG _( L"Unknown command '%ls'. Did you mean 'set %ls %ls'? See the help section on the set command by typing 'help set'.")
|
||||
|
||||
/**
|
||||
Error for invalid redirection token
|
||||
|
@ -2012,9 +2012,10 @@ int parser_t::parse_job(process_t *p,
|
|||
if (! has_command && ! use_implicit_cd)
|
||||
{
|
||||
|
||||
int tmp;
|
||||
const wchar_t *cmd = args.at(0).completion.c_str();
|
||||
|
||||
fprintf(stderr, "arg count: %lu\n", args.size());
|
||||
|
||||
/*
|
||||
We couldn't find the specified command.
|
||||
|
||||
|
@ -2095,7 +2096,7 @@ int parser_t::parse_job(process_t *p,
|
|||
event_fire_generic(L"fish_command_not_found", &event_args);
|
||||
}
|
||||
|
||||
tmp = current_tokenizer_pos;
|
||||
int tmp = current_tokenizer_pos;
|
||||
current_tokenizer_pos = tok_get_pos(tok);
|
||||
|
||||
fwprintf(stderr, L"%ls", parser_t::current_line());
|
||||
|
|
|
@ -2331,6 +2331,13 @@ static void handle_token_history(int forward, int reset)
|
|||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ int tok_get_error(tokenizer_t *tok)
|
|||
}
|
||||
|
||||
|
||||
tokenizer_t::tokenizer_t(const wchar_t *b, tok_flags_t flags) : buff(NULL), orig_buff(NULL), last_type(0), last_pos(0), has_next(false), accept_unfinished(false), show_comments(false), last_quote(0), error(0), squash_errors(false), cached_lineno_offset(0), cached_lineno_count(0)
|
||||
tokenizer_t::tokenizer_t(const wchar_t *b, tok_flags_t flags) : buff(NULL), orig_buff(NULL), last_type(TOK_NONE), last_pos(0), has_next(false), accept_unfinished(false), show_comments(false), last_quote(0), error(0), squash_errors(false), cached_lineno_offset(0), cached_lineno_count(0)
|
||||
{
|
||||
|
||||
/* We can only generate error messages on the main thread due to wgettext() thread safety issues. */
|
||||
|
@ -116,7 +116,7 @@ tokenizer_t::tokenizer_t(const wchar_t *b, tok_flags_t flags) : buff(NULL), orig
|
|||
tok_next(this);
|
||||
}
|
||||
|
||||
int tok_last_type(tokenizer_t *tok)
|
||||
enum token_type tok_last_type(tokenizer_t *tok)
|
||||
{
|
||||
CHECK(tok, TOK_ERROR);
|
||||
CHECK(tok->buff, TOK_ERROR);
|
||||
|
@ -440,7 +440,7 @@ static void read_comment(tokenizer_t *tok)
|
|||
*/
|
||||
static void read_redirect(tokenizer_t *tok, int fd)
|
||||
{
|
||||
int mode = -1;
|
||||
enum token_type redirection_mode = TOK_NONE;
|
||||
|
||||
if ((*tok->buff == L'>') ||
|
||||
(*tok->buff == L'^'))
|
||||
|
@ -449,11 +449,11 @@ static void read_redirect(tokenizer_t *tok, int fd)
|
|||
if (*tok->buff == *(tok->buff-1))
|
||||
{
|
||||
tok->buff++;
|
||||
mode = 1;
|
||||
redirection_mode = TOK_REDIRECT_APPEND;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = 0;
|
||||
redirection_mode = TOK_REDIRECT_OUT;
|
||||
}
|
||||
|
||||
if (*tok->buff == L'|')
|
||||
|
@ -472,7 +472,7 @@ static void read_redirect(tokenizer_t *tok, int fd)
|
|||
else if (*tok->buff == L'<')
|
||||
{
|
||||
tok->buff++;
|
||||
mode = 2;
|
||||
redirection_mode = TOK_REDIRECT_IN;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -493,7 +493,7 @@ static void read_redirect(tokenizer_t *tok, int fd)
|
|||
}
|
||||
else
|
||||
{
|
||||
tok->last_type = TOK_REDIRECT_OUT + mode;
|
||||
tok->last_type = redirection_mode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ struct tokenizer_t
|
|||
wcstring last_token;
|
||||
|
||||
/** Type of last token*/
|
||||
int last_type;
|
||||
enum token_type last_type;
|
||||
|
||||
/** Offset of last token*/
|
||||
size_t last_pos;
|
||||
|
@ -123,7 +123,7 @@ void tok_next(tokenizer_t *tok);
|
|||
/**
|
||||
Returns the type of the last token. Must be one of the values in the token_type enum.
|
||||
*/
|
||||
int tok_last_type(tokenizer_t *tok);
|
||||
enum token_type tok_last_type(tokenizer_t *tok);
|
||||
|
||||
/**
|
||||
Returns the last token string. The string should not be freed by the caller.
|
||||
|
@ -150,7 +150,6 @@ int tok_get_pos(tokenizer_t *tok);
|
|||
*/
|
||||
const wchar_t *tok_string(tokenizer_t *tok);
|
||||
|
||||
|
||||
/**
|
||||
Returns only the first token from the specified string. This is a
|
||||
convenience function, used to retrieve the first token of a
|
||||
|
|
Loading…
Reference in a new issue