mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Declare functions in headers or use internal linkage (static)
Found with gcc's -Wmissing-declarations which gives warnings like ../src/tinyexpr.cpp:61:5: warning: no previous declaration for ‘int get_arity(int)’ [-Wmissing-declarations] 61 | int get_arity(const int type) { The same warnings show up for builtin functions like builtin_bg because they currently don't include their own headers. I left that. Also reformat the touched files.
This commit is contained in:
parent
7a4fece445
commit
fbaa5d193d
16 changed files with 50 additions and 48 deletions
|
@ -313,8 +313,8 @@ void builtin_bind_t::list_modes(io_streams_t &streams) {
|
|||
}
|
||||
}
|
||||
|
||||
int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
static int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
wchar_t *cmd = argv[0];
|
||||
static const wchar_t *const short_options = L":aehkKfM:Lm:s";
|
||||
static const struct woption long_options[] = {{L"all", no_argument, nullptr, 'a'},
|
||||
|
|
|
@ -130,7 +130,7 @@ long convert_digit(wchar_t d, int base) {
|
|||
static bool is_hex_digit(int c) { return std::strchr("0123456789ABCDEF", c) != nullptr; }
|
||||
|
||||
/// This is a specialization of `convert_digit()` that only handles base 16 and only uppercase.
|
||||
long convert_hex_digit(wchar_t d) {
|
||||
static long convert_hex_digit(wchar_t d) {
|
||||
if ((d <= L'9') && (d >= L'0')) {
|
||||
return d - L'0';
|
||||
} else if ((d <= L'Z') && (d >= L'A')) {
|
||||
|
@ -238,23 +238,22 @@ bool is_windows_subsystem_for_linux() {
|
|||
#endif // HAVE_BACKTRACE_SYMBOLS
|
||||
|
||||
template <typename T>
|
||||
inline __attribute__((always_inline))
|
||||
constexpr uintptr_t aligned_start(const T *in, size_t count, uint8_t alignment) {
|
||||
return std::min((uintptr_t) (in + count),
|
||||
(uintptr_t(in) + (uintptr_t)(alignment-1)) & ~((uintptr_t) (alignment -1)));
|
||||
inline __attribute__((always_inline)) constexpr uintptr_t aligned_start(const T *in, size_t count,
|
||||
uint8_t alignment) {
|
||||
return std::min((uintptr_t)(in + count),
|
||||
(uintptr_t(in) + (uintptr_t)(alignment - 1)) & ~((uintptr_t)(alignment - 1)));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline __attribute__((always_inline))
|
||||
constexpr uintptr_t aligned_end(const T *in, size_t count, uint8_t alignment) {
|
||||
return std::max((uintptr_t)in, (uintptr_t)(in + count) & ~((uintptr_t)(alignment-1)));
|
||||
inline __attribute__((always_inline)) constexpr uintptr_t aligned_end(const T *in, size_t count,
|
||||
uint8_t alignment) {
|
||||
return std::max((uintptr_t)in, (uintptr_t)(in + count) & ~((uintptr_t)(alignment - 1)));
|
||||
}
|
||||
|
||||
inline __attribute__((always_inline))
|
||||
bool is_ascii (const char *in, size_t len) {
|
||||
inline __attribute__((always_inline)) bool is_ascii(const char *in, size_t len) {
|
||||
uintptr_t aligned = aligned_start(in, len, 64);
|
||||
char bitmask1 = 0;
|
||||
for (auto ptr = in; (uintptr_t) ptr < aligned; ++ptr) {
|
||||
for (auto ptr = in; (uintptr_t)ptr < aligned; ++ptr) {
|
||||
bitmask1 |= *ptr;
|
||||
}
|
||||
uint64_t bitmask2 = 0;
|
||||
|
@ -266,8 +265,8 @@ bool is_ascii (const char *in, size_t len) {
|
|||
bitmask3 |= *ptr;
|
||||
}
|
||||
|
||||
return (uint64_t(bitmask1 & 0x80) | uint64_t(bitmask3 & 0x80)
|
||||
| (bitmask2 & 0x8080808080808080ULL)) == 0ULL;
|
||||
return (uint64_t(bitmask1 & 0x80) | uint64_t(bitmask3 & 0x80) |
|
||||
(bitmask2 & 0x8080808080808080ULL)) == 0ULL;
|
||||
}
|
||||
|
||||
/// Converts the narrow character string \c in into its wide equivalent, and return it.
|
||||
|
@ -1805,13 +1804,13 @@ static char extract_most_significant_digit(unsigned long long *xp) {
|
|||
return x + '0';
|
||||
}
|
||||
|
||||
void append_ull(char *buff, unsigned long long val, size_t *inout_idx, size_t max_len) {
|
||||
static void append_ull(char *buff, unsigned long long val, size_t *inout_idx, size_t max_len) {
|
||||
size_t idx = *inout_idx;
|
||||
while (val > 0 && idx < max_len) buff[idx++] = extract_most_significant_digit(&val);
|
||||
*inout_idx = idx;
|
||||
}
|
||||
|
||||
void append_str(char *buff, const char *str, size_t *inout_idx, size_t max_len) {
|
||||
static void append_str(char *buff, const char *str, size_t *inout_idx, size_t max_len) {
|
||||
size_t idx = *inout_idx;
|
||||
while (*str && idx < max_len) buff[idx++] = *str++;
|
||||
*inout_idx = idx;
|
||||
|
|
|
@ -819,7 +819,7 @@ static const wchar_t *param_match2(const complete_entry_opt_t *e, const wchar_t
|
|||
/// Returns the position of the last option character (e.g. the position of z which is 2).
|
||||
/// Everything after that is assumed to be part of the parameter.
|
||||
/// Returns wcstring::npos if there is no valid short option.
|
||||
size_t short_option_pos(const wcstring &arg, const option_list_t &options) {
|
||||
static size_t short_option_pos(const wcstring &arg, const option_list_t &options) {
|
||||
if (arg.size() <= 1 || leading_dash_count(arg.c_str()) != 1) {
|
||||
return wcstring::npos;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "common.h"
|
||||
#include "complete.h"
|
||||
#include "env.h"
|
||||
#include "env_dispatch.h"
|
||||
#include "env_universal_common.h"
|
||||
#include "event.h"
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
|
@ -381,18 +382,18 @@ static void update_fish_color_support(const environment_t &vars) {
|
|||
} else if (cur_term != nullptr && max_colors >= 32767) {
|
||||
// $TERM wins, xterm-direct reports 32767 colors, we assume that's the minimum
|
||||
// as xterm is weird when it comes to color.
|
||||
FLOGF(term_support, L"Truecolor support: Enabling per terminfo for %ls with %d colors", term.c_str(), max_colors);
|
||||
FLOGF(term_support, L"Truecolor support: Enabling per terminfo for %ls with %d colors",
|
||||
term.c_str(), max_colors);
|
||||
support_term24bit = true;
|
||||
} else {
|
||||
if (auto ct = vars.get(L"COLORTERM")) {
|
||||
// If someone set $COLORTERM, that's the sort of color they want.
|
||||
if (ct->as_string() == L"truecolor"
|
||||
|| ct->as_string() == L"24bit") {
|
||||
FLOGF(term_support, L"Truecolor support: Enabling per $COLORTERM='%ls'", ct->as_string().c_str());
|
||||
if (ct->as_string() == L"truecolor" || ct->as_string() == L"24bit") {
|
||||
FLOGF(term_support, L"Truecolor support: Enabling per $COLORTERM='%ls'",
|
||||
ct->as_string().c_str());
|
||||
support_term24bit = true;
|
||||
}
|
||||
} else if (vars.get(L"KONSOLE_VERSION")
|
||||
|| vars.get(L"KONSOLE_PROFILE_NAME")) {
|
||||
} else if (vars.get(L"KONSOLE_VERSION") || vars.get(L"KONSOLE_PROFILE_NAME")) {
|
||||
// All konsole versions that use $KONSOLE_VERSION are new enough to support this,
|
||||
// so no check is necessary.
|
||||
FLOGF(term_support, L"Truecolor support: Enabling for Konsole");
|
||||
|
@ -410,7 +411,8 @@ static void update_fish_color_support(const environment_t &vars) {
|
|||
support_term24bit = true;
|
||||
} else if (auto vte = vars.get(L"VTE_VERSION")) {
|
||||
if (fish_wcstod(vte->as_string().c_str(), nullptr) > 3600) {
|
||||
FLOGF(term_support, L"Truecolor support: Enabling for VTE version %ls", vte->as_string().c_str());
|
||||
FLOGF(term_support, L"Truecolor support: Enabling for VTE version %ls",
|
||||
vte->as_string().c_str());
|
||||
support_term24bit = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ void env_dispatch_init(const environment_t &vars);
|
|||
|
||||
class env_stack_t;
|
||||
void env_dispatch_var_change(const wcstring &key, env_stack_t &vars);
|
||||
void guess_emoji_width();
|
||||
|
||||
void env_universal_callbacks(env_stack_t *stack, const callback_data_list_t &callbacks);
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ int g_fish_emoji_width = 0;
|
|||
// 1 is the typical emoji width in Unicode 8.
|
||||
int g_guessed_fish_emoji_width = 1;
|
||||
|
||||
int fish_get_emoji_width(wchar_t c) {
|
||||
static int fish_get_emoji_width(wchar_t c) {
|
||||
(void)c;
|
||||
// Respect an explicit value. If we don't have one, use the guessed value. Do not try to fall
|
||||
// back to wcwidth(), it's hopeless.
|
||||
|
|
|
@ -84,7 +84,7 @@ class fish_cmd_opts_t {
|
|||
};
|
||||
|
||||
/// \return a timeval converted to milliseconds.
|
||||
long long tv_to_msec(const struct timeval &tv) {
|
||||
static long long tv_to_msec(const struct timeval &tv) {
|
||||
long long msec = static_cast<long long>(tv.tv_sec) * 1000; // milliseconds per second
|
||||
msec += tv.tv_usec / 1000; // microseconds per millisecond
|
||||
return msec;
|
||||
|
@ -248,7 +248,8 @@ static void read_init(parser_t &parser, const struct config_paths_t &paths) {
|
|||
}
|
||||
}
|
||||
|
||||
int run_command_list(parser_t &parser, std::vector<std::string> *cmds, const io_chain_t &io) {
|
||||
static int run_command_list(parser_t &parser, std::vector<std::string> *cmds,
|
||||
const io_chain_t &io) {
|
||||
for (const auto &cmd : *cmds) {
|
||||
wcstring cmd_wcs = str2wcstring(cmd);
|
||||
parser.eval(cmd_wcs, io);
|
||||
|
|
|
@ -164,8 +164,8 @@ static highlight_role_t get_fallback(highlight_role_t role) {
|
|||
/// false: the filesystem is not case insensitive
|
||||
/// true: the file system is case insensitive
|
||||
using case_sensitivity_cache_t = std::unordered_map<wcstring, bool>;
|
||||
bool fs_is_case_insensitive(const wcstring &path, int fd,
|
||||
case_sensitivity_cache_t &case_sensitivity_cache) {
|
||||
static bool fs_is_case_insensitive(const wcstring &path, int fd,
|
||||
case_sensitivity_cache_t &case_sensitivity_cache) {
|
||||
bool result = false;
|
||||
#ifdef _PC_CASE_SENSITIVE
|
||||
// Try the cache first.
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
#include "common.h"
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
|
||||
bool string_less_than_string(const wchar_t *a, const wchar_t *b) { return std::wcscmp(a, b) < 0; }
|
||||
static bool string_less_than_string(const wchar_t *a, const wchar_t *b) {
|
||||
return std::wcscmp(a, b) < 0;
|
||||
}
|
||||
|
||||
/// The table of intern'd strings.
|
||||
owning_lock<std::vector<const wchar_t *>> string_table;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// previous cuts.
|
||||
#include "config.h" // IWYU pragma: keep
|
||||
|
||||
#include "kill.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
|
|
@ -773,7 +773,7 @@ bool parse_util_argument_is_help(const wchar_t *s) {
|
|||
|
||||
// \return a pointer to the first argument node of an argument_or_redirection_list_t, or nullptr if
|
||||
// there are no arguments.
|
||||
const ast::argument_t *get_first_arg(const ast::argument_or_redirection_list_t &list) {
|
||||
static const ast::argument_t *get_first_arg(const ast::argument_or_redirection_list_t &list) {
|
||||
for (const ast::argument_or_redirection_t &v : list) {
|
||||
if (v.is_argument()) return &v.argument();
|
||||
}
|
||||
|
|
|
@ -527,7 +527,7 @@ event_t proc_create_event(const wchar_t *msg, event_type_t type, pid_t pid, int
|
|||
|
||||
/// Remove all disowned jobs whose job chain is fully constructed (that is, do not erase disowned
|
||||
/// jobs that still have an in-flight parent job). Note we never print statuses for such jobs.
|
||||
void remove_disowned_jobs(job_list_t &jobs) {
|
||||
static void remove_disowned_jobs(job_list_t &jobs) {
|
||||
auto iter = jobs.begin();
|
||||
while (iter != jobs.end()) {
|
||||
const auto &j = *iter;
|
||||
|
|
|
@ -135,8 +135,8 @@ static inline uint32_t read_generation_count() {
|
|||
/// \return an operation context for a background operation..
|
||||
/// Crucially the operation context itself does not contain a parser.
|
||||
/// It is the caller's responsibility to ensure the environment lives as long as the result.
|
||||
operation_context_t get_bg_context(const std::shared_ptr<environment_t> &env,
|
||||
uint32_t generation_count) {
|
||||
static operation_context_t get_bg_context(const std::shared_ptr<environment_t> &env,
|
||||
uint32_t generation_count) {
|
||||
cancel_checker_t cancel_checker = [generation_count] {
|
||||
// Cancel if the generation count changed.
|
||||
return generation_count != read_generation_count();
|
||||
|
@ -732,7 +732,7 @@ void reader_sighup() {
|
|||
s_sighup_received = true;
|
||||
}
|
||||
|
||||
void redirect_tty_after_sighup() {
|
||||
static void redirect_tty_after_sighup() {
|
||||
// If we have received SIGHUP, redirect the tty to avoid a user script triggering SIGTTIN or
|
||||
// SIGTTOU.
|
||||
assert(s_sighup_received && "SIGHUP not received");
|
||||
|
@ -2248,7 +2248,7 @@ void reader_data_t::set_buffer_maintaining_pager(const wcstring &b, size_t pos,
|
|||
history_search.reset();
|
||||
}
|
||||
|
||||
void set_env_cmd_duration(struct timeval *after, struct timeval *before, env_stack_t &vars) {
|
||||
static void set_env_cmd_duration(struct timeval *after, struct timeval *before, env_stack_t &vars) {
|
||||
time_t secs = after->tv_sec - before->tv_sec;
|
||||
suseconds_t usecs = after->tv_usec - before->tv_usec;
|
||||
|
||||
|
@ -2260,7 +2260,9 @@ void set_env_cmd_duration(struct timeval *after, struct timeval *before, env_sta
|
|||
vars.set_one(ENV_CMD_DURATION, ENV_UNEXPORT, std::to_wstring((secs * 1000) + (usecs / 1000)));
|
||||
}
|
||||
|
||||
eval_res_t reader_run_command(parser_t &parser, const wcstring &cmd) {
|
||||
/// Run the specified command with the correct terminal modes, and while taking care to perform job
|
||||
/// notification, set the title, etc.
|
||||
static eval_res_t reader_run_command(parser_t &parser, const wcstring &cmd) {
|
||||
struct timeval time_before, time_after;
|
||||
|
||||
wcstring ft = tok_command(cmd);
|
||||
|
|
|
@ -144,10 +144,6 @@ void reader_schedule_prompt_repaint();
|
|||
class char_event_t;
|
||||
void reader_queue_ch(const char_event_t &ch);
|
||||
|
||||
/// Run the specified command with the correct terminal modes, and while taking care to perform job
|
||||
/// notification, set the title, etc.
|
||||
void reader_run_command(const wcstring &buff);
|
||||
|
||||
/// Get the string of character currently entered into the command buffer, or 0 if interactive mode
|
||||
/// is uninitialized.
|
||||
const wchar_t *reader_get_buffer();
|
||||
|
|
|
@ -58,7 +58,7 @@ enum {
|
|||
TOK_INFIX
|
||||
};
|
||||
|
||||
int get_arity(const int type) {
|
||||
static int get_arity(const int type) {
|
||||
if (type == TE_FUNCTION3) return 3;
|
||||
if (type == TE_FUNCTION2) return 2;
|
||||
if (type == TE_FUNCTION1) return 1;
|
||||
|
@ -120,7 +120,7 @@ static te_expr *new_expr(const int type, const te_expr *parameters[]) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void te_free_parameters(te_expr *n) {
|
||||
static void te_free_parameters(te_expr *n) {
|
||||
if (!n) return;
|
||||
int arity = get_arity(n->type);
|
||||
// Free all parameters from the back to the front.
|
||||
|
@ -168,7 +168,6 @@ static double ncr(double n, double r) {
|
|||
|
||||
static double npr(double n, double r) { return ncr(n, r) * fac(r); }
|
||||
|
||||
|
||||
static constexpr double bit_and(double a, double b) {
|
||||
return static_cast<double>(static_cast<long long>(a) & static_cast<long long>(b));
|
||||
}
|
||||
|
@ -239,7 +238,7 @@ static constexpr double divide(double a, double b) {
|
|||
|
||||
static constexpr double negate(double a) { return -a; }
|
||||
|
||||
void next_token(state *s) {
|
||||
static void next_token(state *s) {
|
||||
s->type = TOK_NULL;
|
||||
|
||||
do {
|
||||
|
|
|
@ -587,7 +587,7 @@ ssize_t wwrite_to_fd(const wchar_t *input, size_t input_len, int fd) {
|
|||
}
|
||||
|
||||
/// Return one if the code point is in a Unicode private use area.
|
||||
int fish_is_pua(wint_t wc) {
|
||||
static int fish_is_pua(wint_t wc) {
|
||||
if (PUA1_START <= wc && wc < PUA1_END) return 1;
|
||||
if (PUA2_START <= wc && wc < PUA2_END) return 1;
|
||||
if (PUA3_START <= wc && wc < PUA3_END) return 1;
|
||||
|
|
Loading…
Reference in a new issue