This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.h: change regexp_internal attribute from I32 to U32
authorYves Orton <demerphq@gmail.com>
Sat, 12 Feb 2022 04:36:36 +0000 (05:36 +0100)
committerHugo van der Sanden <hv@crypt.org>
Fri, 18 Feb 2022 15:08:25 +0000 (15:08 +0000)
This changes the name_list_idx attribute from I32 to a U32 as it will
never be negative, and as of a963d6d5acabdd8c7 a 0 can be safely used
to represent "no value" for items in the 'data' array.

I noticed this while cleaning up the offsets debug logic and updating
the perlreguts documentation, so I figured I might as well clean it up
at the same time.

pod/perlreguts.pod
regcomp.h

index 2aae739..e19f157 100644 (file)
@@ -832,7 +832,7 @@ value to other engine implementations.
         struct reg_data *data;
         struct reg_code_blocks *code_blocks;
         U32 proglen;
-        int name_list_idx;
+        U32 name_list_idx;
         regnode program[1];
     } regexp_internal;
 
@@ -900,8 +900,8 @@ Stores the length of the compiled program in units of regops.
 
 This is the index into the data array where an AV is stored that contains
 the names of any named capture buffers in the pattern, should there be
-any. This is only used in the debugging version of the regex engine. It
-will be 0 if there is no such data.
+any. This is only used in the debugging version of the regex engine and
+when RXp_PAREN_NAMES(prog) is true. It will be 0 if there is no such data.
 
 =item C<program>
 
index 6b8dc27..2705463 100644 (file)
--- a/regcomp.h
+++ b/regcomp.h
@@ -71,7 +71,10 @@ typedef struct regexp_internal {
                                    strictly reserved for internal purposes. */
         struct reg_code_blocks *code_blocks;/* positions of literal (?{}) */
         U32 proglen;            /* size of the compiled program in regnodes */
-        int name_list_idx;        /* Optional data index of an array of paren names */
+        U32 name_list_idx;      /* Optional data index of an array of paren names,
+                                   only valid when RXp_PAREN_NAMES(prog) is true,
+                                   0 means "no value" like any other index into the
+                                   data array.*/
         regnode program[1];    /* Unwarranted chumminess with compiler. */
 } regexp_internal;