[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] muscles: a function for backward compatibility
From: |
Akim Demaille |
Subject: |
[PATCH 2/3] muscles: a function for backward compatibility |
Date: |
Tue, 9 Oct 2012 15:16:31 +0200 |
* src/muscle-tab.c (muscle_percent_variable_update): New.
Taken from the master branch.
---
src/muscle-tab.c | 37 +++++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/src/muscle-tab.c b/src/muscle-tab.c
index 37a0f0e..c203b37 100644
--- a/src/muscle-tab.c
+++ b/src/muscle-tab.c
@@ -396,6 +396,33 @@ muscle_user_name_list_grow (char const *key, char const
*user_name,
muscle_grow (key, "]]", "");
}
+/** If the \a variable name is obsolete, return the name to use,
+ * otherwise \a variable. */
+static
+char const *
+muscle_percent_variable_update (char const *variable)
+{
+ typedef struct
+ {
+ const char *obsolete;
+ const char *updated;
+ } conversion_type;
+ const conversion_type conversion[] =
+ {
+ { "api.push_pull", "api.push-pull", },
+ { "lr.keep_unreachable_states", "lr.keep-unreachable-states", },
+ };
+ char const *res = variable;
+ int i;
+ for (i = 0; i < ARRAY_CARDINALITY (conversion); ++i)
+ if (STREQ (conversion[i].obsolete, variable))
+ {
+ res = conversion[i].updated;
+ break;
+ }
+ return res;
+}
+
void
muscle_percent_define_insert (char const *variable, location variable_loc,
char const *value,
@@ -407,14 +434,8 @@ muscle_percent_define_insert (char const *variable,
location variable_loc,
char const *syncline_name;
char const *how_name;
- /* Permit certain names with underscores for backward compatibility. */
- if (0 == strcmp (variable, "api.push_pull")
- || 0 == strcmp (variable, "lr.keep_unreachable_states"))
- {
- variable_tr = strdup (variable);
- tr (variable_tr, '_', '-');
- variable = variable_tr;
- }
+ /* Backward compatibility. */
+ variable = muscle_percent_variable_update (variable);
name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
--
1.7.12.2