From 06d3a66065eb5995a69faf357b9a56669284fecd Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Tue, 11 Jan 2022 09:21:27 +0000 Subject: [PATCH] Fix bug in modifier listing --- src/pcre2test.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/pcre2test.c b/src/pcre2test.c index 52c94a7..0a19c20 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -11,7 +11,7 @@ hacked-up (non-) design had also run out of steam. Written by Philip Hazel Original code Copyright (c) 1997-2012 University of Cambridge - Rewritten code Copyright (c) 2016-2021 University of Cambridge + Rewritten code Copyright (c) 2016-2022 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -8442,6 +8442,11 @@ display_one_modifier(modstruct *m, BOOL for_pattern) uint32_t c = (!for_pattern && (m->which == MOD_PND || m->which == MOD_PNDP))? '*' : ' '; printf("%c%s", c, m->name); +for (size_t i = 0; i < C1MODLISTCOUNT; i++) + { + if (strcmp(m->name, c1modlist[i].fullname) == 0) + printf(" (%c)", c1modlist[i].onechar); + } } @@ -8466,6 +8471,7 @@ display_selected_modifiers(BOOL for_pattern, const char *title) uint32_t i, j; uint32_t n = 0; uint32_t list[MODLISTCOUNT]; +uint32_t extra[MODLISTCOUNT]; for (i = 0; i < MODLISTCOUNT; i++) { @@ -8485,6 +8491,7 @@ for (i = 0; i < MODLISTCOUNT; i++) case MOD_CTM: /* Match context */ case MOD_DAT: /* Subject line */ + case MOD_DATP: /* Subject line, OK for Perl-compatible test */ case MOD_PND: /* As PD, but not default pattern */ case MOD_PNDP: /* As PND, OK for Perl-compatible test */ is_pattern = FALSE; @@ -8498,7 +8505,19 @@ for (i = 0; i < MODLISTCOUNT; i++) break; } - if (for_pattern == is_pattern) list[n++] = i; + if (for_pattern == is_pattern) + { + extra[n] = 0; + for (size_t k = 0; k < C1MODLISTCOUNT; k++) + { + if (strcmp(m->name, c1modlist[k].fullname) == 0) + { + extra[n] += 4; + break; + } + } + list[n++] = i; + } } /* Now print from the list in two columns. */ @@ -8511,7 +8530,7 @@ for (i = 0, j = (n+1)/2; i < (n+1)/2; i++, j++) display_one_modifier(m, for_pattern); if (j < n) { - uint32_t k = 27 - strlen(m->name); + uint32_t k = 27 - strlen(m->name) - extra[i]; while (k-- > 0) printf(" "); display_one_modifier(modlist + list[j], for_pattern); }