diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-09-19 09:11:19 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-09-19 09:11:19 +0000 |
commit | 441a0d577e40aa1a43542eff538a9043898c72f6 (patch) | |
tree | 4cbb09f4dafd0df37b5fbb5d500121dd839b9bda | |
parent | 0737a2bfd72b8a09a9f72998fa911d184138cfaa (diff) | |
download | pcre-441a0d577e40aa1a43542eff538a9043898c72f6.tar.gz |
Craig's patch to remove the checks for windows.h and instead check for
_strtoi64 explicitly, and avoid using snprintf() at all.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@257 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | pcre_scanner_unittest.cc | 8 | ||||
-rw-r--r-- | pcrecpp.cc | 10 | ||||
-rw-r--r-- | pcrecpp_unittest.cc | 22 |
5 files changed, 22 insertions, 27 deletions
@@ -33,7 +33,8 @@ Version 7.4 10-Sep-07 7. Added macro for snprintf to pcrecpp_unittest.cc and also for strtoll and strtoull to pcrecpp.cc to select the available functions in WIN32 when the - windows.h file is present (where different names are used). + windows.h file is present (where different names are used). [This was + reversed later after testing - see 16 below.] 8. Changed all #include <config.h> to #include "config.h". There were also some further <pcre.h> cases that I changed to "pcre.h". @@ -67,6 +68,10 @@ Version 7.4 10-Sep-07 15. Added Craig's patch to various pcrecpp modules to avoid compiler warnings. +16. Added Craig's patch to remove the WINDOWS_H tests, that were not working, + and instead check for _strtoi64 explicitly, and avoid the use of snprintf() + entirely. This removes changes made in 7 above. + Version 7.3 28-Aug-07 --------------------- diff --git a/configure.ac b/configure.ac index 9a64c5c..24ec216 100644 --- a/configure.ac +++ b/configure.ac @@ -294,7 +294,7 @@ AC_SUBST(pcre_have_ulong_long) # 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]) diff --git a/pcre_scanner_unittest.cc b/pcre_scanner_unittest.cc index c0b8a33..284c8ea 100644 --- a/pcre_scanner_unittest.cc +++ b/pcre_scanner_unittest.cc @@ -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 TestScanner() { 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"; @@ -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 @@ bool Arg::parse_longlong_radix(const char* str, 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 @@ bool Arg::parse_ulonglong_radix(const char* str, 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 diff --git a/pcrecpp_unittest.cc b/pcrecpp_unittest.cc index 38e77d1..463a11c 100644 --- a/pcrecpp_unittest.cc +++ b/pcrecpp_unittest.cc @@ -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 @@ static void LeakTest() { 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 @@ int main(int argc, char** argv) { 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 @@ int main(int argc, char** argv) { 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'); |