updated for version 7.0138
diff --git a/src/testdir/test58.in b/src/testdir/test58.in
index 530b27a..8bb58bf 100644
--- a/src/testdir/test58.in
+++ b/src/testdir/test58.in
@@ -6,63 +6,50 @@
 :" Don't want to depend on the locale from the environment
 :set enc=latin1
 :e!
-:" First generate a .spl file from a .dic and a .aff file.
-gg:/^affstart1/+1,/^affend1/-1w! Xtest.aff
-gg:/^dicstart/+1,/^dicend/-1w! Xtest.dic
-:mkspell! Xtest Xtest
 :"
-:" use that spell file
-:set spl=Xtest.latin1.spl
-:set spell
-:func SpellTest()
-/^test1:
-normal ]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 4)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
+:" Function to test .aff/.dic with list of good and bad words.
+:func TestOne(aff, dic)
+  set spellfile=
+  $put =''
+  $put ='test '. a:aff . '-' . a:dic
+  " Generate a .spl file from a .dic and .aff file.
+  exe '1;/^' . a:aff . 'affstart/+1,/^' . a:aff . 'affend/-1w! Xtest.aff'
+  exe '1;/^' . a:dic . 'dicstart/+1,/^' . a:dic . 'dicend/-1w! Xtest.dic'
+  mkspell! Xtest Xtest
+  " use that spell file
+  set spl=Xtest.latin1.spl spell
+  " list all valid words
+  spelldump
+  %yank
+  quit
+  $put
+  $put ='-------'
+  " find all bad words and suggestions for them
+  exe '1;/^' . a:aff . 'good:'
+  normal 0f:]s
+  let prevbad = ''
+  while 1
+    let bad = spellbadword()
+    if bad == '' || bad == prevbad || bad == 'badend'
+      break
+    endif
+    let prevbad = bad
+    let lst = spellsuggest(bad, 3)
+    normal mm
+    $put =bad
+    $put =string(lst)
+    normal `m]s
+  endwhile
 endfunc
-:call SpellTest()
-:spelldump
-1GyG:q
-:$put
+:"
+:call TestOne('1', '1')
 :$put =soundfold('goobledygoook')
 :$put =soundfold('kóopërÿnôven')
 :$put =soundfold('oeverloos gezwets edale')
 :"
+:"
 :" and now with SAL instead of SOFO items; test automatic reloading
-gg:/^affstart2/+1,/^affend2/-1w! Xtest.aff
+gg:/^affstart_sal/+1,/^affend_sal/-1w! Xtest.aff
 :mkspell! Xtest Xtest
 :$put =soundfold('goobledygoook')
 :$put =soundfold('kóopërÿnôven')
@@ -101,39 +88,16 @@
 :$put =str
 :"
 :" Postponed prefixes
-gg:/^affstart3/+1,/^affend3/-1w! Xtest.aff
-:mkspell! Xtest Xtest
-:set spellfile=
-:set spl=Xtest.latin1.spl
-:spelldump
-1GyG:q
-:$put
-:call SpellTest()
+:call TestOne('2', '1')
 :"
-:" Compounding
-gg:/^compaffstart/+1,/^compaffend/-1w! Xtest.aff
-gg:/^compdicstart/+1,/^compdicend/-1w! Xtest.dic
-:mkspell! Xtest Xtest
-:set spellfile=
-:set spl=Xtest.latin1.spl
-:spelldump
-1GyG:q
-:$put
-/^comptest:
-:for i in range(11)
-normal ]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 3)
-$put =string(lst)
-normal `m
-endfor
+:" Compound words
+:call TestOne('3', '3')
+:call TestOne('4', '4')
 :"
 gg:/^test output:/,$wq! test.out
 ENDTEST
 
-affstart1
+1affstart
 SET ISO8859-1
 TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ
 
@@ -182,9 +146,27 @@
 MAP cç
 MAP yÿý
 MAP sß
-affend1
+1affend
 
-affstart2
+1good: wrong OK puts. Test the end
+bad:  inputs comment ok Ok. test déôl end the
+badend
+
+1dicstart
+123456
+test/NO
+# comment
+wrong
+Comment
+OK
+uk
+put/ISO
+the end
+deol
+déôr
+1dicend
+
+affstart_sal
 SET ISO8859-1
 TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ
 
