Patchwork [08/11] qjson: add %i for parsing bools

login
register
mail settings
Submitter Anthony Liguori
Date Oct. 17, 2009, 1:36 p.m.
Message ID <1255786571-3528-9-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/36308/
State New
Headers show

Comments

Anthony Liguori - Oct. 17, 2009, 1:36 p.m.
Not a wonderful choice in conversion characters but nothing else seems better.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 qjson.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Patch

diff --git a/qjson.c b/qjson.c
index ce2c942..9279bfb 100644
--- a/qjson.c
+++ b/qjson.c
@@ -339,6 +339,12 @@  static QObject *parse_number(JSONParserContext *ctxt,
                 parse_error(ctxt, ptr, "invalid escape sequence");
                 goto out;
             }
+        } else if (*ptr == 'i') {
+            int val;
+            ptr++;
+            *length = ptr - data;
+            val = va_arg(*ap, int);
+            return QOBJECT(qbool_from_int(val));
         } else if (*ptr == 'f') {
             double val;
             ptr++;