Skip to content

Commit 2da81b0

Browse files
Formatting and style updates
1 parent d4c8817 commit 2da81b0

18 files changed

+115
-79
lines changed

builtin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ wcstring builtin_help_get(parser_t &parser, const wchar_t *name)
214214
/* This won't ever work if no_exec is set */
215215
if (no_exec)
216216
return wcstring();
217-
217+
218218
wcstring_list_t lst;
219219
wcstring out;
220220
const wcstring name_esc = escape_string(name, 1);

builtin_printf.cpp

+60-28
Original file line numberDiff line numberDiff line change
@@ -100,39 +100,71 @@ static int hex_to_bin(const wchar_t &c)
100100
{
101101
switch (c)
102102
{
103-
case L'0': return 0;
104-
case L'1': return 1;
105-
case L'2': return 2;
106-
case L'3': return 3;
107-
case L'4': return 4;
108-
case L'5': return 5;
109-
case L'6': return 6;
110-
case L'7': return 7;
111-
case L'8': return 8;
112-
case L'9': return 9;
113-
case L'a': case L'A': return 10;
114-
case L'b': case L'B': return 11;
115-
case L'c': case L'C': return 12;
116-
case L'd': case L'D': return 13;
117-
case L'e': case L'E': return 14;
118-
case L'f': case L'F': return 15;
119-
default: return -1;
103+
case L'0':
104+
return 0;
105+
case L'1':
106+
return 1;
107+
case L'2':
108+
return 2;
109+
case L'3':
110+
return 3;
111+
case L'4':
112+
return 4;
113+
case L'5':
114+
return 5;
115+
case L'6':
116+
return 6;
117+
case L'7':
118+
return 7;
119+
case L'8':
120+
return 8;
121+
case L'9':
122+
return 9;
123+
case L'a':
124+
case L'A':
125+
return 10;
126+
case L'b':
127+
case L'B':
128+
return 11;
129+
case L'c':
130+
case L'C':
131+
return 12;
132+
case L'd':
133+
case L'D':
134+
return 13;
135+
case L'e':
136+
case L'E':
137+
return 14;
138+
case L'f':
139+
case L'F':
140+
return 15;
141+
default:
142+
return -1;
120143
}
121144
}
122145

123146
static int octal_to_bin(wchar_t c)
124147
{
125148
switch (c)
126149
{
127-
case L'0': return 0;
128-
case L'1': return 1;
129-
case L'2': return 2;
130-
case L'3': return 3;
131-
case L'4': return 4;
132-
case L'5': return 5;
133-
case L'6': return 6;
134-
case L'7': return 7;
135-
default: return -1;
150+
case L'0':
151+
return 0;
152+
case L'1':
153+
return 1;
154+
case L'2':
155+
return 2;
156+
case L'3':
157+
return 3;
158+
case L'4':
159+
return 4;
160+
case L'5':
161+
return 5;
162+
case L'6':
163+
return 6;
164+
case L'7':
165+
return 7;
166+
default:
167+
return -1;
136168
}
137169
}
138170

@@ -358,9 +390,9 @@ long builtin_printf_state_t::print_esc(const wchar_t *escstart, bool octal_0)
358390
uni_value = uni_value * 16 + hex_to_bin(*p);
359391
p++;
360392
}
361-
393+
362394
/* PCA GNU printf respects the limitations described in ISO N717, about which universal characters "shall not" be specified. I believe this limitation is for the benefit of compilers; I see no reason to impose it in builtin_printf.
363-
395+
364396
If __STDC_ISO_10646__ is defined, then it means wchar_t can and does hold Unicode code points, so just use that. If not defined, use the %lc printf conversion; this probably won't do anything good if your wide character set is not Unicode, but such platforms are exceedingly rare.
365397
*/
366398
if (uni_value > 0x10FFFF)

common.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ wcstring wsetlocale(int category, const wchar_t *locale)
568568

569569
// U+23CE is the "return" character
570570
omitted_newline_char = unicode ? L'\x23CE' : L'~';
571-
571+
572572
if (!res)
573573
return wcstring();
574574
else

complete.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ enum
8989

9090
/** This completion should be inserted as-is, without escaping. */
9191
COMPLETE_DONT_ESCAPE = 1 << 4,
92-
92+
9393
/** If you do escape, don't escape tildes */
9494
COMPLETE_DONT_ESCAPE_TILDES = 1 << 5
9595
};

