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

Function htmlParseHTMLAttribute

ThirdParty/libxml2/vtklibxml2/HTMLparser.c:2628–2764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2626 */
2627
2628static xmlChar *
2629htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
2630 xmlChar *buffer = NULL;
2631 int buffer_size = 0;
2632 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
2633 XML_MAX_HUGE_LENGTH :
2634 XML_MAX_TEXT_LENGTH;
2635 xmlChar *out = NULL;
2636 const xmlChar *name = NULL;
2637 const xmlChar *cur = NULL;
2638 const htmlEntityDesc * ent;
2639
2640 /*
2641 * allocate a translation buffer.
2642 */
2643 buffer_size = HTML_PARSER_BUFFER_SIZE;
2644 buffer = (xmlChar *) xmlMallocAtomic(buffer_size);
2645 if (buffer == NULL) {
2646 htmlErrMemory(ctxt);
2647 return(NULL);
2648 }
2649 out = buffer;
2650
2651 /*
2652 * Ok loop until we reach one of the ending chars
2653 */
2654 while ((PARSER_STOPPED(ctxt) == 0) &&
2655 (CUR != 0) && (CUR != stop)) {
2656 if ((stop == 0) && (CUR == '>')) break;
2657 if ((stop == 0) && (IS_BLANK_CH(CUR))) break;
2658 if (CUR == '&') {
2659 if (NXT(1) == '#') {
2660 unsigned int c;
2661 int bits;
2662
2663 c = htmlParseCharRef(ctxt);
2664 if (c < 0x80)
2665 { *out++ = c; bits= -6; }
2666 else if (c < 0x800)
2667 { *out++ =((c >> 6) & 0x1F) | 0xC0; bits= 0; }
2668 else if (c < 0x10000)
2669 { *out++ =((c >> 12) & 0x0F) | 0xE0; bits= 6; }
2670 else
2671 { *out++ =((c >> 18) & 0x07) | 0xF0; bits= 12; }
2672
2673 for ( ; bits >= 0; bits-= 6) {
2674 *out++ = ((c >> bits) & 0x3F) | 0x80;
2675 }
2676
2677 if (out - buffer > buffer_size - 100) {
2678 int indx = out - buffer;
2679
2680 growBuffer(buffer);
2681 out = &buffer[indx];
2682 }
2683 } else {
2684 ent = htmlParseEntityRef(ctxt, &name);
2685 if (name == NULL) {

Callers 1

htmlParseAttValueFunction · 0.85

Calls 3

htmlErrMemoryFunction · 0.85
htmlParseCharRefFunction · 0.85
htmlParseEntityRefFunction · 0.85

Tested by

no test coverage detected