From 6f9328ca348b95ff60b2672e0c425242e6e87419 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Sun, 8 Jan 2023 14:16:36 +0100 Subject: regcomp.pl - fixup intflags debug data to handle gaps properly We were not handling gaps in the sequence properly, and effectively showing the wrong flag names or missing the last flag. Now we die if there are any collisions or if any of the PREGf defines set more than one bit. This also adds some crude tests to validate that intflags serialization is working properly. Note, extflags handles more complex scenarios and seems to handle this gracefully already, hence the reason I haven't touched it as well. This also tweaks a comment in lexical_debug.t which part of this was cribbed from. --- regnodes.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'regnodes.h') diff --git a/regnodes.h b/regnodes.h index 398df445df..5275da64b3 100644 --- a/regnodes.h +++ b/regnodes.h @@ -2862,24 +2862,25 @@ EXTCONST char * const PL_reg_extflags_name[] = { EXTCONST char * PL_reg_intflags_name[]; #else EXTCONST char * const PL_reg_intflags_name[] = { - "SKIP", /* 0x00000001 - PREGf_SKIP */ - "IMPLICIT", /* 0x00000002 - PREGf_IMPLICIT - Converted .* to ^.* */ - "NAUGHTY", /* 0x00000004 - PREGf_NAUGHTY - how exponential is this pattern? */ - "VERBARG_SEEN", /* 0x00000008 - PREGf_VERBARG_SEEN */ - "CUTGROUP_SEEN", /* 0x00000010 - PREGf_CUTGROUP_SEEN */ - "USE_RE_EVAL", /* 0x00000020 - PREGf_USE_RE_EVAL - compiled with "use re 'eval'" */ - "NOSCAN", /* 0x00000040 - PREGf_NOSCAN */ - "GPOS_SEEN", /* 0x00000100 - PREGf_GPOS_SEEN */ - "GPOS_FLOAT", /* 0x00000200 - PREGf_GPOS_FLOAT */ - "ANCH_MBOL", /* 0x00000400 - PREGf_ANCH_MBOL */ - "ANCH_SBOL", /* 0x00000800 - PREGf_ANCH_SBOL */ - "ANCH_GPOS", /* 0x00001000 - PREGf_ANCH_GPOS */ - "RECURSE_SEEN", /* 0x00002000 - PREGf_RECURSE_SEEN */ + "SKIP", /* (1<< 0) - 0x00000001 - PREGf_SKIP */ + "IMPLICIT", /* (1<< 1) - 0x00000002 - PREGf_IMPLICIT - Converted .* to ^.* */ + "NAUGHTY", /* (1<< 2) - 0x00000004 - PREGf_NAUGHTY - how exponential is this pattern? */ + "VERBARG_SEEN", /* (1<< 3) - 0x00000008 - PREGf_VERBARG_SEEN */ + "CUTGROUP_SEEN", /* (1<< 4) - 0x00000010 - PREGf_CUTGROUP_SEEN */ + "USE_RE_EVAL", /* (1<< 5) - 0x00000020 - PREGf_USE_RE_EVAL - compiled with "use re 'eval'" */ + "NOSCAN", /* (1<< 6) - 0x00000040 - PREGf_NOSCAN */ + "", /* (1<< 7) - 0x00000080 - *UNUSED* */ + "GPOS_SEEN", /* (1<< 8) - 0x00000100 - PREGf_GPOS_SEEN */ + "GPOS_FLOAT", /* (1<< 9) - 0x00000200 - PREGf_GPOS_FLOAT */ + "ANCH_MBOL", /* (1<<10) - 0x00000400 - PREGf_ANCH_MBOL */ + "ANCH_SBOL", /* (1<<11) - 0x00000800 - PREGf_ANCH_SBOL */ + "ANCH_GPOS", /* (1<<12) - 0x00001000 - PREGf_ANCH_GPOS */ + "RECURSE_SEEN", /* (1<<13) - 0x00002000 - PREGf_RECURSE_SEEN */ }; #endif /* DOINIT */ #ifdef DEBUGGING -# define REG_INTFLAGS_NAME_SIZE 13 +# define REG_INTFLAGS_NAME_SIZE 14 #endif /* The following have no fixed length. U8 so we can do strchr() on it. */ -- cgit v1.2.1