[Pcre-svn] [425] code/trunk: Add #ifndef SUPPORT_UCP to pcre…

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [425] code/trunk: Add #ifndef SUPPORT_UCP to pcre_ucd.c
Revision: 425
          http://vcs.pcre.org/viewvc?view=rev&revision=425
Author:   ph10
Date:     2009-08-17 15:48:48 +0100 (Mon, 17 Aug 2009)


Log Message:
-----------
Add #ifndef SUPPORT_UCP to pcre_ucd.c

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/maint/MultiStage2.py
    code/trunk/pcre_ucd.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2009-08-15 18:45:00 UTC (rev 424)
+++ code/trunk/ChangeLog    2009-08-17 14:48:48 UTC (rev 425)
@@ -34,6 +34,13 @@
 6.  No libpcreposix.pc file was created for pkg-config; there was just 
     libpcre.pc and libpcrecpp.pc. The omission has been rectified.


+7.  Added #ifndef SUPPORT_UCP into the pcre_ucd.c module, to reduce its size
+    when UCP support is not needed, by modifying the Python script that 
+    generates it from Unicode data files. This should not matter if the module
+    is correctly used as a library, but I received one complaint about 50K of
+    unwanted data. My guess is that the person linked everything into his
+    program rather than using a library. Anyway, it does no harm.
+    


Version 7.9 11-Apr-09
---------------------

Modified: code/trunk/maint/MultiStage2.py
===================================================================
--- code/trunk/maint/MultiStage2.py    2009-08-15 18:45:00 UTC (rev 424)
+++ code/trunk/maint/MultiStage2.py    2009-08-17 14:48:48 UTC (rev 425)
@@ -26,6 +26,7 @@
 #  Adjusted global table names by prefixing _pcre_.
 #  Commented out stuff relating to the casefolding table, which isn't used.
 #  Corrected size calculation
+#  Add #ifndef SUPPORT_UCP to use dummy tables when no UCP support is needed.
 #
 # The tables generated by this script are used by macros defined in
 # pcre_internal.h. They look up Unicode character properties using short 
@@ -276,11 +277,28 @@
 print "#ifdef HAVE_CONFIG_H"
 print "#include \"config.h\""
 print "#endif"
+print
 print "#include \"pcre_internal.h\""
 print
 print "/* Unicode character database. */"
 print "/* This file was autogenerated by the MultiStage2.py script. */"
 print "/* Total size: %d bytes, block size: %d. */" % (min_size, min_block_size)
+print
+print "/* The tables herein are needed only when UCP support is built */"
+print "/* into PCRE. This module should not be referenced otherwise, so */"
+print "/* it should not matter whether it is compiled or not. However */"
+print "/* a comment was received about space saving - maybe the guy linked */"
+print "/* all the modules rather than using a library - so we include a */"
+print "/* condition to cut out the tables when not needed. But don't leave */"
+print "/* a totally empty module because some compilers barf at that. */"
+print "/* Instead, just supply small dummy tables. */"
+print
+print "#ifndef SUPPORT_UCP"
+print "const ucd_record _pcre_ucd_records[] = {{0,0,0 }};"
+print "const uschar _pcre_ucd_stage1[] = {0};"
+print "const pcre_uint16 _pcre_ucd_stage2[] = {0};"
+print "#else"
+print
 print record_struct
 print_records(records, record_size)
 print_table(min_stage1, '_pcre_ucd_stage1')
@@ -288,6 +306,7 @@
 print "#if UCD_BLOCK_SIZE != %d" % min_block_size
 print "#error Please correct UCD_BLOCK_SIZE in pcre_internal.h"
 print "#endif"
+print "#endif  /* SUPPORT_UCP */"


"""


Modified: code/trunk/pcre_ucd.c
===================================================================
--- code/trunk/pcre_ucd.c    2009-08-15 18:45:00 UTC (rev 424)
+++ code/trunk/pcre_ucd.c    2009-08-17 14:48:48 UTC (rev 425)
@@ -1,11 +1,28 @@
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+
 #include "pcre_internal.h"


/* Unicode character database. */
/* This file was autogenerated by the MultiStage2.py script. */
/* Total size: 52808 bytes, block size: 128. */
+
+/* The tables herein are needed only when UCP support is built */
+/* into PCRE. This module should not be referenced otherwise, so */
+/* it should not matter whether it is compiled or not. However */
+/* a comment was received about space saving - maybe the guy linked */
+/* all the modules rather than using a library - so we include a */
+/* condition to cut out the tables when not needed. But don't leave */
+/* a totally empty module because some compilers barf at that. */
+/* Instead, just supply small dummy tables. */
+
+#ifndef SUPPORT_UCP
+const ucd_record _pcre_ucd_records[] = {{0,0,0 }};
+const uschar _pcre_ucd_stage1[] = {0};
+const pcre_uint16 _pcre_ucd_stage2[] = {0};
+#else
+
/* When recompiling tables with a new Unicode version,
please check types in the structure definition from pcre_internal.h:
typedef struct {
@@ -14,6 +31,7 @@
pcre_int32 property_2;
} ucd_record; */

+
 const ucd_record _pcre_ucd_records[] = { /* 3656 bytes, record size 8 */
   {     9,      0,      0, }, /*   0 */
   {     9,     29,      0, }, /*   1 */
@@ -2607,3 +2625,4 @@
 #if UCD_BLOCK_SIZE != 128
 #error Please correct UCD_BLOCK_SIZE in pcre_internal.h
 #endif
+#endif  /* SUPPORT_UCP */