Make C_ (gettext used in completions) return wcstring

This commit is contained in:
ridiculousfish 2014-10-30 18:19:47 -07:00
parent fa854d7a01
commit 16459099af
5 changed files with 16 additions and 12 deletions

View File

@ -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;
}
}

View File

@ -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
{

View File

@ -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();

View File

@ -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",

View File

@ -978,7 +978,6 @@ env_var_t env_get_string(const wcstring &key, env_mode_flags_t mode)
scoped_lock lock(env_lock);
env_node_t *env = search_local ? top : global_env;
wcstring result;
while (env != NULL)
{