Revision: 930
http://www.exim.org/viewvc/pcre2?view=rev&revision=930
Author: ph10
Date: 2018-04-19 17:52:57 +0100 (Thu, 19 Apr 2018)
Log Message:
-----------
Apply some of Daniel Richard G's Windows patches.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/NON-AUTOTOOLS-BUILD
code/trunk/RunTest.bat
code/trunk/src/pcre2grep.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2018-03-19 08:15:52 UTC (rev 929)
+++ code/trunk/ChangeLog 2018-04-19 16:52:57 UTC (rev 930)
@@ -41,7 +41,16 @@
9. When returning an error from pcre2_pattern_convert(), ensure the error
offset is set zero for early errors.
+10. A number of patches for Windows support from Daniel Richard G:
+ (a) List of error numbers in Runtest.bat corrected (it was not the same as in
+ Runtest).
+
+ (b) pcre2grep snprintf() workaround as used elsewhere in the tree.
+
+ (c) Support for non-C99 snprintf() that returns -1 in the overflow case.
+
+
Version 10.31 12-February-2018
------------------------------
Modified: code/trunk/NON-AUTOTOOLS-BUILD
===================================================================
--- code/trunk/NON-AUTOTOOLS-BUILD 2018-03-19 08:15:52 UTC (rev 929)
+++ code/trunk/NON-AUTOTOOLS-BUILD 2018-04-19 16:52:57 UTC (rev 930)
@@ -10,6 +10,7 @@
Calling conventions in Windows environments
Comments about Win32 builds
Building PCRE2 on Windows with CMake
+ Building PCRE2 on Windows with Visual Studio
Testing with RunTest.bat
Building PCRE2 on native z/OS and z/VM
@@ -328,8 +329,20 @@
most recent build configuration is targeted by the tests. A summary of
test results is presented. Complete test output is subsequently
available for review in Testing\Temporary under your build dir.
+
+BUILDING PCRE2 ON WINDOWS WITH VISUAL STUDIO
+The code currently cannot be compiled without a stdint.h header, which is
+available only in relatively recent versions of Visual Studio. However, this
+portable and permissively-licensed implementation of the header worked without
+issue:
+
+
http://www.azillionmonkeys.com/qed/pstdint.h
+
+Just rename it and drop it into the top level of the build tree.
+
+
TESTING WITH RUNTEST.BAT
If configured with CMake, building the test project ("make test" or building
@@ -382,6 +395,6 @@
z/OS file formats. The port provides an API for LE languages such as COBOL and
for the z/OS and z/VM versions of the Rexx languages.
-===============================
-Last Updated: 13 September 2017
-===============================
+===========================
+Last Updated: 19 April 2018
+===========================
Modified: code/trunk/RunTest.bat
===================================================================
--- code/trunk/RunTest.bat 2018-03-19 08:15:52 UTC (rev 929)
+++ code/trunk/RunTest.bat 2018-04-19 16:52:57 UTC (rev 930)
@@ -263,7 +263,7 @@
set failed="yes"
goto :eof
) else if [%1]==[2] (
- %pcre2test% %mode% %4 %5 %6 %7 %8 %9 -error -63,-62,-2,-1,0,100,188,189,190,191 >>%2%bits%\%testoutput%
+ %pcre2test% %mode% %4 %5 %6 %7 %8 %9 -error -65,-62,-2,-1,0,100,101,191,200 >>%2%bits%\%testoutput%
)
set type=
Modified: code/trunk/src/pcre2grep.c
===================================================================
--- code/trunk/src/pcre2grep.c 2018-03-19 08:15:52 UTC (rev 929)
+++ code/trunk/src/pcre2grep.c 2018-04-19 16:52:57 UTC (rev 930)
@@ -96,6 +96,14 @@
#define PCRE2_CODE_UNIT_WIDTH 8
#include "pcre2.h"
+/* Older versions of MSVC lack snprintf(). This define allows for
+warning/error-free compilation and testing with MSVC compilers back to at least
+MSVC 10/2010. Except for VC6 (which is missing some fundamentals and fails). */
+
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#define snprintf _snprintf
+#endif
+
#define FALSE 0
#define TRUE 1
@@ -3663,6 +3671,7 @@
{
char buff1[24];
char buff2[24];
+ int ret;
int baselen = (int)(opbra - op->long_name);
int fulllen = (int)(strchr(op->long_name, ')') - op->long_name + 1);
@@ -3669,10 +3678,11 @@
int arglen = (argequals == NULL || equals == NULL)?
(int)strlen(arg) : (int)(argequals - arg);
- if (snprintf(buff1, sizeof(buff1), "%.*s", baselen, op->long_name) >
- (int)sizeof(buff1) ||
- snprintf(buff2, sizeof(buff2), "%s%.*s", buff1,
- fulllen - baselen - 2, opbra + 1) > (int)sizeof(buff2))
+ if ((ret = snprintf(buff1, sizeof(buff1), "%.*s", baselen, op->long_name),
+ ret < 0 || ret > (int)sizeof(buff1)) ||
+ (ret = snprintf(buff2, sizeof(buff2), "%s%.*s", buff1,
+ fulllen - baselen - 2, opbra + 1),
+ ret < 0 || ret > (int)sizeof(buff2)))
{
fprintf(stderr, "pcre2grep: Buffer overflow when parsing %s option\n",
op->long_name);