goodbye END-CHOOSE
Instead of an additional options file directive to end the last section of a CHOOSE directive, simplify by using an empty-name section, [], instead. So ... CHOOSE one,two [one] ... [two] ... [] ... As with the short-lived END-CHOOSE directive, if no [] is present then the rest of the file is part of the last choice.
This commit is contained in:
+16
-16
@@ -1,4 +1,4 @@
|
|||||||
.\" $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.394 $ $NHDT-Date: 1596754607 2020/08/06 22:56:47 $
|
.\" $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.395 $ $NHDT-Date: 1596785362 2020/08/07 07:29:22 $
|
||||||
.\"
|
.\"
|
||||||
.\" This is an excerpt from the 'roff' man page from the 'groff' package.
|
.\" This is an excerpt from the 'roff' man page from the 'groff' package.
|
||||||
.\" Guidebook.mn currently does *not* fully adhere to these guidelines.
|
.\" Guidebook.mn currently does *not* fully adhere to these guidelines.
|
||||||
@@ -3130,16 +3130,20 @@ the configuration file for you using the default template file.
|
|||||||
.pg
|
.pg
|
||||||
On MS-DOS, it is \(lqdefaults.nh\(rq in the same folder as nethack.exe.
|
On MS-DOS, it is \(lqdefaults.nh\(rq in the same folder as nethack.exe.
|
||||||
.pg
|
.pg
|
||||||
Any line in the configuration file starting with \(oq#\(cq is treated
|
Any line in the configuration file starting with \(oq\f(CR#\fP\(cq is treated
|
||||||
as a comment.
|
as a comment and ignored.
|
||||||
Empty lines are ignored.
|
Empty lines are ignored.
|
||||||
.pg
|
.pg
|
||||||
Any line beginning with \(oq[\(cq and ending in \(oq]\(cq is considered
|
Any line beginning with \(oq\f(CR[\fP\(cq and ending in \(oq\f(CR]\fP\(cq
|
||||||
a section marker.
|
is a section marker (the closing \(oq\f(CR]\fP\(cq can be followed
|
||||||
|
by whitespace and then an arbitrary comment beginning with \(oq\f(CR#\fP\(cq).
|
||||||
The text between the square brackets is the section name.
|
The text between the square brackets is the section name.
|
||||||
Lines after a section marker belong to that section, and are
|
Section markers are only valid after a CHOOSE directive and their names
|
||||||
ignored unless a CHOOSE directive was used to select that section.
|
are case insensitive.
|
||||||
Section names are case insensitive.
|
Lines after a section marker belong to that section up until another
|
||||||
|
section starts or a marker without a name is encountered or the file ends.
|
||||||
|
Lines within sections are ignored unless a CHOOSE directive has selected
|
||||||
|
that section.
|
||||||
.pg
|
.pg
|
||||||
You can use different configuration directives in the file, some
|
You can use different configuration directives in the file, some
|
||||||
of which can be used multiple times.
|
of which can be used multiple times.
|
||||||
@@ -3232,17 +3236,13 @@ CHOOSE=char A,char B
|
|||||||
OPTIONS=role:arc,race:dwa,align:law,gender:fem
|
OPTIONS=role:arc,race:dwa,align:law,gender:fem
|
||||||
[char B]
|
[char B]
|
||||||
OPTIONS=role:wiz,race:elf,align:cha,gender:mal
|
OPTIONS=role:wiz,race:elf,align:cha,gender:mal
|
||||||
END-CHOOSE
|
[] #end of CHOOSE
|
||||||
OPTIONS=!rest_on_space
|
OPTIONS=!rest_on_space
|
||||||
.ft \" revert to previous font
|
.ft \" revert to previous font
|
||||||
.ed
|
.ed
|
||||||
.lp END-CHOOSE
|
.lp ""
|
||||||
An optional way to terminate CHOOSE.
|
If \f(CR[]\fP is present, the preceding section is closed and no new
|
||||||
.\" use of the \% prefix prevents END-CHOOSE from being hyphenated across
|
section begins; whatever follows will be common to all sections.
|
||||||
.\" line boundary despite its hyphen; needed for the plain text output to
|
|
||||||
.\" avoid splitting the directive name
|
|
||||||
You can place an \%END-CHOOSE directive after the last CHOOSE section in
|
|
||||||
order to follow that with other options which are common to all sections.
|
|
||||||
Otherwise the last section extends to the end of the options file.
|
Otherwise the last section extends to the end of the options file.
|
||||||
.lp MENUCOLOR
|
.lp MENUCOLOR
|
||||||
Highlight menu lines with different colors.
|
Highlight menu lines with different colors.
|
||||||
|
|||||||
+18
-12
@@ -3355,12 +3355,20 @@ On MS-DOS it is \mbox{``defaults.nh''} in the same folder as
|
|||||||
\mbox{{\it nethack.exe\/}}.\\
|
\mbox{{\it nethack.exe\/}}.\\
|
||||||
|
|
||||||
%.lp ""
|
%.lp ""
|
||||||
Any line in the configuration file starting with `{\tt \#}' is treated as a comment.
|
Any line in the configuration file starting with `{\tt \#}' is treated
|
||||||
Empty lines are ignored. Any line beginning with `{\tt [}' and ending in `{\tt ]}' is considered a section
|
as a comment and ignored.
|
||||||
marker. The text between the square brackets is the section name.
|
Empty lines are ignored.
|
||||||
Lines after a section marker belong to that section, and are
|
|
||||||
ignored unless a CHOOSE -directive was used to select that section.
|
Any line beginning with `{\tt [}' and ending in `{\tt ]}'
|
||||||
Section names are case insensitive.
|
is a section marker (the closing `{\tt ]}' can be followed
|
||||||
|
by whitespace and then an arbitrary comment beginning with `{\tt #}').
|
||||||
|
The text between the square brackets is the section name.
|
||||||
|
Section markers are only valid after a CHOOSE directive and their names
|
||||||
|
are case insensitive.
|
||||||
|
Lines after a section marker belong to that section up until another
|
||||||
|
section starts or a marker without a name is encountered or the file ends.
|
||||||
|
Lines within sections are ignored unless a CHOOSE directive has selected
|
||||||
|
that section.
|
||||||
|
|
||||||
%.pg
|
%.pg
|
||||||
You can use different configuration directives in the file, some
|
You can use different configuration directives in the file, some
|
||||||
@@ -3474,16 +3482,14 @@ Example:
|
|||||||
OPTIONS=role:arc,race:dwa,align:law,gender:fem
|
OPTIONS=role:arc,race:dwa,align:law,gender:fem
|
||||||
[char B]
|
[char B]
|
||||||
OPTIONS=role:wiz,race:elf,align:cha,gender:mal
|
OPTIONS=role:wiz,race:elf,align:cha,gender:mal
|
||||||
END-CHOOSE
|
[] #end of CHOOSE
|
||||||
OPTIONS=!rest_on_space
|
OPTIONS=!rest_on_space
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
%.ed
|
%.ed
|
||||||
|
|
||||||
%.lp
|
%.lp ""
|
||||||
\item[\bb{END-CHOOSE}]
|
If {\tt []} is present, the preceding section is closed and no new
|
||||||
An optional way to terminate CHOOSE.
|
section begins; whatever follows will be common to all sections.
|
||||||
You can place an END-CHOOSE directive after the last CHOOSE section in
|
|
||||||
order to follow that with other options which are common to all sections.
|
|
||||||
Otherwise the last section extends to the end of the options file.
|
Otherwise the last section extends to the end of the options file.
|
||||||
|
|
||||||
%.lp
|
%.lp
|
||||||
|
|||||||
+5
-5
@@ -1,4 +1,4 @@
|
|||||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.275 $ $NHDT-Date: 1596754606 2020/08/06 22:56:46 $
|
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.276 $ $NHDT-Date: 1596785361 2020/08/07 07:29:21 $
|
||||||
|
|
||||||
General Fixes and Modified Features
|
General Fixes and Modified Features
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
@@ -459,11 +459,11 @@ add 'Sokoban' conduct, tracking the number of times the special Sokoban rules
|
|||||||
reduce verbosity when a mind flayer attacks a headless monster; when a
|
reduce verbosity when a mind flayer attacks a headless monster; when a
|
||||||
tentacle-to-head attack hits but fails to accomplish anything skip
|
tentacle-to-head attack hits but fails to accomplish anything skip
|
||||||
remaining attacks (mind flayer has 3, master mind flayer has 5)
|
remaining attacks (mind flayer has 3, master mind flayer has 5)
|
||||||
add END-CHOOSE directive for run-time config file; CHOOSE section1,section2
|
add section marker [] support to run-time config file; CHOOSE section1,section2
|
||||||
followed by [section1] ... [section2] ... forced all the rest of the
|
followed by [section1] ... [section2] ... forced all the rest of the
|
||||||
file to be part of the last section; that still works the same but
|
file to be part of the last section; that still works the same, but []
|
||||||
END-CHOOSE can be used to terminate the last section and revert to
|
can be used to terminate the last section and revert to common options
|
||||||
common options for the remainder of the file
|
for the remainder of the file
|
||||||
|
|
||||||
|
|
||||||
Platform- and/or Interface-Specific New Features
|
Platform- and/or Interface-Specific New Features
|
||||||
|
|||||||
+9
-35
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 files.c $NHDT-Date: 1596754598 2020/08/06 22:56:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.317 $ */
|
/* NetHack 3.7 files.c $NHDT-Date: 1596785343 2020/08/07 07:29:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.318 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -164,7 +164,6 @@ static boolean FDECL(config_error_nextline, (const char *));
|
|||||||
static void NDECL(free_config_sections);
|
static void NDECL(free_config_sections);
|
||||||
static char *FDECL(choose_random_part, (char *, CHAR_P));
|
static char *FDECL(choose_random_part, (char *, CHAR_P));
|
||||||
static char *FDECL(is_config_section, (char *));
|
static char *FDECL(is_config_section, (char *));
|
||||||
static boolean FDECL(is_end_of_sections, (const char *));
|
|
||||||
static boolean FDECL(handle_config_section, (char *));
|
static boolean FDECL(handle_config_section, (char *));
|
||||||
static char *FDECL(find_optparam, (const char *));
|
static char *FDECL(find_optparam, (const char *));
|
||||||
static void FDECL(parseformat, (int *, char *));
|
static void FDECL(parseformat, (int *, char *));
|
||||||
@@ -2328,7 +2327,7 @@ char *str; /* trailing spaces will be stripped, ']' too iff result is good */
|
|||||||
return (char *) 0;
|
return (char *) 0;
|
||||||
/* last character should be close bracket, ignoring any comment */
|
/* last character should be close bracket, ignoring any comment */
|
||||||
z = index(a, ']');
|
z = index(a, ']');
|
||||||
if (!z || z == a)
|
if (!z)
|
||||||
return (char *) 0;
|
return (char *) 0;
|
||||||
for (c = z + 1; *c && *c != '#'; ++c)
|
for (c = z + 1; *c && *c != '#'; ++c)
|
||||||
continue;
|
continue;
|
||||||
@@ -2342,46 +2341,27 @@ char *str; /* trailing spaces will be stripped, ']' too iff result is good */
|
|||||||
return trimspaces(a);
|
return trimspaces(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean
|
|
||||||
is_end_of_sections(buf)
|
|
||||||
const char *buf;
|
|
||||||
{
|
|
||||||
/* "END-CHOOSE"; bypass match_optname()/match_varname();
|
|
||||||
accepts "ENDCHOOSE", "END CHOOSE", "END-CHOOSE", "END_CHOOSE" */
|
|
||||||
if (!strncmpi(buf, "END", 3) && buf[3]) {
|
|
||||||
boolean sep = index(" -_", buf[3]) != 0;
|
|
||||||
|
|
||||||
if (!strcmpi(&buf[sep ? 4 : 3], "CHOOSE")) {
|
|
||||||
if (!g.config_section_current)
|
|
||||||
config_error_add("END-CHOOSE when not in a CHOOSE section");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
handle_config_section(buf)
|
handle_config_section(buf)
|
||||||
char *buf;
|
char *buf;
|
||||||
{
|
{
|
||||||
boolean was_in_section = (g.config_section_current != 0);
|
|
||||||
char *sect = is_config_section(buf);
|
char *sect = is_config_section(buf);
|
||||||
|
|
||||||
if (sect) {
|
if (sect) {
|
||||||
if (g.config_section_current)
|
if (g.config_section_current)
|
||||||
free(g.config_section_current);
|
free(g.config_section_current), g.config_section_current = 0;
|
||||||
/* is_config_section() removed brackets from 'sect' */
|
/* is_config_section() removed brackets from 'sect' */
|
||||||
if (!g.config_section_chosen) {
|
if (!g.config_section_chosen) {
|
||||||
config_error_add("Section \"[%s]\" without CHOOSE", sect);
|
config_error_add("Section \"[%s]\" without CHOOSE", sect);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
g.config_section_current = dupstr(sect);
|
if (*sect) { /* got a section name */
|
||||||
debugpline1("set config section: '%s'", g.config_section_current);
|
g.config_section_current = dupstr(sect);
|
||||||
return TRUE;
|
debugpline1("set config section: '%s'", g.config_section_current);
|
||||||
} else if (is_end_of_sections(buf)) {
|
} else { /* empty section name => end of sections */
|
||||||
if (was_in_section)
|
free_config_sections();
|
||||||
debugpline0("unset config section");
|
debugpline0("unset config section");
|
||||||
free_config_sections();
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2436,12 +2416,6 @@ char *origbuf;
|
|||||||
but spaces, one of them will be kept even though it leads/trails) */
|
but spaces, one of them will be kept even though it leads/trails) */
|
||||||
mungspaces(buf);
|
mungspaces(buf);
|
||||||
|
|
||||||
/* "END-CHOOSE" doesn't have a value so we need to check for it
|
|
||||||
before checking for that; if found here, is_end_of_sections()
|
|
||||||
will report a config_error */
|
|
||||||
if (is_end_of_sections(buf))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* find the '=' or ':' */
|
/* find the '=' or ':' */
|
||||||
bufp = find_optparam(buf);
|
bufp = find_optparam(buf);
|
||||||
if (!bufp) {
|
if (!bufp) {
|
||||||
|
|||||||
Reference in New Issue
Block a user