rpms/hunspell/F-11 hunspell-1.2.8-2784983.defaultlanguage.patch, NONE, 1.1 hunspell.spec, 1.59, 1.60

Caolan McNamara caolanm at fedoraproject.org
Fri May 1 12:14:41 UTC 2009


Author: caolanm

Update of /cvs/pkgs/rpms/hunspell/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv18210/F-11

Modified Files:
	hunspell.spec 
Added Files:
	hunspell-1.2.8-2784983.defaultlanguage.patch 
Log Message:
Resolves: rhbz#498556 fix default language detection

hunspell-1.2.8-2784983.defaultlanguage.patch:

--- NEW FILE hunspell-1.2.8-2784983.defaultlanguage.patch ---
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);
 	}
 


Index: hunspell.spec
===================================================================
RCS file: /cvs/pkgs/rpms/hunspell/F-11/hunspell.spec,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -p -r1.59 -r1.60
--- hunspell.spec	25 Feb 2009 04:22:51 -0000	1.59
+++ hunspell.spec	1 May 2009 12:14:09 -0000	1.60
@@ -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
 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 
 %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 <caolanm at redhat.com> - 1.2.8-5
+- Resolves: rhbz#498556 fix default language detection
+
 * Tue Feb 24 2009 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.2.8-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
 




More information about the fedora-extras-commits mailing list