Commit e35c7f42 authored by Niels Möller's avatar Niels Möller
Browse files

Added sexp_v()

Rev: src/sexp.c:1.6
Rev: src/sexp.h:1.7
parent b94e6c4a
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "sexp.h" #include "sexp.h"
#include "format.h" #include "format.h"
#include "list.h"
#include "werror.h" #include "werror.h"
#include "xalloc.h" #include "xalloc.h"
...@@ -415,6 +414,18 @@ static struct lsh_string *do_format_sexp_vector(struct sexp *e, int style) ...@@ -415,6 +414,18 @@ static struct lsh_string *do_format_sexp_vector(struct sexp *e, int style)
} }
} }
struct sexp *sexp_v(struct object_list *l)
{
NEW(sexp_vector, v);
v->super.format = do_format_sexp_vector;
v->super.iter = make_iter_vector;
v->elements = l;
return &v->super;
}
struct sexp *sexp_l(unsigned n, ...) struct sexp *sexp_l(unsigned n, ...)
{ {
va_list args; va_list args;
...@@ -429,16 +440,11 @@ struct sexp *sexp_l(unsigned n, ...) ...@@ -429,16 +440,11 @@ struct sexp *sexp_l(unsigned n, ...)
} }
else else
{ {
NEW(sexp_vector, v); struct sexp *v = sexp_v(make_object_listv(n, args));
v->super.format = do_format_sexp_vector;
v->super.iter = make_iter_vector;
v->elements = make_object_listv(n, args);
va_end(args); va_end(args);
return &v->super; return v;
} }
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define LSH_SEXP_H_INCLUDED #define LSH_SEXP_H_INCLUDED
#include "bignum.h" #include "bignum.h"
#include "list.h"
/* Forward declaration */ /* Forward declaration */
struct sexp_iterator; struct sexp_iterator;
...@@ -109,6 +110,9 @@ struct sexp *sexp_c(struct sexp *car, struct sexp_cons *cdr); ...@@ -109,6 +110,9 @@ struct sexp *sexp_c(struct sexp *car, struct sexp_cons *cdr);
/* list */ /* list */
struct sexp *sexp_l(unsigned n, ...); struct sexp *sexp_l(unsigned n, ...);
/* vector */
struct sexp *sexp_v(struct object_list *l);
#if 0 #if 0
/* Extracting information from sexp. These functions accept NULL /* Extracting information from sexp. These functions accept NULL
* arguments, and return NULL if the conversion is not possible */ * arguments, and return NULL if the conversion is not possible */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment