Commit Graph

34 Commits

Author SHA1 Message Date
László Németh 7f28cf7edb Add tests to the COMPOUNDHYPHENMIN=1 compound hyphenation fixes
Test patterns and cases written by Anne-Edgar WILKE
2015-08-28 01:01:29 +02:00
Anne-Edgar WILKE 6df43f8b17 Fix COMPOUNDHYPHENMIN=1 compound hyphenation
FIRST BUG
 ---------

  Problem

In a compound word, the word parts of two characters are never
hyphenated.

  Example

To reproduce the bug, just go to the directory hyphen-2.8.8 and do the
following :

echo "\
UTF-8
LEFTHYPHENMIN 1
RIGHTHYPHENMIN 1
COMPOUNDLEFTHYPHENMIN 1
COMPOUNDRIGHTHYPHENMIN 1
.post1
NEXTLEVEL
e1
a1
" > hyphen.pat

./example hyphen.pat <(echo postea)

The output is post=ea ; but it should be post=e=a.

If you replace postea with posteaque in the command above, you get
post=e=a=que, which is correct. Indeed, the component "eaque" is now
five characters long, so it is hyphenated.

If you replace postea with ea, you get e=a, which is also correct ;
this is because ea is not a compound word.

  Solution

In the file hyphen.c, line 966, "if (i - begin > 1)" must be replaced
with "if (i - begin > 0)".
Indeed, the word part is comprised between begin and i inclusively ;
its length is i - begin + 1. So, if you want to hyphenate the words
parts of length 2 and above, you have to check that i - begin + 1 >= 2,
ie i - begin > 0.

    SECOND BUG
    ----------

  Problem

In a compound word, the word parts are never hyphenated between their
second to last and their last character.

  Example

To reproduce the bug, do the following :

echo "\
UTF-8
LEFTHYPHENMIN 1
RIGHTHYPHENMIN 1
COMPOUNDLEFTHYPHENMIN 1
COMPOUNDRIGHTHYPHENMIN 1
1que.
NEXTLEVEL
e1
" > hyphen.pat

./example hyphen.pat <(echo meaque)

The output is mea=que ; but it should be me=a=que.

Again, if you replace meaque with mea, you get me=a, which is correct,
because mea is not a compound word.

If you replace meaque with eamque, you get e=am=que, as expected ; it
shows that there is no similar bug with the first and the second
character of word parts.

  Solution

In the file hyphen.c, line 983, "for (j = 0; j < i - begin - 1; j++)"
must be replaced with "for (j = 0; j < i - begin; j++)".
Indeed, the word part has length i - begin + 1. So there are i - begin
possible places for a hyphen. Thus j must take i - begin different
values, ie go from 0 to i - begin - 1.
2015-08-28 00:53:59 +02:00
Caolán McNamara 25e74becb5 sf#247 comparison between signed and unsigned 2014-10-17 12:22:19 +00:00
Caolán McNamara d4cd34b4da bump for hyphen 2.8.8 2014-09-18 15:47:14 +00:00
Caolán McNamara 8c5092e493 coverity#58283 patterns vs MAXPATHS 2014-09-18 15:42:34 +00:00
László Németh d36878b962 add missing #include <stdio.h> to hyphen.h 2014-06-30 10:22:51 +00:00
Caolán McNamara 7b5c8ef761 bump version 2014-06-27 08:40:47 +00:00
Caolán McNamara 05191e8d9c Resolves: rhbz#925563 support aarch64 2014-06-27 08:37:30 +00:00
Caolán McNamara 81b1d7eaf4 clang scan-build warnings 2014-06-26 13:45:51 +00:00
Caolán McNamara 9db38a4ba7 #54 hypen compile as C++, missing casts and variable names 2013-06-13 19:43:14 +00:00
László Németh 3bea3aed15 hjn_hyphen_load_file patch for sandboxing by Pawel Hajdan 2013-03-18 10:49:03 +00:00
László Németh 327252245c Set version 2.8.6 2012-09-13 09:40:49 +00:00
László Németh d2dc7334af fdo#43931 (hard hyphen hyphenation) + fdo#54843 (rhmin fix) 2012-09-13 07:50:50 +00:00
Caolán McNamara fc16d4340d bump to 2.8.5 2012-07-12 15:36:58 +00:00
Caolán McNamara 943b612a4e fix bug found by Miklos 2012-07-12 15:29:56 +00:00
Caolán McNamara 5a60cb75a9 fix coverity warnings 2012-06-29 10:02:24 +00:00
Caolán McNamara a86803cdae dump logs on failure 2012-06-29 08:18:32 +00:00
Caolán McNamara 39bf406090 sync 2.8.3 into CVS 2012-06-29 07:10:58 +00:00
Caolán McNamara 058b24a9c3 update autotools foo 2012-06-28 22:20:58 +00:00
László Németh 830eccebc3 NOHYPHEN fix 2010-12-01 01:30:20 +00:00
László Németh f86ce87baa NOHYPHEN feature, see README.compound 2010-11-27 02:20:33 +00:00
Caolán McNamara 06bfd5b5b3 bump 2010-08-10 08:13:30 +00:00
Caolán McNamara 43d188cf89 remove csutil.*, bit over kill for just one make check test 2010-07-19 09:23:18 +00:00
Caolán McNamara ca7de5b5eb use libtool dlopen invocation to ensure we test in-tree invocation during tests 2010-07-17 16:14:13 +00:00
Caolán McNamara 6752c9adc3 strip down csutil.* to the bits that are used 2010-07-17 15:57:17 +00:00
Caolán McNamara e99c1c3297 hun#2005643 tidy string functions, correctly 2010-04-07 14:52:15 +00:00
Caolán McNamara de2862a0d9 add testSubDir to .cvsignore 2010-03-19 09:49:27 +00:00
Caolán McNamara a10d892e2b hun#2005643 tidy string functions 2010-03-04 13:29:16 +00:00
Caolán McNamara ea3a92e522 fix spelling errors 2010-03-04 13:19:21 +00:00
Caolán McNamara e39ae52d7d hun#1999737 add some malloc checks 2010-03-04 13:08:22 +00:00
Caolán McNamara 7107dea0c0 hun#1724558 tidy substrings.c a little 2010-03-04 12:50:21 +00:00
Caolán McNamara 5020b64b0e check return value of fgets 2010-03-04 12:27:39 +00:00
Caolán McNamara 892d87e002 add .cvsignores 2010-03-04 12:19:52 +00:00
Caolán McNamara 21127cc849 Initia import 2010-03-04 12:13:53 +00:00