mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 15:30:40 +08:00
Make C_ (gettext used in completions) return wcstring
This commit is contained in:
parent
fa854d7a01
commit
16459099af
|
@ -232,6 +232,7 @@ bool autoload_t::locate_file_and_maybe_load_it(const wcstring &cmd, bool really_
|
|||
/* If we can use this function, return whether we were able to access it */
|
||||
if (use_cached)
|
||||
{
|
||||
assert(func != NULL);
|
||||
return func->is_internalized || func->access.accessible;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -613,7 +613,7 @@ static int builtin_bind_erase(wchar_t **seq, int all, const wchar_t *mode, int u
|
|||
wcstring seq2;
|
||||
if (get_terminfo_sequence(*seq++, &seq2))
|
||||
{
|
||||
input_mapping_erase(seq2.c_str(), mode);
|
||||
input_mapping_erase(seq2, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -255,7 +255,6 @@ char *wcs2str(const wchar_t *in)
|
|||
{
|
||||
if (! in)
|
||||
return NULL;
|
||||
char *out;
|
||||
size_t desired_size = MAX_UTF8_BYTES*wcslen(in)+1;
|
||||
char local_buff[512];
|
||||
if (desired_size <= sizeof local_buff / sizeof *local_buff)
|
||||
|
@ -277,7 +276,7 @@ char *wcs2str(const wchar_t *in)
|
|||
else
|
||||
{
|
||||
// here we fall into the bad case of allocating a buffer probably much larger than necessary
|
||||
out = (char *)malloc(MAX_UTF8_BYTES*wcslen(in)+1);
|
||||
char *out = (char *)malloc(MAX_UTF8_BYTES*wcslen(in)+1);
|
||||
if (!out)
|
||||
{
|
||||
DIE_MEM();
|
||||
|
|
21
complete.cpp
21
complete.cpp
|
@ -101,9 +101,15 @@
|
|||
response)
|
||||
*/
|
||||
#ifdef USE_GETTEXT
|
||||
#define C_(wstr) ((wcscmp(wstr, L"")==0)?L"":wgettext(wstr))
|
||||
static const wchar_t *C_(const wcstring &s)
|
||||
{
|
||||
return s.empty() ? L"" : wgettext(s);
|
||||
}
|
||||
#else
|
||||
#define C_(string) (string)
|
||||
static const wcstring &C_(const wcstring &s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Testing apparatus */
|
||||
|
@ -158,10 +164,9 @@ typedef struct complete_entry_opt
|
|||
/** Completion flags */
|
||||
complete_flags_t flags;
|
||||
|
||||
const wchar_t *localized_desc() const
|
||||
const wcstring localized_desc() const
|
||||
{
|
||||
const wchar_t *tmp = desc.c_str();
|
||||
return C_(tmp);
|
||||
return C_(desc);
|
||||
}
|
||||
} complete_entry_opt_t;
|
||||
|
||||
|
@ -1535,7 +1540,7 @@ bool completer_t::complete_param(const wcstring &scmd_orig, const wcstring &spop
|
|||
if (o->short_opt != L'\0' &&
|
||||
short_ok(str, o->short_opt, iter->short_opt_str))
|
||||
{
|
||||
const wchar_t *desc = o->localized_desc();
|
||||
const wcstring desc = o->localized_desc();
|
||||
wchar_t completion[2];
|
||||
completion[0] = o->short_opt;
|
||||
completion[1] = 0;
|
||||
|
@ -2110,7 +2115,7 @@ void complete_print(wcstring &out)
|
|||
for (std::vector<const completion_entry_t *>::const_iterator iter = all_completions.begin(); iter != all_completions.end(); ++iter)
|
||||
{
|
||||
const completion_entry_t *e = *iter;
|
||||
const option_list_t options = e->get_options();
|
||||
const option_list_t &options = e->get_options();
|
||||
for (option_list_t::const_iterator oiter = options.begin(); oiter != options.end(); ++oiter)
|
||||
{
|
||||
const complete_entry_opt_t *o = &*oiter;
|
||||
|
@ -2146,7 +2151,7 @@ void complete_print(wcstring &out)
|
|||
|
||||
append_switch(out,
|
||||
L"description",
|
||||
C_(o->desc.c_str()));
|
||||
C_(o->desc));
|
||||
|
||||
append_switch(out,
|
||||
L"arguments",
|
||||
|
|
Loading…
Reference in New Issue
Block a user