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.c50
1 files changed, 2 insertions, 48 deletions
diff --git a/src/block-parser.c b/src/block-parser.c
index 713f963..d5f1f24 100644
--- a/src/block-parser.c
+++ b/src/block-parser.c
@@ -27,6 +27,7 @@
#include "block-parser.h"
#include "gallery-utils.h"
+#include "replace-table.h"
@@ -151,53 +152,6 @@ block_parser_has_unused_data (BlockParser *parser, const char *key)
/* -------------------------------------------------------------------------------------------------------- */
-/*
- * get_next_token: retrieves first token (<!-- $(TOKEN) --> or $(TOKEN)) in the string
- * - returns newly allocated token name, caller is responsible for freeing
- * - start and end are positions of token in the source string 's'
- *
- */
-static char *
-get_next_token (const char *s, char **start, char **end)
-{
- char *dollar;
- char *end_brace;
- char *b;
-
- *start = NULL;
- *end = NULL;
-
- dollar = strstr (s, "$(");
- if (dollar == NULL)
- return NULL;
- end_brace = strchr (dollar + 2, ')');
- if (end_brace == NULL)
- return NULL;
-
- /* Go back and try to find placeholder beginning */
- for (b = dollar; b >= s + 3; b--) {
- if (*b == '-' && *(b-1) == '-' && *(b-2) == '!' && *(b-3) == '<') {
- *start = b - 3;
- break;
- }
- }
- if (*start == NULL)
- *start = dollar;
-
- /* Go forth and try to find placeholder end */
- for (b = end_brace; b <= end_brace + strlen (end_brace) - 3; b++) {
- if (*b == '-' && *(b+1) == '-' && *(b+2) == '>') {
- *end = b + 2;
- break;
- }
- }
- if (*end == NULL)
- *end = end_brace;
-
- return g_strndup (dollar + 2, end_brace - dollar - 2);
-}
-
-
static void
push_string (BlockParser *parser, const char *piece)
{
@@ -257,7 +211,7 @@ block_parser_read_and_parse (BlockParser *parser, FILE *stream)
/* find tokens */
b = buffer;
- while ((token = get_next_token (b, &start, &end))) {
+ while ((token = get_next_token (b, &start, &end, NULL))) {
handled = FALSE;
/* push the string before the token */