Merge branch 'loeliger-develop' into develop

This commit is contained in:
Olof hagsand 2019-01-14 21:24:18 +01:00
commit 26a75a4c50

View file

@ -190,14 +190,16 @@ array_eval(cxobj *xprev,
xml_type(xnext)==CX_ELMNT && xml_type(xnext)==CX_ELMNT &&
strcmp(xml_name(x),xml_name(xnext))==0){ strcmp(xml_name(x),xml_name(xnext))==0){
ns2 = xml_find_type_value(xnext, NULL, "xmlns", CX_ATTR); ns2 = xml_find_type_value(xnext, NULL, "xmlns", CX_ATTR);
if (nsx && ns2 && strcmp(nsx,ns2)==0) if ((!nsx && !ns2)
|| (nsx && ns2 && strcmp(nsx,ns2)==0))
eqnext++; eqnext++;
} }
if (xprev && if (xprev &&
xml_type(xprev)==CX_ELMNT && xml_type(xprev)==CX_ELMNT &&
strcmp(xml_name(x),xml_name(xprev))==0){ strcmp(xml_name(x),xml_name(xprev))==0){
ns2 = xml_find_type_value(xprev, NULL, "xmlns", CX_ATTR); ns2 = xml_find_type_value(xprev, NULL, "xmlns", CX_ATTR);
if (nsx && ns2 && strcmp(nsx,ns2)==0) if ((!nsx && !ns2)
|| (nsx && ns2 && strcmp(nsx,ns2)==0))
eqprev++; eqprev++;
} }
if (eqprev && eqnext) if (eqprev && eqnext)
@ -432,6 +434,8 @@ xml2json1_cbuf(cbuf *cb,
break; break;
} }
int na = xml_child_nr_notype(x, CX_ATTR);
int commas = na - 1;
for (i=0; i<xml_child_nr(x); i++){ for (i=0; i<xml_child_nr(x); i++){
xc = xml_child_i(x, i); xc = xml_child_i(x, i);
if (xml_type(xc) == CX_ATTR) if (xml_type(xc) == CX_ATTR)
@ -444,8 +448,10 @@ xml2json1_cbuf(cbuf *cb,
xc_arraytype, xc_arraytype,
level+1, pretty, 0, bodystr0) < 0) level+1, pretty, 0, bodystr0) < 0)
goto done; goto done;
if (i<xml_child_nr_notype(x, CX_ATTR)-1) if (commas > 0) {
cprintf(cb, ",%s", pretty?"\n":""); cprintf(cb, ",%s", pretty?"\n":"");
--commas;
}
} }
switch (arraytype){ switch (arraytype){
case BODY_ARRAY: case BODY_ARRAY: