mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Hack up gettext to try to fix CentOS build
https://github.com/fish-shell/fish-shell/issues/645
This commit is contained in:
parent
b8f34cdd35
commit
b936be8e34
6 changed files with 49 additions and 35 deletions
29
fallback.cpp
29
fallback.cpp
|
@ -1122,21 +1122,38 @@ int futimes(int fd, const struct timeval *times)
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETTEXT
|
||||
#if HAVE_GETTEXT
|
||||
|
||||
char * gettext(const char * msgid)
|
||||
char * fish_gettext(const char * msgid)
|
||||
{
|
||||
return gettext(msgid);;
|
||||
}
|
||||
|
||||
char * fish_bindtextdomain(const char * domainname, const char * dirname)
|
||||
{
|
||||
return bindtextdomain(domainname, dirname);
|
||||
}
|
||||
|
||||
char * fish_textdomain(const char * domainname)
|
||||
{
|
||||
return textdomain(domainname);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
char * fish_gettext(const char * msgid)
|
||||
{
|
||||
return (char *)msgid;
|
||||
}
|
||||
|
||||
char * bindtextdomain(const char * domainname, const char * dirname)
|
||||
char * fish_bindtextdomain(const char * domainname, const char * dirname)
|
||||
{
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char * textdomain(const char * domainname)
|
||||
char * fish_textdomain(const char * domainname)
|
||||
{
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
22
fallback.h
22
fallback.h
|
@ -387,24 +387,16 @@ int futimes(int fd, const struct timeval *times);
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETTEXT
|
||||
/* autoconf may fail to detect gettext (645), so don't define a function call gettext or we'll get build errors */
|
||||
|
||||
/**
|
||||
Fallback implementation of gettext. Just returns the original string.
|
||||
*/
|
||||
char * gettext(const char * msgid);
|
||||
/** Fallback implementation of gettext. Just returns the original string. */
|
||||
char * fish_gettext(const char * msgid);
|
||||
|
||||
/**
|
||||
Fallback implementation of bindtextdomain. Does nothing.
|
||||
*/
|
||||
char * bindtextdomain(const char * domainname, const char * dirname);
|
||||
/** Fallback implementation of bindtextdomain. Does nothing. */
|
||||
char * fish_bindtextdomain(const char * domainname, const char * dirname);
|
||||
|
||||
/**
|
||||
Fallback implementation of textdomain. Does nothing.
|
||||
*/
|
||||
char * textdomain(const char * domainname);
|
||||
|
||||
#endif
|
||||
/** Fallback implementation of textdomain. Does nothing. */
|
||||
char * fish_textdomain(const char * domainname);
|
||||
|
||||
#ifndef HAVE_DCGETTEXT
|
||||
|
||||
|
|
|
@ -1698,6 +1698,12 @@ void history_tests_t::test_history_speed(void)
|
|||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::string tmp = "sldfjsdlkfjsdlkfjlf";
|
||||
for (size_t i=0; i < 1000000; i++) {
|
||||
str2wcstring(tmp);
|
||||
}
|
||||
exit(0);
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
srand(time(0));
|
||||
configure_thread_assertions_for_testing();
|
||||
|
@ -1715,6 +1721,7 @@ int main(int argc, char **argv)
|
|||
reader_init();
|
||||
env_init();
|
||||
|
||||
|
||||
test_format();
|
||||
test_escape();
|
||||
test_convert();
|
||||
|
|
14
history.cpp
14
history.cpp
|
@ -662,13 +662,13 @@ static bool extract_prefix_and_unescape_yaml(std::string &key, std::string &valu
|
|||
size_t where = line.find(":");
|
||||
if (where != std::string::npos)
|
||||
{
|
||||
key = line.substr(0, where);
|
||||
key.assign(line, 0, where);
|
||||
|
||||
// skip a space after the : if necessary
|
||||
size_t val_start = where + 1;
|
||||
if (val_start < line.size() && line.at(val_start) == ' ')
|
||||
val_start++;
|
||||
value = line.substr(val_start);
|
||||
value.assign(line, val_start, line.size() - val_start);
|
||||
|
||||
unescape_yaml(key);
|
||||
unescape_yaml(value);
|
||||
|
@ -717,12 +717,10 @@ history_item_t history_t::decode_item_fish_2_0(const char *base, size_t len)
|
|||
|
||||
if (key == "when")
|
||||
{
|
||||
/* Parse an int from the timestamp */
|
||||
long tmp = 0;
|
||||
if (sscanf(value.c_str(), "%ld", &tmp) > 0)
|
||||
{
|
||||
when = tmp;
|
||||
}
|
||||
/* Parse an int from the timestamp. Should this fail, strtol returns 0; that's acceptable. */
|
||||
char *end = NULL;
|
||||
long tmp = strtol(value.c_str(), &end, 0);
|
||||
when = tmp;
|
||||
}
|
||||
else if (key == "paths")
|
||||
{
|
||||
|
|
|
@ -156,7 +156,7 @@ static int launch_pos=0;
|
|||
gettext alias
|
||||
*/
|
||||
#ifdef USE_GETTEXT
|
||||
#define _(string) gettext(string)
|
||||
#define _(string) fish_gettext(string)
|
||||
#else
|
||||
#define _(string) (string)
|
||||
#endif
|
||||
|
@ -1210,8 +1210,8 @@ static void launch(char *filter, const string_list_t &files, size_t fileno)
|
|||
static void locale_init()
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
|
||||
textdomain(PACKAGE_NAME);
|
||||
fish_bindtextdomain(PACKAGE_NAME, LOCALEDIR);
|
||||
fish_textdomain(PACKAGE_NAME);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -439,8 +439,8 @@ wcstring wbasename(const wcstring &path)
|
|||
static void wgettext_really_init()
|
||||
{
|
||||
pthread_mutex_init(&wgettext_lock, NULL);
|
||||
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
|
||||
textdomain(PACKAGE_NAME);
|
||||
fish_bindtextdomain(PACKAGE_NAME, LOCALEDIR);
|
||||
fish_textdomain(PACKAGE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -469,7 +469,7 @@ const wchar_t *wgettext(const wchar_t *in)
|
|||
if (val == NULL)
|
||||
{
|
||||
cstring mbs_in = wcs2string(key);
|
||||
char *out = gettext(mbs_in.c_str());
|
||||
char *out = fish_gettext(mbs_in.c_str());
|
||||
val = new wcstring(format_string(L"%s", out));
|
||||
}
|
||||
errno = err;
|
||||
|
|
Loading…
Reference in a new issue