* xmlTextWriterEndComment: * @writer: the xmlTextWriterPtr * * End the current xml comment. * * Returns the bytes written (may be 0 because of buffering) or -1 in case of error */
| 799 | * Returns the bytes written (may be 0 because of buffering) or -1 in case of error |
| 800 | */ |
| 801 | int |
| 802 | xmlTextWriterEndComment(xmlTextWriterPtr writer) |
| 803 | { |
| 804 | int count; |
| 805 | int sum; |
| 806 | xmlLinkPtr lk; |
| 807 | xmlTextWriterStackEntry *p; |
| 808 | |
| 809 | if (writer == NULL) { |
| 810 | xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, |
| 811 | "xmlTextWriterEndComment : invalid writer!\n"); |
| 812 | return -1; |
| 813 | } |
| 814 | |
| 815 | lk = xmlListFront(writer->nodes); |
| 816 | if (lk == 0) { |
| 817 | xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, |
| 818 | "xmlTextWriterEndComment : not allowed in this context!\n"); |
| 819 | return -1; |
| 820 | } |
| 821 | |
| 822 | p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); |
| 823 | if (p == 0) |
| 824 | return -1; |
| 825 | |
| 826 | sum = 0; |
| 827 | switch (p->state) { |
| 828 | case XML_TEXTWRITER_COMMENT: |
| 829 | count = xmlOutputBufferWriteString(writer->out, "-->"); |
| 830 | if (count < 0) |
| 831 | return -1; |
| 832 | sum += count; |
| 833 | break; |
| 834 | default: |
| 835 | return -1; |
| 836 | } |
| 837 | |
| 838 | if (writer->indent) { |
| 839 | count = xmlOutputBufferWriteString(writer->out, "\n"); |
| 840 | if (count < 0) |
| 841 | return -1; |
| 842 | sum += count; |
| 843 | } |
| 844 | |
| 845 | xmlListPopFront(writer->nodes); |
| 846 | return sum; |
| 847 | } |
| 848 | |
| 849 | /** |
| 850 | * xmlTextWriterWriteFormatComment: |
no test coverage detected