MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathStartsWithFunction

Function xmlXPathStartsWithFunction

ThirdParty/libxml2/vtklibxml2/xpath.c:7996–8020  ·  view source on GitHub ↗

* xmlXPathStartsWithFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the starts-with() XPath function * boolean starts-with(string, string) * The starts-with function returns true if the first argument string * starts with the second argument string, and otherwise returns false. */

Source from the content-addressed store, hash-verified

7994 * starts with the second argument string, and otherwise returns false.
7995 */
7996void
7997xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs) {
7998 xmlXPathObjectPtr hay, needle;
7999 int n;
8000
8001 CHECK_ARITY(2);
8002 CAST_TO_STRING;
8003 CHECK_TYPE(XPATH_STRING);
8004 needle = valuePop(ctxt);
8005 CAST_TO_STRING;
8006 hay = valuePop(ctxt);
8007
8008 if ((hay == NULL) || (hay->type != XPATH_STRING)) {
8009 xmlXPathReleaseObject(ctxt->context, hay);
8010 xmlXPathReleaseObject(ctxt->context, needle);
8011 XP_ERROR(XPATH_INVALID_TYPE);
8012 }
8013 n = xmlStrlen(needle->stringval);
8014 if (xmlStrncmp(hay->stringval, needle->stringval, n))
8015 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt, 0));
8016 else
8017 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt, 1));
8018 xmlXPathReleaseObject(ctxt->context, hay);
8019 xmlXPathReleaseObject(ctxt->context, needle);
8020}
8021
8022/**
8023 * xmlXPathSubstringFunction:

Callers

nothing calls this directly

Calls 6

valuePopFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85
xmlStrlenFunction · 0.85
xmlStrncmpFunction · 0.85
valuePushFunction · 0.85
xmlXPathCacheNewBooleanFunction · 0.85

Tested by

no test coverage detected