Auteur: Ze'ev Atlas Date: À: Philip Hazel, Pcre Exim Sujet: [pcre-dev] Bug in DFTABLES.C
Hi Philip
The current version of dftables.c produces wrong output under z/OS and I believe that that bug will manifest itself in other environments as well:
in the past the two fprintf statements would follow each other and than there would be the patch that I've asked for
<snip from PCRE 8.37>fprintf(f, "/*************************************************\n" "* Perl-Compatible Regular Expressions *\n" "*************************************************/\n\n" "/* This file was automatically written by the dftables auxiliary\n" "program. It contains character tables that are used when no external\n" "tables are passed to PCRE by the application that calls it. The tables\n" "are used only for characters whose code values are less than 256.\n\n");fprintf(f, "The following #includes are present because without them gcc 4.x may remove\n" "the array definition from the final binary if PCRE is built into a static\n" "library and dead code stripping is activated. This leads to link errors.\n" "Pulling in the header ensures that the array gets flagged as \"someone\n" "outside this compilation unit might reference this\" and so it will always\n" "be supplied to the linker. */\n\n");
/* Force config.h in z/OS */
#if defined NATIVE_ZOSfprintf(f, "/* For z/OS, config.h is forced */\n" "#ifndef HAVE_CONFIG_H\n" "#define HAVE_CONFIG_H 1\n" "#endif\n\n");#endif<end snip>
However this has been changed in PCRE2 and in 10.20 we have
<snip from PCRE2 10.20>
"/* This file was automatically written by the dftables auxiliary\n" "program. It contains character tables that are used when no external\n" "tables are passed to PCRE2 by the application that calls it. The tables\n" "are used only for characters whose code values are less than 256.\n\n");
/* Force config.h in z/OS */
#if defined NATIVE_ZOSfprintf(f, "/* For z/OS, config.h is forced */\n" "#ifndef HAVE_CONFIG_H\n" "#define HAVE_CONFIG_H 1\n" "#endif\n\n");#endif
fprintf(f, "The following #includes are present because without them gcc 4.x may remove\n" "the array definition from the final binary if PCRE2 is built into a static\n" "library and dead code stripping is activated. This leads to link errors.\n" "Pulling in the header ensures that the array gets flagged as \"someone\n" "outside this compilation unit might reference this\" and so it will always\n" "be supplied to the linker. */\n\n");<end snip>
The result is that in pcre2_chartables the first comment ends with "... z/OS, config.h is forced */", which masks the #if defined and the second comment is interpreted as wrong syntax.
Solution:
Move the last fprintf to its correct place.
BTW,in PCRE2 I do not really need my patch anymore since I've changed the compile process and I do feed the #define as compile parameters akin to -D parameters in gcc. I did not ask to remove the patch in dftables because of two reasons: a) it does not cause any harm if it stays and b) I am still very early in the development of the PCRE2 port.
I enclosed the suggested patch to correct the current bug. I tested it and it work properly under z/OS (i.e pcre2_chartables.c compiles correctly)
Ze'ev Atlas