about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/text/ispell/patches/0005-Do-not-reorder-words.patch
blob: 2d74c078601a77f750627c2b17abb096564c3781 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From: Geoff Kuenning <geoff@cs.hmc.edu>
Date: Thu, 3 Nov 2005 14:14:15 -0800
Subject: 0005 Do not reorder words

ispell reorders words in personal dictionary without good reason.

The correct approach is to build the internal data structure with variant
spellings stored in the same order as they appear in the personal dictionary.
Fortunately, this is easy, though the patch is to a different file. This one
has been tested (That's what I get for trying to rush out a fix before a
meeting!).
---
 makedent.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/makedent.c b/makedent.c
index 0453d11..d121345 100644
--- a/makedent.c
+++ b/makedent.c
@@ -447,9 +447,10 @@ int combinecaps (hdrp, newp)
     if (retval == 0)
 	{
 	/*
-	** Couldn't combine the two entries.  Add a new variant.  For
-	** ease, we'll stick it right behind the header, rather than
-	** at the end of the list.
+	** Couldn't combine the two entries.  Add a new variant.  We
+	** stick it at the end of the variant list because it's
+	** important to maintain order; this causes the personal
+	** dictionary to have a stable ordering.
 	*/
 	forcevheader (hdrp, oldp, newp);
 	tdent = (struct dent *) mymalloc (sizeof (struct dent));
@@ -460,10 +461,13 @@ int combinecaps (hdrp, newp)
 	    return -1;
 	    }
 	*tdent = *newp;
-	tdent->next = hdrp->next;
-	hdrp->next = tdent;
-	tdent->flagfield |= (hdrp->flagfield & MOREVARIANTS);
-	hdrp->flagfield |= MOREVARIANTS;
+	for (oldp = hdrp;
+	  oldp->next != NULL  &&  oldp->flagfield & MOREVARIANTS;
+	  oldp = oldp->next)
+	    ;
+	tdent->next = oldp->next;
+	oldp->next = tdent;
+	oldp->flagfield |= MOREVARIANTS;
 	combineaffixes (hdrp, newp);
 	hdrp->flagfield |= (newp->flagfield & KEEP);
 	if (captype (newp->flagfield) == FOLLOWCASE)
--