if(STRINGS_STRLEN_ARGS != u64_get_num_args(b)) {
return cons(b, rest);
}
- Sexpr* arg = car(b->value.b.args);
+ Sexpr* arg = eval(clone(car(b->value.b.args)), env);
#ifdef TYPECHECK
if(unquote(arg)->type != STR) {
ERR("strlen: ", "argument not string");
return cons(from_nil(), rest);
}
#endif // typecheck
- size_t sl = strlen(arg->value.str);
+ size_t sl = strlen(unquote(arg)->value.str);
sexpr_free(b);
return cons (from_uint(sl), rest);
}
Sexpr* snd = eval(clone(car(args)), env);
Sexpr* fst = eval(clone(car(cdr(args))), env);
#ifdef TYPECHECK
- if(snd->type != STR || fst->type != STR) {
+ if(unquote(snd)->type != STR || unquote(fst)->type != STR) {
ERR("strcat: ", "arguments not string");
sexpr_free(snd);
sexpr_free(fst);
return cons(from_nil(), rest);
}
#endif // typecheck
- char* fs = fst->value.str;
- char* ss = snd->value.str;
+ char* fs = unquote(fst)->value.str;
+ char* ss = unquote(snd)->value.str;
char* out = malloc(sizeof(char)*(strlen(fs)+strlen(ss)));
strcpy(out, fs);
strcat(out, ss);
Sexpr* index = eval(clone(car(cdr(args))), env);
Sexpr* str = eval(clone(car(args)), env);
#ifdef TYPECHECK
- if(str->type != STR || index->type != UINT) {
+ if(unquote(str)->type != STR || unquote(index)->type != UINT) {
ERR("strat: ", "arguments not string");
sexpr_free(index);
sexpr_free(str);
return cons(from_nil(), rest);
}
#endif // typecheck
- size_t len = strlen(str->value.str);
- size_t idx = index->value.u;
+ size_t len = strlen(unquote(str)->value.str);
+ size_t idx = unquote(index)->value.u;
if(len < idx) {
WARN("", "index out of bounds");
return cons(from_nil(), rest);
Sexpr* args = b->value.b.args;
Sexpr* arg = eval(clone(car(args)), env);
#ifdef TYPECHECK
- if(arg->type != STR) {
+ if(unquote(arg)->type != STR) {
ERR("strexpand: ", "argument not string");
sexpr_free(arg);
sexpr_free(b);
return cons(from_nil(), rest);
}
#endif // typecheck
- size_t len = strlen(arg->value.str);
+ size_t len = strlen(unquote(arg)->value.str);
Sexpr* toret = from_nil();
char arr[] = {'\0', '\0'};
while(len > 0) {
Sexpr* subex = eval(clone(car(cdr(args))), env);
Sexpr* strex = eval(clone(car(args)), env);
#ifdef TYPECHECK
- if(subex->type != STR || strex->type != STR) {
+ if(unquote(subex)->type != STR || unquote(strex)->type != STR) {
ERR("substr: ", "arguments not strings");
sexpr_free(subex);
sexpr_free(strex);
}
#endif
Sexpr* result = from_nil();
- char* sub = subex->value.str;
- char* str = strex->value.str;
+ char* sub = unquote(subex)->value.str;
+ char* str = unquote(strex)->value.str;
char* currstr = str;
char* res;
size_t idx;
Sexpr* delimex = eval(clone(car(cdr(args))), env);
Sexpr* strex = eval(clone(car(args)), env);
#ifdef TYPECHECK
- if(delimex->type != STR || strex->type != STR) {
+ if(unquote(delimex)->type != STR || unquote(strex)->type != STR) {
ERR("strtok: ", "arguments not strings");
sexpr_free(delimex);
sexpr_free(strex);
}
#endif
Sexpr* result = from_nil();
- char* delim = delimex->value.str;
- char* str = strex->value.str;
+ char* delim = unquote(delimex)->value.str;
+ char* str = unquote(strex)->value.str;
char* out = strtok(str, delim);
while(out != NULL) {
result = cons(from_string(out), result);