Skip to content
Snippets Groups Projects
Commit d0c15a0c authored by Niels Möller's avatar Niels Möller
Browse files

* sexp.c (sexp_iterator_next): Updated to new sexp_iterator_exit_list.

(sexp_iterator_exit_list): Return with iterator pointing to the
element after the list.
(sexp_iterator_check_type): Call sexp_iterator_next before
returning.
(sexp_iterator_check_types): Likewise.
(sexp_iterator_assoc): Rearranged calls of sexp_iterator_next.

Rev: src/nettle/sexp.c:1.7
parent 18463581
No related branches found
No related tags found
No related merge requests found
...@@ -120,8 +120,7 @@ sexp_iterator_next(struct sexp_iterator *iterator) ...@@ -120,8 +120,7 @@ sexp_iterator_next(struct sexp_iterator *iterator)
if (iterator->type == SEXP_LIST) if (iterator->type == SEXP_LIST)
/* Skip this list */ /* Skip this list */
return sexp_iterator_enter_list(iterator) return sexp_iterator_enter_list(iterator)
&& sexp_iterator_exit_list(iterator) && sexp_iterator_exit_list(iterator);
&& sexp_iterator_next(iterator);
else else
{ {
iterator->type = SEXP_LIST; iterator->type = SEXP_LIST;
...@@ -183,18 +182,14 @@ sexp_iterator_exit_list(struct sexp_iterator *iterator) ...@@ -183,18 +182,14 @@ sexp_iterator_exit_list(struct sexp_iterator *iterator)
if (!iterator->level) if (!iterator->level)
return 0; return 0;
for (;;) while(iterator->type != SEXP_END)
{ if (!sexp_iterator_next(iterator))
if (!sexp_iterator_next(iterator)) return 0;
return 0;
if (iterator->type == SEXP_END) iterator->type = SEXP_START;
{ iterator->level--;
iterator->type = SEXP_START;
iterator->level--; return sexp_iterator_next(iterator);
return 1;
}
}
} }
int int
...@@ -205,7 +200,8 @@ sexp_iterator_check_type(struct sexp_iterator *iterator, ...@@ -205,7 +200,8 @@ sexp_iterator_check_type(struct sexp_iterator *iterator,
&& iterator->type == SEXP_ATOM && iterator->type == SEXP_ATOM
&& !iterator->display && !iterator->display
&& strlen(type) == iterator->atom_length && strlen(type) == iterator->atom_length
&& !memcmp(type, iterator->atom, iterator->atom_length)); && !memcmp(type, iterator->atom, iterator->atom_length)
&& sexp_iterator_next(iterator));
} }
const uint8_t * const uint8_t *
...@@ -222,9 +218,9 @@ sexp_iterator_check_types(struct sexp_iterator *iterator, ...@@ -222,9 +218,9 @@ sexp_iterator_check_types(struct sexp_iterator *iterator,
if (strlen(types[i]) == iterator->atom_length if (strlen(types[i]) == iterator->atom_length
&& !memcmp(types[i], iterator->atom, && !memcmp(types[i], iterator->atom,
iterator->atom_length)) iterator->atom_length))
return types[i]; return sexp_iterator_next(iterator) ? types[i] : NULL;
} }
return 0; return NULL;
} }
...@@ -285,6 +281,8 @@ sexp_iterator_assoc(struct sexp_iterator *iterator, ...@@ -285,6 +281,8 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
break; break;
case SEXP_ATOM: case SEXP_ATOM:
/* Just ignore */ /* Just ignore */
if (!sexp_iterator_next(iterator))
return 0;
break; break;
case SEXP_END: case SEXP_END:
...@@ -294,7 +292,5 @@ sexp_iterator_assoc(struct sexp_iterator *iterator, ...@@ -294,7 +292,5 @@ sexp_iterator_assoc(struct sexp_iterator *iterator,
default: default:
abort(); abort();
} }
if (!sexp_iterator_next(iterator))
return 0;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment