Avoid using [-1] as a suffix in pcre2test as it can provoke a compiler warning.

This commit is contained in:
Philip.Hazel 2020-04-23 15:41:23 +00:00
parent 8b3f8af535
commit ca55d0be6b
2 changed files with 31 additions and 11 deletions

View File

@ -101,6 +101,9 @@ LIST(APPEND...) to allow a setting from the command line to be included.
24. CMake build now checks for secure_getenv() and strerror(). Patch by Carlo. 24. CMake build now checks for secure_getenv() and strerror(). Patch by Carlo.
25. Avoid using [-1] as a suffix in pcre2test because it can provoke a compiler
warning.
Version 10.34 21-November-2019 Version 10.34 21-November-2019
------------------------------ ------------------------------

View File

@ -2980,15 +2980,21 @@ 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. If handed a NULL file, For printing *MARK strings, a negative length is given, indicating that the
just counts chars without printing (because pchar() does that). */ length is in the previous code unit. We can't use strlen() because the string
may contain binary zeros. Avoid using [-1] as a suffix because this can provoke
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[-1]; {
PCRE2_SPTR8 pp = p - 1;
length = *pp;
}
while (length-- > 0) while (length-- > 0)
{ {
if (utf) if (utf)
@ -3017,13 +3023,19 @@ 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. If handed a NULL file, For printing *MARK strings, a negative length is given, indicating that the
just counts chars without printing. */ length is in the previous code unit. Avoid using [-1] as a suffix because this
can provoke a compiler warning. If handed a NULL file, just counts chars
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) length = p[-1]; if (length < 0)
{
PCRE2_SPTR16 pp = p - 1;
length = *pp;
}
while (length-- > 0) while (length-- > 0)
{ {
uint32_t c = *p++ & 0xffff; uint32_t c = *p++ & 0xffff;
@ -3051,15 +3063,20 @@ 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. If handed a NULL file, For printing *MARK strings, a negative length is given, indicating that the
just counts chars without printing. */ length is in the previous code unit. Avoid using [-1] as a suffix because this
can provoke a compiler warning. If handed a NULL file, just counts chars
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[-1]; {
PCRE2_SPTR32 pp = p - 1;
length = *pp;
}
while (length-- > 0) while (length-- > 0)
{ {
uint32_t c = *p++; uint32_t c = *p++;