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

Function xmlXPtrEvalXPtrPart

ThirdParty/libxml2/vtklibxml2/xpointer.c:939–1074  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

937 */
938
939static void
940xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
941 xmlChar *buffer, *cur;
942 int len;
943 int level;
944
945 if (name == NULL)
946 name = xmlXPathParseName(ctxt);
947 if (name == NULL)
948 XP_ERROR(XPATH_EXPR_ERROR);
949
950 if (CUR != '(') {
951 xmlFree(name);
952 XP_ERROR(XPATH_EXPR_ERROR);
953 }
954 NEXT;
955 level = 1;
956
957 len = xmlStrlen(ctxt->cur);
958 len++;
959 buffer = (xmlChar *) xmlMallocAtomic(len);
960 if (buffer == NULL) {
961 xmlXPathPErrMemory(ctxt);
962 xmlFree(name);
963 return;
964 }
965
966 cur = buffer;
967 while (CUR != 0) {
968 if (CUR == ')') {
969 level--;
970 if (level == 0) {
971 NEXT;
972 break;
973 }
974 } else if (CUR == '(') {
975 level++;
976 } else if (CUR == '^') {
977 if ((NXT(1) == ')') || (NXT(1) == '(') || (NXT(1) == '^')) {
978 NEXT;
979 }
980 }
981 *cur++ = CUR;
982 NEXT;
983 }
984 *cur = 0;
985
986 if ((level != 0) && (CUR == 0)) {
987 xmlFree(name);
988 xmlFree(buffer);
989 XP_ERROR(XPTR_SYNTAX_ERROR);
990 }
991
992 if (xmlStrEqual(name, (xmlChar *) "xpointer") ||
993 xmlStrEqual(name, (xmlChar *) "xpath1")) {
994 const xmlChar *oldBase = ctxt->base;
995 const xmlChar *oldCur = ctxt->cur;
996

Callers 1

xmlXPtrEvalFullXPtrFunction · 0.85

Calls 9

xmlXPathParseNameFunction · 0.85
xmlStrlenFunction · 0.85
xmlXPathPErrMemoryFunction · 0.85
xmlStrEqualFunction · 0.85
xmlXPathEvalExprFunction · 0.85
xmlXPathRootFunction · 0.85
xmlXPtrEvalChildSeqFunction · 0.85
xmlXPathParseNCNameFunction · 0.85
xmlXPathRegisterNsFunction · 0.85

Tested by

no test coverage detected