mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Replaced some usage of wchar_t * with wcstring in complete(). Some style fixes.
This commit is contained in:
parent
be80e1a863
commit
4837a2d0df
5 changed files with 64 additions and 73 deletions
|
@ -1095,8 +1095,8 @@ wchar_t *unescape(const wchar_t * orig, int flags)
|
|||
int bracket_count=0;
|
||||
wchar_t prev=0;
|
||||
wchar_t *in;
|
||||
bool unescape_special = !! (flags & UNESCAPE_SPECIAL);
|
||||
bool allow_incomplete = !! (flags & UNESCAPE_INCOMPLETE);
|
||||
bool unescape_special = !!(flags & UNESCAPE_SPECIAL);
|
||||
bool allow_incomplete = !!(flags & UNESCAPE_INCOMPLETE);
|
||||
|
||||
CHECK(orig, 0);
|
||||
|
||||
|
@ -1106,7 +1106,8 @@ wchar_t *unescape(const wchar_t * orig, int flags)
|
|||
if (!in)
|
||||
DIE_MEM();
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
mode_unquoted,
|
||||
mode_single_quotes,
|
||||
mode_double_quotes
|
||||
|
|
36
complete.cpp
36
complete.cpp
|
@ -1765,7 +1765,7 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, complete_ty
|
|||
completer_t completer(cmd, type);
|
||||
|
||||
const wchar_t *tok_begin, *tok_end, *cmdsubst_begin, *cmdsubst_end, *prev_begin, *prev_end;
|
||||
const wchar_t *current_token=0, *prev_token=0;
|
||||
wcstring current_token, prev_token;
|
||||
wcstring current_command;
|
||||
int on_command=0;
|
||||
size_t pos;
|
||||
|
@ -1789,7 +1789,7 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, complete_ty
|
|||
|
||||
/**
|
||||
If we are completing a variable name or a tilde expansion user
|
||||
name, we do that and return. No need for any other competions.
|
||||
name, we do that and return. No need for any other completions.
|
||||
*/
|
||||
|
||||
if (!done)
|
||||
|
@ -1897,7 +1897,14 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, complete_ty
|
|||
|
||||
current_token = wcsndup(tok_begin, cursor_pos-(tok_begin-cmd_cstr));
|
||||
|
||||
prev_token = prev_begin ? wcsndup(prev_begin, prev_end - prev_begin): wcsdup(L"");
|
||||
if (prev_begin)
|
||||
{
|
||||
prev_token.assign(prev_begin, prev_end - prev_begin);
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_token.clear();
|
||||
}
|
||||
|
||||
// debug( 0, L"on_command: %d, %ls %ls\n", on_command, current_command, current_token );
|
||||
|
||||
|
@ -1908,8 +1915,8 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, complete_ty
|
|||
subcommand.
|
||||
*/
|
||||
|
||||
if ((on_command || (wcscmp(current_token, L"--") == 0)) &&
|
||||
(current_token[0] == L'-') &&
|
||||
if ((on_command || current_token == L"--") &&
|
||||
string_prefixes_string(L"-", current_token) &&
|
||||
!(use_command && use_function && use_builtin))
|
||||
{
|
||||
if (use_command == 0)
|
||||
|
@ -1929,22 +1936,7 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, complete_ty
|
|||
on_command=1;
|
||||
}
|
||||
|
||||
/*
|
||||
We don't want these to be null
|
||||
*/
|
||||
|
||||
if (!current_token)
|
||||
{
|
||||
current_token = wcsdup(L"");
|
||||
}
|
||||
|
||||
if (!prev_token)
|
||||
{
|
||||
prev_token = wcsdup(L"");
|
||||
}
|
||||
|
||||
if (current_token && prev_token)
|
||||
{
|
||||
if (on_command)
|
||||
{
|
||||
/* Complete command filename */
|
||||
|
@ -1981,10 +1973,6 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, complete_ty
|
|||
completer.complete_param_expand(current_token, do_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free((void *)current_token);
|
||||
free((void *)prev_token);
|
||||
|
||||
comps = completer.get_completions();
|
||||
completer.get_commands_to_load(commands_to_load);
|
||||
|
|
|
@ -328,7 +328,8 @@ static void test_tok()
|
|||
say(L"Test correct tokenization");
|
||||
|
||||
tokenizer_t t(str, 0);
|
||||
for (size_t i=0; i < sizeof types / sizeof *types; i++, tok_next(&t)) {
|
||||
for (size_t i=0; i < sizeof types / sizeof *types; i++, tok_next(&t))
|
||||
{
|
||||
if (types[i] != tok_last_type(&t))
|
||||
{
|
||||
err(L"Tokenization error:");
|
||||
|
|
|
@ -1187,7 +1187,7 @@ struct autosuggestion_context_t
|
|||
if (! cursor_at_end && iswspace(last_char))
|
||||
return 0;
|
||||
|
||||
// On the other hand, if the line ends with a quote, don't go dumping stuff after the quote
|
||||
/* On the other hand, if the line ends with a quote, don't go dumping stuff after the quote */
|
||||
if (wcschr(L"'\"", last_char) && cursor_at_end)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -227,7 +227,8 @@ static void read_string(tokenizer_t *tok)
|
|||
start = tok->buff;
|
||||
bool is_first = true;
|
||||
|
||||
enum tok_mode_t {
|
||||
enum tok_mode_t
|
||||
{
|
||||
mode_regular_text = 0, // regular text
|
||||
mode_subshell = 1, // inside of subshell
|
||||
mode_array_brackets = 2, // inside of array brackets
|
||||
|
|
Loading…
Reference in a new issue