Implement --disable-percent-zt to avoid %zu and %td even if the environment

claims to be C99 or greater.
This commit is contained in:
Philip.Hazel 2018-11-15 18:09:02 +00:00
parent 19c50b9d41
commit 149af0e21b
12 changed files with 115 additions and 19 deletions

View File

@ -136,6 +136,8 @@ OPTION(PCRE2_BUILD_PCRE2_32 "Build 32 bit PCRE2 library" OFF)
OPTION(PCRE2_DEBUG "Include debugging code" OFF)
OPTION(DISABLE_PERCENT_ZT "Disable the use of %zu and %td (rarely needed)" OFF)
SET(PCRE2_EBCDIC OFF CACHE BOOL
"Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)")

View File

@ -68,6 +68,11 @@ inttypes.h. This supports environments that do not have stdint.h but do have
inttypes.h, which are known to exist. A note in the autotools documentation
says (November 2018) that there are none known that are the other way round.
17. Added --disable-percent-zt to "configure" (and equivalent to CMake) to
forcibly disable the use of %zu and %td in formatting strings because there is
at least one version of VMS that claims to be C99 but does not support these
modifiers.
Version 10.32 10-September-2018
-------------------------------

11
README
View File

@ -374,6 +374,15 @@ library. They are also documented in the pcre2build man page.
If you get error messages about missing functions tgetstr, tgetent, tputs,
tgetflag, or tgoto, this is the problem, and linking with the ncurses library
should fix it.
. The C99 standard defines formatting modifiers z and t for size_t and
ptrdiff_t values, respectively. By default, PCRE2 uses these modifiers in
environments other than Microsoft Visual Studio when __STDC_VERSION__ is
defined and has a value greater than or equal to 199901L (indicating C99).
However, there is at least one environment that claims to be C99 but does not
support these modifiers. If --disable-percent-zt is specified, no use is made
of the z or t modifiers. Instead or %td or %zu, %lu is used, with a cast for
size_t values.
. There is a special option called --enable-fuzz-support for use by people who
want to run fuzzing tests on PCRE2. At present this applies only to the 8-bit
@ -888,4 +897,4 @@ The distribution should contain the files listed below.
Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
Last updated: 19 September 2018
Last updated: 15 November 2018

View File

@ -18,6 +18,7 @@
#cmakedefine SUPPORT_PCRE2_16 1
#cmakedefine SUPPORT_PCRE2_32 1
#cmakedefine PCRE2_DEBUG 1
#cmakedefine DISABLE_PERCENT_ZT 1
#cmakedefine SUPPORT_LIBBZ2 1
#cmakedefine SUPPORT_LIBEDIT 1

View File

@ -131,7 +131,7 @@ AC_ARG_ENABLE(pcre2-32,
, enable_pcre2_32=unset)
AC_SUBST(enable_pcre2_32)
# Handle --dnable-debug (disabled by default)
# Handle --enable-debug (disabled by default)
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[enable debugging code]),
@ -343,6 +343,12 @@ AC_ARG_ENABLE(stack-for-recursion,,
# [don't use stack recursion when matching]),
# , enable_stack_for_recursion=yes)
# Handle --disable-percent_zt (set as "auto" by default)
AC_ARG_ENABLE(percent-zt,
AS_HELP_STRING([--disable-percent-zt],
[disable the use of z and t formatting modifiers]),
, enable_percent_zt=auto)
# Set the default value for pcre2-8
if test "x$enable_pcre2_8" = "xunset"
then
@ -587,6 +593,14 @@ if test "$enable_debug" = "yes"; then
Define to any value to include debugging code.])
fi
if test "$enable_percent_zt" = "no"; then
AC_DEFINE([DISABLE_PERCENT_ZT], [], [
Define to any value to disable the use of the z and t modifiers in
formatting settings such as %zu or %td (this is rarely needed).])
else
enable_percent_zt=auto
fi
# Unless running under Windows, JIT support requires pthreads.
if test "$enable_jit" = "yes"; then
@ -1033,6 +1047,7 @@ $PACKAGE-$VERSION configuration summary:
Valgrind support ................... : ${enable_valgrind}
Code coverage ...................... : ${enable_coverage}
Fuzzer support ..................... : ${enable_fuzz_support}
Use %zu and %td .................... : ${enable_percent_zt}
EOF

View File

