Revision: 204
http://www.exim.org/viewvc/pcre2?view=rev&revision=204
Author: ph10
Date: 2015-02-21 18:53:51 +0000 (Sat, 21 Feb 2015)
Log Message:
-----------
Improve error message for pcre2test stack setting failure; also %ld should
really be %lu throughout.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2test.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2015-02-21 17:26:24 UTC (rev 203)
+++ code/trunk/ChangeLog 2015-02-21 18:53:51 UTC (rev 204)
@@ -80,7 +80,9 @@
failed to allow the zero-repeat case if pcre2_match() was called with an
ovector too small to capture the group.
+16. Improved error message in pcre2test when setting the stack size (-S) fails.
+
Version 10.00 05-January-2015
-----------------------------
Modified: code/trunk/src/pcre2test.c
===================================================================
--- code/trunk/src/pcre2test.c 2015-02-21 17:26:24 UTC (rev 203)
+++ code/trunk/src/pcre2test.c 2015-02-21 18:53:51 UTC (rev 204)
@@ -2550,7 +2550,7 @@
pbuffer16 = (uint16_t *)malloc(pbuffer16_size);
if (pbuffer16 == NULL)
{
- fprintf(stderr, "pcre2test: malloc(%ld) failed for pbuffer16\n",
+ fprintf(stderr, "pcre2test: malloc(%lu) failed for pbuffer16\n",
(unsigned long int)pbuffer16_size);
exit(1);
}
@@ -2627,7 +2627,7 @@
pbuffer32 = (uint32_t *)malloc(pbuffer32_size);
if (pbuffer32 == NULL)
{
- fprintf(stderr, "pcre2test: malloc(%ld) failed for pbuffer32\n",
+ fprintf(stderr, "pcre2test: malloc(%lu) failed for pbuffer32\n",
(unsigned long int)pbuffer32_size);
exit(1);
}
@@ -4010,7 +4010,7 @@
serial = malloc(serial_size);
if (serial == NULL)
{
- fprintf(outfile, "** Failed to get memory (size %ld) for #load\n",
+ fprintf(outfile, "** Failed to get memory (size %lu) for #load\n",
(unsigned long int)serial_size);
return PR_ABEND;
}
@@ -4676,7 +4676,7 @@
}
else if (length2 != length)
{
- fprintf(outfile, "Mismatched substring lengths: %ld %ld\n",
+ fprintf(outfile, "Mismatched substring lengths: %lu %lu\n",
(unsigned long int)length, (unsigned long int)length2);
}
fprintf(outfile, "%2dC ", n);
@@ -4735,7 +4735,7 @@
}
else if (length2 != length)
{
- fprintf(outfile, "Mismatched substring lengths: %ld %ld\n",
+ fprintf(outfile, "Mismatched substring lengths: %lu %lu\n",
(unsigned long int)length, (unsigned long int)length2);
}
fprintf(outfile, " C ");
@@ -5450,8 +5450,8 @@
}
if (n > nsize)
{
- fprintf(outfile, "Replacement buffer setting (%ld) is too large "
- "(max %ld)\n", (unsigned long int)n, (unsigned long int)nsize);
+ fprintf(outfile, "Replacement buffer setting (%lu) is too large "
+ "(max %lu)\n", (unsigned long int)n, (unsigned long int)nsize);
return PR_OK;
}
nsize = n;
@@ -6001,7 +6001,7 @@
{
PCRE2_SIZE startchar;
PCRE2_GET_STARTCHAR(startchar, match_data);
- fprintf(outfile, " at offset %ld", (unsigned long int)startchar);
+ fprintf(outfile, " at offset %lu", (unsigned long int)startchar);
}
fprintf(outfile, "\n");
break;
@@ -6457,10 +6457,19 @@
struct rlimit rlim;
getrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur = stack_size * 1024 * 1024;
+ if (rlim.rlim_cur > rlim.rlim_max)
+ {
+ fprintf(stderr,
+ "pcre2test: requested stack size %luM is greater than hard limit %lu\n",
+ (unsigned long int)stack_size,
+ (unsigned long int)(rlim.rlim_max));
+ exit(1);
+ }
rc = setrlimit(RLIMIT_STACK, &rlim);
if (rc != 0)
{
- fprintf(stderr, "pcre2test: setrlimit() failed with error %d\n", rc);
+ fprintf(stderr, "pcre2test: setting stack size %luM failed: %s\n",
+ (unsigned long int)stack_size, strerror(errno));
exit(1);
}
op++;