From e11cde2765c6dcb1a38ff8c0085f62d39d8a543b Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 21 Jan 2017 13:02:15 +0000 Subject: [PATCH] fix: minor bugs in relative-msgno A locale problem with the regex code caused some character classes to not work. Fix a few typos --- pattern.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pattern.c b/pattern.c index ac344fcb4..a1bcda7d6 100644 --- a/pattern.c +++ b/pattern.c @@ -501,7 +501,7 @@ is_context_available(BUFFER *s, regmatch_t pmatch[], int kind, BUFFER *err) return 1; /* We need a current message. Do we actually have one? */ - if (Context->menu) + if (Context && Context->menu) return 1; /* Nope. */ @@ -509,26 +509,38 @@ is_context_available(BUFFER *s, regmatch_t pmatch[], int kind, BUFFER *err) return 0; } +#ifdef USE_GNU_REGEX +/* The old version of Gnu Regex doesn't interpret the character classes + * correctly. Keep them separate, just in case we drop Gnu altogether. */ +#define RANGE_NUM_RX "([0-9]+|0x[0-9a-fA-F]+)[MmKk]?" +#define RANGE_REL_SLOT_RX "[ \t]*([.^$]|-?" RANGE_NUM_RX ")?[ \t]*" +#define RANGE_REL_RX "^" RANGE_REL_SLOT_RX "," RANGE_REL_SLOT_RX +#define RANGE_ABS_SLOT_RX "[ \t]*([.^$]|" RANGE_NUM_RX ")?[ \t]*" +#define RANGE_ABS_RX "^" RANGE_ABS_SLOT_RX "-" RANGE_ABS_SLOT_RX +#define RANGE_LT_RX "^()[ \t]*(<[ \t]*" RANGE_NUM_RX ")[ \t]*" +#define RANGE_GT_RX "^()[ \t]*(>[ \t]*" RANGE_NUM_RX ")[ \t]*" +#define RANGE_BARE_RX "^[ \t]*([.^$]|" RANGE_NUM_RX ")[ \t]*" +#else +/* The regexes in a modern format */ #define RANGE_NUM_RX "([[:digit:]]+|0x[[:xdigit:]]+)[MmKk]?" -#define RANGE_REL_SLOT_RX \ - "[[:blank:]]*([.^$]|-?" RANGE_NUM_RX ")?[[:blank:]]*" +#define RANGE_REL_SLOT_RX "[[:blank:]]*([.^$]|-?" RANGE_NUM_RX ")?[[:blank:]]*" #define RANGE_REL_RX "^" RANGE_REL_SLOT_RX "," RANGE_REL_SLOT_RX /* Almost the same, but no negative numbers allowed */ -#define RANGE_ABS_SLOT_RX \ - "[[:blank:]]*([.^$]|" RANGE_NUM_RX ")?[[:blank:]]*" +#define RANGE_ABS_SLOT_RX "[[:blank:]]*([.^$]|" RANGE_NUM_RX ")?[[:blank:]]*" #define RANGE_ABS_RX "^" RANGE_ABS_SLOT_RX "-" RANGE_ABS_SLOT_RX -/* Frist group is intentionally empty */ +/* First group is intentionally empty */ #define RANGE_LT_RX "^()[[:blank:]]*(<[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*" #define RANGE_GT_RX "^()[[:blank:]]*(>[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*" /* Single group for min and max */ #define RANGE_BARE_RX "^[[:blank:]]*([.^$]|" RANGE_NUM_RX ")[[:blank:]]*" +#endif #define RANGE_RX_GROUPS 5 -- 2.40.0