* 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
| 8182 | * and substring-after("1999/04/01","19") returns 99/04/01. |
| 8183 | */ |
| 8184 | void |
| 8185 | xmlXPathSubstringAfterFunction(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 | |
| 8211 | error: |
| 8212 | xmlXPathReleaseObject(ctxt->context, str); |
| 8213 | xmlXPathReleaseObject(ctxt->context, find); |
| 8214 | } |
| 8215 | |
| 8216 | /** |
| 8217 | * xmlXPathNormalizeFunction: |
nothing calls this directly
no test coverage detected