mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 12:11:20 -03:00
Mark a bunch of constructors as explicit
This prevents undesired implicit conversions
This commit is contained in:
@@ -27,7 +27,7 @@ file_access_attempt_t access_file(const wcstring &path, int mode);
|
||||
|
||||
struct autoload_function_t : public lru_node_t
|
||||
{
|
||||
autoload_function_t(const wcstring &key) : lru_node_t(key), access(), is_loaded(false), is_placeholder(false), is_internalized(false) { }
|
||||
explicit autoload_function_t(const wcstring &key) : lru_node_t(key), access(), is_loaded(false), is_placeholder(false), is_internalized(false) { }
|
||||
file_access_attempt_t access; /** The last access attempt */
|
||||
bool is_loaded; /** Whether we have actually loaded this function */
|
||||
bool is_placeholder; /** Whether we are a placeholder that stands in for "no such function". If this is true, then is_loaded must be false. */
|
||||
|
||||
@@ -2805,7 +2805,7 @@ static int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
||||
wcstring tokens;
|
||||
tokens.reserve(buff.size());
|
||||
bool empty = true;
|
||||
|
||||
|
||||
for (wcstring_range loc = wcstring_tok(buff, ifs); loc.first != wcstring::npos; loc = wcstring_tok(buff, ifs, loc))
|
||||
{
|
||||
if (!empty) tokens.push_back(ARRAY_SEP);
|
||||
@@ -2820,7 +2820,7 @@ static int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
||||
|
||||
while (i<argc)
|
||||
{
|
||||
loc = wcstring_tok(buff, (i+1<argc) ? ifs : L"", loc);
|
||||
loc = wcstring_tok(buff, (i+1<argc) ? ifs : wcstring(), loc);
|
||||
env_set(argv[i], loc.first == wcstring::npos ? L"" : &buff.c_str()[loc.first], place);
|
||||
|
||||
++i;
|
||||
@@ -3141,7 +3141,7 @@ static int builtin_cd(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
dir_in = argv[1];
|
||||
dir_in = env_var_t(argv[1]);
|
||||
}
|
||||
|
||||
bool got_cd_path = false;
|
||||
|
||||
@@ -126,7 +126,7 @@ class builtin_commandline_scoped_transient_t
|
||||
{
|
||||
size_t token;
|
||||
public:
|
||||
builtin_commandline_scoped_transient_t(const wcstring &cmd);
|
||||
explicit builtin_commandline_scoped_transient_t(const wcstring &cmd);
|
||||
~builtin_commandline_scoped_transient_t();
|
||||
};
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ struct builtin_printf_state_t
|
||||
/* Whether we should stop outputting. This gets set in the case of an error, and also with the \c escape. */
|
||||
bool early_exit;
|
||||
|
||||
builtin_printf_state_t(io_streams_t &s) : streams(s), exit_code(0), early_exit(false)
|
||||
explicit builtin_printf_state_t(io_streams_t &s) : streams(s), exit_code(0), early_exit(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
test_parser(const wcstring_list_t &val) : strings(val)
|
||||
explicit test_parser(const wcstring_list_t &val) : strings(val)
|
||||
{ }
|
||||
|
||||
expression *parse_expression(unsigned int start, unsigned int end);
|
||||
|
||||
16
src/common.h
16
src/common.h
@@ -357,7 +357,7 @@ struct string_fuzzy_match_t
|
||||
size_t match_distance_second;
|
||||
|
||||
/* Constructor */
|
||||
string_fuzzy_match_t(enum fuzzy_match_type_t t, size_t distance_first = 0, size_t distance_second = 0);
|
||||
explicit string_fuzzy_match_t(enum fuzzy_match_type_t t, size_t distance_first = 0, size_t distance_second = 0);
|
||||
|
||||
/* Return -1, 0, 1 if this match is (respectively) better than, equal to, or worse than rhs */
|
||||
int compare(const string_fuzzy_match_t &rhs) const;
|
||||
@@ -486,7 +486,7 @@ class null_terminated_array_t
|
||||
|
||||
public:
|
||||
null_terminated_array_t() : array(NULL) { }
|
||||
null_terminated_array_t(const string_list_t &argv) : array(make_null_terminated_array(argv))
|
||||
explicit null_terminated_array_t(const string_list_t &argv) : array(make_null_terminated_array(argv))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -576,8 +576,8 @@ class scoped_lock
|
||||
public:
|
||||
void lock(void);
|
||||
void unlock(void);
|
||||
scoped_lock(pthread_mutex_t &mutex);
|
||||
scoped_lock(mutex_lock_t &lock);
|
||||
explicit scoped_lock(pthread_mutex_t &mutex);
|
||||
explicit scoped_lock(mutex_lock_t &lock);
|
||||
~scoped_lock();
|
||||
};
|
||||
|
||||
@@ -607,7 +607,7 @@ class scoped_rwlock
|
||||
|
||||
/* No copying */
|
||||
scoped_rwlock &operator=(const scoped_lock &);
|
||||
scoped_rwlock(const scoped_lock &);
|
||||
explicit scoped_rwlock(const scoped_lock &);
|
||||
|
||||
public:
|
||||
void lock(void);
|
||||
@@ -619,8 +619,8 @@ class scoped_rwlock
|
||||
equivalent to `lock.unlock_shared(); lock.lock();`
|
||||
*/
|
||||
void upgrade(void);
|
||||
scoped_rwlock(pthread_rwlock_t &rwlock, bool shared = false);
|
||||
scoped_rwlock(rwlock_t &rwlock, bool shared = false);
|
||||
explicit scoped_rwlock(pthread_rwlock_t &rwlock, bool shared = false);
|
||||
explicit scoped_rwlock(rwlock_t &rwlock, bool shared = false);
|
||||
~scoped_rwlock();
|
||||
};
|
||||
|
||||
@@ -639,7 +639,7 @@ class scoped_push
|
||||
bool restored;
|
||||
|
||||
public:
|
||||
scoped_push(T *r): ref(r), saved_value(*r), restored(false)
|
||||
explicit scoped_push(T *r): ref(r), saved_value(*r), restored(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class completion_t
|
||||
complete_flags_t flags;
|
||||
|
||||
/* Construction. Note: defining these so that they are not inlined reduces the executable size. */
|
||||
completion_t(const wcstring &comp, const wcstring &desc = wcstring(), string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), complete_flags_t flags_val = 0);
|
||||
explicit completion_t(const wcstring &comp, const wcstring &desc = wcstring(), string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), complete_flags_t flags_val = 0);
|
||||
completion_t(const completion_t &);
|
||||
completion_t &operator=(const completion_t &);
|
||||
|
||||
|
||||
@@ -101,12 +101,11 @@ class env_var_t : public wcstring
|
||||
private:
|
||||
bool is_missing;
|
||||
public:
|
||||
static env_var_t missing_var(void)
|
||||
static env_var_t missing_var()
|
||||
{
|
||||
env_var_t result(L"");
|
||||
env_var_t result((wcstring()));
|
||||
result.is_missing = true;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
env_var_t(const env_var_t &x) : wcstring(x), is_missing(x.is_missing) { }
|
||||
|
||||
@@ -338,7 +338,7 @@ env_var_t env_universal_t::get(const wcstring &name) const
|
||||
var_table_t::const_iterator where = vars.find(name);
|
||||
if (where != vars.end())
|
||||
{
|
||||
result = where->second.val;
|
||||
result = env_var_t(where->second.val);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1454,7 +1454,7 @@ class universal_notifier_named_pipe_t : public universal_notifier_t
|
||||
}
|
||||
|
||||
public:
|
||||
universal_notifier_named_pipe_t(const wchar_t *test_path) : pipe_fd(-1), readback_time_usec(0), readback_amount(0), polling_due_to_readable_fd(false), drain_if_still_readable_time_usec(0)
|
||||
explicit universal_notifier_named_pipe_t(const wchar_t *test_path) : pipe_fd(-1), readback_time_usec(0), readback_amount(0), polling_due_to_readable_fd(false), drain_if_still_readable_time_usec(0)
|
||||
{
|
||||
make_pipe(test_path);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class env_universal_t
|
||||
static var_table_t read_message_internal(int fd);
|
||||
|
||||
public:
|
||||
env_universal_t(const wcstring &path);
|
||||
explicit env_universal_t(const wcstring &path);
|
||||
~env_universal_t();
|
||||
|
||||
/* Get the value of the variable with the specified name */
|
||||
|
||||
@@ -87,7 +87,7 @@ struct event_t
|
||||
*/
|
||||
wcstring_list_t arguments;
|
||||
|
||||
event_t(int t);
|
||||
explicit event_t(int t);
|
||||
~event_t();
|
||||
|
||||
static event_t signal_event(int sig);
|
||||
|
||||
@@ -1318,7 +1318,7 @@ static void test_escape_sequences(void)
|
||||
class lru_node_test_t : public lru_node_t
|
||||
{
|
||||
public:
|
||||
lru_node_test_t(const wcstring &tmp) : lru_node_t(tmp) { }
|
||||
explicit lru_node_test_t(const wcstring &tmp) : lru_node_t(tmp) { }
|
||||
};
|
||||
|
||||
class test_lru_t : public lru_cache_t<lru_node_test_t>
|
||||
|
||||
@@ -129,7 +129,7 @@ class time_profiler_t
|
||||
double start;
|
||||
public:
|
||||
|
||||
time_profiler_t(const char *w)
|
||||
explicit time_profiler_t(const char *w)
|
||||
{
|
||||
if (LOG_TIMES)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ class history_lru_node_t : public lru_node_t
|
||||
public:
|
||||
time_t timestamp;
|
||||
path_list_t required_paths;
|
||||
history_lru_node_t(const history_item_t &item) :
|
||||
explicit history_lru_node_t(const history_item_t &item) :
|
||||
lru_node_t(item.str()),
|
||||
timestamp(item.timestamp()),
|
||||
required_paths(item.required_paths)
|
||||
@@ -183,7 +183,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
history_lru_cache_t(size_t max) : lru_cache_t<history_lru_node_t>(max) { }
|
||||
explicit history_lru_cache_t(size_t max) : lru_cache_t<history_lru_node_t>(max) { }
|
||||
|
||||
/* Function to add a history item */
|
||||
void add_item(const history_item_t &item)
|
||||
|
||||
@@ -116,7 +116,7 @@ class history_t
|
||||
history_t &operator=(const history_t&);
|
||||
|
||||
/** Private creator */
|
||||
history_t(const wcstring &pname);
|
||||
explicit history_t(const wcstring &pname);
|
||||
|
||||
/** Privately add an item. If pending, the item will not be returned by history searches until a call to resolve_pending. */
|
||||
void add(const history_item_t &item, bool pending = false);
|
||||
@@ -348,7 +348,7 @@ void history_sanity_check();
|
||||
struct file_detection_context_t
|
||||
{
|
||||
/* Constructor */
|
||||
file_detection_context_t(history_t *hist, history_identifier_t ident = 0);
|
||||
explicit file_detection_context_t(history_t *hist, history_identifier_t ident = 0);
|
||||
|
||||
/* Determine which of potential_paths are valid, and put them in valid_paths */
|
||||
int perform_file_detection();
|
||||
|
||||
6
src/io.h
6
src/io.h
@@ -56,7 +56,7 @@ class io_data_t
|
||||
class io_close_t : public io_data_t
|
||||
{
|
||||
public:
|
||||
io_close_t(int f) :
|
||||
explicit io_close_t(int f) :
|
||||
io_data_t(IO_CLOSE, f)
|
||||
{
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class io_buffer_t : public io_pipe_t
|
||||
/** buffer to save output in */
|
||||
std::vector<char> out_buffer;
|
||||
|
||||
io_buffer_t(int f):
|
||||
explicit io_buffer_t(int f):
|
||||
io_pipe_t(IO_BUFFER, f, false /* not input */),
|
||||
out_buffer()
|
||||
{
|
||||
@@ -195,7 +195,7 @@ class io_chain_t : public std::vector<shared_ptr<io_data_t> >
|
||||
{
|
||||
public:
|
||||
io_chain_t();
|
||||
io_chain_t(const shared_ptr<io_data_t> &);
|
||||
explicit io_chain_t(const shared_ptr<io_data_t> &);
|
||||
|
||||
void remove(const shared_ptr<const io_data_t> &element);
|
||||
void push_back(const shared_ptr<io_data_t> &element);
|
||||
|
||||
@@ -35,7 +35,7 @@ class lru_node_t
|
||||
const wcstring key;
|
||||
|
||||
/** Constructor */
|
||||
lru_node_t(const wcstring &pkey) : prev(NULL), next(NULL), key(pkey) { }
|
||||
explicit lru_node_t(const wcstring &pkey) : prev(NULL), next(NULL), key(pkey) { }
|
||||
|
||||
/** Virtual destructor that does nothing for classes that inherit lru_node_t */
|
||||
virtual ~lru_node_t() {}
|
||||
@@ -117,7 +117,7 @@ class lru_cache_t
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
lru_cache_t(size_t max_size = 1024) : max_node_count(max_size), node_count(0), mouth(wcstring())
|
||||
explicit lru_cache_t(size_t max_size = 1024) : max_node_count(max_size), node_count(0), mouth(wcstring())
|
||||
{
|
||||
/* Hook up the mouth to itself: a one node circularly linked list! */
|
||||
mouth.prev = mouth.next = &mouth;
|
||||
@@ -220,7 +220,7 @@ class lru_cache_t
|
||||
{
|
||||
lru_node_t *node;
|
||||
public:
|
||||
iterator(lru_node_t *val) : node(val) { }
|
||||
explicit iterator(lru_node_t *val) : node(val) { }
|
||||
void operator++()
|
||||
{
|
||||
node = lru_cache_t::get_previous(node);
|
||||
|
||||
@@ -628,7 +628,7 @@ class parse_ll_t
|
||||
public:
|
||||
|
||||
/* Constructor */
|
||||
parse_ll_t(enum parse_token_type_t goal) : fatal_errored(false), should_generate_error_messages(true)
|
||||
explicit parse_ll_t(enum parse_token_type_t goal) : fatal_errored(false), should_generate_error_messages(true)
|
||||
{
|
||||
this->symbol_stack.reserve(16);
|
||||
this->nodes.reserve(64);
|
||||
|
||||
@@ -85,7 +85,7 @@ struct block_t
|
||||
{
|
||||
protected:
|
||||
/** Protected constructor. Use one of the subclasses below. */
|
||||
block_t(block_type_t t);
|
||||
explicit block_t(block_type_t t);
|
||||
|
||||
private:
|
||||
const block_type_t block_type; /**< Type of block. */
|
||||
@@ -134,7 +134,7 @@ struct if_block_t : public block_t
|
||||
struct event_block_t : public block_t
|
||||
{
|
||||
event_t const event;
|
||||
event_block_t(const event_t &evt);
|
||||
explicit event_block_t(const event_t &evt);
|
||||
};
|
||||
|
||||
struct function_block_t : public block_t
|
||||
@@ -147,7 +147,7 @@ struct function_block_t : public block_t
|
||||
struct source_block_t : public block_t
|
||||
{
|
||||
const wchar_t * const source_file;
|
||||
source_block_t(const wchar_t *src);
|
||||
explicit source_block_t(const wchar_t *src);
|
||||
};
|
||||
|
||||
struct for_block_t : public block_t
|
||||
@@ -172,7 +172,7 @@ struct fake_block_t : public block_t
|
||||
|
||||
struct scope_block_t : public block_t
|
||||
{
|
||||
scope_block_t(block_type_t type); //must be BEGIN, TOP or SUBST
|
||||
explicit scope_block_t(block_type_t type); //must be BEGIN, TOP or SUBST
|
||||
};
|
||||
|
||||
struct breakpoint_block_t : public block_t
|
||||
|
||||
29
src/proc.cpp
29
src/proc.cpp
@@ -354,8 +354,6 @@ int job_signal(job_t *j, int signal)
|
||||
|
||||
/**
|
||||
Store the status of the process pid that was returned by waitpid.
|
||||
Return 0 if all went well, nonzero otherwise.
|
||||
This is called from a signal handler.
|
||||
*/
|
||||
static void mark_process_status(const job_t *j, process_t *p, int status)
|
||||
{
|
||||
@@ -374,18 +372,7 @@ static void mark_process_status(const job_t *j, process_t *p, int status)
|
||||
{
|
||||
/* This should never be reached */
|
||||
p->completed = 1;
|
||||
|
||||
char mess[MESS_SIZE];
|
||||
snprintf(mess,
|
||||
MESS_SIZE,
|
||||
"Process %ld exited abnormally\n",
|
||||
(long) p->pid);
|
||||
/*
|
||||
If write fails, do nothing. We're in a signal handlers error
|
||||
handler. If things aren't working properly, it's safer to
|
||||
give up.
|
||||
*/
|
||||
write_ignore(2, mess, strlen(mess));
|
||||
fprintf(stderr, "Process %ld exited abnormally\n", (long)p->pid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,10 +386,8 @@ void job_mark_process_as_failed(const job_t *job, process_t *p)
|
||||
}
|
||||
|
||||
/**
|
||||
Handle status update for child \c pid. This function is called by
|
||||
the signal handler, so it mustn't use malloc or any such hitech
|
||||
nonsense.
|
||||
|
||||
Handle status update for child \c pid.
|
||||
|
||||
\param pid the pid of the process whose status changes
|
||||
\param status the status as returned by wait
|
||||
*/
|
||||
@@ -411,14 +396,6 @@ static void handle_child_status(pid_t pid, int status)
|
||||
bool found_proc = false;
|
||||
const job_t *j = NULL;
|
||||
process_t *p = NULL;
|
||||
// char mess[MESS_SIZE];
|
||||
/*
|
||||
snprintf( mess,
|
||||
MESS_SIZE,
|
||||
"Process %d\n",
|
||||
(int) pid );
|
||||
write( 2, mess, strlen(mess ));
|
||||
*/
|
||||
|
||||
job_iterator_t jobs;
|
||||
while (! found_proc && (j = jobs.next()))
|
||||
|
||||
@@ -422,7 +422,7 @@ class job_iterator_t
|
||||
return job;
|
||||
}
|
||||
|
||||
job_iterator_t(job_list_t &jobs);
|
||||
explicit job_iterator_t(job_list_t &jobs);
|
||||
job_iterator_t();
|
||||
size_t count() const;
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ class scoped_buffer_t
|
||||
int (* const old_writer)(char);
|
||||
|
||||
public:
|
||||
scoped_buffer_t(data_buffer_t *buff) : old_buff(s_writeb_buffer), old_writer(output_get_writer())
|
||||
explicit scoped_buffer_t(data_buffer_t *buff) : old_buff(s_writeb_buffer), old_writer(output_get_writer())
|
||||
{
|
||||
s_writeb_buffer = buff;
|
||||
output_set_writer(s_writeb);
|
||||
|
||||
@@ -195,7 +195,7 @@ class move_word_state_machine_t
|
||||
|
||||
public:
|
||||
|
||||
move_word_state_machine_t(move_word_style_t st);
|
||||
explicit move_word_state_machine_t(move_word_style_t st);
|
||||
bool consume_char(wchar_t c);
|
||||
void reset();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user