summaryrefslogtreecommitdiff
path: root/src/block-parser.c
diff options
context:
space:
mode:
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);