add makedefs options for producing individual files

This may be useful for some build environments to avoid parallel make
issues, and artificially-concocted order dependencies, leaving the ordering
up to that specified in the Makefile.

The related makedefs options are now:

       ‐s     Generate the bogusmon , engrave and epitaph files.

       ‐1     Generate the epitaph file.

       ‐2     Generate the engrave file.

       ‐3     Generate the bogusmon file.

Also resolves an existing issue encountered in doc/makedefs.6 where "and epitaphfiles"
was being produced in the result.
This commit is contained in:
nhmall
2024-05-13 08:45:11 -04:00
parent 97916007ef
commit 29bf3646e0
3 changed files with 80 additions and 34 deletions
+20 -1
View File
@@ -116,7 +116,26 @@ Generate the
, ,
.I engrave .I engrave
and and
.IR epitaph files. .IR epitaph
files.
.br
.TP
.B -1
Generate the
.IR epitaph
file.
.br
.TP
.B -2
Generate the
.IR engrave
file.
.br
.TP
.B -3
Generate the
.IR bogusmon
file.
.br .br
.TP .TP
.B -h .B -h
+6 -6
View File
@@ -103,14 +103,14 @@ rumors: rumors.tru rumors.fal ../util/makedefs
oracles: oracles.txt ../util/makedefs oracles: oracles.txt ../util/makedefs
../util/makedefs -h ../util/makedefs -h
engrave: engrave.txt ../util/makedefs engrave: ../util/makedefs
../util/makedefs -s ../util/makedefs -2
epitaph: epitaph.txt ../util/makedefs epitaph: ../util/makedefs
../util/makedefs -s ../util/makedefs -1
bogusmon: bogusmon.txt ../util/makedefs bogusmon: ../util/makedefs
../util/makedefs -s ../util/makedefs -3
options: ../util/makedefs options: ../util/makedefs
../util/makedefs -v ../util/makedefs -v
+54 -27
View File
@@ -169,7 +169,9 @@ static void do_ext_makedefs(int, char **);
static char *padline(char *, unsigned); static char *padline(char *, unsigned);
static unsigned long read_rumors_file(const char *, int *, static unsigned long read_rumors_file(const char *, int *,
long *, unsigned long, unsigned); long *, unsigned long, unsigned);
static void do_rnd_access_file(const char *, const char *, unsigned); static void rafile(int);
static void do_rnd_access_file(const char *, const char *,
const char *, unsigned);
static boolean d_filter(char *); static boolean d_filter(char *);
static boolean h_filter(char *); static boolean h_filter(char *);
static void opt_out_words(char *, int *); static void opt_out_words(char *, int *);
@@ -327,24 +329,14 @@ do_makedefs(char *options)
break; break;
case 's': case 's':
case 'S': case 'S':
/* rafile('1');
* post-3.6.5: rafile('2');
* File must not be empty to avoid divide by 0 rafile('3');
* in core's rn2(), so provide a default entry. break;
*/ case '1':
do_rnd_access_file(EPITAPHFILE, case '2':
/* default epitaph: parody of the default engraving */ case '3':
"No matter where I went, here I am.", rafile(*options);
MD_PAD_RUMORS); /* '_RUMORS' is correct here */
do_rnd_access_file(ENGRAVEFILE,
/* default engraving: popularized by "The Adventures of
Buckaroo Bonzai Across the 8th Dimension" but predates
that 1984 movie; some attribute it to Confucius */
"No matter where you go, there you are.",
MD_PAD_RUMORS); /* '_RUMORS' used here too */
do_rnd_access_file(BOGUSMONFILE,
/* default bogusmon: iconic monster that isn't in nethack */
"grue", MD_PAD_BOGONS);
break; break;
#if defined(OLD_MAKEDEFS_OPTIONS) #if defined(OLD_MAKEDEFS_OPTIONS)
case 'o': case 'o':
@@ -417,6 +409,37 @@ oldfunctionality(char sought)
} }
#endif /* !OLD_MAKEDEFS_OPTIONS */ #endif /* !OLD_MAKEDEFS_OPTIONS */
static void
rafile(int whichone)
{
switch(whichone) {
/*
* post-3.6.5:
* File must not be empty to avoid divide by 0
* in core's rn2(), so provide a default entry.
*/
case '1':
do_rnd_access_file(EPITAPHFILE, "epitaph",
/* default epitaph: parody of the default engraving */
"No matter where I went, here I am.",
MD_PAD_RUMORS); /* '_RUMORS' is correct here */
break;
case '2':
do_rnd_access_file(ENGRAVEFILE, "engrave",
/* default engraving: popularized by "The Adventures of
Buckaroo Bonzai Across the 8th Dimension" but predates
that 1984 movie; some attribute it to Confucius */
"No matter where you go, there you are.",
MD_PAD_RUMORS); /* '_RUMORS' used here too */
break;
case '3':
do_rnd_access_file(BOGUSMONFILE, "bogusmon",
/* default bogusmon: iconic monster that isn't in nethack */
"grue", MD_PAD_BOGONS);
break;
}
}
static char namebuf[1000]; static char namebuf[1000];
DISABLE_WARNING_FORMAT_NONLITERAL DISABLE_WARNING_FORMAT_NONLITERAL
@@ -1057,11 +1080,14 @@ read_rumors_file(
static void static void
do_rnd_access_file( do_rnd_access_file(
const char *fname, const char *fname,
const char *basefname,
const char *deflt_content, const char *deflt_content,
unsigned padlength) unsigned padlength)
{ {
char *line, buf[BUFSZ], xbuf[BUFSZ]; char *line, buf[BUFSZ], xbuf[BUFSZ],
greptmp[8 + 1 + 3 + 1];
Sprintf(greptmp, "grep-%.3s.tmp", basefname);
Sprintf(filename, DATA_IN_TEMPLATE, fname); Sprintf(filename, DATA_IN_TEMPLATE, fname);
Strcat(filename, ".txt"); Strcat(filename, ".txt");
if (!(ifp = fopen(filename, RDTMODE))) { if (!(ifp = fopen(filename, RDTMODE))) {
@@ -1089,12 +1115,12 @@ do_rnd_access_file(
Strcat(buf, "\n"); /* so make sure that the default one does too */ Strcat(buf, "\n"); /* so make sure that the default one does too */
(void) fputs(xcrypt(padline(buf, padlength), xbuf), ofp); (void) fputs(xcrypt(padline(buf, padlength), xbuf), ofp);
tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE, FLG_TEMPFILE); tfp = getfp(DATA_TEMPLATE, greptmp, WRTMODE, FLG_TEMPFILE);
grep0(ifp, tfp, FLG_TEMPFILE); grep0(ifp, tfp, FLG_TEMPFILE);
#ifndef HAS_NO_MKSTEMP #ifndef HAS_NO_MKSTEMP
ifp = tfp; ifp = tfp;
#else #else
ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE, 0); ifp = getfp(DATA_TEMPLATE, greptmp, RDTMODE, 0);
#endif #endif
set_fgetline_context(NULL, FALSE, FALSE); set_fgetline_context(NULL, FALSE, FALSE);
@@ -1109,7 +1135,7 @@ do_rnd_access_file(
Fclose(ofp); Fclose(ofp);
#ifdef HAS_NO_MKSTEMP #ifdef HAS_NO_MKSTEMP
delete_file(DATA_TEMPLATE, "grep.tmp"); delete_file(DATA_TEMPLATE, greptmp);
#endif #endif
return; return;
} }
@@ -2037,8 +2063,9 @@ text-b/text-c at fseek(0x01234567L + 456L)
void void
do_dungeon(void) do_dungeon(void)
{ {
char *line; char *line, greptmp[8 + 1 + 3 + 1];
Sprintf(greptmp, "grep-%.3s.tmp", "dun");
Sprintf(filename, DATA_IN_TEMPLATE, DGN_I_FILE); Sprintf(filename, DATA_IN_TEMPLATE, DGN_I_FILE);
if (!(ifp = fopen(filename, RDTMODE))) { if (!(ifp = fopen(filename, RDTMODE))) {
perror(filename); perror(filename);
@@ -2057,12 +2084,12 @@ do_dungeon(void)
} }
Fprintf(ofp, "%s", Dont_Edit_Data); Fprintf(ofp, "%s", Dont_Edit_Data);
tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE, FLG_TEMPFILE); tfp = getfp(DATA_TEMPLATE, greptmp, WRTMODE, FLG_TEMPFILE);
grep0(ifp, tfp, FLG_TEMPFILE); grep0(ifp, tfp, FLG_TEMPFILE);
#ifndef HAS_NO_MKSTEMP #ifndef HAS_NO_MKSTEMP
ifp = tfp; ifp = tfp;
#else #else
ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE, 0); ifp = getfp(DATA_TEMPLATE, greptmp, RDTMODE, 0);
#endif #endif
set_fgetline_context(NULL, FALSE, TRUE); set_fgetline_context(NULL, FALSE, TRUE);
while ((line = fgetline(ifp)) != 0) { while ((line = fgetline(ifp)) != 0) {
@@ -2079,7 +2106,7 @@ do_dungeon(void)
Fclose(ofp); Fclose(ofp);
#ifdef HAS_NO_MKSTEMP #ifdef HAS_NO_MKSTEMP
delete_file(DATA_TEMPLATE, "grep.tmp"); delete_file(DATA_TEMPLATE, greptmp);
#endif #endif
return; return;
} }