Fixed things in replace.
authorviric@mandarina
Mon, 13 Aug 2007 23:45:27 +0200
changeset 6 bc41369f4587
parent 5 c87681fff7d3
child 7 c815840c5b65
Fixed things in replace.
Makefile
dict.c
load.c
repeated.c
--- a/Makefile	Mon Aug 13 16:27:41 2007 +0200
+++ b/Makefile	Mon Aug 13 23:45:27 2007 +0200
@@ -1,4 +1,4 @@
-CFLAGS=-O2 -g
+CFLAGS=-g
 CC=gcc
 
 all: dictre idx2index trim-nou8
--- a/dict.c	Mon Aug 13 16:27:41 2007 +0200
+++ b/dict.c	Mon Aug 13 23:45:27 2007 +0200
@@ -107,7 +107,7 @@
         case '8': return 60;
         case '9': return 61;
         case '+': return 62;
-        case '/': return 63;
+        case '-': return 63;
         default:
                   return 0;
     }
--- a/load.c	Mon Aug 13 16:27:41 2007 +0200
+++ b/load.c	Mon Aug 13 23:45:27 2007 +0200
@@ -23,15 +23,8 @@
 
 static void new_word(struct Word *from)
 {
-    static int dispnwords = 0;
     memcpy(&words[nwords], from, sizeof(*from));
     nwords++;
-    dispnwords++;
-    if (dispnwords >= 1000)
-    {
-        dispnwords = 0;
-        printf("Loaded: %i\n", nwords);
-    }
 }
 
 static void new_dont_touch(int n)
@@ -70,11 +63,15 @@
     struct Word w;
     int last_offset = 0;
     int def_avoided = 0;
+    int numword = 0;;
+    static int dispnwords = 0;
 
     do {
         int offset, length;
         char *defstr;
         w.w = get_word(index);
+        /*numword++;
+        printf("words: %i\n", numword);*/
         if (w.w == 0)
             break;
         /*printf("Word: %s\n", w.w);*/
@@ -93,13 +90,22 @@
             int newindex, repindex;
             defstr = get_def(fdefs, offset, length);
             newindex = new_def(defstr, offset, length);
+            /*
+            printf("Length %i (%s): %i\n", newindex, w.w, length);
+            */
             
             /* Store it in the hash for repeated defs */
             repindex = def_repeated(&defs[newindex]);
             if (repindex != -1) 
             {
                 def_avoided += 1;
-                printf("Repeated def avoided %i (word %s)\n", def_avoided, w.w);
+                /*
+                printf("Repeated def avoided %i (for def %i)"
+                        " (%s)\n%i %s\n%i %s\n",
+                        def_avoided, repindex, w.w,
+                        length, defstr,
+                        defs[repindex].length, defs[repindex].d);
+                        */
                 remove_def(newindex);
                 newindex = repindex;
             } else
@@ -112,6 +118,16 @@
         if (strncmp(w.w, "00database", sizeof("00database") - 1) == 0)
                 new_dont_touch(w.def);
         new_word(&w);
+
+        /* stdout Display */
+        dispnwords++;
+        if (dispnwords >= 1000)
+        {
+            dispnwords = 0;
+            printf("Loaded: %i Repeated definitions avoided: %i\n", nwords,
+                    def_avoided);
+        }
+
     } while(1);
 }
 
--- a/repeated.c	Mon Aug 13 16:27:41 2007 +0200
+++ b/repeated.c	Mon Aug 13 23:45:27 2007 +0200
@@ -71,6 +71,9 @@
     el->def = ptr;
     el->next = 0;
     el->index = index;
+    /*
+    printf("New index: %i\n", index);
+    */
 
     /* Let the last point to the new element */
     if (ndhash[hash] != 0)
@@ -99,7 +102,14 @@
         if (hdef->length == ptr->length
                 && (strncmp(hdef->d, ptr->d, ptr->length) == 0))
             /* Repeated found !*/
+        {
+            /*
+            printf("Found: l1: %i l2: %i => %i\n", ptr->length, hdef->length,
+                    h->index);
+                    */
             return h->index;
+        }
+        h = h->next;
     }
 
     /* Not found */