Thanks a lot for the review and comments. Here is an updated patch.

On 6/25/2014 8:20 AM, Abhijit Menon-Sen wrote:
Your patch should definitely add a test case or two to sql/unaccent.sql and expected/unaccent.out showing the behaviour that didn't work before the change.
That would require adding new entries to the "unaccent.rules" template. I'm afraid that the templates I'm using for Arabic now are not complete enough to be including in the default dictionary.

I can create a new template just for the test cases but I've to update the make file to include that file in installation. Should I do this?


Mohammad Alhashash

diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c
old mode 100644
new mode 100755
index a337df6..eb7e2a3
--- a/contrib/unaccent/unaccent.c
+++ b/contrib/unaccent/unaccent.c
@@ -105,15 +105,15 @@ initTrie(char *filename)
                        while ((line = tsearch_readline(&trst)) != NULL)
-                                * The format of each line must be "src trg" 
where src and trg
+                                * The format of each line must be "src [trg]" 
where src and trg
                                 * are sequences of one or more non-whitespace 
                                 * separated by whitespace.  Whitespace at 
start or end of
-                                * line is ignored.
+                                * line is ignored. If trg is empty, a 
zero-length string is used.
                                int                     state;
                                char       *ptr;
                                char       *src = NULL;
-                               char       *trg = NULL;
+                               char       *trg = "";
                                int                     ptrlen;
                                int                     srclen = 0;
                                int                     trglen = 0;
@@ -160,6 +160,10 @@ initTrie(char *filename)
+                               /* It's OK to have a valid src and empty trg. */
+                               if (state > 0 && trglen == 0)
+                                       state = 5;
                                if (state >= 3)
                                        rootTrie = placeChar(rootTrie,
 (unsigned char *) src, srclen,
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to