diff options
Diffstat (limited to 'lib/forlan.c')
-rw-r--r-- | lib/forlan.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/forlan.c b/lib/forlan.c index 2275bc7..977271d 100644 --- a/lib/forlan.c +++ b/lib/forlan.c | |||
@@ -1049,6 +1049,22 @@ func_decode(forlan_eval_env_t env, struct grecs_list *list) | |||
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | static void | 1051 | static void |
1052 | func_dequote(forlan_eval_env_t env, struct grecs_list *list) | ||
1053 | { | ||
1054 | struct forlan_value *val = list->head->data; | ||
1055 | char *s = val->v.string; | ||
1056 | size_t l = strlen(s); | ||
1057 | |||
1058 | if (l >= 2 && s[0] == '"' && s[l-1] == '"') { | ||
1059 | s++; | ||
1060 | l -= 2; | ||
1061 | } | ||
1062 | env->retval.v.string = grecs_malloc(l + 1); | ||
1063 | memcpy(env->retval.v.string, s, l); | ||
1064 | env->retval.v.string[l] = 0; | ||
1065 | } | ||
1066 | |||
1067 | static void | ||
1052 | func_exit(forlan_eval_env_t env, struct grecs_list *list) | 1068 | func_exit(forlan_eval_env_t env, struct grecs_list *list) |
1053 | { | 1069 | { |
1054 | struct forlan_value *val = list->head->data; | 1070 | struct forlan_value *val = list->head->data; |
@@ -1127,6 +1143,7 @@ static struct forlan_function functab[] = { | |||
1127 | { "parent", forlan_value_node, "n", 1, 1, func_parent }, | 1143 | { "parent", forlan_value_node, "n", 1, 1, func_parent }, |
1128 | { "sort", forlan_value_void, "nss", 1, 3, func_sort }, | 1144 | { "sort", forlan_value_void, "nss", 1, 3, func_sort }, |
1129 | { "decode", forlan_value_literal, "s", 1, 1, func_decode }, | 1145 | { "decode", forlan_value_literal, "s", 1, 1, func_decode }, |
1146 | { "dequote", forlan_value_literal, "s", 1, 1, func_dequote }, | ||
1130 | { "exit", forlan_value_void, "s", 1, 1, func_exit }, | 1147 | { "exit", forlan_value_void, "s", 1, 1, func_exit }, |
1131 | { "empty", forlan_value_boolean, "n", 1, 1, func_empty }, | 1148 | { "empty", forlan_value_boolean, "n", 1, 1, func_empty }, |
1132 | { "timestamp", forlan_value_literal, "s", 1, 1, func_timestamp }, | 1149 | { "timestamp", forlan_value_literal, "s", 1, 1, func_timestamp }, |