@ -374,6 +374,15 @@ library. They are also documented in the pcre2build man page.
If you get error messages about missing functions tgetstr, tgetent, tputs,
tgetflag, or tgoto, this is the problem, and linking with the ncurses library
should fix it.
. The C99 standard defines formatting modifiers z and t for size_t and
ptrdiff_t values, respectively. By default, PCRE2 uses these modifiers in
environments other than Microsoft Visual Studio when __STDC_VERSION__ is
defined and has a value greater than or equal to 199901L (indicating C99).
However, there is at least one environment that claims to be C99 but does not
support these modifiers. If --disable-percent-zt is specified, no use is made
of the z or t modifiers. Instead or %td or %zu, %lu is used, with a cast for
size_t values.
. There is a special option called --enable-fuzz-support for use by people who
want to run fuzzing tests on PCRE2. At present this applies only to the 8-bit
@ -888,4 +897,4 @@ The distribution should contain the files listed below.
Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
Last updated: 19 September 2018
Last updated: 15 November 2018

View File

@ -33,11 +33,12 @@ please consult the man page, in case the conversion went wrong.
<li><a name="TOC18" href="#SEC18">INCLUDING DEBUGGING CODE</a>
<li><a name="TOC19" href="#SEC19">DEBUGGING WITH VALGRIND SUPPORT</a>
<li><a name="TOC20" href="#SEC20">CODE COVERAGE REPORTING</a>
<li><a name="TOC21" href="#SEC21">SUPPORT FOR FUZZERS</a>
<li><a name="TOC22" href="#SEC22">OBSOLETE OPTION</a>
<li><a name="TOC23" href="#SEC23">SEE ALSO</a>
<li><a name="TOC24" href="#SEC24">AUTHOR</a>
<li><a name="TOC25" href="#SEC25">REVISION</a>
<li><a name="TOC21" href="#SEC21">DISABLING THE Z AND T FORMATTING MODIFIERS</a>
<li><a name="TOC22" href="#SEC22">SUPPORT FOR FUZZERS</a>
<li><a name="TOC23" href="#SEC23">OBSOLETE OPTION</a>
<li><a name="TOC24" href="#SEC24">SEE ALSO</a>
<li><a name="TOC25" href="#SEC25">AUTHOR</a>
<li><a name="TOC26" href="#SEC26">REVISION</a>
</ul>
<br><a name="SEC1" href="#TOC1">BUILDING PCRE2</a><br>
<P>
@ -523,7 +524,21 @@ This cleans all coverage data including the generated coverage report. For more
information about code coverage, see the <b>gcov</b> and <b>lcov</b>
documentation.
</P>
<br><a name="SEC21" href="#TOC1">SUPPORT FOR FUZZERS</a><br>
<br><a name="SEC21" href="#TOC1">DISABLING THE Z AND T FORMATTING MODIFIERS</a><br>
<P>
The C99 standard defines formatting modifiers z and t for size_t and
ptrdiff_t values, respectively. By default, PCRE2 uses these modifiers in
environments other than Microsoft Visual Studio when __STDC_VERSION__ is
defined and has a value greater than or equal to 199901L (indicating C99).
However, there is at least one environment that claims to be C99 but does not
support these modifiers. If
<pre>
--disable-percent-zt
</pre>
is specified, no use is made of the z or t modifiers. Instead or %td or %zu,
%lu is used, with a cast for size_t values.
</P>
<br><a name="SEC22" href="#TOC1">SUPPORT FOR FUZZERS</a><br>
<P>
There is a special option for use by people who want to run fuzzing tests on
PCRE2:
@ -547,7 +562,7 @@ arguments: if an argument starts with "=" the rest of it is a literal input
string. Otherwise, it is assumed to be a file name, and the contents of the
file are the test string.
</P>
<br><a name="SEC22" href="#TOC1">OBSOLETE OPTION</a><br>
<br><a name="SEC23" href="#TOC1">OBSOLETE OPTION</a><br>
<P>
In versions of PCRE2 prior to 10.30, there were two ways of handling
backtracking in the <b>pcre2_match()</b> function. The default was to use the
@ -559,11 +574,11 @@ was set, memory on the heap was used. From release 10.30 onwards this has
changed (the stack is no longer used) and this option now does nothing except
give a warning.
</P>
<br><a name="SEC23" href="#TOC1">SEE ALSO</a><br>
<br><a name="SEC24" href="#TOC1">SEE ALSO</a><br>
<P>
<b>pcre2api</b>(3), <b>pcre2-config</b>(3).
</P>
<br><a name="SEC24" href="#TOC1">AUTHOR</a><br>
<br><a name="SEC25" href="#TOC1">AUTHOR</a><br>
<P>
Philip Hazel
<br>
@ -572,9 +587,9 @@ University Computing Service
Cambridge, England.
<br>
</P>
<br><a name="SEC25" href="#TOC1">REVISION</a><br>
<br><a name="SEC26" href="#TOC1">REVISION</a><br>
<P>
Last updated: 26 April 2018
Last updated: 15 November 2018
<br>
Copyright &copy; 1997-2018 University of Cambridge.
<br>

