looks good On Thu, 2011-10-06 at 12:42 +0200, Ales Kozumplik wrote: > First, internally translate '.utf8' to '.UTF-8' so it matches the > lang-table. > > Second, if a language missing from the lang-table is used with lang=, > fallback on en_US. > > Resolves: rhbz#731356 > --- > loader/lang.c | 33 +++++++++++++++++++++++++++++++-- > loader/lang.h | 1 + > loader/loader.c | 2 +- > 3 files changed, 33 insertions(+), 3 deletions(-) > > diff --git a/loader/lang.c b/loader/lang.c > index 6b1fa8e..a11de14 100644 > --- a/loader/lang.c > +++ b/loader/lang.c > @@ -36,6 +36,7 @@ > #include <sys/wait.h> > #include <unistd.h> > #include <wchar.h> > +#include <glib.h> > > #include "loader.h" > #include "lang.h" > @@ -103,6 +104,14 @@ char * translateString(char * str) { > static struct langInfo * languages = NULL; > static int numLanguages = 0; > > +static int defaultLanguageIndex(void) { > + int i; > + for (i = 0; i < numLanguages; ++i) > + if (!strcmp(languages[i].lc_all, LANG_DEFAULT)) > + return i; > + return -1; > +} > + > static void loadLanguageList(void) { > char * file = "/etc/lang-table"; > FILE * f; > @@ -144,6 +153,25 @@ int getLangInfo(struct langInfo ** langs) { > return numLanguages; > } > > +/** > + * Normalize the value of lang= boot argument. > + * > + * Currently only replaces the trailing .utf8 with .UTF-8. > + * > + * Returns a heap-allocated string. > + */ > +gchar *normalizeLang(const gchar *s) > +{ > + if (g_str_has_suffix(s, ".utf8")) { > + gchar *lang = g_strndup(s, strlen(s) - strlen(".utf8")); > + gchar *result = g_strconcat(lang, ".UTF-8", NULL); > + g_free(lang); > + return result; > + } > + > + return g_strdup(s); > +} > + > void loadLanguage(void) > { > char *filename; > @@ -395,8 +423,9 @@ int setLanguage (const char * key, int forced) { > } > } > > - logMessage(ERROR, "unable to set to requested language %s", key); > - return -1; > + logMessage(ERROR, "unable to set the requested language '%s', " > + "setting the default '%s'", key, LANG_DEFAULT); > + return setupLanguage(defaultLanguageIndex(), forced | !FL_KICKSTART(flags)); > } > > int chooseLanguage(char ** lang) { > diff --git a/loader/lang.h b/loader/lang.h > index 168ffa3..d2f2d98 100644 > --- a/loader/lang.h > +++ b/loader/lang.h > @@ -34,6 +34,7 @@ int chooseLanguage(char ** lang); > char * translateString(char * str); > int setLanguage (const char * key, int forced); > int getLangInfo(struct langInfo **langs); > +char * normalizeLang(const char *s); > > extern const char *LANG_DEFAULT; > > diff --git a/loader/loader.c b/loader/loader.c > index eedf439..cb8b7ab 100644 > --- a/loader/loader.c > +++ b/loader/loader.c > @@ -992,7 +992,7 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData) { > } else if (!strcasecmp(k, "display")) { > setenv("DISPLAY", v, 1); > } else if (!strcasecmp(k, "lang")) { > - loaderData->lang = g_strdup(v); > + loaderData->lang = normalizeLang(v); > loaderData->lang_set = 1; > } else if (!strcasecmp(k, "keymap")) { > loaderData->kbd = g_strdup(v); -- Martin Gracik <mgracik@xxxxxxxxxx> _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list