summaryrefslogtreecommitdiff
path: root/src/replace-table.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/replace-table.c')
-rw-r--r--src/replace-table.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/replace-table.c b/src/replace-table.c
index 2f80beb..3398bae 100644
--- a/src/replace-table.c
+++ b/src/replace-table.c
@@ -279,7 +279,7 @@ replace_table_process (gchar **buffer, ReplaceTable *table)
replace_value = NULL;
/* match defines */
- if (table->defines && g_str_has_prefix (token, "value(")) {
+ if (table->defines && token_has_prefix (token, "value")) {
s = extract_token_arg (token);
replace_value = g_strdup (g_hash_table_lookup (table->defines, s));
/* fall back to empty string if not defined */
@@ -450,3 +450,21 @@ extract_token_arg (const gchar *str)
return g_strndup (start, end - start - 1);
}
+/*
+ * token_has_prefix: returns TRUE if 'prefix' matches the token syntax (i.e. "prefix (") with unlimited number of spaces before the opening bracket
+ *
+ */
+gboolean
+token_has_prefix (const gchar *token, const gchar *prefix)
+{
+ const gchar *s;
+
+ if (! g_str_has_prefix (token, prefix))
+ return FALSE;
+
+ s = token + strlen (prefix);
+ while (*s != '\0' && (*s == ' ' || *s == '\t'))
+ s++;
+
+ return (*s == '(');
+}