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

Function xmlXPathSubstringAfterFunction

ThirdParty/libxml2/vtklibxml2/xpath.c:8184–8214  ·  view source on GitHub ↗

* xmlXPathSubstringAfterFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the substring-after() XPath function * string substring-after(string, string) * The substring-after function returns the substring of the first * argument string that follows the first occurrence of the second * argument string in the first argument string, or the empty

Source from the content-addressed store, hash-verified

8182 * and substring-after("1999/04/01","19") returns 99/04/01.
8183 */
8184void
8185xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8186 xmlXPathObjectPtr str = NULL;
8187 xmlXPathObjectPtr find = NULL;
8188 const xmlChar *point;
8189 xmlChar *result;
8190
8191 CHECK_ARITY(2);
8192 CAST_TO_STRING;
8193 find = valuePop(ctxt);
8194 CAST_TO_STRING;
8195 str = valuePop(ctxt);
8196 if (ctxt->error != 0)
8197 goto error;
8198
8199 point = xmlStrstr(str->stringval, find->stringval);
8200 if (point == NULL) {
8201 result = xmlStrdup(BAD_CAST "");
8202 } else {
8203 result = xmlStrdup(point + xmlStrlen(find->stringval));
8204 }
8205 if (result == NULL) {
8206 xmlXPathPErrMemory(ctxt);
8207 goto error;
8208 }
8209 valuePush(ctxt, xmlXPathCacheWrapString(ctxt, result));
8210
8211error:
8212 xmlXPathReleaseObject(ctxt->context, str);
8213 xmlXPathReleaseObject(ctxt->context, find);
8214}
8215
8216/**
8217 * xmlXPathNormalizeFunction:

Callers

nothing calls this directly

Calls 8

valuePopFunction · 0.85
xmlStrstrFunction · 0.85
xmlStrdupFunction · 0.85
xmlStrlenFunction · 0.85
xmlXPathPErrMemoryFunction · 0.85
valuePushFunction · 0.85
xmlXPathCacheWrapStringFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85

Tested by

no test coverage detected