third_party/cairo/src/cairo-pdf-operators.c
static int
_word_wrap_stream_count_string_up_to (word_wrap_stream_t *stream,
				      const unsigned char *data, int length)
{
    const unsigned char *s = data;
    int count = 0;
    cairo_bool_t newline = FALSE;

    while (length--) {
	count++;
	stream->column++;
	if (!stream->in_escape) {
	    if (*s == ')') {
		stream->state = WRAP_STATE_DELIMITER;
		break;
	    }
	    if (*s == '\\') {
		stream->in_escape = TRUE;
		stream->escape_digits = 0;
	    } else if (stream->ps_output && stream->column > stream->max_column) {
		newline = TRUE;
		break;
	    }
	} else {
	    if (!_cairo_isdigit(*s) || ++stream->escape_digits == 3)
		stream->in_escape = FALSE;
	}
	s++;
    }

    if (count)
	_cairo_output_stream_write (stream->output, data, count);

    if (newline) {
	_cairo_output_stream_printf (stream->output, "\\\n");
	stream->column = 0;
    }

    return count;
}
/* Count up to either the end of the string or the number of columns
 * remaining.
 */
Count up to either the end of the string or the number of columns
remaining.
Count up to either the end of the string or the number of columns remaining .
static int
_word_wrap_stream_count_string_up_to (word_wrap_stream_t *stream,
				      const unsigned char *data, int length)
{
    const unsigned char *s = data;
    int count = 0;
    cairo_bool_t newline = FALSE;
    while (length--) {
	count++;
	stream->column++;
	if (!stream->in_escape) {
	    if (*s == ')') {
		stream->state = WRAP_STATE_DELIMITER;
		break;
	    }
	    if (*s == '\\') {
		stream->in_escape = TRUE;
		stream->escape_digits = 0;
	    } else if (stream->ps_output && stream->column > stream->max_column) {
		newline = TRUE;
		break;
	    }
	} else {
	    if (!_cairo_isdigit(*s) || ++stream->escape_digits == 3)
		stream->in_escape = FALSE;
	}
	s++;
    }
    if (count)
	_cairo_output_stream_write (stream->output, data, count);
    if (newline) {
	_cairo_output_stream_printf (stream->output, "\\\n");
	stream->column = 0;
    }
    return count;
}
static int _word_wrap_stream_count_string_up_to ( word_wrap_stream_t * stream , const unsigned char * data , int length ) { const unsigned char * s = data ; int count = 0 ; cairo_bool_t newline = FALSE ; while ( length -- ) { count ++ ; stream -> column ++ ; if ( ! stream -> in_escape ) { if ( * s == ' ' ) { stream -> state = WRAP_STATE_DELIMITER ; break ; } if ( * s == ' \\ ' ) { stream -> in_escape = TRUE ; stream -> escape_digits = 0 ; } else if ( stream -> ps_output && stream -> column > stream -> max_column ) { newline = TRUE ; break ; } } else { if ( ! _cairo_isdigit ( * s ) || ++ stream -> escape_digits == 3 ) stream -> in_escape = FALSE ; } s ++ ; } if ( count ) _cairo_output_stream_write ( stream -> output , data , count ) ; if ( newline ) { _cairo_output_stream_printf ( stream -> output , " \\ \n " ) ; stream -> column = 0 ; } return count ; }
Count up to either the end of the string or the number of columns
 remaining.
Count up to either the end of the string or the number of columns remaining .