From db2c45b62b549b0358ea3668e3fa170d12e59757 Mon Sep 17 00:00:00 2001 From: Caolan McNamara Date: May 01 2009 12:14:09 +0000 Subject: Resolves: rhbz#498556 fix default language detection --- diff --git a/hunspell-1.2.8-2784983.defaultlanguage.patch b/hunspell-1.2.8-2784983.defaultlanguage.patch new file mode 100644 index 0000000..773839c --- /dev/null +++ b/hunspell-1.2.8-2784983.defaultlanguage.patch @@ -0,0 +1,112 @@ +diff -ru hunspell-1.2.8.orig/man/hunspell.1 hunspell-1.2.8/man/hunspell.1 +--- hunspell-1.2.8.orig/man/hunspell.1 2008-06-12 09:50:43.000000000 +0100 ++++ hunspell-1.2.8/man/hunspell.1 2009-05-01 09:05:15.000000000 +0100 +@@ -309,9 +309,10 @@ + + .IP \fB\-p\ dict\fR + Set path of personal dictionary. +-Default dictionary depends from the locale settings. +-Without locale support, the default personal dictionary is +-the $HOME/.hunspell_default. ++The default dictionary depends on the locale settings. The ++following environment variables are searched: LANGUAGE, LC_ALL, ++LC_MESSAGES, and LANG. If none are set then the default personal ++dictionary is $HOME/.hunspell_default. + + Setting + .I \-d +@@ -360,6 +361,11 @@ + Equivalent to + .I \-p. + .SH FILES ++The default dictionary depends on the locale settings. The ++following environment variables are searched: LANGUAGE, LC_ALL, ++LC_MESSAGES, and LANG. If none are set then the following ++fallbacks are used: ++ + .BI /usr/share/myspell/default.aff + Path of default affix file. See hunspell(4). + .PP +diff -ru hunspell-1.2.8.orig/src/tools/hunspell.cxx hunspell-1.2.8/src/tools/hunspell.cxx +--- hunspell-1.2.8.orig/src/tools/hunspell.cxx 2008-09-04 14:44:19.000000000 +0100 ++++ hunspell-1.2.8/src/tools/hunspell.cxx 2009-05-01 09:15:33.000000000 +0100 +@@ -168,7 +168,6 @@ + int printgood = 0; // print only good words and lines + int showpath = 0; // show detected path of the dictionary + int checkurl = 0; // check URLs and mail addresses +-char * ui_lang = NULL; // locale for default dic_name + const char * ui_enc = NULL; // locale character encoding (default for I/O) + const char * io_enc = NULL; // I/O character encoding + +@@ -1383,7 +1382,7 @@ + + #ifdef ENABLE_NLS + #ifdef HAVE_LOCALE_H +- ui_lang = setlocale(LC_ALL, ""); ++ setlocale(LC_ALL, ""); + textdomain("hunspell"); + ui_enc = nl_langinfo(CODESET); + #endif +@@ -1515,13 +1514,23 @@ + + if (! dicname) { + if (! (dicname=getenv("DICTIONARY"))) { +- if ((dicname=ui_lang) || (dicname=getenv("LANG"))) { +- dicname = mystrdup(dicname); +- char * dot = strchr(dicname, '.'); +- if (dot) *dot = '\0'; +- char * at = strchr(dicname, '@'); +- if (at) *at = '\0'; +- } else { ++ /* ++ * Search in order of LANGUAGE, LC_ALL, LC_MESSAGES & ++ * LANG ++ */ ++ const char *tests[] = { "LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG" }; ++ for (int i = 0; i < sizeof(tests) / sizeof(const char*); ++i) { ++ if (dicname=getenv(tests[i])) { ++ dicname = mystrdup(dicname); ++ char * dot = strchr(dicname, '.'); ++ if (dot) *dot = '\0'; ++ char * at = strchr(dicname, '@'); ++ if (at) *at = '\0'; ++ break; ++ } ++ } ++ ++ if (! dicname) { + dicname=mystrdup(DEFAULTDICNAME); + } + } else { +@@ -1535,6 +1544,12 @@ + path = add(add(add(add(path, HOME), DIRSEP), USEROOODIR), PATHSEP); + path = add(path, OOODIR); + ++ if (showpath) { ++ fprintf(stderr, gettext("SEARCH PATH:\n%s\n"), path); ++ fprintf(stderr, gettext("AVAILABLE DICTIONARIES (path is not mandatory for -d option):\n"), path); ++ search(path, NULL, NULL); ++ } ++ + if (!privdicname) privdicname = mystrdup(getenv("WORDLIST")); + + int diclen = strlen(dicname); +@@ -1544,9 +1559,6 @@ + char * dic = search(path, dicname, ".dic"); + if (aff && dic) { + if (showpath) { +- fprintf(stderr, gettext("SEARCH PATH:\n%s\n"), path); +- fprintf(stderr, gettext("AVAILABLE DICTIONARIES (path is not mandatory for -d option):\n"), path); +- search(path, NULL, NULL); + fprintf(stderr, gettext("LOADED DICTIONARY:\n%s\n%s\n"), aff, dic); + } + pMS[0] = new Hunspell(aff, dic, key); +@@ -1569,7 +1581,7 @@ + } else if (dic) pMS[dmax-1]->add_dic(dic); + } + } else { +- fprintf(stderr,gettext("Can't open affix or dictionary files.\n")); ++ fprintf(stderr,gettext("Can't open affix or dictionary files for dictionary named \"%s\".\n"), dicname); + exit(1); + } + diff --git a/hunspell.spec b/hunspell.spec index 7a7d31e..f62ce8f 100644 --- a/hunspell.spec +++ b/hunspell.spec @@ -1,7 +1,7 @@ Name: hunspell Summary: A spell checker and morphological analyzer library Version: 1.2.8 -Release: 4%{?dist} +Release: 5%{?dist} Source0: http://downloads.sourceforge.net/%{name}/hunspell-%{version}.tar.gz Source1: http://people.debian.org/~agmartin/misc/ispellaff2myspell Source2: http://people.redhat.com/caolanm/hunspell/wordlist2hunspell @@ -11,6 +11,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) License: LGPLv2+ or GPLv2+ or MPLv1.1 BuildRequires: libtool, ncurses-devel Patch1: hunspell-1.2.7-2314461.ispell-alike.patch +Patch2: hunspell-1.2.8-2784983.defaultlanguage.patch %description Hunspell is a spell checker and morphological analyzer library and program @@ -29,6 +30,7 @@ Includes and definitions for developing with hunspell %prep %setup -q %patch1 -p1 -b .ispell-alike.patch +%patch2 -p1 -b .defaultlanguage.patch # Filter unwanted Requires for the "use explicitely" string in ispellaff2myspell cat << \EOF > %{name}-req #!/bin/sh @@ -105,6 +107,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man3/hunspell.3.gz %changelog +* Fri May 01 2009 Caolan McNamara - 1.2.8-5 +- Resolves: rhbz#498556 fix default language detection + * Tue Feb 24 2009 Fedora Release Engineering - 1.2.8-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild