From a1c185a376d03b8baee06fc18bfe057ac81cf6d3 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Tue, 25 Jan 2011 20:42:41 +0200 Subject: [PATCH] Use 'f' for real and 'F' for number (real or integer) in unpack --- src/pack_unpack.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pack_unpack.c b/src/pack_unpack.c index f91d79c..8d8aa33 100644 --- a/src/pack_unpack.c +++ b/src/pack_unpack.c @@ -380,12 +380,24 @@ static int unpack(scanner_t *s, json_t *root, va_list *ap) return 0; case 'f': - if(!json_is_number(root)) { + if(!json_is_real(root)) { set_error(s, "Expected real, got %s", type_name(root)); return -1; } if(!(s->flags & JSON_VALIDATE_ONLY)) + *va_arg(*ap, double*) = json_real_value(root); + + return 0; + + case 'F': + if(!json_is_number(root)) { + set_error(s, "Expected real or integer, got %s", + type_name(root)); + return -1; + } + + if(!(s->flags & JSON_VALIDATE_ONLY)) *va_arg(*ap, double*) = json_number_value(root); return 0; -- 2.1.4