* xmlBufferWriteQuotedString: * @buf: the XML buffer output * @string: the string to add * * routine which manage and grows an output buffer. This one writes * a quoted or double quoted #xmlChar string, checking first if it holds * quote or double-quotes internally */
| 7702 | * quote or double-quotes internally |
| 7703 | */ |
| 7704 | void |
| 7705 | xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) { |
| 7706 | const xmlChar *cur, *base; |
| 7707 | if (buf == NULL) |
| 7708 | return; |
| 7709 | if (xmlStrchr(string, '\"')) { |
| 7710 | if (xmlStrchr(string, '\'')) { |
| 7711 | xmlBufferCCat(buf, "\""); |
| 7712 | base = cur = string; |
| 7713 | while(*cur != 0){ |
| 7714 | if(*cur == '"'){ |
| 7715 | if (base != cur) |
| 7716 | xmlBufferAdd(buf, base, cur - base); |
| 7717 | xmlBufferAdd(buf, BAD_CAST """, 6); |
| 7718 | cur++; |
| 7719 | base = cur; |
| 7720 | } |
| 7721 | else { |
| 7722 | cur++; |
| 7723 | } |
| 7724 | } |
| 7725 | if (base != cur) |
| 7726 | xmlBufferAdd(buf, base, cur - base); |
| 7727 | xmlBufferCCat(buf, "\""); |
| 7728 | } |
| 7729 | else{ |
| 7730 | xmlBufferCCat(buf, "\'"); |
| 7731 | xmlBufferCat(buf, string); |
| 7732 | xmlBufferCCat(buf, "\'"); |
| 7733 | } |
| 7734 | } else { |
| 7735 | xmlBufferCCat(buf, "\""); |
| 7736 | xmlBufferCat(buf, string); |
| 7737 | xmlBufferCCat(buf, "\""); |
| 7738 | } |
| 7739 | } |
| 7740 | |
| 7741 | |
| 7742 | /** |
nothing calls this directly
no test coverage detected