From: Petri Lehtinen Date: Tue, 25 Jan 2011 18:42:41 +0000 (+0200) Subject: Use 'f' for real and 'F' for number (real or integer) in unpack X-Git-Tag: v2.0~21 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=jansson.git;a=commitdiff_plain;h=a1c185a376d03b8baee06fc18bfe057ac81cf6d3 Use 'f' for real and 'F' for number (real or integer) in unpack --- 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;