JSON negative number patch

This commit is contained in:
Olof Hagsand 2017-11-13 17:11:31 +00:00
parent 3c41a79102
commit 23e40384f7
4 changed files with 11 additions and 13 deletions

View file

@ -4,7 +4,7 @@
* When user callbacks such as statedata() call returns -1, clixon_backend no * When user callbacks such as statedata() call returns -1, clixon_backend no
longer silently exits. Instead a log is printed and an RPC error is returned. longer silently exits. Instead a log is printed and an RPC error is returned.
* Added Floating point support to JSON * Added Floating point and negative number support to JSON
* Restconf: http cookie sent as attribute in rpc restconf_post operations to backend. * Restconf: http cookie sent as attribute in rpc restconf_post operations to backend.
* Added option CLICON_CLISPEC_FILE as complement to CLICON_CLISPEC_DIR to * Added option CLICON_CLISPEC_FILE as complement to CLICON_CLISPEC_DIR to
specify single CLI specification file, not only directory containing files. specify single CLI specification file, not only directory containing files.

View file

@ -632,7 +632,7 @@ json_parse_str(char *str,
* Example compile: * Example compile:
gcc -g -o json -I. -I../clixon ./clixon_json.c -lclixon -lcligen gcc -g -o json -I. -I../clixon ./clixon_json.c -lclixon -lcligen
* Example run: * Example run:
echo "" | xml echo '{"foo": -23}' | ./json
*/ */
#if 0 /* Test program */ #if 0 /* Test program */
@ -643,15 +643,12 @@ usage(char *argv0)
exit(0); exit(0);
} }
#define BUFLEN 1024 /* Size of xml read buffer */
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
cxobj *xt; cxobj *xt;
cxobj *xc; cxobj *xc;
cbuf *cb = cbuf_new(); cbuf *cb = cbuf_new();
int maxbuf = BUFLEN;
char *xmlbuf = NULL;
char *buf = NULL; char *buf = NULL;
int i; int i;
int c; int c;

View file

@ -100,7 +100,7 @@ exp ({integer}|{real})[eE][+-]{integer}
<START>null { return J_NULL; } <START>null { return J_NULL; }
<START>false { return J_FALSE; } <START>false { return J_FALSE; }
<START>true { return J_TRUE; } <START>true { return J_TRUE; }
<START>({integer}|{real}|{exp}) { clixon_json_parselval.string = strdup(yytext); return J_NUMBER;} <START>\-?({integer}|{real}|{exp}) { clixon_json_parselval.string = strdup(yytext); return J_NUMBER;}
<START>. { return -1; } <START>. { return -1; }
<STRING>\" { BEGIN(START); return J_DQ; } <STRING>\" { BEGIN(START); return J_DQ; }
<STRING>\\ { BEGIN(ESCAPE); } <STRING>\\ { BEGIN(ESCAPE); }

View file

@ -1104,6 +1104,7 @@ xmltree2cbuf(cbuf *cb,
for (i=0; i<level*XML_INDENT; i++) for (i=0; i<level*XML_INDENT; i++)
cprintf(cb, " "); cprintf(cb, " ");
if (xml_type(x) != CX_BODY)
cprintf(cb, "%s", xml_type2str(xml_type(x))); cprintf(cb, "%s", xml_type2str(xml_type(x)));
if (xml_namespace(x)==NULL) if (xml_namespace(x)==NULL)
cprintf(cb, " %s", xml_name(x)); cprintf(cb, " %s", xml_name(x));