event.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ enum
4949
*/
5050
struct event_t
5151
{
52-
public:
52+
public:
5353

5454
/** Type of event */
5555
int type;

exec.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ void exec(parser_t &parser, job_t *j)
590590
CHECK(j,);
591591
CHECK_BLOCK();
592592

593-
if (no_exec) {
593+
if (no_exec)
594+
{
594595
exec_no_exec(parser, j);
595596
return;
596597
}
@@ -1312,7 +1313,7 @@ void exec(parser_t &parser, job_t *j)
13121313
/* Get argv and envv before we fork */
13131314
null_terminated_array_t<char> argv_array;
13141315
convert_wide_array_to_narrow(p->get_argv_array(), &argv_array);
1315-
1316+
13161317
/* Ensure that stdin is blocking before we hand it off (see issue #176). It's a little strange that we only do this with stdin and not with stdout or stderr. However in practice, setting or clearing O_NONBLOCK on stdin also sets it for the other two fds, presumably because they refer to the same underlying file (/dev/tty?) */
13171318
make_fd_blocking(STDIN_FILENO);
13181319

expand.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ static void expand_home_directory(wcstring &input)
14901490
{
14911491
size_t tail_idx;
14921492
wcstring username = get_home_directory_name(input, &tail_idx);
1493-
1493+
14941494
bool tilde_error = false;
14951495
wcstring home;
14961496
if (username.empty())
@@ -1539,7 +1539,7 @@ static void unexpand_tildes(const wcstring &input, std::vector<completion_t> *co
15391539
// If it does not, there's nothing to do
15401540
if (input.empty() || input.at(0) != L'~')
15411541
return;
1542-
1542+
15431543
// We only operate on completions that replace their contents
15441544
// If we don't have any, we're done.
15451545
// In particular, empty vectors are common.
@@ -1554,23 +1554,23 @@ static void unexpand_tildes(const wcstring &input, std::vector<completion_t> *co
15541554
}
15551555
if (! has_candidate_completion)
15561556
return;
1557-
1557+
15581558
size_t tail_idx;
15591559
wcstring username_with_tilde = L"~";
15601560
username_with_tilde.append(get_home_directory_name(input, &tail_idx));
1561-
1561+
15621562
// Expand username_with_tilde
15631563
wcstring home = username_with_tilde;
15641564
expand_tilde(home);
1565-
1565+
15661566
// Now for each completion that starts with home, replace it with the username_with_tilde
15671567
for (size_t i=0; i < completions->size(); i++)
15681568
{
15691569
completion_t &comp = completions->at(i);
15701570
if ((comp.flags & COMPLETE_REPLACES_TOKEN) && string_prefixes_string(home, comp.completion))
15711571
{
15721572
comp.completion.replace(0, home.size(), username_with_tilde);
1573-
1573+
15741574
// And mark that our tilde is literal, so it doesn't try to escape it
15751575
comp.flags |= COMPLETE_DONT_ESCAPE_TILDES;
15761576
}
@@ -1607,9 +1607,9 @@ static void remove_internal_separator(wcstring &str, bool conv)
16071607

16081608

16091609
int expand_string(const wcstring &input, std::vector<completion_t> &output, expand_flags_t flags)
1610-
{
1610+
{
16111611
parser_t parser(PARSER_TYPE_ERRORS_ONLY, true /* show errors */);
1612-
1612+
16131613
size_t i;
16141614
int res = EXPAND_OK;
16151615

@@ -1618,7 +1618,7 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
16181618
output.push_back(completion_t(input));
16191619
return EXPAND_OK;
16201620
}
1621-
1621+
16221622
std::vector<completion_t> clist1, clist2;
16231623
std::vector<completion_t> *in = &clist1, *out = &clist2;
16241624

@@ -1642,7 +1642,7 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
16421642
if (! cmdsubst_ok)
16431643
return EXPAND_ERROR;
16441644
}
1645-
1645+
16461646
for (i=0; i < in->size(); i++)
16471647
{
16481648
/*
@@ -1785,19 +1785,19 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
17851785
}
17861786
else
17871787
{
1788-
if (! (flags & ACCEPT_INCOMPLETE))
1788+
if (!(flags & ACCEPT_INCOMPLETE))
17891789
{
17901790
out->push_back(completion_t(next_str));
17911791
}
17921792
}
17931793
}
1794-
1794+
17951795
// Hack to un-expand tildes (see #647)
1796-
if (! (flags & EXPAND_SKIP_HOME_DIRECTORIES))
1796+
if (!(flags & EXPAND_SKIP_HOME_DIRECTORIES))
17971797
{
17981798
unexpand_tildes(input, out);
17991799
}
1800-
1800+
18011801
// Return our output
18021802
output.insert(output.end(), out->begin(), out->end());
18031803

fish.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ int main(int argc, char **argv)
462462
{
463463
/* Stop the exit status of any initialization commands (#635) */
464464
proc_set_last_status(STATUS_BUILTIN_OK);
465-
465+
466466
/* Run the commands specified as arguments, if any */
467467
if (! cmds.empty())
468468
{

fish_tests.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ int main(int argc, char **argv)
17011701
setlocale(LC_ALL, "");
17021702
srand(time(0));
17031703
configure_thread_assertions_for_testing();
1704-
1704+
17051705
program_name=L"(ignore)";
17061706

17071707
say(L"Testing low-level functionality");
@@ -1714,7 +1714,7 @@ int main(int argc, char **argv)
17141714
builtin_init();
17151715
reader_init();
17161716
env_init();
1717-
1717+
17181718
test_format();
17191719
test_escape();
17201720
test_convert();

highlight.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -1377,9 +1377,12 @@ void highlight_shell(const wcstring &buff, std::vector<int> &color, size_t pos,
13771377
for (size_t i=0; i < buff.size(); i++)
13781378
{
13791379
int &current_val = color.at(i);
1380-
if (current_val >= 0) {
1380+
if (current_val >= 0)
1381+
{
13811382
last_val = current_val;
1382-
} else {
1383+
}
1384+
else
1385+
{
13831386
current_val = last_val; //note - this writes into the vector
13841387
}
13851388
}

history.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class history_output_buffer_t
7070
return s ? strlen(s) : 0;
7171
}
7272

73-
public:
73+
public:
7474

7575
/* Add a bit more to HISTORY_OUTPUT_BUFFER_SIZE because we flush once we've exceeded that size */
7676
history_output_buffer_t() : buffer(HISTORY_OUTPUT_BUFFER_SIZE + 128, '\0'), offset(0)
@@ -1070,14 +1070,14 @@ bool history_search_t::go_backwards()
10701070
return false;
10711071

10721072
const bool main_thread = is_main_thread();
1073-
1073+
10741074
while (++idx < max_idx)
10751075
{
10761076
if (main_thread ? reader_interrupted() : reader_thread_job_is_stale())
10771077
{
10781078
return false;
10791079
}
1080-
1080+
10811081
const history_item_t item = history->item_at_index(idx);
10821082
/* We're done if it's empty or we cancelled */
10831083
if (item.empty())
@@ -1165,7 +1165,7 @@ static void unescape_yaml(std::string &str)
11651165
{
11661166
// Operate on a const version of str, to avoid needless COWs that at() does.
11671167
const std::string &const_str = str;
1168-
1168+
11691169
// Look for a backslash
11701170
size_t backslash = const_str.find('\\', cursor);
11711171
if (backslash == std::string::npos || backslash + 1 >= size)
@@ -1429,7 +1429,7 @@ bool history_t::save_internal_via_appending()
14291429
*/
14301430

14311431
/* So far so good. Write all items at or after first_unwritten_new_item_index */
1432-
1432+
14331433
bool errored = false;
14341434
history_output_buffer_t buffer;
14351435
while (first_unwritten_new_item_index < new_items.size())

input.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,8 @@ bool input_terminfo_get_sequence(const wchar_t *name, wcstring *out_seq)
796796
{
797797
errno = err;
798798
return false;
799-
}
800-
799+
}
800+
801801
*out_seq = format_string(L"%s", res);
802802
return true;
803803

input_common.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static void input_flush_callbacks(void)
287287
/* Nothing to do if nothing to do */
288288
if (callback_queue.empty())
289289
return;
290-
290+
291291
/* We move the queue into a local variable, so that events queued up during a callback don't get fired until next round. */
292292
callback_queue_t local_queue;
293293
std::swap(local_queue, callback_queue);

io.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
#include <vector>
55
#if __cplusplus > 199711L
6-
// C++11
7-
#include <memory>
8-
using std::shared_ptr;
6+
// C++11
7+
#include <memory>
8+
using std::shared_ptr;
99
#else
10-
// C++03
11-
#include <tr1/memory>
12-
using std::tr1::shared_ptr;
10+
// C++03
11+
#include <tr1/memory>
12+
using std::tr1::shared_ptr;
1313
#endif
1414

1515
/**

0 commit comments

Comments
 (0)