altos/lisp: convert GC to non-recursive
[fw/altos] / src / lisp / ao_lisp_string.c
index 87024271d2553080178d2eedfd86b8296bcbf2ee..0064064cfe07cfc22730b7ac1f369b5240a23633 100644 (file)
@@ -43,6 +43,18 @@ ao_lisp_string_new(int len) {
        return a;
 }
 
+char *
+ao_lisp_string_copy(char *a)
+{
+       int     alen = strlen(a);
+
+       char    *r = ao_lisp_alloc(alen + 1);
+       if (!r)
+               return NULL;
+       strcpy(r, a);
+       return r;
+}
+
 char *
 ao_lisp_string_cat(char *a, char *b)
 {
@@ -56,16 +68,18 @@ ao_lisp_string_cat(char *a, char *b)
        return r;
 }
 
-const struct ao_lisp_mem_type ao_lisp_string_type = {
+const struct ao_lisp_type ao_lisp_string_type = {
        .mark = string_mark,
        .size = string_size,
        .move = string_move,
 };
 
 void
-ao_lisp_string_print(char *s)
+ao_lisp_string_print(ao_poly p)
 {
+       char    *s = ao_lisp_poly_string(p);
        char    c;
+
        putchar('"');
        while ((c = *s++)) {
                switch (c) {
@@ -85,3 +99,13 @@ ao_lisp_string_print(char *s)
        }
        putchar('"');
 }
+
+void
+ao_lisp_string_patom(ao_poly p)
+{
+       char    *s = ao_lisp_poly_string(p);
+       char    c;
+
+       while ((c = *s++))
+               putchar(c);
+}