@@ -338,9 +320,9 @@
 SAL Y(AEIOU)-            Y
 SAL ZZ-                  _
 SAL Z                    S
-affend2
+affend_sal
 
-affstart3
+2affstart
 SET ISO8859-1
 
 FOL  àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ
@@ -387,23 +369,47 @@
 MAP cç
 MAP yÿý
 MAP sß
-affend3
+2affend
 
-dicstart
-123456
-test/NO
-# comment
-wrong
-Comment
-OK
-uk
-put/ISO
-the end
-deol
-déôr
-dicend
+2good: puts
+bad: inputs comment ok Ok end the. test déôl
+badend
 
-compaffstart
+addstart
+/regions=usgbnz
+elequint/2
+elekwint/3
+addend
+
+test2:
+elequint test elekwint test elekwent asdf
+
+Test rules for compounding.
+
+3affstart
+SET ISO8859-1
+
+COMPOUNDMIN 3
+COMPOUNDFLAGS m*
+NEEDCOMPOUND x
+3affend
+
+3dicstart
+1234
+foo/m
+bar/mx
+mï/m
+la/mx
+3dicend
+
+3good: foo mï foobar foofoobar barfoo barbarfoo
+bad: bar la foomï barmï mïfoo mïbar mïmï lala mïla lamï foola labar
+badend
+
+
+Tests for compounding.
+
+4affstart
 SET ISO8859-1
 
 FOL  àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ
@@ -445,9 +451,9 @@
 
 PFX p N 1
 PFX p 0 pre .
-compaffend
+4affend
 
-compdicstart
+4dicstart
 1234
 word/m
 util/am
@@ -456,37 +462,16 @@
 bork/mp
 start/s
 end/e
-compdicend
+4dicend
 
-addstart
-/regions=usgbnz
-elequint/2
-elekwint/3
-addend
-
-test1:
-inputs	wrong
-comment	wrong
-puts	OK
-ok	wrong
-Ok	wrong
-the end.  test wrong
-déôl
-
-test2:
-elequint test elekwint test elekwent asdf
-
-comptest:
-word util
-wordutil wordutils wordutilize
-pro pro-ok
-bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork
-borkborkborkborkborkbork
-tomato tomatotomato tomatotomatotomato
-startend endstart endend startstart wordend
-startword startwordword wordstart startwordend startwordwordend
-startwordwordwordend startwordwordwordwordend
-prebork preborkprebork preborkborkprebork preborkpreborkbork
-borkpreborkpreborkbork
+4good: word util bork prebork start end wordutil wordutils pro-ok
+	bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork
+	tomato tomatotomato startend startword startwordword startwordend
+	startwordwordend startwordwordwordend prebork preborkprebork
+	preborkborkprebork preborkpreborkbork
+bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato
+	endstart endend startstart wordend wordstart
+ 	startwordwordwordwordend borkpreborkpreborkbork
+badend
 
 test output:
diff --git a/src/testdir/test58.ok b/src/testdir/test58.ok
index 570ab7d..67f1f9c 100644
--- a/src/testdir/test58.ok
+++ b/src/testdir/test58.ok
@@ -1,16 +1,6 @@
 test output:
-inputs
-['input', 'puts', 'outputs', 'put']
-comment
-['Comment']
-ok
-['OK', 'uk']
-Ok
-['OK', 'Uk']
-test
-['test', 'Test']
-déôl
-['deol', 'déôr']
+
+test 1-1
 # file: Xtest.latin1.spl
 Comment
 deol
@@ -28,6 +18,25 @@
 the end
 uk
 wrong
+-------
+bad
+['put', 'OK', 'uk']
+inputs
+['input', 'puts', 'outputs']
+comment
+['Comment']
+ok
+['OK', 'uk', 'put']
+Ok
+['OK', 'Uk', 'Put']
+test
+['test', 'Test', 'testn']
+déôl
+['deol', 'déôr', 'test']
+end
+['put', 'test', 'uk']
+the
+['put', 'uk', 'test']
 gebletegek
 kepereneven
 everles gesvets etele
@@ -43,6 +52,8 @@
 elekwent
 elequint
 elekwint
