From 7d2355846513d76e1c5b79329394a225321715c8fd0554b5bd768c5654abf0ee Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Fri, 1 Aug 2014 06:24:58 +0000 Subject: [PATCH] - make hunspell work with emacs and utf-8 [bnc#883505] - added patches: * hunspell-emacs-utf8.patch OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/hunspell?expand=0&rev=40 --- hunspell-emacs-utf8.patch | 56 +++++++++++++++++++++++++++++++++++++++ hunspell.changes | 7 +++++ hunspell.spec | 2 ++ 3 files changed, 65 insertions(+) create mode 100644 hunspell-emacs-utf8.patch diff --git a/hunspell-emacs-utf8.patch b/hunspell-emacs-utf8.patch new file mode 100644 index 0000000..4507041 --- /dev/null +++ b/hunspell-emacs-utf8.patch @@ -0,0 +1,56 @@ +http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7781#31 +--- src/tools/hunspell.cxx~0 2011-01-21 19:01:29.000000000 +0200 ++++ src/tools/hunspell.cxx 2013-02-07 10:11:54.443610900 +0200 +@@ -710,13 +748,22 @@ if (pos >= 0) { + fflush(stdout); + } else { + char ** wlst = NULL; +- int ns = pMS[d]->suggest(&wlst, token); ++ int byte_offset = parser->get_tokenpos() + pos; ++ int char_offset = 0; ++ if (strcmp(io_enc, "UTF-8") == 0) { ++ for (int i = 0; i < byte_offset; i++) { ++ if ((buf[i] & 0xc0) != 0x80) ++ char_offset++; ++ } ++ } else { ++ char_offset = byte_offset; ++ } ++ int ns = pMS[d]->suggest(&wlst, chenc(token, io_enc, dic_enc[d])); + if (ns == 0) { +- fprintf(stdout,"# %s %d", token, +- parser->get_tokenpos() + pos); ++ fprintf(stdout,"# %s %d", token, char_offset); + } else { + fprintf(stdout,"& %s %d %d: ", token, ns, +- parser->get_tokenpos() + pos); ++ char_offset); + fprintf(stdout,"%s", chenc(wlst[0], dic_enc[d], io_enc)); + } + for (int j = 1; j < ns; j++) { +@@ -745,13 +792,23 @@ if (pos >= 0) { + if (root) free(root); + } else { + char ** wlst = NULL; ++ int byte_offset = parser->get_tokenpos() + pos; ++ int char_offset = 0; ++ if (strcmp(io_enc, "UTF-8") == 0) { ++ for (int i = 0; i < byte_offset; i++) { ++ if ((buf[i] & 0xc0) != 0x80) ++ char_offset++; ++ } ++ } else { ++ char_offset = byte_offset; ++ } + int ns = pMS[d]->suggest(&wlst, chenc(token, io_enc, dic_enc[d])); + if (ns == 0) { + fprintf(stdout,"# %s %d", chenc(token, io_enc, ui_enc), +- parser->get_tokenpos() + pos); ++ char_offset); + } else { + fprintf(stdout,"& %s %d %d: ", chenc(token, io_enc, ui_enc), ns, +- parser->get_tokenpos() + pos); ++ char_offset); + fprintf(stdout,"%s", chenc(wlst[0], dic_enc[d], ui_enc)); + } + for (int j = 1; j < ns; j++) { diff --git a/hunspell.changes b/hunspell.changes index a3c3992..284fcff 100644 --- a/hunspell.changes +++ b/hunspell.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Aug 1 06:16:05 UTC 2014 - pgajdos@suse.com + +- make hunspell work with emacs and utf-8 [bnc#883505] +- added patches: + * hunspell-emacs-utf8.patch + ------------------------------------------------------------------- Mon Jun 23 12:54:06 UTC 2014 - pgajdos@suse.com diff --git a/hunspell.spec b/hunspell.spec index 2a2e1ce..70ec253 100644 --- a/hunspell.spec +++ b/hunspell.spec @@ -26,6 +26,7 @@ Group: System/Libraries Url: http://hunspell.sourceforge.net/ Source0: http://downloads.sourceforge.net/project/%{name}/Hunspell/%{version}/%{name}-%{version}.tar.gz Source1: baselibs.conf +Patch0: hunspell-emacs-utf8.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: gcc-c++ @@ -65,6 +66,7 @@ Includes and definitions for developing with hunspell. %prep %setup -q +%patch0 %build autoreconf -vi