diff mbox

[2/4] datatype: use mpz_set_str instead of gmp_sscanf

Message ID 1420584025-7817-3-git-send-email-cyrus@openwrt.org
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Steven Barth Jan. 6, 2015, 10:40 p.m. UTC
This simplifies the integer parsing logic and restricts it to
functions being part of the mini-gmp subset.

Signed-off-by: Steven Barth <cyrus@openwrt.org>
---
 src/datatype.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox

Patch

diff --git a/src/datatype.c b/src/datatype.c
index 2a9fcdb..76f2af1 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -276,11 +276,9 @@  static struct error_record *integer_type_parse(const struct expr *sym,
 					       struct expr **res)
 {
 	mpz_t v;
-	int len;
 
 	mpz_init(v);
-	if (gmp_sscanf(sym->identifier, "%Zu%n", v, &len) != 1 ||
-	    (int)strlen(sym->identifier) != len) {
+	if (mpz_set_str(v, sym->identifier, 0)) {
 		mpz_clear(v);
 		return error(&sym->location, "Could not parse %s",
 			     sym->dtype->desc);