summary refs log tree commit diff
path: root/src/variable.c
diff options
context:
space:
mode:
authorNakidai <nakidai@disroot.org>2025-03-23 20:56:47 +0300
committerNakidai <nakidai@disroot.org>2025-03-23 20:56:47 +0300
commit159666bae6cc185a5abac154b85c49406f32f30c (patch)
treea5f424eb11e83dd1831b824229e359583bcc9f5d /src/variable.c
parentc74aea420c662039072f606b2d5ef1c73426e481 (diff)
download3cl-159666bae6cc185a5abac154b85c49406f32f30c.tar.gz
3cl-159666bae6cc185a5abac154b85c49406f32f30c.zip
Last time I was here 8 months ago, idk what is this
Diffstat (limited to 'src/variable.c')
-rw-r--r--src/variable.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/variable.c b/src/variable.c
index 38ea2e3..b764c28 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -30,3 +30,29 @@ struct CCLVariable *ccl_variable_getany(struct CCL *ccl, struct CCLFrame *frame,
 
     return NULL;
 }
+
+struct CCLVariable *ccl_variable_set(struct CCLVariable *vars, char name, CCLNum value)
+{
+    struct CCLVariable *toset;
+    struct CCLVariable var = (struct CCLVariable)
+    {
+        .next = NULL,
+        .name = name,
+        .value = value,
+    };
+
+    if (vars->name == '_')
+    {
+        toset = vars;
+        var.prev = NULL;
+    } else
+    {
+        for (toset = vars; toset->next != NULL; toset = toset->next);
+        toset->next = (struct CCLVariable *)malloc(sizeof(*toset->next));
+        var.prev = toset;
+        toset = toset->next;
+    }
+
+    *toset = var;
+    return toset;
+}