[hunspell] Resolves: rhbz#985052 layout problems with very long lines

Caolán McNamara caolanm at fedoraproject.org
Thu Jul 25 08:35:25 UTC 2013


commit f83437d3bc8d1484f83cc202318c1ae1c9d577d3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 25 09:34:02 2013 +0100

    Resolves: rhbz#985052 layout problems with very long lines

 hunspell.rhbz985052.patch |   84 +++++++++++++++++++++++++++++++++++++++++++++
 hunspell.spec             |   11 ++++--
 2 files changed, 92 insertions(+), 3 deletions(-)
---
diff --git a/hunspell.rhbz985052.patch b/hunspell.rhbz985052.patch
new file mode 100644
index 0000000..f2791a0
--- /dev/null
+++ b/hunspell.rhbz985052.patch
@@ -0,0 +1,84 @@
+Index: man/hunspell.1
+===================================================================
+RCS file: /cvsroot/hunspell/hunspell/man/hunspell.1,v
+retrieving revision 1.4
+diff -u -r1.4 hunspell.1
+--- man/hunspell.1	13 Jun 2013 19:13:50 -0000	1.4
++++ man/hunspell.1	25 Jul 2013 08:26:50 -0000
+@@ -385,5 +385,3 @@
+ see hunspell(3).
+ .PP
+ This manual based on Ispell's manual. See ispell(1).
+-.SH BUGS
+-There are some layout problems with long lines.
+Index: src/tools/hunspell.cxx
+===================================================================
+RCS file: /cvsroot/hunspell/hunspell/src/tools/hunspell.cxx,v
+retrieving revision 1.34
+diff -u -r1.34 hunspell.cxx
+--- src/tools/hunspell.cxx	13 Jun 2013 19:37:30 -0000	1.34
++++ src/tools/hunspell.cxx	25 Jul 2013 08:26:50 -0000
+@@ -854,18 +854,19 @@
+ // like mbstowcs which isn't quite correct, but close enough for western
+ // text in UTF-8
+ void strncpyu8(char * dest, const char * src, int begin, int n) {
+-	int u8 = ((ui_enc != NULL) && (strcmp(ui_enc, "UTF-8") == 0)) ? 1 : 0;
+-	int i = 0;
+-	while (i < begin + n) {
+-		if (i >= begin)
+-		{
+-			if (!*src)
+-				break;
+-			*dest++ = *src;
++	if (n) {
++		int u8 = ((ui_enc != NULL) && (strcmp(ui_enc, "UTF-8") == 0)) ? 1 : 0;
++		for (int i = 0; i < begin + n;) {
++			if (!*src) break; // source is at it's end
++			if (!u8 || (*src & 0xc0) != 0x80) i++; // new character
++			if(i > begin){ // copy char (w/ utf-8 bytes)
++				*dest++ = *src++;
++				while(u8 && (*src & 0xc0) == 0x80) *dest++ = *src++;
++			}else{ // skip char (w/ utf-8 bytes)
++				++src;
++				while(u8 && (*src & 0xc0) == 0x80) ++src;
++			}
+ 		}
+-		if (!u8 || (*src & 0xc0) != 0x80)
+-			i++;
+-		++src;
+ 	}
+ 	*dest = '\0';
+ }
+@@ -902,8 +903,6 @@
+ 		expand_tab(lines[i], chenc(parser->get_prevline(i), io_enc, ui_enc), MAXLNLEN);
+ 	}
+ 
+-	int prevline = 0;
+-
+ 	strncpy(line, parser->get_prevline(0), parser->get_tokenpos());
+         line[parser->get_tokenpos()] = '\0';
+ 	int tokenbeg = expand_tab(line2, chenc(line, io_enc, ui_enc), MAXLNLEN);
+@@ -912,10 +911,13 @@
+         line[parser->get_tokenpos() + strlen(token)] = '\0';	
+ 	int tokenend = expand_tab(line2, chenc(line, io_enc, ui_enc), MAXLNLEN);
+ 
+-	int rowindex = tokenend / x;
++	int rowindex = (tokenend - 1) / x;
+ 	int beginrow = rowindex - tokenbeg / x;
+ 	if (beginrow >= MAXPREVLINE) beginrow = MAXPREVLINE - 1;
+ 
++	int ri = rowindex;
++	int prevline = 0;
++
+ 	for (int i = 0; i < MAXPREVLINE; i++) {
+ 	        strncpyu8(line, lines[prevline], x * rowindex, x);
+ 		mvprintw(MAXPREVLINE + 1 - i, 0, "%s", line);
+@@ -927,7 +929,7 @@
+ 	}
+ 
+ 	int linestartpos = tokenbeg - (tokenbeg % x);
+-	strncpyu8(line, lines[0], x * rowindex + linestartpos, tokenbeg % x);
++	strncpyu8(line, lines[0], x * (ri - beginrow),  tokenbeg % x) ;
+ 	mvprintw(MAXPREVLINE + 1 - beginrow, 0, "%s", line);
+ 	attron(A_REVERSE);    
+ 	printw("%s", chenc(token, io_enc, ui_enc));
diff --git a/hunspell.spec b/hunspell.spec
index 1a638b9..2ce91af 100644
--- a/hunspell.spec
+++ b/hunspell.spec
@@ -3,7 +3,7 @@
 Name:      hunspell
 Summary:   A spell checker and morphological analyzer library
 Version:   1.3.2
-Release:   12%{?dist}
+Release:   13%{?dist}
 Source:    http://downloads.sourceforge.net/%{name}/hunspell-%{version}.tar.gz
 Group:     System Environment/Libraries
 URL:       http://hunspell.sourceforge.net/
@@ -20,6 +20,7 @@ Requires:  hunspell-en-US
 Patch0: hunspell.rhbz759647.patch
 Patch1: hunspell.rhbz918938.patch
 Patch2: hunspell-aarch64.patch
+Patch3: hunspell.rhbz985052.patch
 
 %description
 Hunspell is a spell checker and morphological analyzer library and program 
@@ -40,6 +41,7 @@ Includes and definitions for developing with hunspell
 %patch0 -p0 -b .rhbz759647
 %patch1 -p0 -b .rhbz918938
 %patch2 -p1 -b .aarch64
+%patch3 -p0 -b .rhbz985052
 
 %build
 configureflags="--disable-rpath --disable-static --with-ui --with-readline"
@@ -129,6 +131,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man3/hunspell.3.gz
 
 %changelog
+* Thu Jul 25 2013 Caolán McNamara <caolanm at redhat.com> - 1.3.2-13
+- Resolves: rhbz#985052 layout problems with very long lines
+
 * Wed Jul 17 2013 Petr Pisar <ppisar at redhat.com> - 1.3.2-12
 - Perl 5.18 rebuild
 
@@ -288,10 +293,10 @@ rm -rf $RPM_BUILD_ROOT
 - Drop ABI breaking hunspell-1.2.2-xulrunner.pita.patch and fix the
   hunspell include in xulrunner.
 
-* Fri Jun 18 2008 Caolán McNamara <caolanm at redhat.com> - 1.2.4.2-1
+* Wed Jun 18 2008 Caolán McNamara <caolanm at redhat.com> - 1.2.4.2-1
 - latest version
 
-* Thu Jun 17 2008 Caolán McNamara <caolanm at redhat.com> - 1.2.4-1
+* Tue Jun 17 2008 Caolán McNamara <caolanm at redhat.com> - 1.2.4-1
 - latest version
 
 * Fri May 16 2008 Caolán McNamara <caolanm at redhat.com> - 1.2.2-3


More information about the scm-commits mailing list