} If so, I think we'll just add a test for _strtoi64 in configure, and
} solve the problem that way.
OK, I've made up a patch to do this, attached below. It should work
with msys/configure, though I don't know how well it will work with
cmake. I solve the problem in two ways: 1) adding an explicit check
to see if stdlib.h defines the weird _strtoi64 functions; 2) changing
all the snprintf's to printf's.
Sheri, do you want to try this patch against a pristine RC3, and see
what you find? Philip, assuming it works ok, can you apply it?
craig
--cut here--
Index: pcre_scanner_unittest.cc
===================================================================
--- pcre_scanner_unittest.cc (revision 254)
+++ pcre_scanner_unittest.cc (working copy)
@@ -44,10 +44,6 @@
#include "pcre_stringpiece.h"
#include "pcre_scanner.h"
-#ifdef HAVE_WINDOWS_H
-# define snprintf _snprintf
-#endif
-
#define FLAGS_unittest_stack_size 49152
// Dies with a fatal error if the two values are not equal.
@@ -132,8 +128,8 @@
static void TestBigComment() {
string input;
for (int i = 0; i < 1024; ++i) {
- char buf[1024];
- snprintf(buf, sizeof(buf), " # Comment %d\n", i);
+ char buf[1024]; // definitely big enough
+ sprintf(buf, " # Comment %d\n", i);
input += buf;
}
input += "name = value;\n";
Index: configure.ac
===================================================================
--- configure.ac (revision 254)
+++ configure.ac (working copy)
@@ -294,7 +294,7 @@
# Checks for library functions.
-AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll)
+AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll _strtoi64)
# This facilitates -ansi builds under Linux
dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
Index: pcrecpp.cc
===================================================================
--- pcrecpp.cc (revision 254)
+++ pcrecpp.cc (working copy)
@@ -33,12 +33,6 @@
#include "config.h"
#endif
-#ifdef HAVE_WINDOWS_H
-#define HAVE_STRTOQ 1
-#define strtoll _strtoui64
-#define strtoull _strtoi64
-#endif
-
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
@@ -770,6 +764,8 @@
long long r = strtoq(str, &end, radix);
#elif defined HAVE_STRTOLL
long long r = strtoll(str, &end, radix);
+#elif defined HAVE__STRTOI64
+ long long r = _strtoi64(str, &end, radix);
#else
#error parse_longlong_radix: cannot convert input to a long-long
#endif
@@ -797,6 +793,8 @@
unsigned long long r = strtouq(str, &end, radix);
#elif defined HAVE_STRTOLL
unsigned long long r = strtoull(str, &end, radix);
+#elif defined HAVE__STRTOI64
+ unsigned long long r = _strtoui64(str, &end, radix);
#else
#error parse_ulonglong_radix: cannot convert input to a long-long
#endif
Index: pcrecpp_unittest.cc
===================================================================
--- pcrecpp_unittest.cc (revision 254)
+++ pcrecpp_unittest.cc (working copy)
@@ -37,10 +37,6 @@
#include "config.h"
#endif
-#ifdef HAVE_WINDOWS_H
-#define snprintf _snprintf
-#endif
-
#include <stdio.h>
#include <cassert>
#include <vector>
@@ -114,8 +110,8 @@
initial_size = VirtualProcessSize();
printf("Size after 50000: %llu\n", initial_size);
}
- char buf[100];
- snprintf(buf, sizeof(buf), "pat%09d", i);
+ char buf[100]; // definitely big enough
+ sprintf(buf, "pat%09d", i);
RE newre(buf);
}
uint64 final_size = VirtualProcessSize();
@@ -923,23 +919,23 @@
long long v;
static const long long max_value = 0x7fffffffffffffffLL;
static const long long min_value = -max_value - 1;
- char buf[32];
+ char buf[32]; // definitely big enough for a long long
CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100);
- snprintf(buf, sizeof(buf), LLD, max_value);
+ sprintf(buf, LLD, max_value);
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
- snprintf(buf, sizeof(buf), LLD, min_value);
+ sprintf(buf, LLD, min_value);
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value);
- snprintf(buf, sizeof(buf), LLD, max_value);
+ sprintf(buf, LLD, max_value);
assert(buf[strlen(buf)-1] != '9');
buf[strlen(buf)-1]++;
CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
- snprintf(buf, sizeof(buf), LLD, min_value);
+ sprintf(buf, LLD, min_value);
assert(buf[strlen(buf)-1] != '9');
buf[strlen(buf)-1]++;
CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
@@ -950,12 +946,12 @@
unsigned long long v;
long long v2;
static const unsigned long long max_value = 0xffffffffffffffffULL;
- char buf[32];
+ char buf[32]; // definitely big enough for a unsigned long long
CHECK(RE("(-?\\d+)").FullMatch("100",&v)); CHECK_EQ(v, 100);
CHECK(RE("(-?\\d+)").FullMatch("-100",&v2)); CHECK_EQ(v2, -100);
- snprintf(buf, sizeof(buf), LLU, max_value);
+ sprintf(buf, LLU, max_value);
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
assert(buf[strlen(buf)-1] != '9');