third_party/cairo/src/cairo-svg-surface.c
static void
_cairo_svg_surface_emit_attr_value (cairo_svg_stream_t *stream,
				    const unsigned char *value,
				    unsigned int length)
{
    const unsigned char *p;
    const unsigned char *q;
    unsigned int i;

    /* we'll accumulate non-special chars in [q, p) range */
    p = value;
    q = p;
    for (i = 0; i < length; i++, p++) {
	if (*p == '&' || *p == '"') {
	    /* flush what's left before special char */
	    if (p != q) {
		_cairo_svg_stream_write (stream, q, p - q);
		q = p + 1;
	    }

	    if (*p == '&')
		_cairo_svg_stream_printf (stream, "&amp;");
	    else // p == '"'
		_cairo_svg_stream_printf (stream, "&quot;");
	}
    }

    /* flush the trailing chars if any */
    if (p != q)
	_cairo_svg_stream_write (stream, q, p - q);
}
/**
 * _cairo_svg_surface_emit_attr_value:
 *
 * 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: &amp; and &quot;.
 **/
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 ".
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_svg_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_svg_stream_write (stream, q, p - q);
		q = p + 1;
	    }
	    if (*p == '&')
		_cairo_svg_stream_printf (stream, "&amp;");
	    else 
		_cairo_svg_stream_printf (stream, "&quot;");
	}
    }
    if (p != q)
	_cairo_svg_stream_write (stream, q, p - q);
}
static void _cairo_svg_surface_emit_attr_value ( cairo_svg_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_svg_stream_write ( stream , q , p - q ) ; q = p + 1 ; } if ( * p == ' ' ) _cairo_svg_stream_printf ( stream , " " ) ; else _cairo_svg_stream_printf ( stream , " " ) ; } } if ( p != q ) _cairo_svg_stream_write ( stream , q , p - q ) ; }
_cairo_svg_surface_emit_attr_value:
 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: &amp; and &quot;.
_cairo_svg_surface_emit_attr_value : 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 : &amp ; and &quot ; .
/* we'll accumulate non-special chars in [q, p) range */ /* flush what's left before special char */ // p == '"' /* flush the trailing chars if any */