Skip to content

Commit f08cf40

Browse files
demerphqhvds
authored andcommitted
regcomp.h: change regexp_internal attribute from I32 to U32
This changes the name_list_idx attribute from I32 to a U32 as it will never be negative, and as of a963d6d 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.
1 parent 615094e commit f08cf40

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pod/perlreguts.pod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ value to other engine implementations.
832832
struct reg_data *data;
833833
struct reg_code_blocks *code_blocks;
834834
U32 proglen;
835-
int name_list_idx;
835+
U32 name_list_idx;
836836
regnode program[1];
837837
} regexp_internal;
838838

@@ -900,8 +900,8 @@ Stores the length of the compiled program in units of regops.
900900

901901
This is the index into the data array where an AV is stored that contains
902902
the names of any named capture buffers in the pattern, should there be
903-
any. This is only used in the debugging version of the regex engine. It
904-
will be 0 if there is no such data.
903+
any. This is only used in the debugging version of the regex engine and
904+
when RXp_PAREN_NAMES(prog) is true. It will be 0 if there is no such data.
905905

906906
=item C<program>
907907

regcomp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ typedef struct regexp_internal {
7171
strictly reserved for internal purposes. */
7272
struct reg_code_blocks *code_blocks;/* positions of literal (?{}) */
7373
U32 proglen; /* size of the compiled program in regnodes */
74-
int name_list_idx; /* Optional data index of an array of paren names */
74+
U32 name_list_idx; /* Optional data index of an array of paren names,
75+
only valid when RXp_PAREN_NAMES(prog) is true,
76+
0 means "no value" like any other index into the
77+
data array.*/
7578
regnode program[1]; /* Unwarranted chumminess with compiler. */
7679
} regexp_internal;
7780

0 commit comments

Comments
 (0)