parse_text.c
changeset 15 17a66ceb774a
parent 14 a961bb8806b9
child 17 d95d9e7a2b81
--- a/parse_text.c	Wed Aug 29 00:19:14 2007 +0200
+++ b/parse_text.c	Sat Sep 01 00:50:11 2007 +0200
@@ -1,27 +1,41 @@
 #include <stdio.h>
 #include "dictre.h"
 
-static void give_accent_to_word(const char *tmp)
+static void give_accent_to_word(const char *word)
 {
     char def[MAXDEF];
+    char low[MAXWORD];
+    char recased[MAXWORD];
+    enum Case vcase[MAXWORD];
 
-    find_def(tmp, def);
+    /* Get case */
+    get_case(vcase, word);
+
+    /* Get lowercase version */
+    get_lowcase_str(low, word);
+
+    /* Find the lowercase version */
+    find_def(low, def);
     if (def[0] != 0) /* found */
     {
         /* Print the word UNTIL a space.
          * the definition will have the form:
          *    ACCENTED_WORD NOMINATIVE1 NOMINATIVE2 ... \n */
         char *first_space;
-        char *pos;
+        char spacepos;
         first_space = strchr(def, ' ');
         if (first_space != 0) /* Space found */
-            for(pos = def; pos < first_space; ++pos)
-                putchar(*pos);
+        {
+            spacepos = first_space - def;
+            def[spacepos] = 0; /* Mark an end of string */
+            reapply_case(recased, def, vcase);
+            printf("%s", recased);
+        }
         return;
     }
 
     /* if first_space == 0 or word not found */
-    printf("%s", tmp);
+    printf("%s", word);
 }
 
 static void process_text(FILE *in, int pos, int length)