summaryrefslogtreecommitdiff
path: root/src/block-parser.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2011-06-04 18:18:32 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2011-06-04 18:18:32 +0200
commit02fcb53e3a986a85fa8c0248a306132c8996acd8 (patch)
tree2d0b71e8fa241a972b7a049620f5aa8d92431d39 /src/block-parser.c
parentfb5a52884dd17d17bab47de7f53c17c05ced6e1b (diff)
downloadcataract-02fcb53e3a986a85fa8c0248a306132c8996acd8.tar.xz
replace-table: Link to defines table instead of copying on creation
This allows actual defines to be used without explicit update. Also brings the benefit of placing empty string when define is not defined.
Diffstat (limited to 'src/block-parser.c')
-rw-r--r--src/block-parser.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/block-parser.c b/src/block-parser.c
index cfe9047..8bf7181 100644
--- a/src/block-parser.c
+++ b/src/block-parser.c
@@ -219,25 +219,6 @@ push_string (BlockParser *parser, const gchar *piece)
}
}
-static gchar *
-extract_arg (const gchar *str)
-{
- const gchar *start;
- const gchar *end;
-
- start = strstr (str, "(");
- if (start == NULL)
- return NULL;
- start++;
-
- end = strstr (str, ")");
- if (end == NULL)
- return NULL;
- end++;
-
- return g_strndup (start, end - start - 1);
-}
-
/*
* 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
@@ -284,7 +265,7 @@ block_parser_read_and_parse (BlockParser *parser, FILE *stream)
if (parser->conditionals && (g_str_has_prefix (token, "ifdef(") || g_str_has_prefix (token, "ifndef("))) {
data = g_new0 (BlockData, 1);
data->is_conditional = TRUE;
- data->conditional_key = extract_arg (token);
+ data->conditional_key = extract_token_arg (token);
data->should_ignore = ((g_str_has_prefix (token, "ifdef(") && g_hash_table_lookup (parser->conditionals, data->conditional_key) == NULL) ||
(g_str_has_prefix (token, "ifndef(") && g_hash_table_lookup (parser->conditionals, data->conditional_key) != NULL));
if (data->should_ignore && parser->ignore_level == 0)
@@ -297,7 +278,7 @@ block_parser_read_and_parse (BlockParser *parser, FILE *stream)
}
if (parser->conditionals && g_str_has_prefix (token, "endif(")) {
- s = extract_arg (token);
+ s = extract_token_arg (token);
data = g_queue_peek_head (parser->active_tree);
if (data == NULL || !data->is_conditional || strcmp (data->conditional_key, s) != 0) {
log_error ("block_parser_read_and_parse: something is wrong with the parser table: expected '%s' but got '%s'\n", s, data->conditional_key);
@@ -313,7 +294,7 @@ block_parser_read_and_parse (BlockParser *parser, FILE *stream)
}
if (parser->conditionals && g_str_has_prefix (token, "else(")) {
- s = extract_arg (token);
+ s = extract_token_arg (token);
data = g_queue_peek_head (parser->active_tree);
if (data == NULL || !data->is_conditional || strcmp (data->conditional_key, s) != 0) {
log_error ("block_parser_read_and_parse: something is wrong with the parser table: expected '%s' but got '%s'\n", s, data->conditional_key);