diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2012-04-16 23:10:28 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2012-04-16 23:10:28 +0200 |
| commit | 2fb235addd4893bab692504a69006eff083dc71f (patch) | |
| tree | 28039c5b5b16cfd3461c1eb4d8e8f4a6d1f61b0d /src/replace-table.c | |
| parent | 6f0b21b11f8711ef425069b277a1c743202174a7 (diff) | |
| download | cataract-2fb235addd4893bab692504a69006eff083dc71f.tar.xz | |
block-parser: Allow indented token arguments
Some of us like to have indented arguments from a function name.
Diffstat (limited to 'src/replace-table.c')
| -rw-r--r-- | src/replace-table.c | 20 |
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 == '('); +} |
