diff --git a/src/builtin.cpp b/src/builtin.cpp index ef49ccd5e..99d5f5b52 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -93,7 +93,7 @@ void builtin_wperror(const wchar_t *program_name, io_streams_t &streams) { if (err != nullptr) { const wcstring werr = str2wcstring(err); streams.err.append(werr); - streams.err.push_back(L'\n'); + streams.err.push(L'\n'); } } @@ -501,9 +501,7 @@ wcstring_list_t builtin_get_names() { return result; } -wcstring_list_ffi_t builtin_get_names_ffi() { - return builtin_get_names(); -} +wcstring_list_ffi_t builtin_get_names_ffi() { return builtin_get_names(); } /// Insert all builtin names into list. void builtin_get_names(completion_list_t *list) { diff --git a/src/builtins/argparse.cpp b/src/builtins/argparse.cpp index 195278551..04dd766ac 100644 --- a/src/builtins/argparse.cpp +++ b/src/builtins/argparse.cpp @@ -490,7 +490,7 @@ static int validate_arg(parser_t &parser, const argparse_cmd_opts_t &opts, optio int retval = exec_subshell(opt_spec->validation_command, parser, cmd_output, false); for (const auto &output : cmd_output) { streams.err.append(output); - streams.err.push_back(L'\n'); + streams.err.push(L'\n'); } vars.pop(); return retval; diff --git a/src/builtins/bind.cpp b/src/builtins/bind.cpp index c5b31c47f..1f52c391e 100644 --- a/src/builtins/bind.cpp +++ b/src/builtins/bind.cpp @@ -164,7 +164,7 @@ void builtin_bind_t::key_names(bool all, io_streams_t &streams) { const wcstring_list_t names = input_terminfo_get_names(!all); for (const wcstring &name : names) { streams.out.append(name); - streams.out.append(L'\n'); + streams.out.push(L'\n'); } } diff --git a/src/builtins/commandline.cpp b/src/builtins/commandline.cpp index 5dc33a65d..cb954d64f 100644 --- a/src/builtins/commandline.cpp +++ b/src/builtins/commandline.cpp @@ -122,7 +122,7 @@ static void write_part(const wchar_t *begin, const wchar_t *end, int cut_at_curs } else { streams.out.append(begin, end - begin); } - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); } } diff --git a/src/builtins/complete.cpp b/src/builtins/complete.cpp index 5d7edd3fd..7b237d643 100644 --- a/src/builtins/complete.cpp +++ b/src/builtins/complete.cpp @@ -342,7 +342,7 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch wcstring prefix(wcstring(cmd) + L": -n '" + condition_string + L"': "); streams.err.append(*errors->at(i)->describe_with_prefix( condition_string, prefix, parser.is_interactive(), false)); - streams.err.push_back(L'\n'); + streams.err.push(L'\n'); } return STATUS_CMD_ERROR; } @@ -356,7 +356,7 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch if (maybe_t err_text = parse_util_detect_errors_in_argument_list(comp, prefix)) { streams.err.append_format(L"%ls: %ls: contains a syntax error\n", cmd, comp); streams.err.append(*err_text); - streams.err.push_back(L'\n'); + streams.err.push(L'\n'); return STATUS_CMD_ERROR; } } diff --git a/src/builtins/set.cpp b/src/builtins/set.cpp index d6d3b6e94..968638acb 100644 --- a/src/builtins/set.cpp +++ b/src/builtins/set.cpp @@ -546,14 +546,14 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams if (env_var_t::flags_for(var_name) & env_var_t::flag_read_only) { streams.out.append(_(L" (read-only)\n")); } else - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); for (size_t i = 0; i < vals.size(); i++) { if (vals.size() > 100) { if (i == 50) { // try to print a mid-line ellipsis because we are eliding lines not words streams.out.append(get_ellipsis_char() > 256 ? L"\u22EF" : get_ellipsis_str()); - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); } if (i >= 50 && i < vals.size() - 50) continue; } diff --git a/src/builtins/status.cpp b/src/builtins/status.cpp index 23e1fa3aa..0c57b2b5d 100644 --- a/src/builtins/status.cpp +++ b/src/builtins/status.cpp @@ -454,10 +454,10 @@ maybe_t builtin_status(parser_t &parser, io_streams_t &streams, const wchar const auto &var = parser.libdata().status_vars.command; if (!var.empty()) { streams.out.append(var); - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); } else { streams.out.append(program_name); - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); } break; } @@ -465,7 +465,7 @@ maybe_t builtin_status(parser_t &parser, io_streams_t &streams, const wchar CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd) const auto &var = parser.libdata().status_vars.commandline; streams.out.append(var); - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); break; } case STATUS_FISH_PATH: { @@ -482,19 +482,19 @@ maybe_t builtin_status(parser_t &parser, io_streams_t &streams, const wchar auto real = wrealpath(path); if (real && waccess(*real, F_OK)) { streams.out.append(*real); - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); } else { // realpath did not work, just append the path // - maybe this was obtained via $PATH? streams.out.append(path); - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); } } else { // This is a relative path, it depends on where fish's parent process // was when it started it and its idea of $PATH. // The best we can do is to print it directly and hope it works. streams.out.append(path); - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); } break; } diff --git a/src/builtins/string.cpp b/src/builtins/string.cpp index bb993ade3..ab02c8406 100644 --- a/src/builtins/string.cpp +++ b/src/builtins/string.cpp @@ -775,9 +775,9 @@ static int string_join_maybe0(parser_t &parser, io_streams_t &streams, int argc, } if (nargs > 0 && !opts.quiet) { if (is_join0) { - streams.out.push_back(L'\0'); + streams.out.push(L'\0'); } else if (aiter.want_newline()) { - streams.out.push_back(L'\n'); + streams.out.push(L'\n'); } } @@ -1514,7 +1514,7 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, cons } if (!first && !opts.quiet) { - streams.out.append(L'\n'); + streams.out.push(L'\n'); } first = false; @@ -1573,7 +1573,7 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, cons // Historical behavior is to never append a newline if all strings were empty. if (!opts.quiet && !opts.no_newline && !all_empty && aiter.want_newline()) { - streams.out.append(L'\n'); + streams.out.push(L'\n'); } return all_empty ? STATUS_CMD_ERROR : STATUS_CMD_OK; diff --git a/src/io.h b/src/io.h index 8386aa997..8a410a0a1 100644 --- a/src/io.h +++ b/src/io.h @@ -392,8 +392,7 @@ class output_stream_t : noncopyable_t, nonmovable_t { bool append(const wchar_t *s) { return append(s, std::wcslen(s)); } /// Append a char. - bool append(wchar_t s) { return append(&s, 1); } - bool push_back(wchar_t c) { return append(c); } + bool push(wchar_t s) { return append(&s, 1); } // Append data from a narrow buffer, widening it. bool append_narrow_buffer(const separated_buffer_t &buffer);