mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 19:22:11 +01:00
2007-03-15 Marco Barisione <marco@barisione.org> Add GRegex for regular expression matching. (#50075) * configure.in: Handle GRegex compilation. * glib/gregex.c: * glib/gregex.h: Code for GRegex. * glib/Makefile.am: * glib/makefile.msc.in: Updated makefiles. * glib/pcre/*: Internal copy of PCRE. * glib/update-pcre/*: Stuff to automatically update the internal PCRE to a newer version. * tests/regex-test.c: * tests/Makefile.am: * tests/makefile.msc.in: Add tests for GRegex. svn path=/trunk/; revision=5408
134 lines
6.8 KiB
Diff
134 lines
6.8 KiB
Diff
--- pcre_compile.c 2006-10-10 12:00:00.000000000 +0200
|
||
+++ pcre_compile.c 2006-10-10 12:00:00.000000000 +0200
|
||
@@ -246,130 +246,6 @@ static const char *error_texts[] = {
|
||
};
|
||
|
||
|
||
-/* Table to identify digits and hex digits. This is used when compiling
|
||
-patterns. Note that the tables in chartables are dependent on the locale, and
|
||
-may mark arbitrary characters as digits - but the PCRE compiling code expects
|
||
-to handle only 0-9, a-z, and A-Z as digits when compiling. That is why we have
|
||
-a private table here. It costs 256 bytes, but it is a lot faster than doing
|
||
-character value tests (at least in some simple cases I timed), and in some
|
||
-applications one wants PCRE to compile efficiently as well as match
|
||
-efficiently.
|
||
-
|
||
-For convenience, we use the same bit definitions as in chartables:
|
||
-
|
||
- 0x04 decimal digit
|
||
- 0x08 hexadecimal digit
|
||
-
|
||
-Then we can use ctype_digit and ctype_xdigit in the code. */
|
||
-
|
||
-#if !EBCDIC /* This is the "normal" case, for ASCII systems */
|
||
-static const unsigned char digitab[] =
|
||
- {
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 8- 15 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - ' */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* ( - / */
|
||
- 0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /* 0 - 7 */
|
||
- 0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /* 8 - ? */
|
||
- 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* @ - G */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* H - O */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* P - W */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* X - _ */
|
||
- 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* ` - g */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* h - o */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p - w */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x -127 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
|
||
-
|
||
-#else /* This is the "abnormal" case, for EBCDIC systems */
|
||
-static const unsigned char digitab[] =
|
||
- {
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 0 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 8- 15 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 10 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 32- 39 20 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 40- 47 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 48- 55 30 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 56- 63 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - 71 40 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 72- | */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* & - 87 50 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 88- <20> */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - -103 60 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 104- ? */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 70 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- " */
|
||
- 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* 128- g 80 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* h -143 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144- p 90 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* q -159 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160- x A0 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y -175 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* ^ -183 B0 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
|
||
- 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* { - G C0 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* H -207 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* } - P D0 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* Q -223 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* \ - X E0 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* Y -239 */
|
||
- 0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /* 0 - 7 F0 */
|
||
- 0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00};/* 8 -255 */
|
||
-
|
||
-static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */
|
||
- 0x80,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /* 0- 7 */
|
||
- 0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00, /* 8- 15 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /* 16- 23 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /* 32- 39 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 40- 47 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 48- 55 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 56- 63 */
|
||
- 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - 71 */
|
||
- 0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80, /* 72- | */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* & - 87 */
|
||
- 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00, /* 88- <20> */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - -103 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x80, /* 104- ? */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 */
|
||
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- " */
|
||
- 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* 128- g */
|
||
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* h -143 */
|
||
- 0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* 144- p */
|
||
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* q -159 */
|
||
- 0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /* 160- x */
|
||
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* y -175 */
|
||
- 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* ^ -183 */
|
||
- 0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
|
||
- 0x80,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* { - G */
|
||
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* H -207 */
|
||
- 0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* } - P */
|
||
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* Q -223 */
|
||
- 0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /* \ - X */
|
||
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* Y -239 */
|
||
- 0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /* 0 - 7 */
|
||
- 0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00};/* 8 -255 */
|
||
-#endif
|
||
-
|
||
-
|
||
/* Definition to allow mutual recursion */
|
||
|
||
static BOOL
|