diff --git a/.gitignore b/.gitignore index e21398e..cda6a6e 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ include/version.h nbproject config.guess.dh-orig config.sub.dh-orig +debian/libsexpr* +debian/files +debian/tmp diff --git a/configure.ac b/configure.ac index 3dee3e2..2cbc10b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(libsexpr, 1.3.0) +AC_INIT(libsexpr, 1.3.1) AC_CONFIG_HEADERS([config.h]) diff --git a/debian/changelog b/debian/changelog index f50a2db..8bc26b6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,11 @@ +libsexpr (1.3.1) stable; urgency=medium + + * Release 1.3.1 Added helper functions to operate with S-expressions + + -- Alexander Vdolainen Wed, 20 May 2015 15:33:00 +0300 + libsexpr (1.3.0) stable; urgency=low * Initial release (Closes: #nnnn) - -- Alexander Vdolainen Mon, 24 Nov 2014 11:52:48 +0200 + -- Alexander Vdolainen Mon, 24 Nov 2014 11:52:48 +0200 diff --git a/debian/shlibs.local.ex b/debian/shlibs.local.ex index caeda72..0a29093 100644 --- a/debian/shlibs.local.ex +++ b/debian/shlibs.local.ex @@ -1 +1 @@ -liblibsexpr 1.3.0 libsexpr (>> 1.3.0), libsexpr (<< 1.3.99) +liblibsexpr 1.3.1 libsexpr (>> 1.3.0), libsexpr (<< 1.3.99) diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 163aaf8..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) diff --git a/include/sexpr/sexp.h b/include/sexpr/sexp.h index e54987d..891a0cd 100644 --- a/include/sexpr/sexp.h +++ b/include/sexpr/sexp.h @@ -779,6 +779,27 @@ extern "C" { } #endif +/* sexp helpers */ +#define SEXP_IS_LIST(sx) \ + ((sx)->ty == SEXP_LIST) ? 1 : 0 + +#define SEXP_IS_TYPE(sx,type) \ + ((sx)->ty == SEXP_VALUE && (sx)->aty == (type)) ? 1 : 0 + +#define SEXP_ITERATE_LIST(lst, iter, ind) \ + for((ind) = 0, (iter) = (lst)->list; (ind) < sexp_list_length(lst); \ + (ind)++, (iter) = (iter)->next) + +/* additional functions to work with sexp */ +#ifdef __cplusplus +extern "C" { +#endif +int sexp_list_cdr(sexp_t *expr, sexp_t **sx); +int sexp_list_car(sexp_t *expr, sexp_t **sx); +#ifdef __cplusplus +} +#endif + #include "sexp_ops.h" #endif /* __SEXP_H__ */ diff --git a/lib/sexp.c b/lib/sexp.c index 63759ac..8232fc8 100644 --- a/lib/sexp.c +++ b/lib/sexp.c @@ -564,3 +564,26 @@ sexp_t *new_sexp_atom(const char *buf, size_t bs, atom_t aty) { return sx; } + +/* sexp helpers */ +int sexp_list_car(sexp_t *expr, sexp_t **sx) +{ + if (!SEXP_IS_LIST(expr) || expr->list->ty != SEXP_VALUE) return 1; + + *sx = expr->list; + + return 0; +} + +int sexp_list_cdr(sexp_t *expr, sexp_t **sx) +{ + /* Dummy function. Can we do cdr properly? */ + if (!SEXP_IS_LIST(expr) || expr->list->ty != SEXP_VALUE) return 1; + + if (!expr->list->next) *sx = NULL; + else *sx = expr->list->next; + + return 0; +} + +