mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Fix formatting
This commit is contained in:
parent
03c65d7a96
commit
cf766b55cc
20 changed files with 94 additions and 88 deletions
10
builtin.cpp
10
builtin.cpp
|
@ -1617,24 +1617,24 @@ static int builtin_echo(parser_t &parser, wchar_t **argv)
|
||||||
{
|
{
|
||||||
case L'n':
|
case L'n':
|
||||||
print_newline = false;
|
print_newline = false;
|
||||||
break;
|
break;
|
||||||
case L'e':
|
case L'e':
|
||||||
interpret_special_chars = true;
|
interpret_special_chars = true;
|
||||||
break;
|
break;
|
||||||
case L's':
|
case L's':
|
||||||
// fish-specific extension,
|
// fish-specific extension,
|
||||||
// which we should try to nix
|
// which we should try to nix
|
||||||
print_spaces = false;
|
print_spaces = false;
|
||||||
break;
|
break;
|
||||||
case L'E':
|
case L'E':
|
||||||
interpret_special_chars = false;
|
interpret_special_chars = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
invalid_echo_option:
|
invalid_echo_option:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
argv++;
|
argv++;
|
||||||
|
|
|
@ -169,7 +169,7 @@ static void write_part(const wchar_t *begin,
|
||||||
out.push_back(L'\n');
|
out.push_back(L'\n');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -632,7 +632,7 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
modify_allowed_format_specifiers(ok, "aAcdeEfFgGiosuxX", true);
|
modify_allowed_format_specifiers(ok, "aAcdeEfFgGiosuxX", true);
|
||||||
|
|
||||||
for (;; f++, direc_length++)
|
for (;; f++, direc_length++)
|
||||||
|
|
|
@ -1627,7 +1627,7 @@ void completer_t::complete_param_expand(const wcstring &sstr, bool do_file)
|
||||||
|
|
||||||
if (expand_string(comp_str,
|
if (expand_string(comp_str,
|
||||||
this->completions,
|
this->completions,
|
||||||
flags ) == EXPAND_ERROR)
|
flags) == EXPAND_ERROR)
|
||||||
{
|
{
|
||||||
debug(3, L"Error while expanding string '%ls'", comp_str);
|
debug(3, L"Error while expanding string '%ls'", comp_str);
|
||||||
}
|
}
|
||||||
|
@ -1911,7 +1911,7 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, completion_
|
||||||
end_loop=1;
|
end_loop=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -127,7 +127,7 @@ public:
|
||||||
completion_t(const wcstring &comp, const wcstring &desc = L"", string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), int flags_val = 0);
|
completion_t(const wcstring &comp, const wcstring &desc = L"", string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), int flags_val = 0);
|
||||||
completion_t(const completion_t &);
|
completion_t(const completion_t &);
|
||||||
completion_t &operator=(const completion_t &);
|
completion_t &operator=(const completion_t &);
|
||||||
|
|
||||||
/* Compare two completions. No operating overlaoding to make this always explicit (there's potentially multiple ways to compare completions). */
|
/* Compare two completions. No operating overlaoding to make this always explicit (there's potentially multiple ways to compare completions). */
|
||||||
static bool is_alphabetically_less_than(const completion_t &a, const completion_t &b);
|
static bool is_alphabetically_less_than(const completion_t &a, const completion_t &b);
|
||||||
static bool is_alphabetically_equal_to(const completion_t &a, const completion_t &b);
|
static bool is_alphabetically_equal_to(const completion_t &a, const completion_t &b);
|
||||||
|
|
22
exec.cpp
22
exec.cpp
|
@ -551,7 +551,7 @@ static bool can_use_posix_spawn_for_job(const job_t *job, const process_t *proce
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now see if we have a redirection involving a file. The only one we allow is /dev/null, which we assume will not fail. */
|
/* Now see if we have a redirection involving a file. The only one we allow is /dev/null, which we assume will not fail. */
|
||||||
bool result = true;
|
bool result = true;
|
||||||
if (chain_contains_redirection_to_real_file(job->block_io_chain()) || chain_contains_redirection_to_real_file(process->io_chain()))
|
if (chain_contains_redirection_to_real_file(job->block_io_chain()) || chain_contains_redirection_to_real_file(process->io_chain()))
|
||||||
|
@ -790,11 +790,11 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
echo alpha | cat < beta.txt
|
echo alpha | cat < beta.txt
|
||||||
|
|
||||||
Should cat output alpha or beta? bash and ksh output 'beta', tcsh gets it right and complains about ambiguity, and zsh outputs both (!). No shells appear to output 'alpha', so we match bash here. That would mean putting the pipe first, so that it gets trumped by the file redirection.
|
Should cat output alpha or beta? bash and ksh output 'beta', tcsh gets it right and complains about ambiguity, and zsh outputs both (!). No shells appear to output 'alpha', so we match bash here. That would mean putting the pipe first, so that it gets trumped by the file redirection.
|
||||||
|
|
||||||
However, eval does this:
|
However, eval does this:
|
||||||
|
|
||||||
echo "begin; $argv "\n" ;end eval2_inner <&3 3<&-" | source 3<&0
|
echo "begin; $argv "\n" ;end eval2_inner <&3 3<&-" | source 3<&0
|
||||||
|
|
||||||
which depends on the redirection being evaluated before the pipe. So the write end of the pipe comes first, the read pipe of the pipe comes last. See issue #966.
|
which depends on the redirection being evaluated before the pipe. So the write end of the pipe comes first, the read pipe of the pipe comes last. See issue #966.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -811,7 +811,7 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
|
|
||||||
/* The explicit IO redirections associated with the process */
|
/* The explicit IO redirections associated with the process */
|
||||||
process_net_io_chain.append(p->io_chain());
|
process_net_io_chain.append(p->io_chain());
|
||||||
|
|
||||||
/* Read pipe goes last */
|
/* Read pipe goes last */
|
||||||
if (p != j->first_process)
|
if (p != j->first_process)
|
||||||
{
|
{
|
||||||
|
@ -820,7 +820,7 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
pipe_read->pipe_fd[0] = pipe_current_read;
|
pipe_read->pipe_fd[0] = pipe_current_read;
|
||||||
process_net_io_chain.push_back(pipe_read);
|
process_net_io_chain.push_back(pipe_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This call is used so the global environment variable array
|
This call is used so the global environment variable array
|
||||||
|
@ -1241,16 +1241,16 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
forking is expensive, fish tries to avoid it when
|
forking is expensive, fish tries to avoid it when
|
||||||
possible.
|
possible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool fork_was_skipped = false;
|
bool fork_was_skipped = false;
|
||||||
|
|
||||||
const shared_ptr<io_data_t> stdout_io = process_net_io_chain.get_io_for_fd(STDOUT_FILENO);
|
const shared_ptr<io_data_t> stdout_io = process_net_io_chain.get_io_for_fd(STDOUT_FILENO);
|
||||||
const shared_ptr<io_data_t> stderr_io = process_net_io_chain.get_io_for_fd(STDERR_FILENO);
|
const shared_ptr<io_data_t> stderr_io = process_net_io_chain.get_io_for_fd(STDERR_FILENO);
|
||||||
|
|
||||||
/* If we are outputting to a file, we have to actually do it, even if we have no output, so that we can truncate the file. Does not apply to /dev/null. */
|
/* If we are outputting to a file, we have to actually do it, even if we have no output, so that we can truncate the file. Does not apply to /dev/null. */
|
||||||
bool must_fork = redirection_is_to_real_file(stdout_io.get()) || redirection_is_to_real_file(stderr_io.get());
|
bool must_fork = redirection_is_to_real_file(stdout_io.get()) || redirection_is_to_real_file(stderr_io.get());
|
||||||
if (! must_fork)
|
if (! must_fork)
|
||||||
{
|
{
|
||||||
if (p->next == NULL)
|
if (p->next == NULL)
|
||||||
{
|
{
|
||||||
const bool stdout_is_to_buffer = stdout_io && stdout_io->io_mode == IO_BUFFER;
|
const bool stdout_is_to_buffer = stdout_io && stdout_io->io_mode == IO_BUFFER;
|
||||||
|
@ -1299,7 +1299,7 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fork_was_skipped)
|
if (fork_was_skipped)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1752,15 +1752,15 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
|
||||||
|
|
||||||
remove_internal_separator(next_str, (EXPAND_SKIP_WILDCARDS & flags) ? true : false);
|
remove_internal_separator(next_str, (EXPAND_SKIP_WILDCARDS & flags) ? true : false);
|
||||||
const wchar_t *next = next_str.c_str();
|
const wchar_t *next = next_str.c_str();
|
||||||
|
|
||||||
const bool has_wildcard = wildcard_has(next, 1);
|
const bool has_wildcard = wildcard_has(next, 1);
|
||||||
|
|
||||||
if (has_wildcard && (flags & EXECUTABLES_ONLY))
|
if (has_wildcard && (flags & EXECUTABLES_ONLY))
|
||||||
{
|
{
|
||||||
// Don't do wildcard expansion for executables. See #785. So do nothing here.
|
// Don't do wildcard expansion for executables. See #785. So do nothing here.
|
||||||
}
|
}
|
||||||
else if (((flags & ACCEPT_INCOMPLETE) && (!(flags & EXPAND_SKIP_WILDCARDS))) ||
|
else if (((flags & ACCEPT_INCOMPLETE) && (!(flags & EXPAND_SKIP_WILDCARDS))) ||
|
||||||
has_wildcard)
|
has_wildcard)
|
||||||
{
|
{
|
||||||
const wchar_t *start, *rest;
|
const wchar_t *start, *rest;
|
||||||
|
|
||||||
|
|
|
@ -1506,7 +1506,7 @@ static int mk_wcswidth(const wchar_t *pwcs, size_t n)
|
||||||
{
|
{
|
||||||
if (pwcs[i] == L'\0')
|
if (pwcs[i] == L'\0')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int w = mk_wcwidth(pwcs[i]);
|
int w = mk_wcwidth(pwcs[i]);
|
||||||
if (w < 0)
|
if (w < 0)
|
||||||
{
|
{
|
||||||
|
|
11
fish.cpp
11
fish.cpp
|
@ -366,9 +366,12 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *out_c
|
||||||
is_login |= (strcmp(argv[0], "-fish") == 0);
|
is_login |= (strcmp(argv[0], "-fish") == 0);
|
||||||
|
|
||||||
/* We are an interactive session if we are either forced, or have not been given an explicit command to execute and stdin is a tty. */
|
/* We are an interactive session if we are either forced, or have not been given an explicit command to execute and stdin is a tty. */
|
||||||
if (force_interactive) {
|
if (force_interactive)
|
||||||
|
{
|
||||||
is_interactive_session = true;
|
is_interactive_session = true;
|
||||||
} else if (is_interactive_session) {
|
}
|
||||||
|
else if (is_interactive_session)
|
||||||
|
{
|
||||||
is_interactive_session = ! has_cmd && (my_optind == argc) && isatty(STDIN_FILENO);
|
is_interactive_session = ! has_cmd && (my_optind == argc) && isatty(STDIN_FILENO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +405,7 @@ int main(int argc, char **argv)
|
||||||
debug(1, _(L"Can not use the no-execute mode when running an interactive session"));
|
debug(1, _(L"Can not use the no-execute mode when running an interactive session"));
|
||||||
no_exec = 0;
|
no_exec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */
|
/* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */
|
||||||
if (is_interactive_session)
|
if (is_interactive_session)
|
||||||
{
|
{
|
||||||
|
@ -509,7 +512,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res);
|
proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res);
|
||||||
|
|
||||||
restore_term_mode();
|
restore_term_mode();
|
||||||
restore_term_foreground_process_group();
|
restore_term_foreground_process_group();
|
||||||
history_destroy();
|
history_destroy();
|
||||||
|
|
|
@ -532,7 +532,7 @@ static void test_utils()
|
||||||
{
|
{
|
||||||
say(L"Testing utils");
|
say(L"Testing utils");
|
||||||
const wchar_t *a = L"echo (echo (echo hi";
|
const wchar_t *a = L"echo (echo (echo hi";
|
||||||
|
|
||||||
const wchar_t *begin = NULL, *end = NULL;
|
const wchar_t *begin = NULL, *end = NULL;
|
||||||
parse_util_cmdsubst_extent(a, 0, &begin, &end);
|
parse_util_cmdsubst_extent(a, 0, &begin, &end);
|
||||||
if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
|
if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
|
||||||
|
@ -542,7 +542,7 @@ static void test_utils()
|
||||||
if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
|
if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
|
||||||
parse_util_cmdsubst_extent(a, 3, &begin, &end);
|
parse_util_cmdsubst_extent(a, 3, &begin, &end);
|
||||||
if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
|
if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
|
||||||
|
|
||||||
parse_util_cmdsubst_extent(a, 8, &begin, &end);
|
parse_util_cmdsubst_extent(a, 8, &begin, &end);
|
||||||
if (begin != a + wcslen(L"echo (")) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
|
if (begin != a + wcslen(L"echo (")) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ static void test_path()
|
||||||
{
|
{
|
||||||
err(L"Bug in canonical PATH code");
|
err(L"Bug in canonical PATH code");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paths_are_equivalent(L"/foo/bar/baz", L"foo/bar/baz")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);
|
if (paths_are_equivalent(L"/foo/bar/baz", L"foo/bar/baz")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);
|
||||||
if (! paths_are_equivalent(L"///foo///bar/baz", L"/foo/bar////baz//")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);
|
if (! paths_are_equivalent(L"///foo///bar/baz", L"/foo/bar////baz//")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);
|
||||||
if (! paths_are_equivalent(L"/foo/bar/baz", L"/foo/bar/baz")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);
|
if (! paths_are_equivalent(L"/foo/bar/baz", L"/foo/bar/baz")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);
|
||||||
|
|
|
@ -629,7 +629,7 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
|
||||||
scoped_lock locker(lock);
|
scoped_lock locker(lock);
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
std::set<wcstring> seen;
|
std::set<wcstring> seen;
|
||||||
|
|
||||||
/* Append new items. Note that in principle we could use const_reverse_iterator, but we do not because reverse_iterator is not convertible to const_reverse_iterator ( http://github.com/fish-shell/fish-shell/issues/431 ) */
|
/* Append new items. Note that in principle we could use const_reverse_iterator, but we do not because reverse_iterator is not convertible to const_reverse_iterator ( http://github.com/fish-shell/fish-shell/issues/431 ) */
|
||||||
|
@ -638,7 +638,7 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
|
||||||
/* Skip duplicates */
|
/* Skip duplicates */
|
||||||
if (! seen.insert(iter->str()).second)
|
if (! seen.insert(iter->str()).second)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (! first)
|
if (! first)
|
||||||
result.append(separator);
|
result.append(separator);
|
||||||
result.append(iter->str());
|
result.append(iter->str());
|
||||||
|
@ -651,11 +651,11 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
|
||||||
{
|
{
|
||||||
size_t offset = *iter;
|
size_t offset = *iter;
|
||||||
const history_item_t item = history_t::decode_item(mmap_start + offset, mmap_length - offset, mmap_type);
|
const history_item_t item = history_t::decode_item(mmap_start + offset, mmap_length - offset, mmap_type);
|
||||||
|
|
||||||
/* Skip duplicates */
|
/* Skip duplicates */
|
||||||
if (! seen.insert(item.str()).second)
|
if (! seen.insert(item.str()).second)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (! first)
|
if (! first)
|
||||||
result.append(separator);
|
result.append(separator);
|
||||||
result.append(item.str());
|
result.append(item.str());
|
||||||
|
|
|
@ -245,10 +245,10 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
|
||||||
const wchar_t * const cursor = buff + cursor_pos;
|
const wchar_t * const cursor = buff + cursor_pos;
|
||||||
|
|
||||||
CHECK(buff,);
|
CHECK(buff,);
|
||||||
|
|
||||||
const size_t bufflen = wcslen(buff);
|
const size_t bufflen = wcslen(buff);
|
||||||
assert(cursor_pos <= bufflen);
|
assert(cursor_pos <= bufflen);
|
||||||
|
|
||||||
/* ap and bp are the beginning and end of the tightest command substitition found so far */
|
/* ap and bp are the beginning and end of the tightest command substitition found so far */
|
||||||
const wchar_t *ap = buff, *bp = buff + bufflen;
|
const wchar_t *ap = buff, *bp = buff + bufflen;
|
||||||
const wchar_t *pos = buff;
|
const wchar_t *pos = buff;
|
||||||
|
@ -265,7 +265,7 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
|
||||||
{
|
{
|
||||||
end = const_cast<wchar_t *>(buff) + bufflen;
|
end = const_cast<wchar_t *>(buff) + bufflen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (begin < cursor && end >= cursor)
|
if (begin < cursor && end >= cursor)
|
||||||
{
|
{
|
||||||
/* This command substitution surrounds the cursor, so it's a tighter fit */
|
/* This command substitution surrounds the cursor, so it's a tighter fit */
|
||||||
|
@ -290,7 +290,7 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
|
||||||
assert(pos <= buff + bufflen);
|
assert(pos <= buff + bufflen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a != NULL) *a = ap;
|
if (a != NULL) *a = ap;
|
||||||
if (b != NULL) *b = bp;
|
if (b != NULL) *b = bp;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ static void job_or_process_extent(const wchar_t *buff,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
10
parser.cpp
10
parser.cpp
|
@ -2013,7 +2013,7 @@ int parser_t::parse_job(process_t *p,
|
||||||
{
|
{
|
||||||
|
|
||||||
const wchar_t *cmd = args.at(0).completion.c_str();
|
const wchar_t *cmd = args.at(0).completion.c_str();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We couldn't find the specified command.
|
We couldn't find the specified command.
|
||||||
|
|
||||||
|
@ -2036,20 +2036,20 @@ int parser_t::parse_job(process_t *p,
|
||||||
if (equals_ptr != NULL)
|
if (equals_ptr != NULL)
|
||||||
{
|
{
|
||||||
/* Try to figure out if this is a pure variable assignment (foo=bar), or if this appears to be running a command (foo=bar ruby...) */
|
/* Try to figure out if this is a pure variable assignment (foo=bar), or if this appears to be running a command (foo=bar ruby...) */
|
||||||
|
|
||||||
const wcstring name_str = wcstring(cmd, equals_ptr - cmd); //variable name, up to the =
|
const wcstring name_str = wcstring(cmd, equals_ptr - cmd); //variable name, up to the =
|
||||||
const wcstring val_str = wcstring(equals_ptr + 1); //variable value, past the =
|
const wcstring val_str = wcstring(equals_ptr + 1); //variable value, past the =
|
||||||
|
|
||||||
wcstring next_str;
|
wcstring next_str;
|
||||||
if (tok_peek_next(tok, &next_str) == TOK_STRING && ! next_str.empty())
|
if (tok_peek_next(tok, &next_str) == TOK_STRING && ! next_str.empty())
|
||||||
{
|
{
|
||||||
wcstring ellipsis_str = wcstring(1, ellipsis_char);
|
wcstring ellipsis_str = wcstring(1, ellipsis_char);
|
||||||
if (ellipsis_str == L"$")
|
if (ellipsis_str == L"$")
|
||||||
ellipsis_str = L"...";
|
ellipsis_str = L"...";
|
||||||
|
|
||||||
/* Looks like a command */
|
/* Looks like a command */
|
||||||
debug(0,
|
debug(0,
|
||||||
_( L"Unknown command '%ls'. Did you mean to run %ls with a modified environment? Try 'env %ls=%ls %ls%ls'. See the help section on the set command by typing 'help set'."),
|
_(L"Unknown command '%ls'. Did you mean to run %ls with a modified environment? Try 'env %ls=%ls %ls%ls'. See the help section on the set command by typing 'help set'."),
|
||||||
cmd,
|
cmd,
|
||||||
next_str.c_str(),
|
next_str.c_str(),
|
||||||
name_str.c_str(),
|
name_str.c_str(),
|
||||||
|
|
16
path.cpp
16
path.cpp
|
@ -400,7 +400,7 @@ void path_make_canonical(wcstring &path)
|
||||||
path.at(trailing++) = c;
|
path.at(trailing++) = c;
|
||||||
}
|
}
|
||||||
prev_was_slash = is_slash;
|
prev_was_slash = is_slash;
|
||||||
}
|
}
|
||||||
assert(trailing <= len);
|
assert(trailing <= len);
|
||||||
if (trailing < len)
|
if (trailing < len)
|
||||||
path.resize(trailing);
|
path.resize(trailing);
|
||||||
|
@ -410,32 +410,32 @@ bool paths_are_equivalent(const wcstring &p1, const wcstring &p2)
|
||||||
{
|
{
|
||||||
if (p1 == p2)
|
if (p1 == p2)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
size_t len1 = p1.size(), len2 = p2.size();
|
size_t len1 = p1.size(), len2 = p2.size();
|
||||||
|
|
||||||
// Ignore trailing slashes after the first character
|
// Ignore trailing slashes after the first character
|
||||||
while (len1 > 1 && p1.at(len1 - 1) == L'/') len1--;
|
while (len1 > 1 && p1.at(len1 - 1) == L'/') len1--;
|
||||||
while (len2 > 1 && p2.at(len2 - 1) == L'/') len2--;
|
while (len2 > 1 && p2.at(len2 - 1) == L'/') len2--;
|
||||||
|
|
||||||
// Start walking
|
// Start walking
|
||||||
size_t idx1 = 0, idx2 = 0;
|
size_t idx1 = 0, idx2 = 0;
|
||||||
while (idx1 < len1 && idx2 < len2)
|
while (idx1 < len1 && idx2 < len2)
|
||||||
{
|
{
|
||||||
wchar_t c1 = p1.at(idx1), c2 = p2.at(idx2);
|
wchar_t c1 = p1.at(idx1), c2 = p2.at(idx2);
|
||||||
|
|
||||||
// If the characters are different, the strings are not equivalent
|
// If the characters are different, the strings are not equivalent
|
||||||
if (c1 != c2)
|
if (c1 != c2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
idx1++;
|
idx1++;
|
||||||
idx2++;
|
idx2++;
|
||||||
|
|
||||||
// If the character was a slash, walk forwards until we hit the end of the string, or a non-slash
|
// If the character was a slash, walk forwards until we hit the end of the string, or a non-slash
|
||||||
// Note the first condition is invariant within the loop
|
// Note the first condition is invariant within the loop
|
||||||
while (c1 == L'/' && idx1 < len1 && p1.at(idx1) == L'/') idx1++;
|
while (c1 == L'/' && idx1 < len1 && p1.at(idx1) == L'/') idx1++;
|
||||||
while (c2 == L'/' && idx2 < len2 && p2.at(idx2) == L'/') idx2++;
|
while (c2 == L'/' && idx2 < len2 && p2.at(idx2) == L'/') idx2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We matched if we consumed all of the characters in both strings
|
// We matched if we consumed all of the characters in both strings
|
||||||
return idx1 == len1 && idx2 == len2;
|
return idx1 == len1 && idx2 == len2;
|
||||||
}
|
}
|
||||||
|
|
5
proc.h
5
proc.h
|
@ -373,7 +373,10 @@ public:
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
|
||||||
/* Returns the block IO redirections associated with the job. These are things like the IO redirections associated with the begin...end statement. */
|
/* Returns the block IO redirections associated with the job. These are things like the IO redirections associated with the begin...end statement. */
|
||||||
const io_chain_t &block_io_chain() const { return this->block_io; }
|
const io_chain_t &block_io_chain() const
|
||||||
|
{
|
||||||
|
return this->block_io;
|
||||||
|
}
|
||||||
|
|
||||||
/* Fetch all the IO redirections associated with the job */
|
/* Fetch all the IO redirections associated with the job */
|
||||||
io_chain_t all_io_redirections() const;
|
io_chain_t all_io_redirections() const;
|
||||||
|
|
20
reader.cpp
20
reader.cpp
|
@ -984,9 +984,9 @@ void reader_init()
|
||||||
// PCA disable VDSUSP (typically control-Y), which is a funny job control
|
// PCA disable VDSUSP (typically control-Y), which is a funny job control
|
||||||
// function available only on OS X and BSD systems
|
// function available only on OS X and BSD systems
|
||||||
// This lets us use control-Y for yank instead
|
// This lets us use control-Y for yank instead
|
||||||
#ifdef VDSUSP
|
#ifdef VDSUSP
|
||||||
shell_modes.c_cc[VDSUSP] = _POSIX_VDISABLE;
|
shell_modes.c_cc[VDSUSP] = _POSIX_VDISABLE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1723,7 +1723,7 @@ static const completion_t *cycle_competions(const std::vector<completion_t> &com
|
||||||
// note start_idx will be set to -1 initially, so that when it gets incremented we start at 0
|
// note start_idx will be set to -1 initially, so that when it gets incremented we start at 0
|
||||||
const size_t start_idx = *inout_idx;
|
const size_t start_idx = *inout_idx;
|
||||||
size_t idx = start_idx;
|
size_t idx = start_idx;
|
||||||
|
|
||||||
const completion_t *result = NULL;
|
const completion_t *result = NULL;
|
||||||
size_t remaining = comp.size();
|
size_t remaining = comp.size();
|
||||||
while (remaining--)
|
while (remaining--)
|
||||||
|
@ -2340,7 +2340,7 @@ static void handle_token_history(int forward, int reset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -3814,34 +3814,34 @@ const wchar_t *reader_readline(void)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case R_UPCASE_WORD:
|
case R_UPCASE_WORD:
|
||||||
case R_DOWNCASE_WORD:
|
case R_DOWNCASE_WORD:
|
||||||
case R_CAPITALIZE_WORD:
|
case R_CAPITALIZE_WORD:
|
||||||
{
|
{
|
||||||
// For capitalize_word, whether we've capitalized a character so far
|
// For capitalize_word, whether we've capitalized a character so far
|
||||||
bool capitalized_first = false;
|
bool capitalized_first = false;
|
||||||
|
|
||||||
// We apply the operation from the current location to the end of the word
|
// We apply the operation from the current location to the end of the word
|
||||||
size_t pos = data->buff_pos;
|
size_t pos = data->buff_pos;
|
||||||
move_word(MOVE_DIR_RIGHT, false, move_word_style_punctuation, false);
|
move_word(MOVE_DIR_RIGHT, false, move_word_style_punctuation, false);
|
||||||
for (; pos < data->buff_pos; pos++)
|
for (; pos < data->buff_pos; pos++)
|
||||||
{
|
{
|
||||||
wchar_t chr = data->command_line.at(pos);
|
wchar_t chr = data->command_line.at(pos);
|
||||||
|
|
||||||
// We always change the case; this decides whether we go uppercase (true) or lowercase (false)
|
// We always change the case; this decides whether we go uppercase (true) or lowercase (false)
|
||||||
bool make_uppercase;
|
bool make_uppercase;
|
||||||
if (c == R_CAPITALIZE_WORD)
|
if (c == R_CAPITALIZE_WORD)
|
||||||
make_uppercase = ! capitalized_first && iswalnum(chr);
|
make_uppercase = ! capitalized_first && iswalnum(chr);
|
||||||
else
|
else
|
||||||
make_uppercase = (c == R_UPCASE_WORD);
|
make_uppercase = (c == R_UPCASE_WORD);
|
||||||
|
|
||||||
// Apply the operation and then record what we did
|
// Apply the operation and then record what we did
|
||||||
if (make_uppercase)
|
if (make_uppercase)
|
||||||
chr = towupper(chr);
|
chr = towupper(chr);
|
||||||
else
|
else
|
||||||
chr = towlower(chr);
|
chr = towlower(chr);
|
||||||
|
|
||||||
data->command_line.at(pos) = chr;
|
data->command_line.at(pos) = chr;
|
||||||
capitalized_first = capitalized_first || make_uppercase;
|
capitalized_first = capitalized_first || make_uppercase;
|
||||||
}
|
}
|
||||||
|
@ -3850,7 +3850,7 @@ const wchar_t *reader_readline(void)
|
||||||
reader_repaint();
|
reader_repaint();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Other, if a normal character, we add it to the command */
|
/* Other, if a normal character, we add it to the command */
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
34
screen.cpp
34
screen.cpp
|
@ -137,14 +137,14 @@ static bool allow_soft_wrap(void)
|
||||||
size_t escape_code_length(const wchar_t *code)
|
size_t escape_code_length(const wchar_t *code)
|
||||||
{
|
{
|
||||||
assert(code != NULL);
|
assert(code != NULL);
|
||||||
|
|
||||||
/* The only escape codes we recognize start with \x1b */
|
/* The only escape codes we recognize start with \x1b */
|
||||||
if (code[0] != L'\x1b')
|
if (code[0] != L'\x1b')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size_t resulting_length = 0;
|
size_t resulting_length = 0;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (cur_term != NULL)
|
if (cur_term != NULL)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -158,12 +158,12 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
set_foreground,
|
set_foreground,
|
||||||
set_background,
|
set_background,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t p=0; p < sizeof esc / sizeof *esc && !found; p++)
|
for (size_t p=0; p < sizeof esc / sizeof *esc && !found; p++)
|
||||||
{
|
{
|
||||||
if (!esc[p])
|
if (!esc[p])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (size_t k=0; k<8; k++)
|
for (size_t k=0; k<8; k++)
|
||||||
{
|
{
|
||||||
size_t len = try_sequence(tparm(esc[p],k), code);
|
size_t len = try_sequence(tparm(esc[p],k), code);
|
||||||
|
@ -176,7 +176,7 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_term != NULL)
|
if (cur_term != NULL)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -206,9 +206,9 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
exit_standout_mode,
|
exit_standout_mode,
|
||||||
enter_secure_mode
|
enter_secure_mode
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (size_t p=0; p < sizeof esc2 / sizeof *esc2 && !found; p++)
|
for (size_t p=0; p < sizeof esc2 / sizeof *esc2 && !found; p++)
|
||||||
{
|
{
|
||||||
if (!esc2[p])
|
if (!esc2[p])
|
||||||
|
@ -226,7 +226,7 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
if (code[1] == L'k')
|
if (code[1] == L'k')
|
||||||
|
@ -251,7 +251,7 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
/* Generic VT100 one byte sequence: CSI followed by something in the range @ through _ */
|
/* Generic VT100 one byte sequence: CSI followed by something in the range @ through _ */
|
||||||
|
@ -261,7 +261,7 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
/* Generic VT100 CSI-style sequence. <esc>, followed by zero or more ASCII characters NOT in the range [@,_], followed by one character in that range */
|
/* Generic VT100 CSI-style sequence. <esc>, followed by zero or more ASCII characters NOT in the range [@,_], followed by one character in that range */
|
||||||
|
@ -273,11 +273,11 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
{
|
{
|
||||||
/* Consume a sequence of ASCII characters not in the range [@, ~] */
|
/* Consume a sequence of ASCII characters not in the range [@, ~] */
|
||||||
wchar_t c = code[cursor];
|
wchar_t c = code[cursor];
|
||||||
|
|
||||||
/* If we're not in ASCII, just stop */
|
/* If we're not in ASCII, just stop */
|
||||||
if (c > 127)
|
if (c > 127)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* If we're the end character, then consume it and then stop */
|
/* If we're the end character, then consume it and then stop */
|
||||||
if (c >= L'@' && c <= L'~')
|
if (c >= L'@' && c <= L'~')
|
||||||
{
|
{
|
||||||
|
@ -290,7 +290,7 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
resulting_length = cursor;
|
resulting_length = cursor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! found)
|
if (! found)
|
||||||
{
|
{
|
||||||
/* Generic VT100 two byte sequence: <esc> followed by something in the range @ through _ */
|
/* Generic VT100 two byte sequence: <esc> followed by something in the range @ through _ */
|
||||||
|
@ -300,7 +300,7 @@ size_t escape_code_length(const wchar_t *code)
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resulting_length;
|
return resulting_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1060,7 +1060,7 @@ struct screen_layout_t
|
||||||
wcstring autosuggestion;
|
wcstring autosuggestion;
|
||||||
|
|
||||||
/* Whether the prompts get their own line or not */
|
/* Whether the prompts get their own line or not */
|
||||||
bool prompts_get_own_line;
|
bool prompts_get_own_line;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Given a vector whose indexes are offsets and whose values are the widths of the string if truncated at that offset, return the offset that fits in the given width. Returns width_by_offset.size() - 1 if they all fit. The first value in width_by_offset is assumed to be 0. */
|
/* Given a vector whose indexes are offsets and whose values are the widths of the string if truncated at that offset, return the offset that fits in the given width. Returns width_by_offset.size() - 1 if they all fit. The first value in width_by_offset is assumed to be 0. */
|
||||||
|
|
4
screen.h
4
screen.h
|
@ -140,7 +140,7 @@ public:
|
||||||
|
|
||||||
/** If we support soft wrapping, we can output to this location without any cursor motion. */
|
/** If we support soft wrapping, we can output to this location without any cursor motion. */
|
||||||
screen_data_t::cursor_t soft_wrap_location;
|
screen_data_t::cursor_t soft_wrap_location;
|
||||||
|
|
||||||
/** Whether the last-drawn autosuggestion (if any) is truncated, or hidden entirely */
|
/** Whether the last-drawn autosuggestion (if any) is truncated, or hidden entirely */
|
||||||
bool autosuggestion_is_truncated;
|
bool autosuggestion_is_truncated;
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ public:
|
||||||
|
|
||||||
/** If we need to clear, this is how many lines the actual screen had, before we reset it. This is used when resizing the window larger: if the cursor jumps to the line above, we need to remember to clear the subsequent lines. */
|
/** If we need to clear, this is how many lines the actual screen had, before we reset it. This is used when resizing the window larger: if the cursor jumps to the line above, we need to remember to clear the subsequent lines. */
|
||||||
size_t actual_lines_before_reset;
|
size_t actual_lines_before_reset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
These status buffers are used to check if any output has occurred
|
These status buffers are used to check if any output has occurred
|
||||||
other than from fish's main loop, in which case we need to redraw.
|
other than from fish's main loop, in which case we need to redraw.
|
||||||
|
|
|
@ -647,20 +647,20 @@ enum token_type tok_peek_next(tokenizer_t *tok, wcstring *out_next_string)
|
||||||
{
|
{
|
||||||
out_next_string->clear();
|
out_next_string->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum token_type result = TOK_END;
|
enum token_type result = TOK_END;
|
||||||
if (tok_has_next(tok))
|
if (tok_has_next(tok))
|
||||||
{
|
{
|
||||||
int saved = tok_get_pos(tok);
|
int saved = tok_get_pos(tok);
|
||||||
tok_next(tok);
|
tok_next(tok);
|
||||||
result = tok_last_type(tok);
|
result = tok_last_type(tok);
|
||||||
|
|
||||||
if (out_next_string != NULL)
|
if (out_next_string != NULL)
|
||||||
{
|
{
|
||||||
const wchar_t *last = tok_last(tok);
|
const wchar_t *last = tok_last(tok);
|
||||||
out_next_string->assign(last ? last : L"");
|
out_next_string->assign(last ? last : L"");
|
||||||
}
|
}
|
||||||
|
|
||||||
tok_set_pos(tok, saved);
|
tok_set_pos(tok, saved);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -317,7 +317,7 @@ static bool wildcard_complete_internal(const wcstring &orig,
|
||||||
if (wildcard_complete_internal(orig, str + i, wc+1, false, desc, desc_func, out, expand_flags, flags))
|
if (wildcard_complete_internal(orig, str + i, wc+1, false, desc, desc_func, out, expand_flags, flags))
|
||||||
{
|
{
|
||||||
res = true;
|
res = true;
|
||||||
|
|
||||||
/* #929: if the recursive call gives us a prefix match, just stop. This is sloppy - what we really want to do is say, once we've seen a match of a particular type, ignore all matches of that type further down the string, such that the wildcard produces the "minimal match." */
|
/* #929: if the recursive call gives us a prefix match, just stop. This is sloppy - what we really want to do is say, once we've seen a match of a particular type, ignore all matches of that type further down the string, such that the wildcard produces the "minimal match." */
|
||||||
bool has_prefix_match = false;
|
bool has_prefix_match = false;
|
||||||
const size_t after_count = out.size();
|
const size_t after_count = out.size();
|
||||||
|
|
Loading…
Reference in a new issue