From: Niels Möller Date: Sun, 6 Oct 2002 20:17:35 +0000 (+0200) Subject: * sexp.c (sexp_iterator_enter_list): Call sexp_iterator_next to X-Git-Tag: nettle_1.7_release_20030311~289 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18463581cf58c6ab79f1a18080da9459caaafab0;p=thirdparty%2Fnettle.git * sexp.c (sexp_iterator_enter_list): Call sexp_iterator_next to 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 --- diff --git a/sexp.c b/sexp.c index 112b694b..03d41224 100644 --- 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; } } diff --git a/testsuite/sexp-test.c b/testsuite/sexp-test.c index 92cd4c09..f97104ad 100644 --- a/testsuite/sexp-test.c +++ b/testsuite/sexp-test.c @@ -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