|
|
@ -5,6 +5,15 @@
|
|
|
|
#include <libse.h>
|
|
|
|
#include <libse.h>
|
|
|
|
#include <internal/exstring.h>
|
|
|
|
#include <internal/exstring.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char* strdup(const char* str)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
register size_t size = strlen(str);
|
|
|
|
|
|
|
|
char* ret = malloc(size+1);
|
|
|
|
|
|
|
|
memcpy(ret, str, size);
|
|
|
|
|
|
|
|
ret[size] = 0;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void _addcar(list_t* out, exString* token, int nil, int ucase)
|
|
|
|
static void _addcar(list_t* out, exString* token, int nil, int ucase)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(ucase)
|
|
|
|
if(ucase)
|
|
|
@ -304,3 +313,60 @@ list_t* se_new(char* str, int dupe)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _se_new(str, SE_STRING, dupe); //We don't need the list part.
|
|
|
|
return _se_new(str, SE_STRING, dupe); //We don't need the list part.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
car_t se_make(const char* fmt)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!fmt)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
car_t c;
|
|
|
|
|
|
|
|
memset(&c, 0, sizeof(car_t));
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(*fmt && iws(*fmt))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fmt+=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!*fmt) return se_make(NULL);
|
|
|
|
|
|
|
|
else if(*fmt == '(') {
|
|
|
|
|
|
|
|
car_t c;
|
|
|
|
|
|
|
|
list_t* ret = se_parse(fmt, SETP_DEFAULT);
|
|
|
|
|
|
|
|
memset(&c,0,sizeof(car_t));
|
|
|
|
|
|
|
|
c.ptr = ret;
|
|
|
|
|
|
|
|
c.alloced= 1;
|
|
|
|
|
|
|
|
c.size = sizeof(list_t);
|
|
|
|
|
|
|
|
c.sexpr = 1;
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
car_t c;
|
|
|
|
|
|
|
|
memset(&c,0,sizeof(car_t));
|
|
|
|
|
|
|
|
c.ptr = strdup(fmt);
|
|
|
|
|
|
|
|
c.alloced=1;
|
|
|
|
|
|
|
|
c.size = strlen((char*)c.ptr);
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void se_rplaca(list_t* cons, car_t car)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(cons->car.alloced && cons->ptr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch(se_typeof(cons))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case SE_LIST:
|
|
|
|
|
|
|
|
se_free(cons->ptr); break;
|
|
|
|
|
|
|
|
case SE_STRING:
|
|
|
|
|
|
|
|
free(cons->ptr); break;
|
|
|
|
|
|
|
|
default: break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&cons->car, &car, sizeof(car_t));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void se_rplacd(list_t* cons, list_t* cdr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(cons->cdr)
|
|
|
|
|
|
|
|
se_free(cons->cdr);
|
|
|
|
|
|
|
|
cons->cdr = cdr;
|
|
|
|
|
|
|
|
}
|
|
|
|