summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-03-07 11:02:28 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-03-07 11:02:28 +0000
commita1609fda1aaf8a8499844b5021f7b03ec66e7d43 (patch)
tree03e16816cb2d6382b6cb48c7bdd273b051f21d93
parentf1bf86368f88991a780fe5e0142c2e7b5b019f10 (diff)
downloadpcre-a1609fda1aaf8a8499844b5021f7b03ec66e7d43.tar.gz
Added some additional #ifdef SUPPORT_UTF8 to minimize the code when UTF-8
support is not compiled. git-svn-id: svn://vcs.exim.org/pcre/code/trunk@107 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog6
-rw-r--r--pcre_compile.c4
-rw-r--r--pcre_printint.src7
-rw-r--r--pcre_study.c4
-rw-r--r--pcre_tables.c4
-rw-r--r--pcretest.c15
6 files changed, 36 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d09cba0..3242942 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,12 @@ Version 7.1 05-Mar-07
to update Builducptable as well, so it won't revert if ucptable.h is ever
re-created.
+ 9. Added some extra #ifdef SUPPORT_UTF8 conditionals into pcretest.c,
+ pcre_printint.src, pcre_compile.c, pcre_study.c, and pcre_tables.c, in
+ order to be able to cut out the UTF-8 tables in the latter when UTF-8
+ support is not required. This saves 1.5-2K of code, which is important in
+ some applications.
+
Version 7.0 19-Dec-06
---------------------
diff --git a/pcre_compile.c b/pcre_compile.c
index df89266..20e0f80 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -1246,6 +1246,7 @@ for (;;)
else
{
code += _pcre_OP_lengths[c];
+#ifdef SUPPORT_UTF8
if (utf8) switch(c)
{
case OP_CHAR:
@@ -1266,6 +1267,7 @@ for (;;)
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f];
break;
}
+#endif
}
}
}
@@ -1309,6 +1311,7 @@ for (;;)
else
{
code += _pcre_OP_lengths[c];
+#ifdef SUPPORT_UTF8
if (utf8) switch(c)
{
case OP_CHAR:
@@ -1329,6 +1332,7 @@ for (;;)
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f];
break;
}
+#endif
}
}
}
diff --git a/pcre_printint.src b/pcre_printint.src
index a6f4333..ecbf7a0 100644
--- a/pcre_printint.src
+++ b/pcre_printint.src
@@ -71,6 +71,12 @@ print_char(FILE *f, uschar *ptr, BOOL utf8)
{
int c = *ptr;
+#ifndef SUPPORT_UTF8
+utf8 = utf8; /* Avoid compiler warning */
+if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
+return 0;
+
+#else
if (!utf8 || (c & 0xc0) != 0xc0)
{
if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
@@ -102,6 +108,7 @@ else
if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);
return a;
}
+#endif
}
diff --git a/pcre_study.c b/pcre_study.c
index 87f8c6f..b23a3fb 100644
--- a/pcre_study.c
+++ b/pcre_study.c
@@ -394,11 +394,13 @@ do
character with a value > 255. */
case OP_NCLASS:
+#ifdef SUPPORT_UTF8
if (utf8)
{
start_bits[24] |= 0xf0; /* Bits for 0xc4 - 0xc8 */
memset(start_bits+25, 0xff, 7); /* Bits for 0xc9 - 0xff */
}
+#endif
/* Fall through */
case OP_CLASS:
@@ -411,6 +413,7 @@ do
value is > 127. In fact, there are only two possible starting bytes for
characters in the range 128 - 255. */
+#ifdef SUPPORT_UTF8
if (utf8)
{
for (c = 0; c < 16; c++) start_bits[c] |= tcode[c];
@@ -428,6 +431,7 @@ do
/* In non-UTF-8 mode, the two bit maps are completely compatible. */
else
+#endif
{
for (c = 0; c < 32; c++) start_bits[c] |= tcode[c];
}
diff --git a/pcre_tables.c b/pcre_tables.c
index 53690d7..18a4bb1 100644
--- a/pcre_tables.c
+++ b/pcre_tables.c
@@ -61,6 +61,8 @@ const uschar _pcre_OP_lengths[] = { OP_LENGTHS };
/* These are the breakpoints for different numbers of bytes in a UTF-8
character. */
+#ifdef SUPPORT_UTF8
+
const int _pcre_utf8_table1[] =
{ 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
@@ -194,4 +196,6 @@ const ucp_type_table _pcre_utt[] = {
const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);
+#endif /* SUPPORT_UTF8 */
+
/* End of pcre_tables.c */
diff --git a/pcretest.c b/pcretest.c
index d5249fa..56b50a0 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -114,10 +114,17 @@ Makefile. */
#include "pcreposix.h"
#endif
-/* It is also possible, for the benefit of the version imported into Exim, to
-build pcretest without support for UTF8 (define NOUTF8), without the interface
-to the DFA matcher (NODFA), and without the doublecheck of the old "info"
-function (define NOINFOCHECK). */
+/* It is also possible, for the benefit of the version currently imported into
+Exim, to build pcretest without support for UTF8 (define NOUTF8), without the
+interface to the DFA matcher (NODFA), and without the doublecheck of the old
+"info" function (define NOINFOCHECK). In fact, we automatically cut out the
+UTF8 support if PCRE is built without it. */
+
+#ifndef SUPPORT_UTF8
+#ifndef NOUTF8
+#define NOUTF8
+#endif
+#endif
/* Other parameters */