]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
* sexp.c (sexp_iterator_enter_list): Call sexp_iterator_next to
authorNiels Möller <nisse@lysator.liu.se>
Sun, 6 Oct 2002 20:17:35 +0000 (22:17 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sun, 6 Oct 2002 20:17:35 +0000 (22:17 +0200)
get to the first element of the list. Updated callers.

Rev: src/nettle/sexp.c:1.6
Rev: src/nettle/testsuite/sexp-test.c:1.6

sexp.c
testsuite/sexp-test.c

diff --git a/sexp.c b/sexp.c
index 112b694bdd2c9325c949059b43110fec58c35d82..03d4122462f3011c454a812836e68837995289f5 100644 (file)
--- a/sexp.c
+++ b/sexp.c
@@ -172,7 +172,8 @@ sexp_iterator_enter_list(struct sexp_iterator *iterator)
 
   iterator->level++;
   iterator->type = SEXP_START;
-  return 1;
+  
+  return sexp_iterator_next(iterator);
 }
 
 /* Skips the rest of the current list */
@@ -201,7 +202,6 @@ sexp_iterator_check_type(struct sexp_iterator *iterator,
                         const uint8_t *type)
 {
   return (sexp_iterator_enter_list(iterator)
-         && sexp_iterator_next(iterator)
          && iterator->type == SEXP_ATOM
          && !iterator->display
          && strlen(type) == iterator->atom_length
@@ -214,7 +214,6 @@ sexp_iterator_check_types(struct sexp_iterator *iterator,
                          const uint8_t **types)
 {
   if (sexp_iterator_enter_list(iterator)
-      && sexp_iterator_next(iterator)
       && iterator->type == SEXP_ATOM
       && !iterator->display)
     {
@@ -247,16 +246,12 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
   
   for (;;)
     {
-      if (!sexp_iterator_next(iterator))
-       return 0;
-
       switch (iterator->type)
        {
        case SEXP_LIST:
 
          /* FIXME: Use sexp_iterator_check_type? */
-         if (! (sexp_iterator_enter_list(iterator)
-                && sexp_iterator_next(iterator)))
+         if (!sexp_iterator_enter_list(iterator))
            return 0;
          
          if (iterator->type == SEXP_ATOM
@@ -299,5 +294,7 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
        default:
          abort();
        }
+      if (!sexp_iterator_next(iterator))
+       return 0;
     }
 }
index 92cd4c09d0afda5e5c45c6e55b6d55a1b54750aa..f97104ad2d197151497c76340e3ccf165fa1c11f 100644 (file)
@@ -12,14 +12,13 @@ test_main(void)
   ASSERT(sexp_iterator_first(&i, LDATA("()")));
   ASSERT(i.type == SEXP_LIST
         && sexp_iterator_enter_list(&i)
-        && sexp_iterator_next(&i) && i.type == SEXP_END
+        && i.type == SEXP_END
         && sexp_iterator_exit_list(&i)
         && sexp_iterator_next(&i) && i.type == SEXP_END);
 
   ASSERT(sexp_iterator_first(&i, LDATA("(")));
   ASSERT(i.type == SEXP_LIST
-        && sexp_iterator_enter_list(&i)
-        && !sexp_iterator_next(&i));
+        && !sexp_iterator_enter_list(&i));
 
   ASSERT(sexp_iterator_first(&i, LDATA("3:foo0:[3:bar]1:x")));
   ASSERT(i.type == SEXP_ATOM