* xmlXPathContainsFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the contains() XPath function * boolean contains(string, string) * The contains function returns true if the first argument string * contains the second argument string, and otherwise returns false. */
| 7960 | * contains the second argument string, and otherwise returns false. |
| 7961 | */ |
| 7962 | void |
| 7963 | xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 7964 | xmlXPathObjectPtr hay, needle; |
| 7965 | |
| 7966 | CHECK_ARITY(2); |
| 7967 | CAST_TO_STRING; |
| 7968 | CHECK_TYPE(XPATH_STRING); |
| 7969 | needle = valuePop(ctxt); |
| 7970 | CAST_TO_STRING; |
| 7971 | hay = valuePop(ctxt); |
| 7972 | |
| 7973 | if ((hay == NULL) || (hay->type != XPATH_STRING)) { |
| 7974 | xmlXPathReleaseObject(ctxt->context, hay); |
| 7975 | xmlXPathReleaseObject(ctxt->context, needle); |
| 7976 | XP_ERROR(XPATH_INVALID_TYPE); |
| 7977 | } |
| 7978 | if (xmlStrstr(hay->stringval, needle->stringval)) |
| 7979 | valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt, 1)); |
| 7980 | else |
| 7981 | valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt, 0)); |
| 7982 | xmlXPathReleaseObject(ctxt->context, hay); |
| 7983 | xmlXPathReleaseObject(ctxt->context, needle); |
| 7984 | } |
| 7985 | |
| 7986 | /** |
| 7987 | * xmlXPathStartsWithFunction: |
nothing calls this directly
no test coverage detected