View File

@ -4158,6 +4158,21 @@ CODE COVERAGE REPORTING
mentation.
DISABLING THE Z AND T FORMATTING MODIFIERS
The C99 standard defines formatting modifiers z and t for size_t and
ptrdiff_t values, respectively. By default, PCRE2 uses these modifiers
in environments other than Microsoft Visual Studio when __STDC_VER-
SION__ is defined and has a value greater than or equal to 199901L
(indicating C99). However, there is at least one environment that
claims to be C99 but does not support these modifiers. If
--disable-percent-zt
is specified, no use is made of the z or t modifiers. Instead or %td or
%zu, %lu is used, with a cast for size_t values.
SUPPORT FOR FUZZERS
There is a special option for use by people who want to run fuzzing
@ -4210,7 +4225,7 @@ AUTHOR
REVISION
Last updated: 26 April 2018
Last updated: 15 November 2018
Copyright (c) 1997-2018 University of Cambridge.
------------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
.TH PCRE2BUILD 3 "26 April 2018" "PCRE2 10.32"
.TH PCRE2BUILD 3 "15 November 2018" "PCRE2 10.33"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.
@ -533,6 +533,22 @@ information about code coverage, see the \fBgcov\fP and \fBlcov\fP
documentation.
.
.
.SH "DISABLING THE Z AND T FORMATTING MODIFIERS"
.rs
.sp
The C99 standard defines formatting modifiers z and t for size_t and
ptrdiff_t values, respectively. By default, PCRE2 uses these modifiers in
environments other than Microsoft Visual Studio when __STDC_VERSION__ is
defined and has a value greater than or equal to 199901L (indicating C99).
However, there is at least one environment that claims to be C99 but does not
support these modifiers. If
.sp
--disable-percent-zt
.sp
is specified, no use is made of the z or t modifiers. Instead or %td or %zu,
%lu is used, with a cast for size_t values.
.
.
.SH "SUPPORT FOR FUZZERS"
.rs
.sp
@ -591,6 +607,6 @@ Cambridge, England.
.rs
.sp
.nf
Last updated: 26 April 2018
Last updated: 15 November 2018
Copyright (c) 1997-2018 University of Cambridge.
.fi

View File

@ -35,6 +35,10 @@ sure both macros are undefined; an emulation function will then be used. */
*/
/* #undef BSR_ANYCRLF */
/* Define to any value to disable the use of the z and t modifiers in
formatting settings such as %zu or %td (this is rarely needed). */
/* #undef DISABLE_PERCENT_ZT */
/* If you are compiling for a system that uses EBCDIC instead of ASCII
character codes, define this macro to any value. When EBCDIC is set, PCRE2
assumes that all input strings are in EBCDIC. If you do not define this

View File

@ -35,6 +35,10 @@ sure both macros are undefined; an emulation function will then be used. */
*/
#undef BSR_ANYCRLF
/* Define to any value to disable the use of the z and t modifiers in
formatting settings such as %zu or %td (this is rarely needed). */
#undef DISABLE_PERCENT_ZT
/* If you are compiling for a system that uses EBCDIC instead of ASCII
character codes, define this macro to any value. When EBCDIC is set, PCRE2
assumes that all input strings are in EBCDIC. If you do not define this

View File

@ -169,9 +169,10 @@ commented out the original, but kept it around just in case. */
/* void vms_setsymbol( char *, char *, int ); Original code from [1]. */
#endif
/* VC and older compilers don't support %td or %zu. */
/* VC and older compilers don't support %td or %zu, and even some that claim to
be C99 don't support it (hence DISABLE_PERCENT_ZT). */
#if defined(_MSC_VER) || !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#if defined(_MSC_VER) || !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L || defined(DISABLE_PERCENT_ZT)
#define PTR_FORM "lu"
#define SIZ_FORM "lu"
#define SIZ_CAST (unsigned long int)