blob: a12efc52609799e57eaa850fb3fb3718c49d8db2 [file] [log] [blame]
From 5238ab10c5f3082a4be38410bd01a47ab176dfde Mon Sep 17 00:00:00 2001
From: Christian Persch <chpe@gnome.org>
Date: Sun, 12 Feb 2012 19:29:42 +0100
Subject: [PATCH] regex: Use g_ascii_is[x]digit
---
glib/pcre/pcre_compile.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/glib/pcre/pcre_compile.c b/glib/pcre/pcre_compile.c
index 8070f51..eb985df 100644
--- a/glib/pcre/pcre_compile.c
+++ b/glib/pcre/pcre_compile.c
@@ -52,6 +52,7 @@ supporting internal functions that are not used by other modules. */
#include "pcre_internal.h"
+#include "gstrfuncs.h"
/* When PCRE_DEBUG is defined, we need the pcre(16)_printint() function, which
is also used by pcretest. PCRE_DEBUG is not defined when building a production
@@ -513,6 +514,7 @@ into a subtraction and unsigned comparison). */
#define IS_DIGIT(x) ((x) >= CHAR_0 && (x) <= CHAR_9)
+#if 0
#ifndef EBCDIC
/* This is the "normal" case, for ASCII systems, and EBCDIC systems running in
@@ -626,7 +628,7 @@ static const pcre_uint8 ebcdic_chartab[] = { /* chartable partial dup */
0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /* 0 - 7 */
0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00};/* 8 -255 */
#endif
-
+#endif /* 0 */
/* Definition to allow mutual recursion */
@@ -812,10 +814,10 @@ else
{
/* In JavaScript, \u must be followed by four hexadecimal numbers.
Otherwise it is a lowercase u letter. */
- if (MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0
- && MAX_255(ptr[2]) && (digitab[ptr[2]] & ctype_xdigit) != 0
- && MAX_255(ptr[3]) && (digitab[ptr[3]] & ctype_xdigit) != 0
- && MAX_255(ptr[4]) && (digitab[ptr[4]] & ctype_xdigit) != 0)
+ if (MAX_255(ptr[1]) && g_ascii_isxdigit(ptr[1]) != 0
+ && MAX_255(ptr[2]) && g_ascii_isxdigit(ptr[2]) != 0
+ && MAX_255(ptr[3]) && g_ascii_isxdigit(ptr[3]) != 0
+ && MAX_255(ptr[4]) && g_ascii_isxdigit(ptr[4]) != 0)
{
c = 0;
for (i = 0; i < 4; ++i)
@@ -1012,8 +1014,8 @@ else
{
/* In JavaScript, \x must be followed by two hexadecimal numbers.
Otherwise it is a lowercase x letter. */
- if (MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0
- && MAX_255(ptr[2]) && (digitab[ptr[2]] & ctype_xdigit) != 0)
+ if (MAX_255(ptr[1]) && g_ascii_isxdigit(ptr[1]) != 0
+ && MAX_255(ptr[2]) && g_ascii_isxdigit(ptr[2]) != 0)
{
c = 0;
for (i = 0; i < 2; ++i)
@@ -1036,7 +1038,7 @@ else
const pcre_uchar *pt = ptr + 2;
c = 0;
- while (MAX_255(*pt) && (digitab[*pt] & ctype_xdigit) != 0)
+ while (MAX_255(*pt) && g_ascii_isxdigit(*pt) != 0)
{
register int cc = *pt++;
if (c == 0 && cc == CHAR_0) continue; /* Leading zeroes */
@@ -1060,7 +1062,7 @@ else
if (c < 0)
{
- while (MAX_255(*pt) && (digitab[*pt] & ctype_xdigit) != 0) pt++;
+ while (MAX_255(*pt) && g_ascii_isxdigit(*pt) != 0) pt++;
*errorcodeptr = ERR34;
}
@@ -1078,7 +1080,7 @@ else
/* Read just a single-byte hex-defined char */
c = 0;
- while (i++ < 2 && MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0)
+ while (i++ < 2 && MAX_255(ptr[1]) && g_ascii_isxdigit(ptr[1]) != 0)
{
int cc; /* Some compilers don't like */
cc = *(++ptr); /* ++ in initializers */
--
1.7.5.1.217.g4e3aa.dirty