mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
lint: remove or comment out unused functions
Cppcheck has identified a lot of unused functions. This removes funcs that are unlikely to ever be used. Others that might be useful for debugging I've commented out with "#if 0".
This commit is contained in:
parent
3f1fc332e7
commit
9dd6873e58
10 changed files with 25 additions and 74 deletions
|
@ -3925,6 +3925,8 @@ static int builtin_history(parser_t &parser, io_streams_t &streams, wchar_t **ar
|
|||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809.
|
||||
int builtin_parse(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
||||
{
|
||||
struct sigaction act;
|
||||
|
@ -3966,6 +3968,7 @@ int builtin_parse(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
|||
}
|
||||
return STATUS_BUILTIN_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
int builtin_true(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
||||
{
|
||||
|
@ -3992,6 +3995,7 @@ static const builtin_data_t builtin_datas[]=
|
|||
{
|
||||
{ L"[", &builtin_test, N_(L"Test a condition") },
|
||||
#if 0
|
||||
// Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809.
|
||||
{ L"__fish_parse", &builtin_parse, N_(L"Try out the new parser") },
|
||||
#endif
|
||||
{ L"and", &builtin_generic, N_(L"Execute command if previous command suceeded") },
|
||||
|
|
|
@ -689,11 +689,6 @@ void debug(int level, const char *msg, ...)
|
|||
errno = errno_old;
|
||||
}
|
||||
|
||||
void print_stderr(const wcstring &str)
|
||||
{
|
||||
fprintf(stderr, "%ls\n", str.c_str());
|
||||
}
|
||||
|
||||
void read_ignore(int fd, void *buff, size_t count)
|
||||
{
|
||||
size_t ignore __attribute__((unused));
|
||||
|
|
|
@ -811,9 +811,6 @@ ssize_t read_loop(int fd, void *buff, size_t count);
|
|||
void debug(int level, const char *msg, ...);
|
||||
void debug(int level, const wchar_t *msg, ...);
|
||||
|
||||
/** Writes a string to stderr, followed by a newline */
|
||||
void print_stderr(const wcstring &str);
|
||||
|
||||
/**
|
||||
Replace special characters with backslash escape sequences. Newline is
|
||||
replaced with \n, etc.
|
||||
|
|
|
@ -1998,62 +1998,6 @@ bool fish_xdm_login_hack_hack_hack_hack(std::vector<std::string> *cmds, int argc
|
|||
return result;
|
||||
}
|
||||
|
||||
bool fish_openSUSE_dbus_hack_hack_hack_hack(std::vector<completion_t> *args)
|
||||
{
|
||||
static signed char isSUSE = -1;
|
||||
if (isSUSE == 0)
|
||||
return false;
|
||||
|
||||
bool result = false;
|
||||
if (args && ! args->empty())
|
||||
{
|
||||
const wcstring &cmd = args->at(0).completion;
|
||||
if (cmd.find(L"DBUS_SESSION_BUS_") != wcstring::npos)
|
||||
{
|
||||
/* See if we are SUSE */
|
||||
if (isSUSE < 0)
|
||||
{
|
||||
struct stat buf = {};
|
||||
isSUSE = (0 == stat("/etc/SuSE-release", &buf));
|
||||
}
|
||||
|
||||
if (isSUSE)
|
||||
{
|
||||
/* Look for an equal sign */
|
||||
size_t where = cmd.find(L'=');
|
||||
if (where != wcstring::npos)
|
||||
{
|
||||
/* Oh my. It's presumably of the form foo=bar; find the = and split */
|
||||
const wcstring key = wcstring(cmd, 0, where);
|
||||
|
||||
/* Trim whitespace and semicolon */
|
||||
wcstring val = wcstring(cmd, where+1);
|
||||
size_t last_good = val.find_last_not_of(L"\n ;");
|
||||
if (last_good != wcstring::npos)
|
||||
val.resize(last_good + 1);
|
||||
|
||||
args->clear();
|
||||
append_completion(args, L"set");
|
||||
if (key == L"DBUS_SESSION_BUS_ADDRESS")
|
||||
append_completion(args, L"-x");
|
||||
append_completion(args, key);
|
||||
append_completion(args, val);
|
||||
result = true;
|
||||
}
|
||||
else if (string_prefixes_string(L"export DBUS_SESSION_BUS_ADDRESS;", cmd))
|
||||
{
|
||||
/* Nothing, we already exported it */
|
||||
args->clear();
|
||||
append_completion(args, L"echo");
|
||||
append_completion(args, L"-n");
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool expand_abbreviation(const wcstring &src, wcstring *output)
|
||||
{
|
||||
if (src.empty())
|
||||
|
|
|
@ -168,7 +168,6 @@ bool expand_abbreviation(const wcstring &src, wcstring *output);
|
|||
|
||||
/* Terrible hacks */
|
||||
bool fish_xdm_login_hack_hack_hack_hack(std::vector<std::string> *cmds, int argc, const char * const *argv);
|
||||
bool fish_openSUSE_dbus_hack_hack_hack_hack(std::vector<completion_t> *args);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2887,8 +2887,7 @@ public:
|
|||
static void test_history(void);
|
||||
static void test_history_merge(void);
|
||||
static void test_history_formats(void);
|
||||
static void test_history_speed(void);
|
||||
|
||||
// static void test_history_speed(void);
|
||||
static void test_history_races(void);
|
||||
static void test_history_races_pound_on_history();
|
||||
};
|
||||
|
@ -3378,6 +3377,8 @@ void history_tests_t::test_history_formats(void)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// This test isn't run at this time. It was added by commit b9283d48 but not actually enabled.
|
||||
void history_tests_t::test_history_speed(void)
|
||||
{
|
||||
say(L"Testing history speed (pid is %d)", getpid());
|
||||
|
@ -3403,6 +3404,7 @@ void history_tests_t::test_history_speed(void)
|
|||
hist->clear();
|
||||
delete hist;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void test_new_parser_correctness(void)
|
||||
{
|
||||
|
@ -4483,8 +4485,8 @@ int main(int argc, char **argv)
|
|||
if (should_test_function("history_merge")) history_tests_t::test_history_merge();
|
||||
if (should_test_function("history_races")) history_tests_t::test_history_races();
|
||||
if (should_test_function("history_formats")) history_tests_t::test_history_formats();
|
||||
//history_tests_t::test_history_speed();
|
||||
if (should_test_function("string")) test_string();
|
||||
// history_tests_t::test_history_speed();
|
||||
|
||||
say(L"Encountered %d errors in low-level tests", err_count);
|
||||
if (s_test_run_count == 0)
|
||||
|
|
|
@ -183,6 +183,9 @@ void io_chain_t::append(const io_chain_t &chain)
|
|||
this->insert(this->end(), chain.begin(), chain.end());
|
||||
}
|
||||
|
||||
#if 0
|
||||
// This isn't used so the lint tools were complaining about its presence. I'm keeping it in the
|
||||
// source because it could be useful for debugging.
|
||||
void io_print(const io_chain_t &chain)
|
||||
{
|
||||
if (chain.empty())
|
||||
|
@ -206,6 +209,7 @@ void io_print(const io_chain_t &chain)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the given fd is used by the io chain, duplicates it repeatedly until an fd not used in the io chain is found, or we run out. If we return a new fd or an error, closes the old one. Any fd created is marked close-on-exec. Returns -1 on failure (in which case the given fd is still closed). */
|
||||
static int move_fd_to_unused(int fd, const io_chain_t &io_chain)
|
||||
|
|
4
src/io.h
4
src/io.h
|
@ -304,7 +304,9 @@ struct io_streams_t
|
|||
}
|
||||
};
|
||||
|
||||
/** Print debug information about the specified IO redirection chain to stderr. */
|
||||
#if 0
|
||||
// Print debug information about the specified IO redirection chain to stderr.
|
||||
void io_print(const io_chain_t &chain);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -842,8 +842,6 @@ int parser_t::eval_acquiring_tree(const wcstring &cmd, const io_chain_t &io, enu
|
|||
return 0;
|
||||
}
|
||||
|
||||
//print_stderr(block_stack_description());
|
||||
|
||||
/* Determine the initial eval level. If this is the first context, it's -1; otherwise it's the eval level of the top context. This is sort of wonky because we're stitching together a global notion of eval level from these separate objects. A better approach would be some profile object that all contexts share, and that tracks the eval levels on its own. */
|
||||
int exec_eval_level = (execution_contexts.empty() ? -1 : execution_contexts.back()->current_eval_level());
|
||||
|
||||
|
|
12
src/proc.cpp
12
src/proc.cpp
|
@ -94,15 +94,21 @@ size_t job_iterator_t::count() const
|
|||
return this->job_list->size();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// This isn't used so the lint tools were complaining about its presence. I'm keeping it in the
|
||||
// source because it could be useful for debugging. However, it would probably be better to add a
|
||||
// verbose or debug option to the builtin `jobs` command.
|
||||
void print_jobs(void)
|
||||
{
|
||||
job_iterator_t jobs;
|
||||
job_t *j;
|
||||
while ((j = jobs.next()))
|
||||
{
|
||||
printf("%p -> %ls -> (foreground %d, complete %d, stopped %d, constructed %d)\n", j, j->command_wcstr(), job_get_flag(j, JOB_FOREGROUND), job_is_completed(j), job_is_stopped(j), job_get_flag(j, JOB_CONSTRUCTED));
|
||||
while (j = jobs.next()) {
|
||||
printf("%p -> %ls -> (foreground %d, complete %d, stopped %d, constructed %d)\n",
|
||||
j, j->command_wcstr(), job_get_flag(j, JOB_FOREGROUND), job_is_completed(j),
|
||||
job_is_stopped(j), job_get_flag(j, JOB_CONSTRUCTED));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int is_interactive_session=0;
|
||||
int is_subshell=0;
|
||||
|
|
Loading…
Reference in a new issue