mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-27 20:31:17 -03:00
Make arguments to builtins const
Prior to this change, builtins would take their arguments as `wchar_t **`. This implies that the order of the arguments may be changed (which is true, `wgetopter` does so) but also that the strings themselves may be changed, which no builtin should do. Switch them all to take `const wchar_t **` instead: now the arguments may be rearranged but their contents may no longer be modified.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "null_terminated_array.h"
|
||||
|
||||
template <typename CharT>
|
||||
static CharT **make_null_terminated_array_helper(
|
||||
static const CharT **make_null_terminated_array_helper(
|
||||
const std::vector<std::basic_string<CharT> > &argv) {
|
||||
size_t count = argv.size();
|
||||
|
||||
@@ -48,14 +48,14 @@ static CharT **make_null_terminated_array_helper(
|
||||
assert(reinterpret_cast<unsigned char *>(strings) - base ==
|
||||
static_cast<std::ptrdiff_t>(pointers_allocation_len + strings_allocation_len));
|
||||
|
||||
return reinterpret_cast<CharT **>(base);
|
||||
return reinterpret_cast<const CharT **>(base);
|
||||
}
|
||||
|
||||
wchar_t **make_null_terminated_array(const wcstring_list_t &lst) {
|
||||
const wchar_t **make_null_terminated_array(const wcstring_list_t &lst) {
|
||||
return make_null_terminated_array_helper(lst);
|
||||
}
|
||||
|
||||
char **make_null_terminated_array(const std::vector<std::string> &lst) {
|
||||
const char **make_null_terminated_array(const std::vector<std::string> &lst) {
|
||||
return make_null_terminated_array_helper(lst);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user