+
+test 2-1
 # file: Xtest.latin1.spl
 Comment
 deol
@@ -60,18 +71,59 @@
 the end
 uk
 wrong
+-------
+bad
+['put', 'uk', 'OK']
 inputs
-['input', 'puts', 'put', 'outputs']
+['input', 'puts', 'put']
 comment
 ['Comment']
 ok
-['OK', 'uk']
+['OK', 'uk', 'put']
 Ok
-['OK', 'Uk']
+['OK', 'Uk', 'Put']
+end
+['put', 'uk', 'deol']
+the
+['put', 'uk', 'test']
 test
-['test', 'Test']
+['test', 'Test', 'testn']
 déôl
-['deol', 'déôr']
+['deol', 'déôr', 'test']
+
+test 3-3
+# file: Xtest.latin1.spl
+foo
+mï
+-------
+bad
+['foo', 'mï']
+bar
+['foobar', 'foo', 'mï']
+la
+['mï', 'foo']
+foomï
+['foo mï', 'foo', 'foofoo']
+barmï
+['bar mï', 'barfoo', 'barbar']
+mïfoo
+['mï foo', 'foo', 'foofoo']
+mïbar
+['foobar', 'barbar', 'mï']
+mïmï
+['mï mï', 'mï', 'la mï']
+lala
+['la mï']
+mïla
+['mï', 'mï mï']
+lamï
+['la mï', 'mï', 'mï mï']
+foola
+['foo', 'foobar', 'foofoo']
+labar
+['barbar', 'foobar']
+
+test 4-4
 # file: Xtest.latin1.spl
 bork
 prebork
@@ -83,6 +135,9 @@
 utilize
 utils
 word
+-------
+bad
+['end', 'bork', 'word']
 wordutilize
 ['word utilize', 'wordutils', 'wordutil']
 pro
diff --git a/src/testdir/test59.in b/src/testdir/test59.in
index a49514f..aab48ae 100644
--- a/src/testdir/test59.in
+++ b/src/testdir/test59.in
@@ -8,65 +8,52 @@
 :" text is in latin1, the test text is utf-8.
 :set enc=latin1
 :e!
-:set fenc=
-:" First generate a .spl file from a .dic and a .aff file.
-gg:/^affstart1/+1,/^affend1/-1w! Xtest.aff
-gg:/^dicstart/+1,/^dicend/-1w! Xtest.dic
 :set enc=utf-8
-:mkspell! Xtest Xtest
+:set fenc=
 :"
