mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-15 03:30:44 +02:00
Merge branch 'ctype' into 'master'
Replace use of ctype functions with internal version where only ASCII chars are used See merge request cairo/cairo!310
This commit is contained in:
commit
0e1cffe364
6 changed files with 99 additions and 36 deletions
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <pixman.h>
|
||||
|
||||
#include <cairo-ctype-inline.h>
|
||||
#include <cairo-types-private.h>
|
||||
#include <cairo-scaled-font-private.h>
|
||||
|
||||
|
|
@ -39,7 +40,6 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
|
@ -561,7 +561,7 @@ _cairo_boilerplate_target_matches_name (const cairo_boilerplate_target_t *target
|
|||
if (! (name_len == 1 && 0 == strncmp (tname, "?", 1))) { /* wildcard? */
|
||||
if (0 != strncmp (target->name, tname, name_len)) /* exact match? */
|
||||
return FALSE;
|
||||
if (isalnum (target->name[name_len]))
|
||||
if (_cairo_isalnum (target->name[name_len]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "cairo-perf.h"
|
||||
#include "cairo-missing.h"
|
||||
#include "cairo-stats.h"
|
||||
#include "cairo-ctype-inline.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -100,7 +101,7 @@ do { \
|
|||
#define parse_string(result) \
|
||||
do { \
|
||||
for (end = s; *end; end++) \
|
||||
if (isspace (*end)) \
|
||||
if (_cairo_isspace (*end)) \
|
||||
break; \
|
||||
(result) = strndup (s, end - s); \
|
||||
if ((result) == NULL) { \
|
||||
|
|
|
|||
86
src/cairo-ctype-inline.h
Normal file
86
src/cairo-ctype-inline.h
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009,2016,2021,2022 Adrian Johnson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is University of Southern
|
||||
* California.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Adrian Johnson <ajohnson@redneon.com>
|
||||
*/
|
||||
|
||||
#ifndef _CAIRO_CTYPE_INLINE_H_
|
||||
#define _CAIRO_CTYPE_INLINE_H_
|
||||
|
||||
#include "cairo-error-private.h"
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
/* ASCII only versions of some ctype.h character classification functions.
|
||||
* The glibc versions 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');
|
||||
}
|
||||
|
||||
static inline int cairo_const
|
||||
_cairo_isxdigit (int c)
|
||||
{
|
||||
return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
|
||||
}
|
||||
|
||||
static inline int cairo_const
|
||||
_cairo_isalpha (int c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
static inline int cairo_const
|
||||
_cairo_isprint (int c)
|
||||
{
|
||||
return (c >= 0x20 && c <= 0x7e);
|
||||
}
|
||||
|
||||
static inline int cairo_const
|
||||
_cairo_isalnum (int c)
|
||||
{
|
||||
return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
|
||||
}
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#endif /* _CAIRO_CTYPE_INLINE_H_ */
|
||||
|
|
@ -3315,7 +3315,7 @@ ESCAPED_CHAR:
|
|||
_cairo_output_stream_printf (ctx->stream, "\\%c", c);
|
||||
break;
|
||||
default:
|
||||
if (isprint (c) || isspace (c)) {
|
||||
if (_cairo_isprint(c)) {
|
||||
_cairo_output_stream_printf (ctx->stream, "%c", c);
|
||||
} else {
|
||||
char buf[4] = { '\\' };
|
||||
|
|
|
|||
|
|
@ -271,33 +271,7 @@ static inline void put_unaligned_be32 (uint32_t v, unsigned char *p)
|
|||
p[3] = v & 0xff;
|
||||
}
|
||||
|
||||
/* 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');
|
||||
}
|
||||
|
||||
static inline int cairo_const
|
||||
_cairo_isxdigit (int c)
|
||||
{
|
||||
return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
|
||||
}
|
||||
|
||||
static inline int cairo_const
|
||||
_cairo_isalpha (int c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
#include "cairo-ctype-inline.h"
|
||||
#include "cairo-types-private.h"
|
||||
#include "cairo-cache-private.h"
|
||||
#include "cairo-reference-count-private.h"
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@
|
|||
# include <cairo-ft.h>
|
||||
#endif
|
||||
|
||||
#include "cairo-ctype-inline.h"
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
|
@ -565,7 +567,7 @@ _trace_dtostr (char *buffer, size_t size, double d)
|
|||
if (*p == '+' || *p == '-')
|
||||
p++;
|
||||
|
||||
while (isdigit (*p))
|
||||
while (_cairo_isdigit (*p))
|
||||
p++;
|
||||
|
||||
if (strncmp (p, decimal_point, decimal_point_len) == 0)
|
||||
|
|
@ -585,7 +587,7 @@ _trace_dtostr (char *buffer, size_t size, double d)
|
|||
if (*p == '+' || *p == '-')
|
||||
p++;
|
||||
|
||||
while (isdigit (*p))
|
||||
while (_cairo_isdigit (*p))
|
||||
p++;
|
||||
|
||||
if (strncmp (p, decimal_point, decimal_point_len) == 0) {
|
||||
|
|
@ -651,7 +653,7 @@ _trace_vprintf (const char *fmt, va_list ap)
|
|||
f++;
|
||||
}
|
||||
|
||||
while (isdigit (*f))
|
||||
while (_cairo_isdigit (*f))
|
||||
f++;
|
||||
|
||||
length_modifier = 0;
|
||||
|
|
@ -1850,7 +1852,7 @@ _encode_string_literal (char *out, int max,
|
|||
max -= 2;
|
||||
break;
|
||||
default:
|
||||
if (isprint (c) || isspace (c)) {
|
||||
if (_cairo_isprint (c)) {
|
||||
*out++ = c;
|
||||
} else {
|
||||
int octal = 0;
|
||||
|
|
@ -1920,7 +1922,7 @@ ESCAPED_CHAR:
|
|||
_trace_printf ("\\%c", c);
|
||||
break;
|
||||
default:
|
||||
if (isprint (c) || isspace (c)) {
|
||||
if (_cairo_isprint (c)) {
|
||||
_trace_printf ("%c", c);
|
||||
} else {
|
||||
char buf[4] = { '\\' };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue