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

Function xmlCurrentChar

ThirdParty/libxml2/vtklibxml2/parserInternals.c:745–869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743 */
744
745int
746xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
747 const unsigned char *cur;
748 size_t avail;
749 int c;
750
751 if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
752
753 avail = ctxt->input->end - ctxt->input->cur;
754
755 if (avail < INPUT_CHUNK) {
756 xmlParserGrow(ctxt);
757 avail = ctxt->input->end - ctxt->input->cur;
758 }
759
760 cur = ctxt->input->cur;
761 c = *cur;
762
763 if (c < 0x80) {
764 /* 1-byte code */
765 if (c < 0x20) {
766 /*
767 * 2.11 End-of-Line Handling
768 * the literal two-character sequence "#xD#xA" or a standalone
769 * literal #xD, an XML processor must pass to the application
770 * the single character #xA.
771 */
772 if (c == '\r') {
773 /*
774 * TODO: This function shouldn't change the 'cur' pointer
775 * as side effect, but the NEXTL macro in parser.c relies
776 * on this behavior when incrementing line numbers.
777 */
778 if (cur[1] == '\n')
779 ctxt->input->cur++;
780 *len = 1;
781 c = '\n';
782 } else if (c == 0) {
783 if (ctxt->input->cur >= ctxt->input->end) {
784 *len = 0;
785 } else {
786 *len = 1;
787 /*
788 * TODO: Null bytes should be handled by callers,
789 * but this can be tricky.
790 */
791 xmlFatalErr(ctxt, XML_ERR_INVALID_CHAR,
792 "Char 0x0 out of allowed range\n");
793 }
794 } else {
795 *len = 1;
796 }
797 } else {
798 *len = 1;
799 }
800
801 return(c);
802 } else {

Callers

nothing calls this directly

Calls 3

xmlParserGrowFunction · 0.85
xmlFatalErrFunction · 0.85
xmlCtxtErrIOFunction · 0.85

Tested by

no test coverage detected