projects
/
jansson.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ac96ac1
)
Use 'f' for real and 'F' for number (real or integer) in unpack
author
Petri Lehtinen
<petri@digip.org>
Tue, 25 Jan 2011 18:42:41 +0000
(20:42 +0200)
committer
Petri Lehtinen
<petri@digip.org>
Tue, 25 Jan 2011 18:42:41 +0000
(20:42 +0200)
src/pack_unpack.c
patch
|
blob
|
history
diff --git
a/src/pack_unpack.c
b/src/pack_unpack.c
index
f91d79c
..
8d8aa33
100644
(file)
--- 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':
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))
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;
*va_arg(*ap, double*) = json_number_value(root);
return 0;