Merge branch 'master' into win32-x64-working

Conflicts:
	include/config.h
	src/options.c
This commit is contained in:
nhmall
2015-04-12 11:58:14 -04:00
11 changed files with 187 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 options.c $NHDT-Date: 1427073746 2015/03/23 01:22:26 $ $NHDT-Branch: master $:$NHDT-Revision: 1.164 $ */
/* NetHack 3.5 options.c $NHDT-Date: 1428088105 2015/04/03 19:08:25 $ $NHDT-Branch: scshunt-regex $:$NHDT-Revision: 1.182 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1169,11 +1169,6 @@ char *str;
int i, c = NO_COLOR, a = ATR_NONE;
struct menucoloring *tmp;
char *tmps, *cs = strchr(str, '=');
#ifdef MENU_COLOR_REGEX_POSIX
int errnum;
char errbuf[80];
#endif
const char *err = (char *)0;
if (!cs || !str) return FALSE;
@@ -1216,28 +1211,9 @@ char *str;
}
tmp = (struct menucoloring *)alloc(sizeof(struct menucoloring));
#ifdef MENU_COLOR_REGEX
#ifdef MENU_COLOR_REGEX_POSIX
errnum = regcomp(&tmp->match, tmps, REG_EXTENDED | REG_NOSUB);
if (errnum != 0)
{
regerror(errnum, &tmp->match, errbuf, sizeof(errbuf));
err = errbuf;
}
#else
tmp->match.translate = 0;
tmp->match.fastmap = 0;
tmp->match.buffer = 0;
tmp->match.allocated = 0;
tmp->match.regs_allocated = REGS_FIXED;
err = re_compile_pattern(tmps, strlen(tmps), &tmp->match);
#endif
#else
tmp->match = (char *)alloc(strlen(tmps)+1);
(void) memcpy((genericptr_t)tmp->match, (genericptr_t)tmps, strlen(tmps)+1);
#endif
if (err) {
raw_printf("\nMenucolor regex error: %s\n", err);
tmp->match = regex_init();
if (!regex_compile(tmps, tmp->match)) {
raw_printf("\nMenucolor regex error: %s\n", regex_error_desc(tmp->match));
wait_synch();
free(tmp);
return FALSE;
@@ -1258,15 +1234,7 @@ int *color, *attr;
struct menucoloring *tmpmc;
if (iflags.use_menu_color)
for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next)
#ifdef MENU_COLOR_REGEX
# ifdef MENU_COLOR_REGEX_POSIX
if (regexec(&tmpmc->match, str, 0, NULL, 0) == 0) {
# else
if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) {
# endif
#else
if (pmatch(tmpmc->match, str)) {
#endif
if (regex_match(str, tmpmc->match)) {
*color = tmpmc->color;
*attr = tmpmc->attr;
return TRUE;
@@ -1281,11 +1249,7 @@ free_menu_coloring()
while (tmp) {
struct menucoloring *tmp2 = tmp->next;
#ifdef MENU_COLOR_REGEX
(void) regfree(&tmp->match);
#else
free(tmp->match);
#endif
regex_free(tmp->match);
free(tmp);
tmp = tmp2;
}