feature options (#version output)
I've sometimes seen , and basic NetHack features. as the last line of the features section from '#version'. I thought it was due to the way feature phrases were split into individual words by makedefs, but it turned out to be due to inserting pattern matching method at run-time. That dynamic options update had a second problem: if the final phrase "and basic NetHack features" was split across two lines, the run-time substitution didn't find it and the pattern matching entry ended up being left out. This fixes both problems, but if future dynamic entries become more complex, the phrase-splitting/word-wrapping being done by makedefs may need to be moved into nethack. Also, add entries for XLOGFILE and PANICLOG to makedefs' options and re-order a couple of existing ones alphabetically (a failry hopeless endeavor).
This commit is contained in:
@@ -453,6 +453,10 @@ when lit candelabrum burned out, persistent inventory window showed that it
|
|||||||
improve hilite_status, allowing multiple stops per field, and temporarily or
|
improve hilite_status, allowing multiple stops per field, and temporarily or
|
||||||
permanently hilited fields
|
permanently hilited fields
|
||||||
give feedback when released from a bear trap
|
give feedback when released from a bear trap
|
||||||
|
#version output sometimes had ", and basic NetHack features." on its own line
|
||||||
|
depending upon how the dynamically inserted pattern-match phrase fit
|
||||||
|
#version output left out "pattern matching via <method>" if the basic NetHack
|
||||||
|
features entry was split across two lines
|
||||||
|
|
||||||
|
|
||||||
Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
|
Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
|
||||||
|
|||||||
+25
-65
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 version.c $NHDT-Date: 1449328116 2015/12/05 15:08:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.41 $ */
|
/* NetHack 3.6 version.c $NHDT-Date: 1506993902 2017/10/03 01:25:02 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.44 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#define BETA_INFO ""
|
#define BETA_INFO ""
|
||||||
|
|
||||||
STATIC_DCL void FDECL(insert_rtoptions, (winid,char *,const char *));
|
STATIC_DCL void FDECL(insert_rtoption, (char *));
|
||||||
|
|
||||||
/* fill buffer with short version (so caller can avoid including date.h) */
|
/* fill buffer with short version (so caller can avoid including date.h) */
|
||||||
char *
|
char *
|
||||||
@@ -57,9 +57,8 @@ int
|
|||||||
doextversion()
|
doextversion()
|
||||||
{
|
{
|
||||||
dlb *f;
|
dlb *f;
|
||||||
char *pd, buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
winid win = create_nhwindow(NHW_TEXT);
|
winid win = create_nhwindow(NHW_TEXT);
|
||||||
boolean rtadded = FALSE;
|
|
||||||
|
|
||||||
/* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle
|
/* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle
|
||||||
the file manually so we can include dynamic version info */
|
the file manually so we can include dynamic version info */
|
||||||
@@ -74,8 +73,7 @@ doextversion()
|
|||||||
/*
|
/*
|
||||||
* already inserted above:
|
* already inserted above:
|
||||||
* + outdented program name and version plus build date and time
|
* + outdented program name and version plus build date and time
|
||||||
* dat/options; display the contents with lines prefixed by '-'
|
* dat/options; display contents with lines prefixed by '-' deleted:
|
||||||
* deleted:
|
|
||||||
* - blank-line
|
* - blank-line
|
||||||
* - indented program name and version
|
* - indented program name and version
|
||||||
* blank-line
|
* blank-line
|
||||||
@@ -108,16 +106,9 @@ doextversion()
|
|||||||
if (prolog || !*buf)
|
if (prolog || !*buf)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!rtadded) {
|
if (index(buf, ':'))
|
||||||
const char *catchphrase = ", and basic NetHack features.";
|
insert_rtoption(buf);
|
||||||
|
|
||||||
pd = strstri(buf, catchphrase);
|
|
||||||
if (pd) {
|
|
||||||
*pd = '\0';
|
|
||||||
insert_rtoptions(win, buf, &catchphrase[2]);
|
|
||||||
rtadded = TRUE; /* only do it once */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (*buf)
|
if (*buf)
|
||||||
putstr(win, 0, buf);
|
putstr(win, 0, buf);
|
||||||
}
|
}
|
||||||
@@ -130,10 +121,19 @@ doextversion()
|
|||||||
|
|
||||||
extern const char regex_id[];
|
extern const char regex_id[];
|
||||||
|
|
||||||
static const char *rt_opts[] = {
|
/*
|
||||||
"pattern matching via", regex_id,
|
* makedefs should put the first token into dat/options; we'll substitute
|
||||||
|
* the second value for it. The token must contain at least one colon
|
||||||
|
* so that we can spot it, and should not contain spaces so that makedefs
|
||||||
|
* won't split it across lines. Ideally the length should be close to
|
||||||
|
* that of the substituted value since we don't do phrase-splitting/line-
|
||||||
|
* wrapping when displaying it.
|
||||||
|
*/
|
||||||
|
static struct rt_opt {
|
||||||
|
const char *token, *value;
|
||||||
|
} rt_opts[] = {
|
||||||
|
{ ":PATMATCH:", regex_id },
|
||||||
};
|
};
|
||||||
static const char indent[] = " ";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 3.6.0
|
* 3.6.0
|
||||||
@@ -142,57 +142,17 @@ static const char indent[] = " ";
|
|||||||
* game image, so we insert those options here.
|
* game image, so we insert those options here.
|
||||||
*/
|
*/
|
||||||
STATIC_OVL void
|
STATIC_OVL void
|
||||||
insert_rtoptions(win, buf, finalphrase)
|
insert_rtoption(buf)
|
||||||
winid win;
|
|
||||||
char *buf;
|
char *buf;
|
||||||
const char *finalphrase;
|
|
||||||
{
|
{
|
||||||
char rtbuf[BUFSZ];
|
int i;
|
||||||
int l, i;
|
|
||||||
const char *s1 = 0, *s2 = 0, *s3 = 0, *s4 = 0;
|
|
||||||
|
|
||||||
if ((int) strlen(buf) >= (BUFSZ - 1))
|
for (i = 0; i < SIZE(rt_opts); ++i) {
|
||||||
return;
|
if (strstri(buf, rt_opts[i].token))
|
||||||
|
(void) strsubst(buf, rt_opts[i].token, rt_opts[i].value);
|
||||||
strcpy(rtbuf, buf);
|
/* we don't break out of the loop after a match; there might be
|
||||||
for (i = 0; i < (SIZE(rt_opts) + 1); i += 2) {
|
other matches on the same line */
|
||||||
if (i < SIZE(rt_opts)) {
|
|
||||||
s1 = ", ";
|
|
||||||
s2 = rt_opts[i];
|
|
||||||
s3 = " ";
|
|
||||||
s4 = rt_opts[i+1];
|
|
||||||
} else {
|
|
||||||
s1 = " ";
|
|
||||||
s2 = finalphrase;
|
|
||||||
s3 = "";
|
|
||||||
s4 = "";
|
|
||||||
}
|
|
||||||
l = (int) strlen(rtbuf) + (int) strlen(s1) + (int) strlen(s2)
|
|
||||||
+ (int) strlen(s3) + (int) strlen(s4) + 1;
|
|
||||||
if (l <= (COLNO - 5) && l < (BUFSZ - 1)) {
|
|
||||||
Strcat(rtbuf, s1);
|
|
||||||
Strcat(rtbuf, s2);
|
|
||||||
Strcat(rtbuf, s3);
|
|
||||||
Strcat(rtbuf, s4);
|
|
||||||
} else {
|
|
||||||
putstr(win, 0, rtbuf);
|
|
||||||
if (i >= SIZE(rt_opts))
|
|
||||||
s1 = "";
|
|
||||||
l = (int) strlen(indent) + (int) strlen(s1) + (int) strlen(s2)
|
|
||||||
+ (int) strlen(s3) + (int) strlen(s4) + 1;
|
|
||||||
if (l <= (COLNO - 5) && l < (BUFSZ - 1)) {
|
|
||||||
Strcpy(rtbuf, indent);
|
|
||||||
Strcat(rtbuf, s1);
|
|
||||||
Strcat(rtbuf, s2);
|
|
||||||
Strcat(rtbuf, s3);
|
|
||||||
Strcat(rtbuf, s4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l)
|
|
||||||
putstr(win, 0, rtbuf);
|
|
||||||
*buf = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MICRO
|
#ifdef MICRO
|
||||||
|
|||||||
+20
-12
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 makedefs.c $NHDT-Date: 1459208813 2016/03/28 23:46:53 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.110 $ */
|
/* NetHack 3.6 makedefs.c $NHDT-Date: 1506993895 2017/10/03 01:24:55 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.117 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* Copyright (c) M. Stephenson, 1990, 1991. */
|
/* Copyright (c) M. Stephenson, 1990, 1991. */
|
||||||
/* Copyright (c) Dean Luick, 1990. */
|
/* Copyright (c) Dean Luick, 1990. */
|
||||||
@@ -1437,21 +1437,27 @@ static const char *build_opts[] = {
|
|||||||
#ifdef DUMPLOG
|
#ifdef DUMPLOG
|
||||||
"end-of-game dumplogs",
|
"end-of-game dumplogs",
|
||||||
#endif
|
#endif
|
||||||
#ifdef MFLOPPY
|
|
||||||
"floppy drive support",
|
|
||||||
#endif
|
|
||||||
#ifdef INSURANCE
|
|
||||||
"insurance files for recovering from crashes",
|
|
||||||
#endif
|
|
||||||
#ifdef HOLD_LOCKFILE_OPEN
|
#ifdef HOLD_LOCKFILE_OPEN
|
||||||
"exclusive lock on level 0 file",
|
"exclusive lock on level 0 file",
|
||||||
#endif
|
#endif
|
||||||
#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
|
#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
|
||||||
"external program as a message handler",
|
"external program as a message handler",
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef MFLOPPY
|
||||||
|
"floppy drive support",
|
||||||
|
#endif
|
||||||
|
#ifdef INSURANCE
|
||||||
|
"insurance files for recovering from crashes",
|
||||||
|
#endif
|
||||||
#ifdef LOGFILE
|
#ifdef LOGFILE
|
||||||
"log file",
|
"log file",
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef XLOGFILE
|
||||||
|
"extended log file",
|
||||||
|
#endif
|
||||||
|
#ifdef PANICLOG
|
||||||
|
"errors and warnings log file",
|
||||||
|
#endif
|
||||||
#ifdef MAIL
|
#ifdef MAIL
|
||||||
"mail daemon",
|
"mail daemon",
|
||||||
#endif
|
#endif
|
||||||
@@ -1472,6 +1478,8 @@ static const char *build_opts[] = {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
/* pattern matching method will be substituted by nethack at run time */
|
||||||
|
"pattern matching via :PATMATCH:",
|
||||||
#ifdef SELECTSAVED
|
#ifdef SELECTSAVED
|
||||||
"restore saved games via menu",
|
"restore saved games via menu",
|
||||||
#endif
|
#endif
|
||||||
@@ -1539,7 +1547,8 @@ static const char *build_opts[] = {
|
|||||||
#ifdef SYSCF
|
#ifdef SYSCF
|
||||||
"system configuration at run-time",
|
"system configuration at run-time",
|
||||||
#endif
|
#endif
|
||||||
save_bones_compat_buf, "and basic NetHack features"
|
save_bones_compat_buf,
|
||||||
|
"and basic NetHack features"
|
||||||
};
|
};
|
||||||
|
|
||||||
struct win_info {
|
struct win_info {
|
||||||
@@ -1604,8 +1613,7 @@ windowing_sanity()
|
|||||||
for (i = 0; window_opts[i].id; ++i)
|
for (i = 0; window_opts[i].id; ++i)
|
||||||
if (!strcmp(window_opts[i].id, DEFAULT_WINDOW_SYS))
|
if (!strcmp(window_opts[i].id, DEFAULT_WINDOW_SYS))
|
||||||
break;
|
break;
|
||||||
if (!window_opts[i]
|
if (!window_opts[i].id) { /* went through whole list without a match */
|
||||||
.id) { /* went through whole list without a match */
|
|
||||||
Fprintf(stderr, "Configuration error: DEFAULT_WINDOW_SYS (%s)\n",
|
Fprintf(stderr, "Configuration error: DEFAULT_WINDOW_SYS (%s)\n",
|
||||||
DEFAULT_WINDOW_SYS);
|
DEFAULT_WINDOW_SYS);
|
||||||
Fprintf(stderr,
|
Fprintf(stderr,
|
||||||
@@ -1649,7 +1657,8 @@ do_options()
|
|||||||
Fprintf(ofp, "\nOptions compiled into this edition:\n");
|
Fprintf(ofp, "\nOptions compiled into this edition:\n");
|
||||||
length = COLNO + 1; /* force 1st item onto new line */
|
length = COLNO + 1; /* force 1st item onto new line */
|
||||||
for (i = 0; i < SIZE(build_opts); i++) {
|
for (i = 0; i < SIZE(build_opts); i++) {
|
||||||
str = strcpy(buf, build_opts[i]);
|
str = strcat(strcpy(buf, build_opts[i]),
|
||||||
|
(i < SIZE(build_opts) - 1) ? "," : ".");
|
||||||
while (*str) {
|
while (*str) {
|
||||||
word = index(str, ' ');
|
word = index(str, ' ');
|
||||||
if (word)
|
if (word)
|
||||||
@@ -1661,7 +1670,6 @@ do_options()
|
|||||||
Fprintf(ofp, "%s", str), length += strlen(str);
|
Fprintf(ofp, "%s", str), length += strlen(str);
|
||||||
str += strlen(str) + (word ? 1 : 0);
|
str += strlen(str) + (word ? 1 : 0);
|
||||||
}
|
}
|
||||||
Fprintf(ofp, (i < SIZE(build_opts) - 1) ? "," : "."), length++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
winsyscnt = SIZE(window_opts) - 1;
|
winsyscnt = SIZE(window_opts) - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user