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

Function xmlParseCommentComplex

ThirdParty/libxml2/vtklibxml2/parser.c:5106–5208  ·  view source on GitHub ↗

* xmlParseCommentComplex: * @ctxt: an XML parser context * @buf: the already parsed part of the buffer * @len: number of bytes in the buffer * @size: allocated size of the buffer * * Skip an XML (SGML) comment <!-- .... --> * The spec says that "For compatibility, the string "--" (double-hyphen) * must not occur within comments. " * This is the slow routine in case the accelerator f

Source from the content-addressed store, hash-verified

5104 * [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
5105 */
5106static void
5107xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
5108 size_t len, size_t size) {
5109 int q, ql;
5110 int r, rl;
5111 int cur, l;
5112 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
5113 XML_MAX_HUGE_LENGTH :
5114 XML_MAX_TEXT_LENGTH;
5115
5116 if (buf == NULL) {
5117 len = 0;
5118 size = XML_PARSER_BUFFER_SIZE;
5119 buf = (xmlChar *) xmlMallocAtomic(size);
5120 if (buf == NULL) {
5121 xmlErrMemory(ctxt);
5122 return;
5123 }
5124 }
5125 q = CUR_CHAR(ql);
5126 if (q == 0)
5127 goto not_terminated;
5128 if (!IS_CHAR(q)) {
5129 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
5130 "xmlParseComment: invalid xmlChar value %d\n",
5131 q);
5132 xmlFree (buf);
5133 return;
5134 }
5135 NEXTL(ql);
5136 r = CUR_CHAR(rl);
5137 if (r == 0)
5138 goto not_terminated;
5139 if (!IS_CHAR(r)) {
5140 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
5141 "xmlParseComment: invalid xmlChar value %d\n",
5142 r);
5143 xmlFree (buf);
5144 return;
5145 }
5146 NEXTL(rl);
5147 cur = CUR_CHAR(l);
5148 if (cur == 0)
5149 goto not_terminated;
5150 while (IS_CHAR(cur) && /* checked */
5151 ((cur != '>') ||
5152 (r != '-') || (q != '-'))) {
5153 if ((r == '-') && (q == '-')) {
5154 xmlFatalErr(ctxt, XML_ERR_HYPHEN_IN_COMMENT, NULL);
5155 }
5156 if (len + 5 >= size) {
5157 xmlChar *new_buf;
5158 size_t new_size;
5159
5160 new_size = size * 2;
5161 new_buf = (xmlChar *) xmlRealloc(buf, new_size);
5162 if (new_buf == NULL) {
5163 xmlFree (buf);

Callers 1

xmlParseCommentFunction · 0.85

Calls 3

xmlErrMemoryFunction · 0.85
xmlFatalErrFunction · 0.85
commentMethod · 0.80

Tested by

no test coverage detected