* xmlXPathEqualValues: * @ctxt: the XPath Parser context * * Implement the equal operation on XPath objects content: @arg1 == @arg2 * * Returns 0 or 1 depending on the results of the test. */
| 6120 | * Returns 0 or 1 depending on the results of the test. |
| 6121 | */ |
| 6122 | int |
| 6123 | xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) { |
| 6124 | xmlXPathObjectPtr arg1, arg2, argtmp; |
| 6125 | int ret = 0; |
| 6126 | |
| 6127 | if ((ctxt == NULL) || (ctxt->context == NULL)) return(0); |
| 6128 | arg2 = valuePop(ctxt); |
| 6129 | arg1 = valuePop(ctxt); |
| 6130 | if ((arg1 == NULL) || (arg2 == NULL)) { |
| 6131 | if (arg1 != NULL) |
| 6132 | xmlXPathReleaseObject(ctxt->context, arg1); |
| 6133 | else |
| 6134 | xmlXPathReleaseObject(ctxt->context, arg2); |
| 6135 | XP_ERROR0(XPATH_INVALID_OPERAND); |
| 6136 | } |
| 6137 | |
| 6138 | if (arg1 == arg2) { |
| 6139 | xmlXPathFreeObject(arg1); |
| 6140 | return(1); |
| 6141 | } |
| 6142 | |
| 6143 | /* |
| 6144 | *If either argument is a nodeset, it's a 'special case' |
| 6145 | */ |
| 6146 | if ((arg2->type == XPATH_NODESET) || (arg2->type == XPATH_XSLT_TREE) || |
| 6147 | (arg1->type == XPATH_NODESET) || (arg1->type == XPATH_XSLT_TREE)) { |
| 6148 | /* |
| 6149 | *Hack it to assure arg1 is the nodeset |
| 6150 | */ |
| 6151 | if ((arg1->type != XPATH_NODESET) && (arg1->type != XPATH_XSLT_TREE)) { |
| 6152 | argtmp = arg2; |
| 6153 | arg2 = arg1; |
| 6154 | arg1 = argtmp; |
| 6155 | } |
| 6156 | switch (arg2->type) { |
| 6157 | case XPATH_UNDEFINED: |
| 6158 | break; |
| 6159 | case XPATH_NODESET: |
| 6160 | case XPATH_XSLT_TREE: |
| 6161 | ret = xmlXPathEqualNodeSets(ctxt, arg1, arg2, 0); |
| 6162 | break; |
| 6163 | case XPATH_BOOLEAN: |
| 6164 | if ((arg1->nodesetval == NULL) || |
| 6165 | (arg1->nodesetval->nodeNr == 0)) ret = 0; |
| 6166 | else |
| 6167 | ret = 1; |
| 6168 | ret = (ret == arg2->boolval); |
| 6169 | break; |
| 6170 | case XPATH_NUMBER: |
| 6171 | ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 0); |
| 6172 | break; |
| 6173 | case XPATH_STRING: |
| 6174 | ret = xmlXPathEqualNodeSetString(ctxt, arg1, |
| 6175 | arg2->stringval, 0); |
| 6176 | break; |
| 6177 | case XPATH_USERS: |
| 6178 | #ifdef LIBXML_XPTR_LOCS_ENABLED |
| 6179 | case XPATH_POINT: |
no test coverage detected