Commits

Mikhail Korobov committed 2b9346b

update dawgdic to latest svn (this fixes segfaults with empty dawgs)

  • Participants
  • Parent commits 98c4bfa

Comments (0)

Files changed (5)

File lib/dawgdic/completer.h

     key_[length] = '\0';
 
     index_stack_.clear();
-    index_stack_.push_back(index);
-    last_index_ = dic_->root();
+    if (guide_->size() != 0) {
+      index_stack_.push_back(index);
+      last_index_ = dic_->root();
+    }
   }
 
   // Gets the next key.

File lib/dawgdic/guide.h

   }
 
   // Swaps Guides.
-  void Swap(Guide *Guide) {
-    std::swap(units_, Guide->units_);
-    std::swap(size_, Guide->size_);
-    units_buf_.swap(Guide->units_buf_);
+  void Swap(Guide *guide) {
+    std::swap(units_, guide->units_);
+    std::swap(size_, guide->size_);
+    units_buf_.swap(guide->units_buf_);
   }
 
   // Initializes a Guide.

File lib/dawgdic/ranked-completer.h

     value_ = -1;
 
     nodes_.clear();
-    CreateNode(index, 0, 'X');
-
     node_queue_.clear();
-    EnqueueNode(0);
-
     while (!candidate_queue_.empty()) {
       candidate_queue_.pop();
     }
+
+    if (guide_->size() != 0) {
+      CreateNode(index, 0, 'X');
+      EnqueueNode(0);
+    }
   }
 
   // Gets the next key.

File lib/dawgdic/ranked-guide.h

   }
 
   // Swaps RankedGuides.
-  void Swap(RankedGuide *RankedGuide) {
-    std::swap(units_, RankedGuide->units_);
-    std::swap(size_, RankedGuide->size_);
-    units_buf_.swap(RankedGuide->units_buf_);
+  void Swap(RankedGuide *guide) {
+    std::swap(units_, guide->units_);
+    std::swap(size_, guide->size_);
+    units_buf_.swap(guide->units_buf_);
   }
 
   // Initializes a RankedGuide.

File tests/test_dawg.py

             assert "can't load _dawg.Dictionary" in e.args[0]
 
     def test_no_segfaults_on_empty_dawg(self):
-        pytest.skip("this test segfaults")
         d = dawg.CompletionDAWG([])
         assert d.keys() == []