* xmlXPathConcatFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the concat() XPath function * string concat(string, string, string*) * The concat function returns the concatenation of its arguments. */
| 7913 | * The concat function returns the concatenation of its arguments. |
| 7914 | */ |
| 7915 | void |
| 7916 | xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 7917 | xmlXPathObjectPtr cur, newobj; |
| 7918 | xmlChar *tmp; |
| 7919 | |
| 7920 | if (ctxt == NULL) return; |
| 7921 | if (nargs < 2) { |
| 7922 | CHECK_ARITY(2); |
| 7923 | } |
| 7924 | |
| 7925 | CAST_TO_STRING; |
| 7926 | cur = valuePop(ctxt); |
| 7927 | if ((cur == NULL) || (cur->type != XPATH_STRING)) { |
| 7928 | xmlXPathReleaseObject(ctxt->context, cur); |
| 7929 | return; |
| 7930 | } |
| 7931 | nargs--; |
| 7932 | |
| 7933 | while (nargs > 0) { |
| 7934 | CAST_TO_STRING; |
| 7935 | newobj = valuePop(ctxt); |
| 7936 | if ((newobj == NULL) || (newobj->type != XPATH_STRING)) { |
| 7937 | xmlXPathReleaseObject(ctxt->context, newobj); |
| 7938 | xmlXPathReleaseObject(ctxt->context, cur); |
| 7939 | XP_ERROR(XPATH_INVALID_TYPE); |
| 7940 | } |
| 7941 | tmp = xmlStrcat(newobj->stringval, cur->stringval); |
| 7942 | if (tmp == NULL) |
| 7943 | xmlXPathPErrMemory(ctxt); |
| 7944 | newobj->stringval = cur->stringval; |
| 7945 | cur->stringval = tmp; |
| 7946 | xmlXPathReleaseObject(ctxt->context, newobj); |
| 7947 | nargs--; |
| 7948 | } |
| 7949 | valuePush(ctxt, cur); |
| 7950 | } |
| 7951 | |
| 7952 | /** |
| 7953 | * xmlXPathContainsFunction: |
nothing calls this directly
no test coverage detected