1 /* NetHack 3.6 pmatchregex.c $NHDT-Date: 1544482890 2018/12/10 23:01:30 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.2 $ */
2 /* Copyright (c) Sean Hunt 2015. */
3 /* NetHack may be freely redistributed. See license for details. */
7 /* Implementation of the regex engine using pmatch().
8 * [Switched to pmatchi() so as to ignore case.]
10 * This is a fallback ONLY and should be avoided where possible, as it results
11 * in regexes not behaving as POSIX extended regular expressions. As a result,
12 * configuration files for NetHacks built with this engine will not be
13 * portable to ones built with an alternate regex engine.
16 const char regex_id[] = "pmatchregex";
27 re = (struct nhregex *) alloc(sizeof (struct nhregex));
28 re->pat = (const char *) 0;
40 free((genericptr_t) re->pat);
48 struct nhregex *re UNUSED;
50 return "pattern match compilation error";
58 if (!re || !re->pat || !s)
61 return pmatchi(re->pat, s);
70 free((genericptr_t) re->pat);
71 free((genericptr_t) re);