-:" use that spell file
-:set spl=Xtest.utf-8.spl
-:set spell
-:func SpellTest()
-/^test1:
-normal ]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 4)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
-normal `m]smm
-let str = spellbadword()
-$put =str
-normal `m
-let lst = spellsuggest(str, 2)
-$put =string(lst)
+:" Function to test .aff/.dic with list of good and bad words.
+:func TestOne(aff, dic)
+  set spellfile=
+  $put =''
+  $put ='test '. a:aff . '-' . a:dic
+  " Generate a .spl file from a .dic and .aff file.
+  exe '1;/^' . a:aff . 'affstart/+1,/^' . a:aff . 'affend/-1w! Xtest.aff'
+  exe '1;/^' . a:dic . 'dicstart/+1,/^' . a:dic . 'dicend/-1w! Xtest.dic'
+  mkspell! Xtest Xtest
+  " use that spell file
+  set spl=Xtest.utf-8.spl spell
+  " list all valid words
+  spelldump
+  %yank
+  quit
+  $put
+  $put ='-------'
+  " find all bad words and suggestions for them
+  exe '1;/^' . a:aff . 'good:'
+  normal 0f:]s
+  let prevbad = ''
+  while 1
+    let bad = spellbadword()
+    if bad == '' || bad == prevbad || bad == 'badend'
+      break
+    endif
+    let prevbad = bad
+    let lst = spellsuggest(bad, 3)
+    normal mm
+    $put =bad
+    $put =string(lst)
+    normal `m]s
+  endwhile
 endfunc
-:call SpellTest()
-:spelldump
-1GyG:q
-:$put
+:"
+:call TestOne('1', '1')
 :$put =soundfold('goobledygoook')
 :$put =soundfold('kóopërÿnôven')
 :$put =soundfold('oeverloos gezwets edale')
 :"
+:"
 :" and now with SAL instead of SOFO items; test automatic reloading
-gg:/^affstart2/+1,/^affend2/-1w! Xtest.aff
+gg:/^affstart_sal/+1,/^affend_sal/-1w! Xtest.aff
 :mkspell! Xtest Xtest
 :$put =soundfold('goobledygoook')
 :$put =soundfold('kóopërÿnôven')
@@ -105,20 +92,16 @@
 :$put =str
 :"
 :" Postponed prefixes
-gg:/^affstart3/+1,/^affend3/-1w! Xtest.aff
-:mkspell! Xtest Xtest
-:set spellfile=
-:set spl=Xtest.utf-8.spl
-:mess
-:spelldump
-1GyG:q
-:$put
-:call SpellTest()
+:call TestOne('2', '1')
+:"
+:" Compound words
+:call TestOne('3', '3')
+:call TestOne('4', '4')
 :"
 gg:/^test output:/,$wq! test.out
 ENDTEST
 
-affstart1
+1affstart
 SET ISO8859-1
 TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ
 
@@ -167,9 +150,9 @@
 MAP cç
 MAP yÿý
 MAP sß
-affend1
+1affend
 
-affstart2
+affstart_sal
 SET ISO8859-1
 TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ
 
@@ -323,9 +306,9 @@
 SAL Y(AEIOU)-            Y
 SAL ZZ-                  _
 SAL Z                    S
-affend2
+affend_sal
 
-affstart3
+2affstart
 SET ISO8859-1
 
 FOL  àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ
@@ -372,9 +355,9 @@
 MAP cç
 MAP yÿý
 MAP sß
-affend3
+2affend
 
-dicstart
+1dicstart
 123456
 test/NO
 # comment
@@ -386,7 +369,7 @@
 the end
 deol
 déôr
-dicend
+1dicend
 
 addstart
 /regions=usgbnz
@@ -394,17 +377,105 @@
 elekwint/3
 addend
 
-test1:
-inputs	wrong
-comment	wrong
-puts	OK
-ok	wrong
-Ok	wrong
-the end.  test wrong
-déôl
+1good: wrong OK puts. Test the end
+bad:  inputs comment ok Ok. test déôl end the
+badend
+
+2good: puts
+bad: inputs comment ok Ok end the. test déôl
+badend
+
+Test rules for compounding.
+
+3affstart
+SET ISO8859-1
+
+COMPOUNDMIN 3
+COMPOUNDFLAGS m*
+NEEDCOMPOUND x
+3affend
+
+3dicstart
+1234
+foo/m
+bar/mx
+mï/m
+la/mx
+3dicend
+
+3good: foo mï foobar foofoobar barfoo barbarfoo
+bad: bar la foomï barmï mïfoo mïbar mïmï lala mïla lamï foola labar
+badend
+
+
+Tests for compounding.
+
+4affstart
+SET ISO8859-1
+
+FOL  àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ
+LOW  àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ
+UPP  ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßÿ
+
+COMPOUNDFLAGS m+
+COMPOUNDFLAGS sm*e
+COMPOUNDFLAGS sm+
+COMPOUNDMIN 3
+COMPOUNDMAX 3
+
+COMPOUNDSYLMAX 5
+SYLLABLE aáeéiíoóöõuúüûy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui
+
+MAP 9
+MAP aàáâãäå
+MAP eèéêë
+MAP iìíîï
+MAP oòóôõö
+MAP uùúûü
+MAP nñ
+MAP cç
+MAP yÿý
+MAP sß
+
+NEEDAFFIX x
+
+PFXPOSTPONE
+
+MIDWORD '-
+
+SFX q N 1
+SFX q   0    -ok .
+
+SFX a Y 2
+SFX a 0 s .
+SFX a 0 ize . nocomp
+
+PFX p N 1
+PFX p 0 pre .
+4affend
+
+4dicstart
+1234
+word/m
+util/am
+pro/xq
+tomato/m
+bork/mp
+start/s
+end/e
+4dicend
+
+4good: word util bork prebork start end wordutil wordutils pro-ok
+	bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork
+	tomato tomatotomato startend startword startwordword startwordend
+	startwordwordend startwordwordwordend prebork preborkprebork
+	preborkborkprebork preborkpreborkbork
+bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato
+	endstart endend startstart wordend wordstart
+ 	startwordwordwordwordend borkpreborkpreborkbork
+badend
 
 test2:
 elequint test elekwint test elekwent asdf
 
-
 test output:
diff --git a/src/testdir/test59.ok b/src/testdir/test59.ok
index 6bbed6e..e09eaac 100644
--- a/src/testdir/test59.ok
+++ b/src/testdir/test59.ok
@@ -1,16 +1,6 @@
 test output:
-inputs
-['input', 'puts', 'outputs', 'put']
-comment
-['Comment']
-ok
-['OK', 'uk']
-Ok
-['OK', 'Uk']
-test
-['test', 'Test']
-déôl
-['deol', 'déôr']
+
+test 1-1
 # file: Xtest.utf-8.spl
 Comment
 deol
@@ -28,6 +18,25 @@
 the end
 uk
 wrong
+-------
+bad
+['put', 'OK', 'uk']
+inputs
+['input', 'puts', 'outputs']
+comment
+['Comment']
+ok
+['OK', 'uk', 'put']
+Ok
+['OK', 'Uk', 'Put']
+test
+['test', 'Test', 'testn']
+déôl
+['deol', 'déôr', 'test']
+end
+['put', 'test', 'uk']
+the
+['put', 'uk', 'test']
 gebletegek
 kepereneven
 everles gesvets etele
@@ -43,6 +52,8 @@
 elekwent
 elequint
 elekwint
+
+test 2-1
 # file: Xtest.utf-8.spl
 Comment
 deol
@@ -60,15 +71,92 @@
 the end
 uk
 wrong
+-------
+bad
+['put', 'uk', 'OK']
 inputs
-['input', 'puts', 'put', 'outputs']
+['input', 'puts', 'put']
 comment
 ['Comment']
 ok
-['OK', 'uk']
+['OK', 'uk', 'put']
 Ok
-['OK', 'Uk']
+['OK', 'Uk', 'Put']
+end
+['put', 'uk', 'deol']
+the
+['put', 'uk', 'test']
 test
-['test', 'Test']
+['test', 'Test', 'testn']
 déôl
-['deol', 'déôr']
+['deol', 'déôr', 'test']
+
+test 3-3
+# file: Xtest.utf-8.spl
+foo
+mï
+-------
+bad
+['foo', 'mï']
+bar
+['foobar', 'foo', 'mï']
+la
+['foo', 'mï']
+foomï
+['foo mï', 'foo', 'foofoo']
+barmï
+['bar mï', 'barfoo', 'barbar']
+mïfoo
+['mï foo', 'foo', 'foofoo']
+mïbar
+['foobar', 'barbar', 'mï']
+mïmï
+['mï mï', 'mï', 'la mï']
+lala
+[]
+mïla
+['mï']
+lamï
+['la mï', 'mï', 'mï mï']
+foola
+['foo', 'foobar', 'foofoo']
+labar
+['barbar', 'foobar']
+
+test 4-4
+# file: Xtest.utf-8.spl
+bork
+prebork
+end
+pro-ok
+start
+tomato
+util
+utilize
+utils
+word
+-------
+bad
+['end', 'bork', 'word']
+wordutilize
+['word utilize', 'wordutils', 'wordutil']
+pro
+['bork', 'end', 'word']
+borkborkborkborkborkbork
+['borkbork borkborkborkbork', 'borkborkbork borkborkbork', 'borkborkborkborkbork bork']
+tomatotomatotomato
+['tomato tomatotomato', 'tomatotomato tomato', 'tomato tomato tomato']
+endstart
+['end start', 'start']
+endend
+['end end', 'end']
+startstart
+['start start']
+wordend
+['word end', 'wordword', 'word']
+wordstart
+['word start', 'bork start']
+startwordwordwordwordend
+['startwordwordwordword end', 'startwordwordwordword', 'start wordwordwordword end']
+borkpreborkpreborkbork
+['borkpreborkprebork bork', 'borkprebork preborkbork', 'bork preborkpreborkbork']