diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2013-04-07 12:01:40 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2013-04-07 12:12:42 +0200 |
| commit | ddadb157cfa3e1658f120341b4085ec5421ff73f (patch) | |
| tree | 18d6939c52fdd1d9da01010f84419611def133f5 /src/replace-table.c | |
| parent | 125aaf366c2ae370306f678b9c9c0b408e0d3908 (diff) | |
| download | cataract-ddadb157cfa3e1658f120341b4085ec5421ff73f.tar.xz | |
Strip unused template tags by default
If there's a tag defined but not used on replace table processing,
this option determines whether it should be written in the generated
file or ignored completely.
Turned on by default, this will save a few bytes. Use commandline option
'--debug-dont-strip-unused-tags' to turn it off, e.g. when debugging
template files.
Diffstat (limited to 'src/replace-table.c')
| -rw-r--r-- | src/replace-table.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/replace-table.c b/src/replace-table.c index 9c1b254..a36a83c 100644 --- a/src/replace-table.c +++ b/src/replace-table.c @@ -34,6 +34,7 @@ struct ReplaceTable { GHashTable *table; GHashTable *defines; GHashTable *functions; + gboolean strip_unused_tags; }; typedef struct { @@ -50,6 +51,7 @@ replace_table_new () table = g_new0 (ReplaceTable, 1); table->table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); table->functions = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + table->strip_unused_tags = TRUE; /* default */ return table; } @@ -66,6 +68,18 @@ replace_table_free (ReplaceTable *table) /* + * replace_table_set_strip_unused_tags: set whether all unused/unknown tags should be stripped (default = TRUE) + * + */ +void +replace_table_set_strip_unused_tags (ReplaceTable *table, gboolean value) +{ + g_return_if_fail (table != NULL); + + table->strip_unused_tags = value; +} + +/* * replace_table_add_key: add tag/value pair to replace * * tag, value will be referenced inside @@ -345,7 +359,7 @@ replace_table_process (gchar **buffer, ReplaceTable *table) } /* push the tag if not matched above */ - if (! handled) + if (! handled && ! table->strip_unused_tags) g_string_append_len (dst, start, end - start + 1); g_free (token); |
