summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAntti-Juhani Kaijanaho <ajk@debian.org>2012-04-22 22:15:39 +0300
committerAntti-Juhani Kaijanaho <ajk@debian.org>2012-04-22 22:15:39 +0300
commitb2a4f15ad801b30fb8ffdad6856433fcd43c6590 (patch)
tree6c2bbf8886a9b474e81740c5c3751c643a91ed1f /lib
parent72505e09d0e04ee3ed2ac9fd6d9ded688ad88f38 (diff)
downloaddctrl-tools-b2a4f15ad801b30fb8ffdad6856433fcd43c6590.tar.gz
grep-dctrl: Allow distributing atom modifiers over a parenthesed predicate.
Signed-off-by: Antti-Juhani Kaijanaho <ajk@debian.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/strlist.c14
-rw-r--r--lib/strlist.h7
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/strlist.c b/lib/strlist.c
index c21a410..2877dc5 100644
--- a/lib/strlist.c
+++ b/lib/strlist.c
@@ -85,3 +85,17 @@ void strlist_iterator_next(struct strlist_iterator * it)
{
it->i++;
}
+
+struct strlist_memento strlist_save(struct strlist *sl)
+{
+ struct strlist_memento rv = {
+ .sl = sl,
+ .n = sl->n
+ };
+ return rv;
+}
+void strlist_restore(struct strlist_memento mem)
+{
+ mem.sl->n = mem.n;
+}
+
diff --git a/lib/strlist.h b/lib/strlist.h
index da64623..d0de21a 100644
--- a/lib/strlist.h
+++ b/lib/strlist.h
@@ -24,12 +24,19 @@ struct strlist_iterator {
struct strlist *sl;
size_t i;
};
+struct strlist_memento {
+ struct strlist *sl;
+ size_t n;
+};
struct strlist *strlist_new(void);
_Bool strlist_append(struct strlist *, const char *);
_Bool strlist_is_empty(struct strlist *);
void strlist_free(struct strlist *);
+struct strlist_memento strlist_save(struct strlist *);
+void strlist_restore(struct strlist_memento);
+
struct strlist_iterator strlist_begin(struct strlist *);
_Bool strlist_iterator_at_end(struct strlist_iterator);
const char *strlist_iterator_get(struct strlist_iterator);