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

Function xmlParseNmtoken

ThirdParty/libxml2/vtklibxml2/parser.c:3663–3729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3661 */
3662
3663xmlChar *
3664xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
3665 xmlChar buf[XML_MAX_NAMELEN + 5];
3666 xmlChar *ret;
3667 int len = 0, l;
3668 int c;
3669 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3670 XML_MAX_TEXT_LENGTH :
3671 XML_MAX_NAME_LENGTH;
3672
3673 c = CUR_CHAR(l);
3674
3675 while (xmlIsNameChar(ctxt, c)) {
3676 COPY_BUF(buf, len, c);
3677 NEXTL(l);
3678 c = CUR_CHAR(l);
3679 if (len >= XML_MAX_NAMELEN) {
3680 /*
3681 * Okay someone managed to make a huge token, so he's ready to pay
3682 * for the processing speed.
3683 */
3684 xmlChar *buffer;
3685 int max = len * 2;
3686
3687 buffer = (xmlChar *) xmlMallocAtomic(max);
3688 if (buffer == NULL) {
3689 xmlErrMemory(ctxt);
3690 return(NULL);
3691 }
3692 memcpy(buffer, buf, len);
3693 while (xmlIsNameChar(ctxt, c)) {
3694 if (len + 10 > max) {
3695 xmlChar *tmp;
3696
3697 max *= 2;
3698 tmp = (xmlChar *) xmlRealloc(buffer, max);
3699 if (tmp == NULL) {
3700 xmlErrMemory(ctxt);
3701 xmlFree(buffer);
3702 return(NULL);
3703 }
3704 buffer = tmp;
3705 }
3706 COPY_BUF(buffer, len, c);
3707 if (len > maxLength) {
3708 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
3709 xmlFree(buffer);
3710 return(NULL);
3711 }
3712 NEXTL(l);
3713 c = CUR_CHAR(l);
3714 }
3715 buffer[len] = 0;
3716 return(buffer);
3717 }
3718 }
3719 if (len == 0)
3720 return(NULL);

Callers 2

xmlParseEnumerationTypeFunction · 0.85
xmlParseQNameHashedFunction · 0.85

Calls 4

xmlIsNameCharFunction · 0.85
xmlErrMemoryFunction · 0.85
xmlFatalErrFunction · 0.85
xmlStrndupFunction · 0.85

Tested by

no test coverage detected