* xmlXPathBooleanFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the boolean() XPath function * boolean boolean(object) * The boolean function converts its argument to a boolean 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
| 8395 | * - a string is true if and only if its length is non-zero |
| 8396 | */ |
| 8397 | void |
| 8398 | xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 8399 | xmlXPathObjectPtr cur; |
| 8400 | |
| 8401 | CHECK_ARITY(1); |
| 8402 | cur = valuePop(ctxt); |
| 8403 | if (cur == NULL) XP_ERROR(XPATH_INVALID_OPERAND); |
| 8404 | if (cur->type != XPATH_BOOLEAN) { |
| 8405 | int boolval = xmlXPathCastToBoolean(cur); |
| 8406 | |
| 8407 | xmlXPathReleaseObject(ctxt->context, cur); |
| 8408 | cur = xmlXPathCacheNewBoolean(ctxt, boolval); |
| 8409 | } |
| 8410 | valuePush(ctxt, cur); |
| 8411 | } |
| 8412 | |
| 8413 | /** |
| 8414 | * xmlXPathNotFunction: |
no test coverage detected