From eb3092f8bd30d065c4e6f4bf0159309e1a960156 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 31 Mar 2011 23:23:24 +0200 Subject: block-parser: Add function to mark block as used Some blocks such as "IMG_LIST" are containers themselves and no data are retrieved from them. That way they don't ever get marked as used, resulting in constant hit in the generator loop. --- src/block-parser.c | 17 +++++++++++++++++ src/block-parser.h | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/src/block-parser.c b/src/block-parser.c index d4a04c1..d4fcccb 100644 --- a/src/block-parser.c +++ b/src/block-parser.c @@ -147,6 +147,23 @@ block_parser_has_unused_data (BlockParser *parser, const gchar *key) return FALSE; } +/* + * block_parser_set_as_used: manually set data as used - sometimes blocks can act as containers for other nested blocks and + * cannot be used itself + * + */ +void +block_parser_set_as_used (BlockParser *parser, const gchar *key) +{ + BlockData *data = NULL; + + g_assert (parser != NULL); + + data = g_hash_table_lookup (parser->table, key); + if (data != NULL && data->finished == TRUE) { + data->used = TRUE; + } +} diff --git a/src/block-parser.h b/src/block-parser.h index 666d27a..21d0cfb 100644 --- a/src/block-parser.h +++ b/src/block-parser.h @@ -55,6 +55,13 @@ gchar * block_parser_get_data (BlockParser *parser, const gchar *key); */ gboolean block_parser_has_unused_data (BlockParser *parser, const gchar *key); +/* + * block_parser_set_as_used: manually set data as used - sometimes blocks can act as containers for other nested blocks and + * cannot be used itself + * + */ +void block_parser_set_as_used (BlockParser *parser, const gchar *key); + /* * block_parser_read_and_parse: reads input from the file and returns parsed line * - if there's a multiline block, string before the opening placeholder and -- cgit v1.2.3