/* Write the value to output the stream as a sequence of characters, while escaping those which have special meaning in the XML attribute's value context: & and ".  */
static void _cairo_svg_surface_emit_attr_value(cairo_output_stream_t *stream, const unsigned char *value, unsigned int length)
/* Write the value to output the stream as a sequence of characters, while escaping those which have special meaning in the XML attribute's value context: & and ".  */
static void _cairo_svg_surface_emit_attr_value(cairo_output_stream_t *stream, const unsigned char *value, unsigned int length)
{
    const unsigned char *p;
    const unsigned char *q;
    unsigned int i;
    p = value;
    q = p;
    for (i = 0; i < length; i++, p++) {
	if (*p == '&' || *p == '"') {
	    if (p != q) {
		_cairo_output_stream_write (stream, q, p - q);
		q = p + 1;
	    }
	    if (*p == '&')
		_cairo_output_stream_printf (stream, "&amp;");
	    else
		_cairo_output_stream_printf (stream, "&quot;");
	}
    }
    if (p != q)
	_cairo_output_stream_write (stream, q, p - q);
}