[Pcre-svn] [1247] code/trunk: Second attempt at getting rid …

Kezdőlap
Üzenet törlése
Szerző: Subversion repository
Dátum:  
Címzett: pcre-svn
Tárgy: [Pcre-svn] [1247] code/trunk: Second attempt at getting rid of gcc 10 warning.
Revision: 1247
          http://www.exim.org/viewvc/pcre2?view=rev&revision=1247
Author:   ph10
Date:     2020-04-24 16:36:53 +0100 (Fri, 24 Apr 2020)
Log Message:
-----------
Second attempt at getting rid of gcc 10 warning.


Modified Paths:
--------------
    code/trunk/src/pcre2test.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/src/pcre2test.c
===================================================================
--- code/trunk/src/pcre2test.c    2020-04-23 16:50:45 UTC (rev 1246)
+++ code/trunk/src/pcre2test.c    2020-04-24 15:36:53 UTC (rev 1247)
@@ -2981,20 +2981,14 @@


/* 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
-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). */
+length is in the first code unit. 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)
{
uint32_t c = 0;
int yield = 0;
-if (length < 0)
- {
- PCRE2_SPTR8 pp = p - 1;
- length = *pp;
- }
+if (length < 0) length = *p++;
while (length-- > 0)
{
if (utf)
@@ -3024,18 +3018,13 @@

/* 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
-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
+length is in the first code unit. If handed a NULL file, just counts chars
without printing. */

static int pchars16(PCRE2_SPTR16 p, int length, BOOL utf, FILE *f)
{
int yield = 0;
-if (length < 0)
- {
- PCRE2_SPTR16 pp = p - 1;
- length = *pp;
- }
+if (length < 0) length = *p++;
while (length-- > 0)
{
uint32_t c = *p++ & 0xffff;
@@ -3064,8 +3053,7 @@

/* 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
-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
+length is in the first code unit. If handed a NULL file, just counts chars
without printing. */

 static int pchars32(PCRE2_SPTR32 p, int length, BOOL utf, FILE *f)
@@ -3072,11 +3060,7 @@
 {
 int yield = 0;
 (void)(utf);  /* Avoid compiler warning */
-if (length < 0)
-  {
-  PCRE2_SPTR32 pp = p - 1;
-  length = *pp;
-  }
+if (length < 0) length = *p++;
 while (length-- > 0)
   {
   uint32_t c = *p++;
@@ -6327,7 +6311,7 @@
   else
     {
     fprintf(outfile, "Latest Mark: ");
-    PCHARSV(cb->mark, 0, -1, utf, outfile);
+    PCHARSV(cb->mark, -1, -1, utf, outfile);
     putc('\n', outfile);
     }
   last_callout_mark = cb->mark;
@@ -7848,7 +7832,7 @@
          TESTFLD(match_data, mark, !=, NULL))
       {
       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");
       }


@@ -7880,7 +7864,7 @@
          TESTFLD(match_data, mark, !=, NULL))
       {
       fprintf(outfile, ", mark=");
-      PCHARS(rubriclength, CASTFLD(void *, match_data, mark), 0, -1, utf,
+      PCHARS(rubriclength, CASTFLD(void *, match_data, mark), -1, -1, utf,
         outfile);
       rubriclength += 7;
       }
@@ -7979,7 +7963,7 @@
              TESTFLD(match_data, mark, !=, NULL))
           {
           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)
           fprintf(outfile, " (JIT)");


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2020-04-23 16:50:45 UTC (rev 1246)
+++ code/trunk/testdata/testinput2    2020-04-24 15:36:53 UTC (rev 1247)
@@ -5855,4 +5855,13 @@
 /^\w+/tables=3
     É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


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2020-04-23 16:50:45 UTC (rev 1246)
+++ code/trunk/testdata/testoutput2    2020-04-24 15:36:53 UTC (rev 1247)
@@ -17603,6 +17603,24 @@
     École
  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
 Error -70: PCRE2_ERROR_BADDATA (unknown error number)
 Error -62: bad serialized data