Merge branch 'master' into win32-x64-working

Conflicts:
	src/display.c
This commit is contained in:
nhmall
2015-06-16 05:59:07 -04:00
14 changed files with 364 additions and 76 deletions

View File

@@ -186,7 +186,7 @@ effort to scratch it behind the two ragged bits on top of its head.
It was a relief to find someone else besides another ghost who could
see him, and Greebo, he couldn't help feeling, was a distinctly unusual
cat. Most of the castle cats were either pampered pets or flat-eared
kitchen and stable habitués who generally resembled the very rodents
kitchen and stable habitues who generally resembled the very rodents
they lived on. This cat, on the other hand, was its own animal. All
cats give that impression, of course, but instead of the mindless
animal self-absorption that passes for secret wisdom in the creatures,
@@ -358,7 +358,8 @@ too, o'course.
#
#
#
%title Lords and Ladies (1)
%title Lords and Ladies (12)
# p. 122 (Harper Torch edition)
%passage 1
Elves are wonderful. They provoke wonder.
Elves are marvellous. They cause marvels.
@@ -366,15 +367,226 @@ Elves are fantastic. They create fantasies.
Elves are glamorous. They project glamour.
Elves are enchanting. They weave enchantment.
Elves are terrific. They beget terror.
The thing about words is that meanings can twist just like a snake,
and if you want to find snakes look for them behind words that have
changed their meaning.
No one ever said elves are nice.
Elves are bad.
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 32
%passage 2
"Hope she does all right as queen," said Nanny.
"We taught her everything she knows," said Granny Weatherwax.
"Yeah," said Nanny Ogg, as they disappeared into the bracken. "D'you
think... maybe... ?"
"What?"
"D'you think maybe we ought to have taught her everything /we/ know?"
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 36
%passage 3
It was very hard, being a reader in Invisible Writings.(1)
(1) The study of invisible writings was a new discipline made available by
the discovery of the bi-directional nature of Library-Space. The thaumic
mathematics are complex, but boil down to the fact that all books,
everywhere, affect all other books. This is obvious: books inspire
other books written in the future, and cite books written in the past.
But the General Theory(2) of L-Space suggests that, in that case, the
contents of books /as yet unwritten/ can be deduced from books now in
existence.
(2) There's a Special Theory as well, but no one bothers with it much
because it's self-evidently a load of marsh gas.
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 51
%passage 4
"Don't hold with schools," said Granny Weatherwax. "They get in the way
of education. All them books. Books? What good are they? There's too
much reading these days. We never had time to read when we was young, I
know that."
[Lords and Ladies, by Terry Pratchett]
%e passage
# pp. 79-80
%passage 5
The highwayman stepped over the groaning body of the driver and marched
toward the door of the coach, dragging his stepladder behind him.
He opened the door.
"Your money or, I'm sorry to say, your--"
A blast of octarine fire blew his hat off.
The dwarf's expression did not change.
"I wonder if I might be allowed to rephrase my demands?"
Ridcully looked the elegantly dressed stranger up and down, or rather
down and further down.
"You don't look like a dwarf," he said, "apart from the height, that is."
"Don't look like a dwarf apart from the height?"
I mean, the helmet and iron boots department is among those you are lacking
in," said Ridcully.
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 95
%passage 6
What is magic?
There is the wizards' explanation, which comes in two forms, depending on
the age of the wizard. Older wizards talk about candles, circles, planets,
stars, bananas, chants, runes, and the importance of having at least four
good meals every day. Younger wizards, particularly the pale ones who
spend most of their time in the High Energy Magic building,(1) chatter at
length about fluxes in the morphic nature of the universe, the essentially
impermanent quality of even the most apparently rigid time-space framework,
the impossibility of reality, and so on: what this means is that they have
got hold of something hot and are gabbling the physics as they go along.
(1) It was here that the thaum, hitherto believed to be the smallest
possible particle of magic, was successfully demonstrated to made up of
/resons/(2) or reality fragments. Currently research indicates that each
reson is itself made up of a combination of at least five "flavors,"
known as "up," "down," "sideways," "sex appeal," and "peppermint."
(2) Lit: "Thing-ies."
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 107
%passage 7
What is magic?
Then there is the witches' explanation, which comes in two forms, depending
on the age of the witch. Older witches hardly put words to it at all, but
may suspect in their hearts that the universe really doesn't know what the
hell is going on and consists of a zillion trillion billion possibilities,
and could become any of them if a trained mind rigid with quantum certainty
was inserted in the crack and /twisted/; that, if you really had to make
someone's hat explode, all you needed to do was /twist/ into the universe
where a large number of hat molecules all decide at the same time to bounce
off in different directions.
Younger witches, on the other hand, talk about it all the time and believe
it involves crystals, mystic forces, and dancing about without yer drawers
on.
Everyone may to right, all at the same time. That's the thing about
quantum.
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 114; 'colorful' & 'humor' are spelled the American way, 'or' not 'our'
%passage 8
He knocked on the coach door. The window slid down.
"I wouldn't like you to think of this as a robbery," he said. "I'd like
you to think of it more as a colorful anecdote you might enjoy telling your
grandchildren about."
A voice from within said, "That's him! He stole my horse!"
A wizard's staff poked out. The chieftain saw the knob on the end.
"Now then," he said pleasantly. "I know the rules. Wizards aren't allowed
to use magic against civilians except in genuine life-threatening situa--"
There was a burst of octarine light.
"Actually, it's not a rule," said Ridcully. "It's more a guideline." He
turned to Ponder Stibbons. "Interestin' use of Stacklady's Morphic
Resonator here, I hoped you noticed."
Ponder lookd down.
The chieftain had been turned into a pumpkin, although, in accordance with
the rules of universal humor, he still had his hat on.
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 149 (second half of a paragraph)
%passage 9
Things had to balance. You couldn't set out to be a good witch or a bad
witch. It never worked for long. All you could try to be was a /witch/,
as hard as you could.
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 162 (mid-paragraph)
%passage 10
"I'm the head wizard now. I've only got to give an order and a thousand
wizards will... uh... disobey, come to think of it, or say 'What?', or
start to argue. But they have to take notice.
"I've been to that University a few times," said Granny. "A bunch of fat
old men in beards."
"That's right! That's /them/!"
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 190
%passage 11
The window was no escape this time. There was the bed to hide under, and
that'd work for all of two seconds, wouldn't it?
Her eye was drawn by some kind of horrible magic back to the room's
garderobe, lurking behind its curtain.
Margrat lifted the lid. The shaft was definitely wide enough to admit a
body. Garderobes were notorious in that respect. Several unpopular kings
met their end, as it were, in the garderobe, at the hands of an assassin
with good climbing ability, a spear, and a fundamental approach to politics.
[Lords and Ladies, by Terry Pratchett]
%e passage
# p. 191 ('a' historian, not 'an'; 'Ynci' is correct)
%passage 12
Some shape, some trick of moonlight, some expression on a painted face
somehow cut through her terror and caught her eye.
That was a portrait she'd never seen before. She'd never walked down this
far. The idiot vapidity of the assembled queens had depressed her. But
this one...
Ths one, somehow, reached out to her.
She stopped.
It couldn't have been done from life. In the days of /this/ queen, the
only paint known locally was a sort of blue, and generally used on the body.
But a few generations ago King Lully I had been a bit of a historian and a
romantic. He'd researched what was known of the early days of Lancre, and
where actual evidence had been a bit sparse he had, in the best traditions
of the keen ethnic historian, inferred from revealed self-evident wisdom(1)
and extrapolated from associated sources(2). He'd commissioned the
portrait of Queen Ynci the Short-Tempered, one of the founders of the
kingdom.
(1) Made it up.
(2) Had read a lot of stuff that other people had made up, too.
[Lords and Ladies, by Terry Pratchett]
%e passage
%e title
#
#

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 context.h $NHDT-Date: 1432512775 2015/05/25 00:12:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.25 $ */
/* NetHack 3.6 context.h $NHDT-Date: 1434421363 2015/06/16 02:22:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -80,8 +80,9 @@ struct tribute_info {
size_t tributesz; /* make it possible to skip this in future */
boolean enabled; /* Do we have tributes turned on? */
Bitfield(bookstock, 1); /* Have we stocked the book? */
Bitfield(Deathnotice,1); /* Did Death notice the book? */
/* Markers for other tributes can go here */
/* 31 free bits */
/* 30 free bits */
};
struct context_info {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1434330826 2015/06/15 01:13:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.503 $ */
/* NetHack 3.6 extern.h $NHDT-Date: 1434421365 2015/06/16 02:22:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.504 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -765,7 +765,8 @@ E void NDECL(really_close);
#ifdef DEBUG
E boolean FDECL(debugcore, (const char *, BOOLEAN_P));
#endif
E boolean FDECL(read_tribute, (const char *, const char *, int));
E boolean FDECL(read_tribute, (const char *, const char *, int, char *, int));
E boolean FDECL(Death_quote, (char *, int));
/* ### fountain.c ### */
@@ -901,6 +902,7 @@ E struct obj *FDECL(sobj_at, (int, int, int));
E struct obj *FDECL(nxtobj, (struct obj *, int, BOOLEAN_P));
E struct obj *FDECL(carrying, (int));
E boolean NDECL(have_lizard);
E struct obj *NDECL(u_have_novel);
E struct obj *FDECL(o_on, (unsigned int, struct obj *));
E boolean FDECL(obj_here, (struct obj *, int, int));
E boolean NDECL(wearing_armor);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 display.c $NHDT-Date: 1434025166 2015/06/11 12:19:26 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.68 $ */
/* NetHack 3.6 display.c $NHDT-Date: 1434447701 2015/06/16 09:41:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
/* and Dave Cohrs, 1990. */
/* NetHack may be freely redistributed. See license for details. */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 end.c $NHDT-Date: 1434071495 2015/06/12 01:11:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */
/* NetHack 3.6 end.c $NHDT-Date: 1434408399 2015/06/15 22:46:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.100 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -979,8 +979,10 @@ die:
force_launch_placement();
/* maintain ugrave_arise even for !bones_ok */
if (how == BURNING || how == DISSOLVED) /* corpse gets burnt up too */
u.ugrave_arise = (NON_PM - 2); /* leave no corpse */
if (how == PANICKED)
u.ugrave_arise = (NON_PM - 3); /* no corpse, no grave */
else if (how == BURNING || how == DISSOLVED) /* corpse burns up too */
u.ugrave_arise = (NON_PM - 2); /* leave no corpse */
else if (how == STONING)
u.ugrave_arise = (NON_PM - 1); /* statue instead of corpse */
else if (how == TURNED_SLIME)
@@ -1097,16 +1099,12 @@ die:
if (have_windows) {
wait_synch();
display_nhwindow(WIN_MESSAGE, TRUE);
destroy_nhwindow(WIN_MAP);
destroy_nhwindow(WIN_MAP), WIN_MAP = WIN_ERR;
#ifndef STATUS_VIA_WINDOWPORT
destroy_nhwindow(WIN_STATUS);
#endif
destroy_nhwindow(WIN_MESSAGE);
#ifdef STATUS_VIA_WINDOWPORT
WIN_MESSAGE = WIN_MAP = WIN_ERR;
#else
WIN_MESSAGE = WIN_STATUS = WIN_MAP = WIN_ERR;
destroy_nhwindow(WIN_STATUS), WIN_STATUS = WIN_ERR;
#endif
destroy_nhwindow(WIN_MESSAGE), WIN_MESSAGE = WIN_ERR;
if (!done_stopprint || flags.tombstone)
endwin = create_nhwindow(NHW_TEXT);
@@ -1115,9 +1113,9 @@ die:
} else
done_stopprint = 1; /* just avoid any more output */
if (u.uhave.amulet)
if (u.uhave.amulet) {
Strcat(killer.name, " (with the Amulet)");
else if (how == ESCAPED) {
} else if (how == ESCAPED) {
if (Is_astralevel(&u.uz)) /* offered Amulet to wrong deity */
Strcat(killer.name, " (in celestial disgrace)");
else if (carrying(FAKE_AMULET_OF_YENDOR))

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 files.c $NHDT-Date: 1434249087 2015/06/14 02:31:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.179 $ */
/* NetHack 3.6 files.c $NHDT-Date: 1434425313 2015/06/16 03:28:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.182 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3392,9 +3392,10 @@ boolean wildcards;
#define PASSAGESCOPE 3
boolean
read_tribute(tribsection, tribtitle, tribpassage)
read_tribute(tribsection, tribtitle, tribpassage, nowin_buf, bufsz)
const char *tribsection, *tribtitle;
int tribpassage;
int tribpassage, bufsz;
char *nowin_buf;
{
dlb *fp;
char *endp;
@@ -3406,10 +3407,12 @@ int tribpassage;
boolean matchedsection = FALSE, matchedtitle = FALSE;
winid tribwin = WIN_ERR;
boolean grasped = FALSE;
boolean foundpassage = FALSE;
/* check for mandatories */
if (!tribsection || !tribtitle) {
pline("It's %s of \"%s\"!", badtranslation, tribtitle);
if (!nowin_buf)
pline("It's %s of \"%s\"!", badtranslation, tribtitle);
return grasped;
}
@@ -3419,7 +3422,8 @@ int tribpassage;
fp = dlb_fopen(TRIBUTEFILE, "r");
if (!fp) {
/* this is actually an error - cannot open tribute file! */
pline("You feel too overwhelmed to continue!");
if (!nowin_buf)
pline("You feel too overwhelmed to continue!");
return grasped;
}
@@ -3494,12 +3498,16 @@ int tribpassage;
passagenum = atoi(st);
if (passagenum && (passagenum <= passagecnt)) {
scope = PASSAGESCOPE;
if (matchedtitle && (passagenum == targetpassage))
tribwin = create_nhwindow(NHW_MENU);
if (matchedtitle && (passagenum == targetpassage)) {
if (!nowin_buf)
tribwin = create_nhwindow(NHW_MENU);
else
foundpassage = TRUE;
}
}
} else if (!strncmpi(&line[1], "e ", sizeof("e ") - 1)) {
if (matchedtitle && (scope == PASSAGESCOPE)
&& tribwin != WIN_ERR)
&& ((!nowin_buf && tribwin != WIN_ERR) || (nowin_buf && foundpassage)))
goto cleanup;
if (scope == TITLESCOPE)
matchedtitle = FALSE;
@@ -3516,16 +3524,21 @@ int tribpassage;
/* comment only, next! */
break;
default:
if (matchedtitle && scope == PASSAGESCOPE && tribwin != WIN_ERR) {
putstr(tribwin, 0, line);
Strcpy(lastline, line);
if (matchedtitle && scope == PASSAGESCOPE) {
if (!nowin_buf && tribwin != WIN_ERR) {
putstr(tribwin, 0, line);
Strcpy(lastline, line);
} else if (nowin_buf) {
if ((int)strlen(line) < bufsz-1)
Strcpy(nowin_buf, line);
}
}
}
}
cleanup:
(void) dlb_fclose(fp);
if (tribwin != WIN_ERR) {
if (!nowin_buf && tribwin != WIN_ERR) {
if (matchedtitle && scope == PASSAGESCOPE) {
display_nhwindow(tribwin, FALSE);
/* put the final attribution line into message history,
@@ -3540,11 +3553,22 @@ cleanup:
tribwin = WIN_ERR;
grasped = TRUE;
} else {
pline("It seems to be %s of \"%s\"!", badtranslation, tribtitle);
if (!nowin_buf)
pline("It seems to be %s of \"%s\"!", badtranslation, tribtitle);
else
if (foundpassage)
grasped = TRUE;
}
return grasped;
}
boolean
Death_quote(buf, bufsz)
char *buf;
int bufsz;
{
return read_tribute("Death", "Death Quotes", 0, buf, bufsz);
}
/* ---------- END TRIBUTE ----------- */
/*files.c*/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 invent.c $NHDT-Date: 1432939569 2015/05/29 22:46:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.166 $ */
/* NetHack 3.6 invent.c $NHDT-Date: 1434421348 2015/06/16 02:22:28 $ $NHDT-Branch: master $:$NHDT-Revision: 1.167 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -815,6 +815,18 @@ have_lizard()
return (FALSE);
}
/* 3.6.0 tribute */
struct obj *
u_have_novel()
{
register struct obj *otmp;
for (otmp = invent; otmp; otmp = otmp->nobj)
if (otmp->otyp == SPE_NOVEL)
return otmp;
return (struct obj *)0;
}
struct obj *
o_on(id, objchn)
unsigned int id;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 sounds.c $NHDT-Date: 1432510145 2015/05/24 23:29:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */
/* NetHack 3.6 sounds.c $NHDT-Date: 1434421352 2015/06/16 02:22:32 $ $NHDT-Branch: master $:$NHDT-Revision: 1.64 $ */
/* Copyright (c) 1989 Janet Walz, Mike Threepoint */
/* NetHack may be freely redistributed. See license for details. */
@@ -906,7 +906,29 @@ register struct monst *mtmp;
: soldier_foe_msg[rn2(3)];
} break;
case MS_RIDER:
if (ptr == &mons[PM_DEATH] && !rn2(10))
/* 3.6.0 tribute */
if (ptr == &mons[PM_DEATH] &&
!context.tribute.Deathnotice && u_have_novel()) {
struct obj *book = u_have_novel();
const char *tribtitle = (char *)0;
if (book) {
int novelidx = book->novelidx;
tribtitle = noveltitle(&novelidx);
}
if (tribtitle) {
Sprintf(verbuf,
"Ah, so you have a copy of '%s'. I may have been misquoted there.",
tribtitle);
verbl_msg = verbuf;
context.tribute.Deathnotice = 1;
}
} else if (ptr == &mons[PM_DEATH] &&
!rn2(2) && Death_quote(verbuf, BUFSZ)) {
verbl_msg = verbuf;
}
/* end of tribute addition */
else if (ptr == &mons[PM_DEATH] && !rn2(10))
pline_msg = "is busy reading a copy of Sandman #8.";
else
verbl_msg = "Who do you think you are, War?";

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 spell.c $NHDT-Date: 1432512766 2015/05/25 00:12:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */
/* NetHack 3.6 spell.c $NHDT-Date: 1434421353 2015/06/16 02:22:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */
/* Copyright (c) M. Stephenson 1988 */
/* NetHack may be freely redistributed. See license for details. */
@@ -473,7 +473,7 @@ register struct obj *spellbook;
if (booktype == SPE_NOVEL) {
/* Obtain current Terry Pratchett book title */
const char *tribtitle = noveltitle(&spellbook->novelidx);
if (read_tribute("books", tribtitle, 0)) {
if (read_tribute("books", tribtitle, 0, (char *)0, 0)) {
u.uconduct.literate++;
check_unpaid(spellbook);
if (!u.uevent.read_tribute) {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 version.c $NHDT-Date: 1434151385 2015/06/12 23:23:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.32 $ */
/* NetHack 3.6 version.c $NHDT-Date: 1434446944 2015/06/16 09:29:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -130,9 +130,9 @@ doextversion()
return 0;
}
extern char regex_id[];
extern const char regex_id[];
static char *rt_opts[] = {
static const char *rt_opts[] = {
"pattern matching via", regex_id,
};
static const char indent[] = " ";
@@ -150,7 +150,7 @@ char *buf;
{
char rtbuf[BUFSZ];
char *pd;
int l, i = 0, j = 0;
int l, i = 0;
if (strlen(buf) >= BUFSZ - 3)
return;

View File

@@ -10,7 +10,7 @@
extern "C" {
#include <hack.h>
char regex_id[] = "cppregex";
const char regex_id[] = "cppregex";
struct nhregex {
std::unique_ptr<std::regex> re;
@@ -25,7 +25,9 @@ extern "C" {
if (!re)
return FALSE;
try {
re->re.reset(new std::regex(s, std::regex::extended | std::regex::nosubs | std::regex::optimize));
re->re.reset(new std::regex(s, (std::regex::extended
| std::regex::nosubs
| std::regex::optimize)));
re->err.reset(nullptr);
return TRUE;
} catch (const std::regex_error& err) {

View File

@@ -1,10 +1,11 @@
/* NetHack 3.6 posixregex.c $NHDT-Date: 1434151360 2015/06/12 23:22:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.0 $ */
/* NetHack 3.6 posixregex.c $NHDT-Date: 1434446946 2015/06/16 09:29:06 $ $NHDT-Branch: master $:$NHDT-Revision: 1.1 $ */
/* Copyright (c) Sean Hunt 2015. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
/* Implementation of the regex engine using pmatch().
* [Switched to pmatchi() so as to ignore case.]
*
* This is a fallback ONLY and should be avoided where possible, as it results
* in regexes not behaving as POSIX extended regular expressions. As a result,
@@ -12,56 +13,61 @@
* portable to ones built with an alternate regex engine.
*/
/*
* NOTE: This file is untested.
*/
char regex_id[] = "pmatchregex";
const char regex_id[] = "pmatchregex";
struct nhregex {
const char *pat;
const char *pat;
};
struct nhregex *
regex_init()
{
return (struct nhregex *) alloc(sizeof(struct nhregex));
struct nhregex *re;
re = (struct nhregex *) alloc(sizeof (struct nhregex));
re->pat = (const char *) 0;
return re;
}
boolean
regex_compile(const char *s, struct nhregex *re)
regex_compile(s, re)
const char *s;
struct nhregex *re;
{
if (!re)
return FALSE;
if (re->pat);
free(re->path);
if (re->pat)
free((genericptr_t) re->pat);
re->pat = alloc(strlen(s) + 1);
strcpy(re->pat, s);
re->pat = dupstr(s);
return TRUE;
}
const char *
regex_error_desc(struct nhregex *re)
regex_error_desc(re)
struct nhregex *re UNUSED;
{
return "pattern match compilation error";
}
boolean
regex_match(const char *s, struct nhregex *re)
regex_match(s, re)
const char *s;
struct nhregex *re;
{
if (!re || !re->pat || !s)
return FALSE;
return pmatch(re->pat, s);
return pmatchi(re->pat, s);
}
void
regex_free(struct nhregex *re)
regex_free(re)
struct nhregex *re;
{
if (!re)
return FALSE;
if (re->pat)
free(re->pat);
free(re);
if (re) {
if (re->pat)
free((genericptr_t) re->pat);
free((genericptr_t) re);
}
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 posixregex.c $NHDT-Date: 1434151361 2015/06/12 23:22:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.4 $ */
/* NetHack 3.6 posixregex.c $NHDT-Date: 1434446947 2015/06/16 09:29:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
/* Copyright (c) Sean Hunt 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -44,7 +44,7 @@
* Deallocate a regex object.
*/
char regex_id[] = "posixregex";
const char regex_id[] = "posixregex";
struct nhregex {
regex_t re;

View File

@@ -1,5 +1,5 @@
# NetHack Makefile.
# NetHack 3.6 Makefile.src $NHDT-Date: 1432512789 2015/05/25 00:13:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.43 $
# NetHack 3.6 Makefile.src $NHDT-Date: 1434446945 2015/06/16 09:29:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.44 $
# Root of source tree:
NHSROOT=..
@@ -167,6 +167,11 @@ CXX=g++
#CXX=arm-linux-g++
#LINK=arm-linux-gcc
# file for regular expression matching
REGEXOBJ = posixregex.o
#REGEXOBJ = pmatchregex.o
#REGEXOBJ = cppregex.o
# Set the WINSRC, WINOBJ, and WINLIB lines to correspond to your desired
# combination of windowing systems. Also set windowing systems in config.h.
# Note that if you are including multiple tiled window systems, you don't
@@ -337,7 +342,9 @@ HACKCSRC = allmain.c alloc.c apply.c artifact.c attrib.c ball.c bones.c \
# all operating-system-dependent .c (for dependencies and such)
SYSCSRC = ../sys/atari/tos.c ../sys/share/pcmain.c ../sys/share/pcsys.c \
../sys/share/pctty.c ../sys/share/pcunix.c ../sys/share/posixregex.c ../sys/share/random.c \
../sys/share/pctty.c ../sys/share/pcunix.c \
../sys/share/pmatchregex.c ../sys/share/posixregex.c \
../sys/share/random.c \
../sys/share/ioctl.c ../sys/share/unixtty.c ../sys/unix/unixmain.c \
../sys/unix/unixunix.c ../sys/unix/unixres.c ../sys/be/bemain.c
@@ -391,14 +398,14 @@ HOBJ = $(FIRSTOBJ) allmain.o alloc.o apply.o artifact.o attrib.o ball.o \
minion.o mklev.o mkmap.o \
mkmaze.o mkobj.o mkroom.o mon.o mondata.o monmove.o monstr.o \
mplayer.o mthrowu.o muse.o music.o o_init.o objnam.o options.o \
pager.o pickup.o pline.o polyself.o posixregex.o potion.o pray.o priest.o \
pager.o pickup.o pline.o polyself.o potion.o pray.o priest.o \
quest.o questpgr.o read.o rect.o region.o restore.o rip.o rnd.o \
role.o rumors.o save.o shk.o shknam.o sit.o sounds.o sp_lev.o spell.o \
sys.o \
steal.o steed.o teleport.o timeout.o topten.o track.o trap.o u_init.o \
uhitm.o vault.o vision.o vis_tab.o weapon.o were.o wield.o windows.o \
wizard.o worm.o worn.o write.o zap.o \
$(RANDOBJ) $(SYSOBJ) $(WINOBJ) $(HINTOBJ) version.o
$(REGEXOBJ) $(RANDOBJ) $(SYSOBJ) $(WINOBJ) $(HINTOBJ) version.o
# the .o files from the HACKCSRC, SYSSRC, and WINSRC lists
$(GAME): $(SYSTEM)
@@ -599,12 +606,14 @@ pctty.o: ../sys/share/pctty.c $(HACK_H)
$(CC) $(CFLAGS) -c ../sys/share/pctty.c
pcunix.o: ../sys/share/pcunix.c $(HACK_H)
$(CC) $(CFLAGS) -c ../sys/share/pcunix.c
pmatchregex.o: ../sys/share/pmatchregex.c $(HACK_H)
$(CC) $(CFLAGS) -c ../sys/share/pmatchregex.c
posixregex.o: ../sys/share/posixregex.c $(HACK_H)
$(CC) $(CFLAGS) -c ../sys/share/posixregex.c
random.o: ../sys/share/random.c $(HACK_H)
$(CC) $(CFLAGS) -c ../sys/share/random.c
ioctl.o: ../sys/share/ioctl.c $(HACK_H) ../include/tcap.h
$(CC) $(CFLAGS) -c ../sys/share/ioctl.c
posixregex.o: ../sys/share/posixregex.c $(HACK_H)
$(CC) $(CFLAGS) -c ../sys/share/posixregex.c
unixtty.o: ../sys/share/unixtty.c $(HACK_H)
$(CC) $(CFLAGS) -c ../sys/share/unixtty.c
unixmain.o: ../sys/unix/unixmain.c $(HACK_H) ../include/dlb.h