• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 5238ab10c5f3082a4be38410bd01a47ab176dfde Mon Sep 17 00:00:00 2001
2From: Christian Persch <chpe@gnome.org>
3Date: Sun, 12 Feb 2012 19:29:42 +0100
4Subject: [PATCH] regex: Use g_ascii_is[x]digit
5
6---
7 glib/pcre/pcre_compile.c |   22 ++++++++++++----------
8 1 files changed, 12 insertions(+), 10 deletions(-)
9
10diff --git a/glib/pcre/pcre_compile.c b/glib/pcre/pcre_compile.c
11index 8070f51..eb985df 100644
12--- a/glib/pcre/pcre_compile.c
13+++ b/glib/pcre/pcre_compile.c
14@@ -52,6 +52,7 @@ supporting internal functions that are not used by other modules. */
15
16 #include "pcre_internal.h"
17
18+#include "gstrfuncs.h"
19
20 /* When PCRE_DEBUG is defined, we need the pcre(16)_printint() function, which
21 is also used by pcretest. PCRE_DEBUG is not defined when building a production
22@@ -513,6 +514,7 @@ into a subtraction and unsigned comparison). */
23
24 #define IS_DIGIT(x) ((x) >= CHAR_0 && (x) <= CHAR_9)
25
26+#if 0
27 #ifndef EBCDIC
28
29 /* This is the "normal" case, for ASCII systems, and EBCDIC systems running in
30@@ -626,7 +628,7 @@ static const pcre_uint8 ebcdic_chartab[] = { /* chartable partial dup */
31   0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /*  0 - 7  */
32   0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00};/*  8 -255 */
33 #endif
34-
35+#endif /* 0 */
36
37 /* Definition to allow mutual recursion */
38
39@@ -812,10 +814,10 @@ else
40       {
41       /* In JavaScript, \u must be followed by four hexadecimal numbers.
42       Otherwise it is a lowercase u letter. */
43-      if (MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0
44-        && MAX_255(ptr[2]) && (digitab[ptr[2]] & ctype_xdigit) != 0
45-        && MAX_255(ptr[3]) && (digitab[ptr[3]] & ctype_xdigit) != 0
46-        && MAX_255(ptr[4]) && (digitab[ptr[4]] & ctype_xdigit) != 0)
47+      if (MAX_255(ptr[1]) && g_ascii_isxdigit(ptr[1]) != 0
48+        && MAX_255(ptr[2]) && g_ascii_isxdigit(ptr[2]) != 0
49+        && MAX_255(ptr[3]) && g_ascii_isxdigit(ptr[3]) != 0
50+        && MAX_255(ptr[4]) && g_ascii_isxdigit(ptr[4]) != 0)
51         {
52         c = 0;
53         for (i = 0; i < 4; ++i)
54@@ -1012,8 +1014,8 @@ else
55       {
56       /* In JavaScript, \x must be followed by two hexadecimal numbers.
57       Otherwise it is a lowercase x letter. */
58-      if (MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0
59-        && MAX_255(ptr[2]) && (digitab[ptr[2]] & ctype_xdigit) != 0)
60+      if (MAX_255(ptr[1]) && g_ascii_isxdigit(ptr[1]) != 0
61+        && MAX_255(ptr[2]) && g_ascii_isxdigit(ptr[2]) != 0)
62         {
63         c = 0;
64         for (i = 0; i < 2; ++i)
65@@ -1036,7 +1038,7 @@ else
66       const pcre_uchar *pt = ptr + 2;
67
68       c = 0;
69-      while (MAX_255(*pt) && (digitab[*pt] & ctype_xdigit) != 0)
70+      while (MAX_255(*pt) && g_ascii_isxdigit(*pt) != 0)
71         {
72         register int cc = *pt++;
73         if (c == 0 && cc == CHAR_0) continue;     /* Leading zeroes */
74@@ -1060,7 +1062,7 @@ else
75
76       if (c < 0)
77         {
78-        while (MAX_255(*pt) && (digitab[*pt] & ctype_xdigit) != 0) pt++;
79+        while (MAX_255(*pt) && g_ascii_isxdigit(*pt) != 0) pt++;
80         *errorcodeptr = ERR34;
81         }
82
83@@ -1078,7 +1080,7 @@ else
84     /* Read just a single-byte hex-defined char */
85
86     c = 0;
87-    while (i++ < 2 && MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0)
88+    while (i++ < 2 && MAX_255(ptr[1]) && g_ascii_isxdigit(ptr[1]) != 0)
89       {
90       int cc;                                  /* Some compilers don't like */
91       cc = *(++ptr);                           /* ++ in initializers */
92--
931.7.5.1.217.g4e3aa.dirty
94
95