diff --git a/builtin_commandline.cpp b/builtin_commandline.cpp index c1bf7de0d..5564d05b7 100644 --- a/builtin_commandline.cpp +++ b/builtin_commandline.cpp @@ -169,7 +169,11 @@ static void write_part(const wchar_t *begin, out.push_back(L'\n'); break; } - + + default: + { + break; + } } } diff --git a/complete.cpp b/complete.cpp index 7b0b41735..6f5da9ec3 100644 --- a/complete.cpp +++ b/complete.cpp @@ -1915,6 +1915,11 @@ void complete(const wcstring &cmd, std::vector &comps, completion_ end_loop=1; break; } + + default: + { + break; + } } if (tok_get_pos(&tok) >= (long)pos) diff --git a/parse_util.cpp b/parse_util.cpp index dca23d3ef..2f95a3e25 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -381,6 +381,11 @@ static void job_or_process_extent(const wchar_t *buff, break; } + + default: + { + break; + } } } diff --git a/parser.cpp b/parser.cpp index 93e068d78..49e5a9661 100644 --- a/parser.cpp +++ b/parser.cpp @@ -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,8 +2012,9 @@ 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()); diff --git a/reader.cpp b/reader.cpp index 4696055f7..228fa9183 100644 --- a/reader.cpp +++ b/reader.cpp @@ -2331,6 +2331,13 @@ static void handle_token_history(int forward, int reset) } } + break; + + default: + { + break; + } + } } } diff --git a/tokenizer.cpp b/tokenizer.cpp index 4521c164d..62094f92c 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -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; } } diff --git a/tokenizer.h b/tokenizer.h index 4357757dc..42516a1b5 100644 --- a/tokenizer.h +++ b/tokenizer.h @@ -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