diff --git a/env.c b/env.c index f78e3f3..4425b1e 100644 --- a/env.c +++ b/env.c @@ -1,5 +1,6 @@ #include #include +#include #include "lake.h" #include "env.h" #include "hashtab.h" diff --git a/lake.c b/lake.c index b3447a8..18025b4 100644 --- a/lake.c +++ b/lake.c @@ -16,6 +16,7 @@ #include "env.h" #include "lake.h" #include "parse.h" +#include "string.h" static LakeVal _NIL = { TYPE_NIL, sizeof(LakeVal) }; LakeVal *NIL = &_NIL; diff --git a/string.c b/string.c index c191791..b9f4817 100644 --- a/string.c +++ b/string.c @@ -18,6 +18,20 @@ void str_free(LakeStr *str) free(str); } +NILP str_set(LakeStr *str, char *s) +{ + str->n = strlen(s); + str->s = strdup(s); + return NIL; +} + +LakeStr *str_from_c(char *s) +{ + LakeStr *str = str_alloc(); + str_set(str, s); + return str; +} + LakeStr *str_make(void) { return str_from_c(""); @@ -33,25 +47,11 @@ LakeStr *str_copy(LakeStr *str) return str_from_c(str->s); } -LakeStr *str_from_c(char *s) -{ - LakeStr *str = str_alloc(); - str_set(str, s); - return str; -} - char *str_val(LakeStr *str) { return strdup(str->s); } -NILP str_set(LakeStr *str, char *s) -{ - str->n = strlen(s); - str->s = strdup(s); - return NIL; -} - #define MIN(a, b) (a < b ? a : b) LakeInt *str_cmp(LakeStr *a, LakeStr *b)