From 19c69d8e5a9151d25938eb06244978eb753995e8 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 13 Mar 2003 10:31:35 +0000 Subject: [PATCH] Better debugging output. --- ChangeLog | 4 ++++ src/search.cc | 45 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 973d00d..4b2eb2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2002-12-07 Bruno Haible + * src/search.cc (Search::prepare_asso_values) [DEBUG]: Also print + the keyword list in order. + (Search::find_asso_values) [DEBUG]: Upon failure, print the union_set. + * src/options.h (Options::get_size_multiple): Change return type to float. (Options::_size_multiple): Change type to float. diff --git a/src/search.cc b/src/search.cc index 4d2c58f..cb0ed8f 100644 --- a/src/search.cc +++ b/src/search.cc @@ -830,9 +830,39 @@ Search::prepare_asso_values () _collision_detector = new Bool_Array (_max_hash_value + 1); if (option[DEBUG]) - fprintf (stderr, "total non-linked keys = %d\nmaximum associated value is %d" - "\nmaximum size of generated hash table is %d\n", - non_linked_length, asso_value_max, _max_hash_value); + { + fprintf (stderr, "total non-linked keys = %d\nmaximum associated value is %d" + "\nmaximum size of generated hash table is %d\n", + non_linked_length, asso_value_max, _max_hash_value); + + int field_width; + + field_width = 0; + { + for (KeywordExt_List *temp = _head; temp; temp = temp->rest()) + { + KeywordExt *keyword = temp->first(); + if (field_width < keyword->_selchars_length) + field_width = keyword->_selchars_length; + } + } + + fprintf (stderr, "\ndumping the keyword list without duplicates\n"); + fprintf (stderr, "keyword #, %*s, keyword\n", field_width, "keysig"); + int i = 0; + for (KeywordExt_List *temp = _head; temp; temp = temp->rest()) + { + KeywordExt *keyword = temp->first(); + fprintf (stderr, "%9d, ", ++i); + if (field_width > keyword->_selchars_length) + fprintf (stderr, "%*s", field_width - keyword->_selchars_length, ""); + for (int j = 0; j < keyword->_selchars_length; j++) + putc (keyword->_selchars[j], stderr); + fprintf (stderr, ", %.*s\n", + keyword->_allchars_length, keyword->_allchars); + } + fprintf (stderr, "\nend of keyword list\n\n"); + } if (option[RANDOM] || option.get_jump () == 0) /* We will use rand(), so initialize the random number generator. */ @@ -1191,8 +1221,15 @@ Search::find_asso_values () if (option[DEBUG]) { - fprintf (stderr, "** collision not resolved after %d iterations, backtracking...\n", + fprintf (stderr, "** collision not resolved after %d iterations of asso_value[", iterations); + for (union_index = 0; union_index < union_set_length; union_index++) + { + if (union_index > 0) + fprintf (stderr, ","); + fprintf(stderr, "'%c'", union_set[union_index]); + } + fprintf (stderr, "], backtracking...\n"); fflush (stderr); } }