mark some functions static

This commit is contained in:
Aaron Gyes 2021-10-31 03:51:16 -07:00
parent 70186f2abb
commit 8ab05a4036
9 changed files with 24 additions and 23 deletions

View File

@ -93,10 +93,10 @@ int builtin_count_args(const wchar_t *const *argv) {
/// This function works like wperror, but it prints its result into the streams.err string instead
/// to stderr. Used by the builtin commands.
void builtin_wperror(const wchar_t *s, io_streams_t &streams) {
void builtin_wperror(const wchar_t *program_name, io_streams_t &streams) {
char *err = std::strerror(errno);
if (s != nullptr) {
streams.err.append(s);
if (program_name != nullptr) {
streams.err.append(program_name);
streams.err.append(L": ");
}
if (err != nullptr) {
@ -319,21 +319,21 @@ static maybe_t<int> builtin_breakpoint(parser_t &parser, io_streams_t &streams,
return parser.get_last_status();
}
maybe_t<int> builtin_true(parser_t &parser, io_streams_t &streams, const wchar_t **argv) {
static maybe_t<int> builtin_true(parser_t &parser, io_streams_t &streams, const wchar_t **argv) {
UNUSED(parser);
UNUSED(streams);
UNUSED(argv);
return STATUS_CMD_OK;
}
maybe_t<int> builtin_false(parser_t &parser, io_streams_t &streams, const wchar_t **argv) {
static maybe_t<int> builtin_false(parser_t &parser, io_streams_t &streams, const wchar_t **argv) {
UNUSED(parser);
UNUSED(streams);
UNUSED(argv);
return STATUS_CMD_ERROR;
}
maybe_t<int> builtin_gettext(parser_t &parser, io_streams_t &streams, const wchar_t **argv) {
static maybe_t<int> builtin_gettext(parser_t &parser, io_streams_t &streams, const wchar_t **argv) {
UNUSED(parser);
UNUSED(streams);
for (int i = 1; i < builtin_count_args(argv); i++) {

View File

@ -101,7 +101,7 @@ void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wch
void builtin_print_error_trailer(parser_t &parser, output_stream_t &b, const wchar_t *cmd);
void builtin_wperror(const wchar_t *s, io_streams_t &streams);
void builtin_wperror(const wchar_t *program_name, io_streams_t &streams);
struct help_only_cmd_opts_t {
bool print_help = false;

View File

@ -17,6 +17,7 @@
#include <vector>
#include "builtin.h"
#include "builtin_set.h"
#include "common.h"
#include "env.h"
#include "expand.h"
@ -313,7 +314,7 @@ struct split_var_t {
/// Returns:
/// a split var on success, none() on error, in which case an error will have been printed.
/// If no index is found, this leaves indexes empty.
maybe_t<split_var_t> split_var_and_indexes(const wchar_t *arg, env_mode_flags_t mode,
static maybe_t<split_var_t> split_var_and_indexes(const wchar_t *arg, env_mode_flags_t mode,
const environment_t &vars, io_streams_t &streams) {
split_var_t res{};
const wchar_t *open_bracket = std::wcschr(arg, L'[');

View File

@ -124,7 +124,7 @@ struct token_info_t {
unsigned int flags;
};
const token_info_t *token_for_string(const wcstring &str) {
static const token_info_t *token_for_string(const wcstring &str) {
static const std::map<wcstring, const token_info_t> token_infos = {
{L"", {test_unknown, 0}},
{L"!", {test_bang, 0}},

View File

@ -77,7 +77,7 @@ bool function_set_t::allow_autoload(const wcstring &name) const {
} // namespace
/// \return a copy of some function props, in a new shared_ptr.
std::shared_ptr<function_properties_t> copy_props(const function_properties_ref_t &props) {
static std::shared_ptr<function_properties_t> copy_props(const function_properties_ref_t &props) {
assert(props && "Null props");
return std::make_shared<function_properties_t>(*props);
}

View File

@ -109,7 +109,7 @@ const enum_map<parse_keyword_t> keyword_enum_map[] = {{parse_keyword_t::kw_excla
#define keyword_enum_map_len (sizeof keyword_enum_map / sizeof *keyword_enum_map)
// Statement decorations like 'command' or 'exec'.
enum class statement_decoration_t {
enum class statement_decoration_t : uint8_t {
none,
command,
builtin,
@ -117,7 +117,7 @@ enum class statement_decoration_t {
};
// Parse error code list.
enum parse_error_code_t {
enum parse_error_code_t : uint8_t {
parse_error_none,
// Matching values from enum parser_error.
@ -159,10 +159,10 @@ enum {
/// Indicate that extra semis should be generated.
parse_flag_show_extra_semis = 1 << 5,
};
typedef unsigned int parse_tree_flags_t;
using parse_tree_flags_t = uint8_t;
enum { PARSER_TEST_ERROR = 1, PARSER_TEST_INCOMPLETE = 2 };
typedef unsigned int parser_test_error_bits_t;
using parser_test_error_bits_t = uint8_t;
struct parse_error_t {
/// Text of the error.
@ -193,7 +193,7 @@ wcstring token_type_user_presentable_description(parse_token_type_t type,
void parse_error_offset_source_start(parse_error_list_t *errors, size_t amt);
// The location of a pipeline.
enum class pipeline_position_t {
enum class pipeline_position_t : uint8_t {
none, // not part of a pipeline
first, // first command in a pipeline
subsequent // second or further command in a pipeline

View File

@ -98,7 +98,7 @@ bool path_get_path(const wcstring &cmd, wcstring *out_path, const environment_t
return path_get_path_core(cmd, out_path, vars.get(L"PATH"));
}
bool path_is_executable(const std::string &path) {
static bool path_is_executable(const std::string &path) {
if (access(path.c_str(), X_OK)) return false;
struct stat buff;
if (stat(path.c_str(), &buff) == -1) {
@ -221,11 +221,11 @@ maybe_t<wcstring> path_get_cdpath(const wcstring &dir, const wcstring &wd,
assert(!wd.empty() && wd.back() == L'/');
auto paths = path_apply_cdpath(dir, wd, env_vars);
for (const wcstring &dir : paths) {
for (const wcstring &a_dir : paths) {
struct stat buf;
if (wstat(dir, &buf) == 0) {
if (wstat(a_dir, &buf) == 0) {
if (S_ISDIR(buf.st_mode)) {
return dir;
return a_dir;
}
err = ENOTDIR;
}

View File

@ -24,7 +24,7 @@
#include "wait_handle.h"
/// Types of processes.
enum class process_type_t {
enum class process_type_t : uint8_t {
/// A regular external command.
external,
/// A builtin command.
@ -37,7 +37,7 @@ enum class process_type_t {
exec,
};
enum class job_control_t {
enum class job_control_t : uint8_t {
all,
interactive,
none,

View File

@ -930,7 +930,7 @@ void term_copy_modes() {
}
/// Grab control of terminal.
void term_steal() {
static void term_steal() {
term_copy_modes();
while (true) {
if (tcsetattr(STDIN_FILENO, TCSANOW, &shell_modes) == -1) {
@ -4184,7 +4184,7 @@ void reader_queue_ch(const char_event_t &ch) {
}
/// Sets the command line contents, clearing the pager.
void reader_set_buffer(const wcstring &b, size_t pos) {
static void reader_set_buffer(const wcstring &b, size_t pos) {
reader_data_t *data = current_data_or_null();
if (!data) return;