Update style and formatting to conform to fish style guide.

This commit is contained in:
ridiculousfish 2014-01-15 01:40:40 -08:00
parent e2fe873049
commit 53814983ff
28 changed files with 703 additions and 683 deletions

View file

@ -149,7 +149,11 @@ static void err(const wchar_t *blah, ...)
/* Test sane escapes */
static void test_unescape_sane()
{
const struct test_t {const wchar_t * input; const wchar_t * expected;} tests[] =
const struct test_t
{
const wchar_t * input;
const wchar_t * expected;
} tests[] =
{
{L"abcd", L"abcd"},
{L"'abcd'", L"abcd"},
@ -754,7 +758,8 @@ static void test_indents()
say(L"Testing indents");
// Here are the components of our source and the indents we expect those to be
struct indent_component_t {
struct indent_component_t
{
const wchar_t *txt;
int indent;
};
@ -2539,7 +2544,8 @@ static void test_highlighting(void)
if (system("touch /tmp/fish_highlight_test/bar")) err(L"touch failed");
// Here are the components of our source and the colors we expect those to be
struct highlight_component_t {
struct highlight_component_t
{
const wchar_t *txt;
int color;
};

View file

@ -1700,7 +1700,7 @@ class highlighter_t
/* Colors the source range of a node with a given color */
void color_node(const parse_node_t &node, int color);
public:
public:
/* Constructor */
highlighter_t(const wcstring &str, size_t pos, const env_vars_snapshot_t &ev, const wcstring &wd) : buff(str), cursor_pos(pos), vars(ev), working_directory(wd), color_array(str.size())
@ -1947,7 +1947,7 @@ void highlighter_t::color_redirection(const parse_node_t &redirection_node)
}
/* NOCLOB means that we must not overwrite files that exist */
target_is_valid = file_is_writable && ! (file_exists && redirect_type == TOK_REDIRECT_NOCLOB);
target_is_valid = file_is_writable && !(file_exists && redirect_type == TOK_REDIRECT_NOCLOB);
}
break;

View file

@ -128,7 +128,8 @@ enum parse_error_code_t
parse_error_double_background // foo && bar, has special error message
};
enum {
enum
{
PARSER_TEST_ERROR = 1,
PARSER_TEST_INCOMPLETE = 2
};

View file

@ -325,7 +325,7 @@ parse_execution_result_t parse_execution_context_t::run_begin_statement(const pa
parser->pop_block(sb);
return ret;
}
}
/* Define a function */
parse_execution_result_t parse_execution_context_t::run_function_statement(const parse_node_t &header, const parse_node_t &contents)

View file

@ -32,7 +32,7 @@ enum parse_execution_result_t
class parse_execution_context_t
{
private:
private:
const parse_node_tree_t tree;
const wcstring src;
io_chain_t block_io;
@ -102,7 +102,7 @@ class parse_execution_context_t
parse_execution_result_t run_job_list(const parse_node_t &job_list_node, const block_t *associated_block);
parse_execution_result_t populate_job_from_job_node(job_t *j, const parse_node_t &job_node, const block_t *associated_block);
public:
public:
parse_execution_context_t(const parse_node_tree_t &t, const wcstring &s, parser_t *p);
/* Start executing at the given node offset. Returns 0 if there was no error, 1 if there was an error */

View file

@ -569,7 +569,7 @@ class parse_ll_t
}
}
public:
public:
/* Constructor */
parse_ll_t() : fatal_errored(false), should_generate_error_messages(true)

View file

@ -1215,7 +1215,8 @@ static screen_layout_t compute_layout(screen_t *s,
// If the command wraps, and the prompt is not short, place the command on its own line.
// A short prompt is 33% or less of the terminal's width.
const size_t prompt_percent_width = (100 * left_prompt_width) / screen_width;
if (left_prompt_width + first_command_line_width + 1 > screen_width && prompt_percent_width > 33) {
if (left_prompt_width + first_command_line_width + 1 > screen_width && prompt_percent_width > 33)
{
result.prompts_get_own_line = true;
}

View file

@ -458,10 +458,18 @@ static size_t read_redirection_or_fd_pipe(const wchar_t *buff, enum token_type *
/* We did not find a leading digit, so there's no explicit fd. Infer it from the type */
switch (buff[idx])
{
case L'>': fd = STDOUT_FILENO; break;
case L'<': fd = STDIN_FILENO; break;
case L'^': fd = STDERR_FILENO; break;
default: errored = true; break;
case L'>':
fd = STDOUT_FILENO;
break;
case L'<':
fd = STDIN_FILENO;
break;
case L'^':
fd = STDERR_FILENO;
break;
default:
errored = true;
break;
}
}
@ -556,10 +564,14 @@ int oflags_for_redirection_type(enum token_type type)
{
switch (type)
{
case TOK_REDIRECT_APPEND: return O_CREAT | O_APPEND | O_WRONLY;
case TOK_REDIRECT_OUT: return O_CREAT | O_WRONLY | O_TRUNC;
case TOK_REDIRECT_NOCLOB: return O_CREAT | O_EXCL | O_WRONLY;
case TOK_REDIRECT_IN: return O_RDONLY;
case TOK_REDIRECT_APPEND:
return O_CREAT | O_APPEND | O_WRONLY;
case TOK_REDIRECT_OUT:
return O_CREAT | O_WRONLY | O_TRUNC;
case TOK_REDIRECT_NOCLOB:
return O_CREAT | O_EXCL | O_WRONLY;
case TOK_REDIRECT_IN:
return O_RDONLY;
default:
return -1;