mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-08 15:20:24 +01:00
Provide a builtin implementation of isspace() and isdigit()
The glibc versions are slow in utf8 locales.
This commit is contained in:
parent
f571356d34
commit
600dd83398
4 changed files with 28 additions and 17 deletions
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <locale.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Numbers printed with %f are printed with this number of significant
|
||||
|
|
@ -341,7 +340,7 @@ _cairo_dtostr (char *buffer, size_t size, double d, cairo_bool_t limited_precisi
|
|||
if (*p == '+' || *p == '-')
|
||||
p++;
|
||||
|
||||
while (isdigit (*p))
|
||||
while (_cairo_isdigit (*p))
|
||||
p++;
|
||||
|
||||
if (strncmp (p, decimal_point, decimal_point_len) == 0)
|
||||
|
|
@ -362,7 +361,7 @@ _cairo_dtostr (char *buffer, size_t size, double d, cairo_bool_t limited_precisi
|
|||
if (*p == '+' || *p == '-')
|
||||
p++;
|
||||
|
||||
while (isdigit (*p))
|
||||
while (_cairo_isdigit (*p))
|
||||
p++;
|
||||
|
||||
if (strncmp (p, decimal_point, decimal_point_len) == 0) {
|
||||
|
|
@ -434,7 +433,7 @@ _cairo_output_stream_vprintf (cairo_output_stream_t *stream,
|
|||
f++;
|
||||
}
|
||||
|
||||
while (isdigit (*f))
|
||||
while (_cairo_isdigit (*f))
|
||||
f++;
|
||||
|
||||
length_modifier = 0;
|
||||
|
|
|
|||
|
|
@ -48,8 +48,6 @@
|
|||
#include "cairo-output-stream-private.h"
|
||||
#include "cairo-scaled-font-subsets-private.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_pdf_operators_end_text (cairo_pdf_operators_t *pdf_operators);
|
||||
|
||||
|
|
@ -180,7 +178,7 @@ _count_word_up_to (const unsigned char *s, int length)
|
|||
int word = 0;
|
||||
|
||||
while (length--) {
|
||||
if (! (isspace (*s) || *s == '<')) {
|
||||
if (! (_cairo_isspace (*s) || *s == '<')) {
|
||||
s++;
|
||||
word++;
|
||||
} else {
|
||||
|
|
@ -239,7 +237,7 @@ _word_wrap_stream_write (cairo_output_stream_t *base,
|
|||
length--;
|
||||
_cairo_output_stream_printf (stream->output, ">");
|
||||
stream->column++;
|
||||
} else if (isspace (*data)) {
|
||||
} else if (_cairo_isspace (*data)) {
|
||||
newline = (*data == '\n' || *data == '\r');
|
||||
if (! newline && stream->column >= stream->max_column) {
|
||||
_cairo_output_stream_printf (stream->output, "\n");
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@
|
|||
#include FT_OUTLINE_H
|
||||
#include FT_TYPE1_TABLES_H
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
typedef struct _cairo_type1_font_subset {
|
||||
cairo_scaled_font_subset_t *scaled_font_subset;
|
||||
|
||||
|
|
@ -295,8 +293,8 @@ cairo_type1_font_erase_dict_key (cairo_type1_font_subset_t *font,
|
|||
p = start + strlen(key);
|
||||
/* skip integers or array of integers */
|
||||
while (p < segment_end &&
|
||||
(isspace(*p) ||
|
||||
isdigit(*p) ||
|
||||
(_cairo_isspace(*p) ||
|
||||
_cairo_isdigit(*p) ||
|
||||
*p == '[' ||
|
||||
*p == ']'))
|
||||
{
|
||||
|
|
@ -354,7 +352,7 @@ cairo_type1_font_subset_write_header (cairo_type1_font_subset_t *font,
|
|||
start = find_token (font->header_segment, segment_end, "/UniqueID");
|
||||
if (start) {
|
||||
start += 9;
|
||||
while (start < segment_end && isspace (*start))
|
||||
while (start < segment_end && _cairo_isspace (*start))
|
||||
start++;
|
||||
if (start + 5 < segment_end && memcmp(start, "known", 5) == 0) {
|
||||
_cairo_output_stream_write (font->output, font->header_segment,
|
||||
|
|
@ -474,7 +472,7 @@ cairo_type1_font_subset_decrypt_eexec_segment (cairo_type1_font_subset_t *font)
|
|||
while (in < end) {
|
||||
if (font->eexec_segment_is_ascii) {
|
||||
c = *in++;
|
||||
if (isspace (c))
|
||||
if (_cairo_isspace (c))
|
||||
continue;
|
||||
c = (hex_to_int (c) << 4) | hex_to_int (*in++);
|
||||
} else {
|
||||
|
|
@ -510,10 +508,10 @@ cairo_type1_font_subset_decrypt_eexec_segment (cairo_type1_font_subset_t *font)
|
|||
static const char *
|
||||
skip_token (const char *p, const char *end)
|
||||
{
|
||||
while (p < end && isspace(*p))
|
||||
while (p < end && _cairo_isspace(*p))
|
||||
p++;
|
||||
|
||||
while (p < end && !isspace(*p))
|
||||
while (p < end && !_cairo_isspace(*p))
|
||||
p++;
|
||||
|
||||
if (p == end)
|
||||
|
|
@ -969,7 +967,7 @@ cairo_type1_font_subset_for_each_glyph (cairo_type1_font_subset_t *font,
|
|||
|
||||
/* Skip binary data and |- or ND token. */
|
||||
p = skip_token (charstring + charstring_length, dict_end);
|
||||
while (p < dict_end && isspace(*p))
|
||||
while (p < dict_end && _cairo_isspace(*p))
|
||||
p++;
|
||||
|
||||
/* In case any of the skip_token() calls above reached EOF, p will
|
||||
|
|
|
|||
|
|
@ -229,6 +229,22 @@ be32_to_cpu(uint32_t v)
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
/* The glibc versions of ispace() and isdigit() are slow in UTF-8 locales.
|
||||
*/
|
||||
|
||||
static inline int cairo_const
|
||||
_cairo_isspace (int c)
|
||||
{
|
||||
return (c == 0x20 || (c >= 0x09 && c <= 0x0d));
|
||||
}
|
||||
|
||||
static inline int cairo_const
|
||||
_cairo_isdigit (int c)
|
||||
{
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
#include "cairo-types-private.h"
|
||||
#include "cairo-cache-private.h"
|
||||
#include "cairo-reference-count-private.h"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue