aboutsummaryrefslogtreecommitdiff
path: root/lib/forlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/forlan.c')
-rw-r--r--lib/forlan.c17
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)
}
static void
+func_dequote(forlan_eval_env_t env, struct grecs_list *list)
+{
+ struct forlan_value *val = list->head->data;
+ char *s = val->v.string;
+ size_t l = strlen(s);
+
+ if (l >= 2 && s[0] == '"' && s[l-1] == '"') {
+ s++;
+ l -= 2;
+ }
+ env->retval.v.string = grecs_malloc(l + 1);
+ memcpy(env->retval.v.string, s, l);
+ env->retval.v.string[l] = 0;
+}
+
+static void
func_exit(forlan_eval_env_t env, struct grecs_list *list)
{
struct forlan_value *val = list->head->data;
@@ -1127,6 +1143,7 @@ static struct forlan_function functab[] = {
{ "parent", forlan_value_node, "n", 1, 1, func_parent },
{ "sort", forlan_value_void, "nss", 1, 3, func_sort },
{ "decode", forlan_value_literal, "s", 1, 1, func_decode },
+ { "dequote", forlan_value_literal, "s", 1, 1, func_dequote },
{ "exit", forlan_value_void, "s", 1, 1, func_exit },
{ "empty", forlan_value_boolean, "n", 1, 1, func_empty },
{ "timestamp", forlan_value_literal, "s", 1, 1, func_timestamp },

Return to:

Send suggestions and report system problems to the System administrator.