[tracker/parser-unicode-libs-review] Added --verbose option to the parser tester
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/parser-unicode-libs-review] Added --verbose option to the parser tester
- Date: Wed, 5 May 2010 08:52:22 +0000 (UTC)
commit 6ad51c47ceadb99e93c2365ba2452a6848f3c7cd
Author: Aleksander Morgado <aleksander lanedo com>
Date: Wed May 5 10:51:24 2010 +0200
Added --verbose option to the parser tester
tests/libtracker-fts/tracker-parser-test.c | 81 ++++++++++++++++------------
1 files changed, 46 insertions(+), 35 deletions(-)
---
diff --git a/tests/libtracker-fts/tracker-parser-test.c b/tests/libtracker-fts/tracker-parser-test.c
index 463b004..1c38215 100644
--- a/tests/libtracker-fts/tracker-parser-test.c
+++ b/tests/libtracker-fts/tracker-parser-test.c
@@ -32,13 +32,20 @@
#define DEFAULT_MAX_WORD_LENGTH 30
-static gint max_word_length = DEFAULT_MAX_WORD_LENGTH;
-static gchar *text;
-static gchar *filename;
+static gint max_word_length = DEFAULT_MAX_WORD_LENGTH;
+static gchar *text;
+static gchar *filename;
+static gboolean verbose;
/* Command Line options */
static const GOptionEntry options [] = {
{
+ "verbose", 'v', G_OPTION_FLAG_NO_ARG,
+ G_OPTION_ARG_NONE, &verbose,
+ "Enable verbose output",
+ NULL
+ },
+ {
"max-word-length", 'm', 0,
G_OPTION_ARG_INT, &max_word_length,
"Maximum word length to consider",
@@ -148,15 +155,12 @@ run_parsing (void)
/* Loop through all words! */
while (1) {
const gchar *word;
- gchar *word_hex;
- gchar *original_word;
- gchar *original_word_hex;
gint position;
gint byte_offset_start;
gint byte_offset_end;
gboolean stop_word;
gint word_length;
- gint original_word_length;
+
/* Process next word */
word = tracker_parser_next (parser,
@@ -171,34 +175,41 @@ run_parsing (void)
break;
}
- /* Get original word */
- original_word_length = byte_offset_end - byte_offset_start;
- original_word = g_malloc (original_word_length + 1);
- memcpy (original_word,
- &text[byte_offset_start],
- original_word_length);
- original_word[original_word_length] = '\0';
-
- /* Get hex strings */
- word_hex = tracker_strhex (word, word_length, ':');
- original_word_hex = tracker_strhex (original_word,
- original_word_length,
- ':');
-
- g_print ("WORD at %d [%d,%d] Original: '%s' (%s), "
- "Processed: '%s' (%s) (stop? %s)\n",
- position,
- byte_offset_start,
- byte_offset_end,
- original_word,
- original_word_hex,
- word,
- word_hex,
- stop_word ? "yes" : "no");
-
- g_free (word_hex);
- g_free (original_word_hex);
- g_free (original_word);
+ if (verbose) {
+ gchar *word_hex;
+ gchar *original_word;
+ gchar *original_word_hex;
+ gint original_word_length;
+
+ /* Get original word */
+ original_word_length = byte_offset_end - byte_offset_start;
+ original_word = g_malloc (original_word_length + 1);
+ memcpy (original_word,
+ &text[byte_offset_start],
+ original_word_length);
+ original_word[original_word_length] = '\0';
+
+ /* Get hex strings */
+ word_hex = tracker_strhex (word, word_length, ':');
+ original_word_hex = tracker_strhex (original_word,
+ original_word_length,
+ ':');
+
+ g_print ("WORD at %d [%d,%d] Original: '%s' (%s), "
+ "Processed: '%s' (%s) (stop? %s)\n",
+ position,
+ byte_offset_start,
+ byte_offset_end,
+ original_word,
+ original_word_hex,
+ word,
+ word_hex,
+ stop_word ? "yes" : "no");
+
+ g_free (word_hex);
+ g_free (original_word_hex);
+ g_free (original_word);
+ }
}
g_print ("\n----> Parsing finished after '%lf' seconds\n",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]