Added XPATH function boolean()
* This caused problem for new NTP YANG in RFC 9249 Fixed segv on anydata for http parser
This commit is contained in:
parent
d9cdd669d2
commit
4cf1d04cb7
7 changed files with 76 additions and 11 deletions
|
|
@ -228,7 +228,7 @@ xml2txt1(cxobj *xn,
|
|||
xc = NULL;
|
||||
while ((xc = xml_child_each(xn, xc, -1)) != NULL){
|
||||
if (xml_type(xc) == CX_ELMNT || xml_type(xc) == CX_BODY){
|
||||
if (yang_key_match(yn, xml_name(xc), NULL))
|
||||
if (yn && yang_key_match(yn, xml_name(xc), NULL))
|
||||
continue; /* Skip keys, already printed */
|
||||
if (xml2txt1(xc, fn, f, level+1, leafl, leaflname) < 0)
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1070,6 +1070,11 @@ xp_eval(xp_ctx *xc,
|
|||
goto done;
|
||||
goto ok;
|
||||
break;
|
||||
case XPATHFN_BOOLEAN:
|
||||
if (xp_function_boolean(xc, xs->xs_c0, nsc, localonly, xrp) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
break;
|
||||
case XPATHFN_NOT:
|
||||
if (xp_function_not(xc, xs->xs_c0, nsc, localonly, xrp) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -635,16 +635,22 @@ xp_function_contains(xp_ctx *xc,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! The not function returns true if its argument is false, and false otherwise.
|
||||
/*! The boolean function converts its argument to a boolean
|
||||
*
|
||||
* Signature: boolean not(boolean)
|
||||
* Conversion is as follows:
|
||||
* - a number is true if and only if it is neither positive or negative zero nor NaN
|
||||
* - a node-set is true if and only if it is non-empty
|
||||
* - a string is true if and only if its length is non-zero
|
||||
* - an object of a type other than the four basic types is converted to a boolean in a way that
|
||||
* is dependent on that type
|
||||
* Signature: boolean boolean(object)
|
||||
*/
|
||||
int
|
||||
xp_function_not(xp_ctx *xc,
|
||||
struct xpath_tree *xs,
|
||||
cvec *nsc,
|
||||
int localonly,
|
||||
xp_ctx **xrp)
|
||||
xp_function_boolean(xp_ctx *xc,
|
||||
struct xpath_tree *xs,
|
||||
cvec *nsc,
|
||||
int localonly,
|
||||
xp_ctx **xrp)
|
||||
{
|
||||
int retval = -1;
|
||||
xp_ctx *xr = NULL;
|
||||
|
|
@ -664,7 +670,7 @@ xp_function_not(xp_ctx *xc,
|
|||
}
|
||||
memset(xr, 0, sizeof(*xr));
|
||||
xr->xc_type = XT_BOOL;
|
||||
xr->xc_bool = !bool;
|
||||
xr->xc_bool = bool;
|
||||
*xrp = xr;
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
@ -673,6 +679,23 @@ xp_function_not(xp_ctx *xc,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! The not function returns true if its argument is false, and false otherwise.
|
||||
*
|
||||
* Signature: boolean not(boolean)
|
||||
*/
|
||||
int
|
||||
xp_function_not(xp_ctx *xc,
|
||||
struct xpath_tree *xs,
|
||||
cvec *nsc,
|
||||
int localonly,
|
||||
xp_ctx **xrp)
|
||||
{
|
||||
if (xp_function_boolean(xc, xs, nsc, localonly, xrp) < 0)
|
||||
return -1;
|
||||
(*xrp)->xc_bool = !(*xrp)->xc_bool;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! The true function returns true.
|
||||
*
|
||||
* Signature: boolean true()
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ enum clixon_xpath_function{
|
|||
XPATHFN_STRING_LENGTH, /* XPATH 1.0 4.2 NYI */
|
||||
XPATHFN_NORMALIZE_SPACE, /* XPATH 1.0 4.2 NYI */
|
||||
XPATHFN_TRANSLATE, /* XPATH 1.0 4.2 NYI */
|
||||
XPATHFN_BOOLEAN, /* XPATH 1.0 4.3 NYI */
|
||||
XPATHFN_BOOLEAN, /* XPATH 1.0 4.3 */
|
||||
XPATHFN_NOT, /* XPATH 1.0 4.3 */
|
||||
XPATHFN_TRUE, /* XPATH 1.0 4.3 */
|
||||
XPATHFN_FALSE, /* XPATH 1.0 4.3 */
|
||||
|
|
@ -101,6 +101,7 @@ int xp_function_position(xp_ctx *xc, struct xpath_tree *xs, cvec *nsc, int local
|
|||
int xp_function_count(xp_ctx *xc, struct xpath_tree *xs, cvec *nsc, int localonly, xp_ctx **xrp);
|
||||
int xp_function_name(xp_ctx *xc, struct xpath_tree *xs, cvec *nsc, int localonly, xp_ctx **xrp);
|
||||
int xp_function_contains(xp_ctx *xc, struct xpath_tree *xs, cvec *nsc, int localonly, xp_ctx **xrp);
|
||||
int xp_function_boolean(xp_ctx *xc, struct xpath_tree *xs, cvec *nsc, int localonly, xp_ctx **xrp);
|
||||
int xp_function_not(xp_ctx *xc, struct xpath_tree *xs, cvec *nsc, int localonly, xp_ctx **xrp);
|
||||
int xp_function_true(xp_ctx *xc, struct xpath_tree *xs, cvec *nsc, int localonly, xp_ctx **xrp);
|
||||
int xp_function_false(xp_ctx *xc, struct xpath_tree *xs, cvec *nsc, int localonly, xp_ctx **xrp);
|
||||
|
|
|
|||
|
|
@ -266,7 +266,6 @@ xp_primary_function(clixon_xpath_yacc *xpy,
|
|||
case XPATHFN_STRING_LENGTH:
|
||||
case XPATHFN_NORMALIZE_SPACE:
|
||||
case XPATHFN_TRANSLATE:
|
||||
case XPATHFN_BOOLEAN:
|
||||
case XPATHFN_LANG:
|
||||
case XPATHFN_NUMBER:
|
||||
case XPATHFN_SUM:
|
||||
|
|
@ -290,6 +289,7 @@ xp_primary_function(clixon_xpath_yacc *xpy,
|
|||
case XPATHFN_COUNT:
|
||||
case XPATHFN_NAME:
|
||||
case XPATHFN_CONTAINS:
|
||||
case XPATHFN_BOOLEAN:
|
||||
case XPATHFN_NOT:
|
||||
case XPATHFN_TRUE:
|
||||
case XPATHFN_FALSE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue