Skip to content

Commit cf766b5

Browse files
Fix formatting
1 parent 03c65d7 commit cf766b5

20 files changed

+94
-88
lines changed

builtin.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1617,24 +1617,24 @@ static int builtin_echo(parser_t &parser, wchar_t **argv)
16171617
{
16181618
case L'n':
16191619
print_newline = false;
1620-
break;
1620+
break;
16211621
case L'e':
16221622
interpret_special_chars = true;
1623-
break;
1623+
break;
16241624
case L's':
16251625
// fish-specific extension,
16261626
// which we should try to nix
16271627
print_spaces = false;
1628-
break;
1628+
break;
16291629
case L'E':
16301630
interpret_special_chars = false;
1631-
break;
1631+
break;
16321632
}
16331633
}
16341634
}
16351635
else
16361636
{
1637-
invalid_echo_option:
1637+
invalid_echo_option:
16381638
break;
16391639
}
16401640
argv++;

builtin_commandline.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static void write_part(const wchar_t *begin,
169169
out.push_back(L'\n');
170170
break;
171171
}
172-
172+
173173
default:
174174
{
175175
break;

builtin_printf.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
632632
}
633633
break;
634634
}
635-
635+
636636
modify_allowed_format_specifiers(ok, "aAcdeEfFgGiosuxX", true);
637637

638638
for (;; f++, direc_length++)

complete.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ void completer_t::complete_param_expand(const wcstring &sstr, bool do_file)
16271627

16281628
if (expand_string(comp_str,
16291629
this->completions,
1630-
flags ) == EXPAND_ERROR)
1630+
flags) == EXPAND_ERROR)
16311631
{
16321632
debug(3, L"Error while expanding string '%ls'", comp_str);
16331633
}
@@ -1911,7 +1911,7 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, completion_
19111911
end_loop=1;
19121912
break;
19131913
}
1914-
1914+
19151915
default:
19161916
{
19171917
break;

complete.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class completion_t
127127
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);
128128
completion_t(const completion_t &);
129129
completion_t &operator=(const completion_t &);
130-
130+
131131
/* Compare two completions. No operating overlaoding to make this always explicit (there's potentially multiple ways to compare completions). */
132132
static bool is_alphabetically_less_than(const completion_t &a, const completion_t &b);
133133
static bool is_alphabetically_equal_to(const completion_t &a, const completion_t &b);

exec.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ static bool can_use_posix_spawn_for_job(const job_t *job, const process_t *proce
551551
return false;
552552
}
553553
}
554-
554+
555555
/* Now see if we have a redirection involving a file. The only one we allow is /dev/null, which we assume will not fail. */
556556
bool result = true;
557557
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)
790790
echo alpha | cat < beta.txt
791791
792792
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.
793-
793+
794794
However, eval does this:
795-
795+
796796
echo "begin; $argv "\n" ;end eval2_inner <&3 3<&-" | source 3<&0
797-
797+
798798
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.
799799
*/
800800

@@ -811,7 +811,7 @@ void exec_job(parser_t &parser, job_t *j)
811811

812812
/* The explicit IO redirections associated with the process */
813813
process_net_io_chain.append(p->io_chain());
814-
814+
815815
/* Read pipe goes last */
816816
if (p != j->first_process)
817817
{
@@ -820,7 +820,7 @@ void exec_job(parser_t &parser, job_t *j)
820820
pipe_read->pipe_fd[0] = pipe_current_read;
821821
process_net_io_chain.push_back(pipe_read);
822822
}
823-
823+
824824

825825
/*
826826
This call is used so the global environment variable array
@@ -1241,16 +1241,16 @@ void exec_job(parser_t &parser, job_t *j)
12411241
forking is expensive, fish tries to avoid it when
12421242
possible.
12431243
*/
1244-
1244+
12451245
bool fork_was_skipped = false;
1246-
1246+
12471247
const shared_ptr<io_data_t> stdout_io = process_net_io_chain.get_io_for_fd(STDOUT_FILENO);
12481248
const shared_ptr<io_data_t> stderr_io = process_net_io_chain.get_io_for_fd(STDERR_FILENO);
1249-
1249+
12501250
/* 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. */
12511251
bool must_fork = redirection_is_to_real_file(stdout_io.get()) || redirection_is_to_real_file(stderr_io.get());
12521252
if (! must_fork)
1253-
{
1253+
{
12541254
if (p->next == NULL)
12551255
{
12561256
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)
12991299
}
13001300
}
13011301
}
1302-
1302+
13031303

13041304
if (fork_was_skipped)
13051305
{

expand.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1752,15 +1752,15 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
17521752

17531753
remove_internal_separator(next_str, (EXPAND_SKIP_WILDCARDS & flags) ? true : false);
17541754
const wchar_t *next = next_str.c_str();
1755-
1755+
17561756
const bool has_wildcard = wildcard_has(next, 1);
1757-
1757+
17581758
if (has_wildcard && (flags & EXECUTABLES_ONLY))
17591759
{
17601760
// Don't do wildcard expansion for executables. See #785. So do nothing here.
17611761
}
17621762
else if (((flags & ACCEPT_INCOMPLETE) && (!(flags & EXPAND_SKIP_WILDCARDS))) ||
1763-
has_wildcard)
1763+
has_wildcard)
17641764
{
17651765
const wchar_t *start, *rest;
17661766

fallback.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ static int mk_wcswidth(const wchar_t *pwcs, size_t n)
15061506
{
15071507
if (pwcs[i] == L'\0')
15081508
break;
1509-
1509+
15101510
int w = mk_wcwidth(pwcs[i]);
15111511
if (w < 0)
15121512
{

fish.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,12 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *out_c
366366
is_login |= (strcmp(argv[0], "-fish") == 0);
367367

368368
/* 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. */
369-
if (force_interactive) {
369+
if (force_interactive)
370+
{
370371
is_interactive_session = true;
371-
} else if (is_interactive_session) {
372+
}
373+
else if (is_interactive_session)
374+
{
372375
is_interactive_session = ! has_cmd && (my_optind == argc) && isatty(STDIN_FILENO);
373376
}
374377

@@ -402,7 +405,7 @@ int main(int argc, char **argv)
402405
debug(1, _(L"Can not use the no-execute mode when running an interactive session"));
403406
no_exec = 0;
404407
}
405-
408+
406409
/* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */
407410
if (is_interactive_session)
408411
{
@@ -509,7 +512,7 @@ int main(int argc, char **argv)
509512
}
510513

511514
proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res);
512-
515+
513516
restore_term_mode();
514517
restore_term_foreground_process_group();
515518
history_destroy();

fish_tests.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ static void test_utils()
532532
{
533533
say(L"Testing utils");
534534
const wchar_t *a = L"echo (echo (echo hi";
535-
535+
536536
const wchar_t *begin = NULL, *end = NULL;
537537
parse_util_cmdsubst_extent(a, 0, &begin, &end);
538538
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()
542542
if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
543543
parse_util_cmdsubst_extent(a, 3, &begin, &end);
544544
if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
545-
545+
546546
parse_util_cmdsubst_extent(a, 8, &begin, &end);
547547
if (begin != a + wcslen(L"echo (")) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__);
548548

@@ -788,7 +788,7 @@ static void test_path()
788788
{
789789
err(L"Bug in canonical PATH code");
790790
}
791-
791+
792792
if (paths_are_equivalent(L"/foo/bar/baz", L"foo/bar/baz")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);
793793
if (! paths_are_equivalent(L"///foo///bar/baz", L"/foo/bar////baz//")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);
794794
if (! paths_are_equivalent(L"/foo/bar/baz", L"/foo/bar/baz")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__);

history.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
629629
scoped_lock locker(lock);
630630

631631
bool first = true;
632-
632+
633633
std::set<wcstring> seen;
634634

635635
/* 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
638638
/* Skip duplicates */
639639
if (! seen.insert(iter->str()).second)
640640
continue;
641-
641+
642642
if (! first)
643643
result.append(separator);
644644
result.append(iter->str());
@@ -651,11 +651,11 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
651651
{
652652
size_t offset = *iter;
653653
const history_item_t item = history_t::decode_item(mmap_start + offset, mmap_length - offset, mmap_type);
654-
654+
655655
/* Skip duplicates */
656656
if (! seen.insert(item.str()).second)
657657
continue;
658-
658+
659659
if (! first)
660660
result.append(separator);
661661
result.append(item.str());

parse_util.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
245245
const wchar_t * const cursor = buff + cursor_pos;
246246

247247
CHECK(buff,);
248-
248+
249249
const size_t bufflen = wcslen(buff);
250250
assert(cursor_pos <= bufflen);
251-
251+
252252
/* ap and bp are the beginning and end of the tightest command substitition found so far */
253253
const wchar_t *ap = buff, *bp = buff + bufflen;
254254
const wchar_t *pos = buff;
@@ -265,7 +265,7 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
265265
{
266266
end = const_cast<wchar_t *>(buff) + bufflen;
267267
}
268-
268+
269269
if (begin < cursor && end >= cursor)
270270
{
271271
/* 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
290290
assert(pos <= buff + bufflen);
291291
}
292292
}
293-
293+
294294
if (a != NULL) *a = ap;
295295
if (b != NULL) *b = bp;
296296
}
@@ -383,7 +383,7 @@ static void job_or_process_extent(const wchar_t *buff,
383383

384384
break;
385385
}
386-
386+
387387
default:
388388
{
389389
break;

parser.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ int parser_t::parse_job(process_t *p,
20132013
{
20142014

20152015
const wchar_t *cmd = args.at(0).completion.c_str();
2016-
2016+
20172017
/*
20182018
We couldn't find the specified command.
20192019
@@ -2036,20 +2036,20 @@ int parser_t::parse_job(process_t *p,
20362036
if (equals_ptr != NULL)
20372037
{
20382038
/* 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...) */
2039-
2039+
20402040
const wcstring name_str = wcstring(cmd, equals_ptr - cmd); //variable name, up to the =
20412041
const wcstring val_str = wcstring(equals_ptr + 1); //variable value, past the =
2042-
2042+
20432043
wcstring next_str;
20442044
if (tok_peek_next(tok, &next_str) == TOK_STRING && ! next_str.empty())
20452045
{
20462046
wcstring ellipsis_str = wcstring(1, ellipsis_char);
20472047
if (ellipsis_str == L"$")
20482048
ellipsis_str = L"...";
2049-
2049+
20502050
/* Looks like a command */
20512051
debug(0,
2052-
_( 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'."),
2052+
_(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'."),
20532053
cmd,
20542054
next_str.c_str(),
20552055
name_str.c_str(),

path.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ void path_make_canonical(wcstring &path)
400400
path.at(trailing++) = c;
401401
}
402402
prev_was_slash = is_slash;
403-
}
403+
}
404404
assert(trailing <= len);
405405
if (trailing < len)
406406
path.resize(trailing);
@@ -410,32 +410,32 @@ bool paths_are_equivalent(const wcstring &p1, const wcstring &p2)
410410
{
411411
if (p1 == p2)
412412
return true;
413-
413+
414414
size_t len1 = p1.size(), len2 = p2.size();
415-
415+
416416
// Ignore trailing slashes after the first character
417417
while (len1 > 1 && p1.at(len1 - 1) == L'/') len1--;
418418
while (len2 > 1 && p2.at(len2 - 1) == L'/') len2--;
419-
419+
420420
// Start walking
421421
size_t idx1 = 0, idx2 = 0;
422422
while (idx1 < len1 && idx2 < len2)
423423
{
424424
wchar_t c1 = p1.at(idx1), c2 = p2.at(idx2);
425-
425+
426426
// If the characters are different, the strings are not equivalent
427427
if (c1 != c2)
428428
break;
429-
429+
430430
idx1++;
431431
idx2++;
432-
432+
433433
// If the character was a slash, walk forwards until we hit the end of the string, or a non-slash
434434
// Note the first condition is invariant within the loop
435435
while (c1 == L'/' && idx1 < len1 && p1.at(idx1) == L'/') idx1++;
436436
while (c2 == L'/' && idx2 < len2 && p2.at(idx2) == L'/') idx2++;
437437
}
438-
438+
439439
// We matched if we consumed all of the characters in both strings
440440
return idx1 == len1 && idx2 == len2;
441441
}

0 commit comments

Comments
 (0)