Second attempt at getting rid of gcc 10 warning.

This commit is contained in:
Philip.Hazel 2020-04-24 15:36:53 +00:00
parent 5ec5c45423
commit ce558bbff1
3 changed files with 38 additions and 27 deletions

View File

@ -2981,20 +2981,14 @@ return (int)(pp - p);
/* Must handle UTF-8 strings in utf8 mode. Yields number of characters printed. /* Must handle UTF-8 strings in utf8 mode. Yields number of characters printed.
For printing *MARK strings, a negative length is given, indicating that the For printing *MARK strings, a negative length is given, indicating that the
length is in the previous code unit. We can't use strlen() because the string length is in the first code unit. If handed a NULL file, this function just
may contain binary zeros. Avoid using [-1] as a suffix because this can provoke counts chars without printing (because pchar() does that). */
a compiler warning. If handed a NULL file, this function just counts chars
without printing (because pchar() does that). */
static int pchars8(PCRE2_SPTR8 p, int length, BOOL utf, FILE *f) static int pchars8(PCRE2_SPTR8 p, int length, BOOL utf, FILE *f)
{ {
uint32_t c = 0; uint32_t c = 0;
int yield = 0; int yield = 0;
if (length < 0) if (length < 0) length = *p++;
{
PCRE2_SPTR8 pp = p - 1;
length = *pp;
}
while (length-- > 0) while (length-- > 0)
{ {
if (utf) if (utf)
@ -3024,18 +3018,13 @@ return yield;
/* Must handle UTF-16 strings in utf mode. Yields number of characters printed. /* Must handle UTF-16 strings in utf mode. Yields number of characters printed.
For printing *MARK strings, a negative length is given, indicating that the For printing *MARK strings, a negative length is given, indicating that the
length is in the previous code unit. Avoid using [-1] as a suffix because this length is in the first code unit. If handed a NULL file, just counts chars
can provoke a compiler warning. If handed a NULL file, just counts chars
without printing. */ without printing. */
static int pchars16(PCRE2_SPTR16 p, int length, BOOL utf, FILE *f) static int pchars16(PCRE2_SPTR16 p, int length, BOOL utf, FILE *f)
{ {
int yield = 0; int yield = 0;
if (length < 0) if (length < 0) length = *p++;
{
PCRE2_SPTR16 pp = p - 1;
length = *pp;
}
while (length-- > 0) while (length-- > 0)
{ {
uint32_t c = *p++ & 0xffff; uint32_t c = *p++ & 0xffff;
@ -3064,19 +3053,14 @@ return yield;
/* Must handle UTF-32 strings in utf mode. Yields number of characters printed. /* Must handle UTF-32 strings in utf mode. Yields number of characters printed.
For printing *MARK strings, a negative length is given, indicating that the For printing *MARK strings, a negative length is given, indicating that the
length is in the previous code unit. Avoid using [-1] as a suffix because this length is in the first code unit. If handed a NULL file, just counts chars
can provoke a compiler warning. If handed a NULL file, just counts chars
without printing. */ without printing. */
static int pchars32(PCRE2_SPTR32 p, int length, BOOL utf, FILE *f) static int pchars32(PCRE2_SPTR32 p, int length, BOOL utf, FILE *f)
{ {
int yield = 0; int yield = 0;
(void)(utf); /* Avoid compiler warning */ (void)(utf); /* Avoid compiler warning */
if (length < 0) if (length < 0) length = *p++;
{
PCRE2_SPTR32 pp = p - 1;
length = *pp;
}
while (length-- > 0) while (length-- > 0)
{ {
uint32_t c = *p++; uint32_t c = *p++;
@ -6327,7 +6311,7 @@ if (cb->mark != last_callout_mark)
else else
{ {
fprintf(outfile, "Latest Mark: "); fprintf(outfile, "Latest Mark: ");
PCHARSV(cb->mark, 0, -1, utf, outfile); PCHARSV(cb->mark, -1, -1, utf, outfile);
putc('\n', outfile); putc('\n', outfile);
} }
last_callout_mark = cb->mark; last_callout_mark = cb->mark;
@ -7848,7 +7832,7 @@ for (gmatched = 0;; gmatched++)
TESTFLD(match_data, mark, !=, NULL)) TESTFLD(match_data, mark, !=, NULL))
{ {
fprintf(outfile, "MK: "); fprintf(outfile, "MK: ");
PCHARSV(CASTFLD(void *, match_data, mark), 0, -1, utf, outfile); PCHARSV(CASTFLD(void *, match_data, mark), -1, -1, utf, outfile);
fprintf(outfile, "\n"); fprintf(outfile, "\n");
} }
@ -7880,7 +7864,7 @@ for (gmatched = 0;; gmatched++)
TESTFLD(match_data, mark, !=, NULL)) TESTFLD(match_data, mark, !=, NULL))
{ {
fprintf(outfile, ", mark="); fprintf(outfile, ", mark=");
PCHARS(rubriclength, CASTFLD(void *, match_data, mark), 0, -1, utf, PCHARS(rubriclength, CASTFLD(void *, match_data, mark), -1, -1, utf,
outfile); outfile);
rubriclength += 7; rubriclength += 7;
} }
@ -7979,7 +7963,7 @@ for (gmatched = 0;; gmatched++)
TESTFLD(match_data, mark, !=, NULL)) TESTFLD(match_data, mark, !=, NULL))
{ {
fprintf(outfile, ", mark = "); fprintf(outfile, ", mark = ");
PCHARSV(CASTFLD(void *, match_data, mark), 0, -1, utf, outfile); PCHARSV(CASTFLD(void *, match_data, mark), -1, -1, utf, outfile);
} }
if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used) if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used)
fprintf(outfile, " (JIT)"); fprintf(outfile, " (JIT)");

9
testdata/testinput2 vendored
View File

@ -5855,4 +5855,13 @@ a)"xI
/^\w+/tables=3 /^\w+/tables=3
École École
/"(*MARK:>" 00 "<).."/hex,mark,no_start_optimize
AB
A\=ph
\= Expect no match
A
/"(*MARK:>" 00 "<).(?C1)."/hex,mark,no_start_optimize
AB
# End of testinput2 # End of testinput2

18
testdata/testoutput2 vendored
View File

@ -17603,6 +17603,24 @@ No match
École École
0: \xc3 0: \xc3
/"(*MARK:>" 00 "<).."/hex,mark,no_start_optimize
AB
0: AB
MK: >\x00<
A\=ph
Partial match, mark=>\x00<: A
\= Expect no match
A
No match, mark = >\x00<
/"(*MARK:>" 00 "<).(?C1)."/hex,mark,no_start_optimize
AB
--->AB
1 ^^ .
Latest Mark: >\x00<
0: AB
MK: >\x00<
# End of testinput2 # End of testinput2
Error -70: PCRE2_ERROR_BADDATA (unknown error number) Error -70: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data Error -62: bad serialized data