]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(nettle_mpz_set_sexp): Call sexp_iterator_next on
authorNiels Möller <nisse@lysator.liu.se>
Thu, 30 Jan 2003 17:35:21 +0000 (18:35 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 30 Jan 2003 17:35:21 +0000 (18:35 +0100)
success. That means the iterator argument can't be const.

Rev: src/nettle/bignum.h:1.7
Rev: src/nettle/sexp2bignum.c:1.4

bignum.h
sexp2bignum.c

index 3ba8ea5deb5f5af83d62f475de71d0582480d474..dce95126fb6677ee0840ff1822b1a9cfa5c4be0c 100644 (file)
--- a/bignum.h
+++ b/bignum.h
@@ -80,8 +80,9 @@ nettle_mpz_random(mpz_t x,
 
 struct sexp_iterator;
 
-/* If LIMIT is non-zero, the number must be at most LIMIT bits. */
+/* If LIMIT is non-zero, the number must be at most LIMIT bits.
+ * Implies sexp_iterator_next. */
 int
-nettle_mpz_set_sexp(mpz_t x, unsigned limit, const struct sexp_iterator *i);
+nettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i);
 
 #endif /* NETTLE_BIGNUM_H_INCLUDED */
index f7ef68843f9feb6003c403d01776234503442578..e75e6988c6a3d6e626023dbfe98d1615b14512d6 100644 (file)
@@ -32,7 +32,7 @@
 #include "bignum.h"
 
 int
-nettle_mpz_set_sexp(mpz_t x, unsigned limit, const struct sexp_iterator *i)
+nettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i)
 {
   if (i->type == SEXP_ATOM
       && i->atom_length
@@ -43,8 +43,12 @@ nettle_mpz_set_sexp(mpz_t x, unsigned limit, const struct sexp_iterator *i)
        return 0;
       
       nettle_mpz_set_str_256_s(x, i->atom_length, i->atom);
+
       /* FIXME: How to interpret a limit for negative numbers? */
-      return !limit || mpz_sizeinbase(x, 2) <= limit;
+      if (limit && mpz_sizeinbase(x, 2) > limit)
+       return 0;
+      
+      return sexp_iterator_next(i);
     }
   else
     return 0;