diff --git a/doc/makedefs.6 b/doc/makedefs.6 new file mode 100644 index 000000000..3c42ca26b --- /dev/null +++ b/doc/makedefs.6 @@ -0,0 +1,235 @@ +.TH MAKEDEFS 6 "29 Apr 2010" +.\" NetHack 3.5 makedefs.6 $Date$ $Revision$ +.UC 4 +.SH NAME +makedefs \- NetHack miscellaneous build-time functions +.SH SYNOPSIS +.B makedefs +{ +.B -o +| +.B -d +| +.B -e +| +.B -m +| +.B -v +| +.B -p +| +.B -q +| +.B -r +| +.B -h +| +.B -z +} +.P +.B makedefs --input +.I file +.B --output +.I file +.BI -- command +.SH DESCRIPTION +.PP +.B Makedefs +is a build-time tool used for a variety of +.BR NetHack (6) +source file creation and modification tasks. For historical reasons, +.B makedefs +takes two types of command lines. When invoked with a short option, the +files operated on are determined when +.B makedefs +is compiled. When invoked with a long option, the +.B --input +and +.B --output +options are used to specify the files for the +.BI -- command. +Each command is only available in one of the two formats. +.SH SHORT COMMANDS +Upper and lower case are both accepted for the short commands. +.TP +.B -o +Generate +.I onames.h. +.br +.TP +.B -d +Generate +.I data.base. +.br +.TP +.B -e +Generate +.I dungeon.pdf. +The input file +.I dungeon.def +is passed through the +same logic as that used by the +.B --grep +command; see the +.B MDGREP FUNCTIONS +section below for details. +.br +.TP +.B -m +Generate +.I monster.c. +.br +.TP +.B -v +Generate +.I date.h +and +.I options +file. +.br +.TP +.B -p +Generate +.I pm.h +.br +.TP +.B -q +Generate +.IR quest.dat . +.br +.TP +.B -r +Generate the +.I rumors +file. +.br +.TP +.B -h +Generate the +.B oracles +file. +.br +.TP +.B -z +Generate +.I vis_tab.c +and +.IR vis_tab.h . +.SH LONG COMMANDS +.TP +.BI --input " file" +Specify the input +.I file +for the command (if needed). If the file is - standard +input is read. +.br +.TP +.BI --output " file" +Specify the output +.I file +for the command (if needed). If the file is - standard +output is written. +.br +.TP +.B --svs \fR[\fIdelimiter\fR] +Generate a version string to standard output without a trailing newline. +If specified, the delimiter is used between each part of the version string. +.br +.TP +.B --grep +Filter the input +.I file to the output +.IR file . +See the +.B MDGREP FUNCTIONS +section below for information on controlling the filtering operation. +.br +.TP +.B --grep-showvars +Show the name and value for each variable known to the grep option. +.br +.TP +.B --grep-trace +Turn on debug tracing for the grep function ( +.B --grep +must be specified as well). +.br +.TP +.BI --grep-define " symbol" +Force the value of +.I symbol +to be "defined." +.I Symbol +must already be known to +.BR makedefs . +.br +.TP +.BI --grep-undef " symbol" +Force the definition of +.I symbol +to be "undefined." +.I Symbol +must already be known to +.BR makedefs . +.SH MDGREP FUNCTIONS +The +.B --grep +command (and certain other commands) filter their input, on a line-by-line +basis, according to control lines embedded in the input and on information +gleaned from the +.BR NetHack (6) +configuration. This allows certain changes such as embedding platform-specific +documentation into the master documentation files. +.P +Rules: +.RS +.IP - 4 +The default conditional state is printing enabled. +.IP - 4 +Any line +.I NOT +starting with a caret (^) is either suppressed or passed through unchanged +depending on the current conditional state. +.IP - 4 +Any line starting with a caret is a control line; as in C, zero or more spaces +may be embedded in the line almost anywhere (except immediately after the +caret); however the caret must be in column 1. +.IP - 4 +Conditionals may be nested. +.IP - 4 +.I Makedefs +will exit with an error code if any errors are detected; processing will +continue (if it can) to allow as many errors as possible to be detected. +.IP - 4 +Unknown identifiers are treated as both TRUE and as an error. Note that +.BR --undef " or " #undef +in the +.BR NetHack (6) +configuration are different from unknown. +.RE +.P +Control lines: +.RS +.IP ^^ 4 +a line starting with a (single) literal caret +.IP ^# +a comment +.IP ^?\fIID +if the +.I ID +is defined set the conditional state to TRUE +.IP ^!\fIID +if the +.I ID +is not defined set the conditional state to TRUE +.IP ^: +else; invert the conditional state +.IP ^. +end the most recent conditional +.RE +.\".SH EXAMPLES +.SH AUTHOR +The NetHack Development Team +.SH "SEE ALSO" +.PP +.BR dgn_comp (6) diff --git a/sys/unix/Makefile.doc b/sys/unix/Makefile.doc index aa5da9445..f1d64f705 100644 --- a/sys/unix/Makefile.doc +++ b/sys/unix/Makefile.doc @@ -1,6 +1,5 @@ # NetHack Makefile. # NetHack 3.5 Makefile.doc $Date$ $Revision$ -# SCCS Id: @(#)Makefile.doc 3.5 2007/05/25 # Root of source tree: NHSROOT=.. @@ -68,12 +67,14 @@ LEVMANCREATE = cat lev_comp.6 | $(NHGREP) > DGNMANCREATE = cat dgn_comp.6 | $(NHGREP) > RCVRMANCREATE = cat recover.6 | $(NHGREP) > DLBMANCREATE = cat dlb.6 | $(NHGREP) > +MDMANCREATE = cat makedefs.6 | $(NHGREP) > # manual installation for most SYSV-style systems # GAMEMANCREATE = cat nethack.6 | $(NHGREP) | nroff -man - > # LEVMANCREATE = cat lev_comp.6 | $(NHGREP) | nroff -man - > # DGNMANCREATE = cat dgn_comp.6 | $(NHGREP) | nroff -man - > # RCVRMANCREATE = cat recover.6 | $(NHGREP) | nroff -man - > # DLBMANCREATE = cat dlb.6 | $(NHGREP) | nroff -man - > +MDMANCREATE = cat makedefs.6 | $(NHGREP) | nroff -man - > manpages: -$(GAMEMANCREATE) $(MANDIR)/$(GAME).$(MANEXT) @@ -81,9 +82,11 @@ manpages: -$(DGNMANCREATE) $(MANDIR)/dgn_comp.$(MANEXT) -$(RCVRMANCREATE) $(MANDIR)/recover.$(MANEXT) -$(DLBMANCREATE) $(MANDIR)/dlb.$(MANEXT) + -$(MDMANCREATE) $(MANDIR)/makedefs.$(MANEXT) # manual creation for distribution -DISTRIB = Guidebook.txt nethack.txt lev_comp.txt dgn_comp.txt recover.txt dlb.txt +DISTRIB = Guidebook.txt nethack.txt lev_comp.txt dgn_comp.txt recover.txt \ + dlb.txt makedefs.txt distrib: $(DISTRIB) @echo "Plain text documentation is up to date." @@ -101,6 +104,8 @@ recover.txt : recover.6 cat recover.6 | $(MAN2TXT) > recover.txt dlb.txt : dlb.6 cat dlb.6 | $(MAN2TXT) > dlb.txt +makedefs.txt : makedefs.6 + cat makedefs.6 | $(MAN2TXT) > makedefs.txt clean: -rm -f Guidebook.aux Guidebook.log diff --git a/util/makedefs.c b/util/makedefs.c index 14e233600..9425fdc49 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -346,6 +346,41 @@ char *options; } +static char namebuf[1000]; +static char * +name_file(template, tag) + char *template; + char *tag; +{ + Sprintf(namebuf, template, tag); + return namebuf; +} + +static void +delete_file(template, tag) + char *template; + char *tag; +{ + char *name = name_file(template, tag); + Unlink(name); +} + +static FILE * +getfp(template, tag, mode) + char *template; + char *tag; + char *mode; +{ + char *name = name_file(template, tag); + FILE *rv = fopen(name, mode); + if(!rv){ + Fprintf(stderr, "Can't open '%s'.\n", name); + exit(EXIT_FAILURE); + } + return rv; +} + + static FILE *inputfp; static FILE *outputfp; @@ -677,10 +712,10 @@ do_grep_rewrite(buf) } #endif +static void grep0(FILE *, FILE *); + static void do_grep(){ - char buf[16384]; /* looong, just in case */ - if(!inputfp){ Fprintf(stderr,"--grep requires --input\n"); } @@ -691,15 +726,25 @@ do_grep(){ exit(EXIT_FAILURE); } - while(!feof(inputfp) && !ferror(inputfp)){ + grep0(inputfp, outputfp); +} + +static void +grep0(inputfp0, outputfp0) + FILE *inputfp0; + FILE *outputfp0; +{ + char buf[16384]; /* looong, just in case */ + + while(!feof(inputfp0) && !ferror(inputfp0)){ char *tmp; char *buf1; - if(fgets(buf, sizeof(buf), inputfp) == 0) break; + if(fgets(buf, sizeof(buf), inputfp0) == 0) break; if( (tmp=strchr(buf,'\n')) ) *tmp = '\0'; grep_lineno++; if(grep_trace){ - Fprintf(outputfp, "%04d %c >%s\n", + Fprintf(outputfp0, "%04d %c >%s\n", grep_lineno, grep_writing?' ':'#', buf @@ -717,18 +762,18 @@ do_grep(){ do_grep_rewrite(buf1); #endif if(grep_writing) - Fprintf(outputfp, "%s\n", buf1); + Fprintf(outputfp0, "%s\n", buf1); } - if(ferror(inputfp)){ + if(ferror(inputfp0)){ Fprintf(stderr, "read error!\n"); exit(EXIT_FAILURE); } - if(ferror(outputfp)){ + if(ferror(outputfp0)){ Fprintf(stderr, "write error!\n"); exit(EXIT_FAILURE); } - fclose(inputfp); - fclose(outputfp); + fclose(inputfp0); + fclose(outputfp0); if(grep_sp){ Fprintf(stderr, "%d unterminated conditional level%s\n", grep_sp, grep_sp==1?"":"s"); @@ -1159,6 +1204,9 @@ static const char *build_opts[] = { #ifdef COM_COMPL "command line completion", #endif +#ifdef LIFE + "Conway's Game of Life", +#endif #ifdef COMPRESS "data file compression", #endif @@ -1765,6 +1813,10 @@ do_dungeon() } Fprintf(ofp,Dont_Edit_Data); + tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE); + grep0(ifp, tfp); + ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE); + while (fgets(in_line, sizeof in_line, ifp) != 0) { SpinCursor(3); @@ -1790,6 +1842,7 @@ recheck: Fclose(ifp); Fclose(ofp); + delete_file(DATA_TEMPLATE, "grep.tmp"); return; } diff --git a/util/mdgrep.h b/util/mdgrep.h index b9ba580cd..a70e1d645 100644 --- a/util/mdgrep.h +++ b/util/mdgrep.h @@ -1,9 +1,9 @@ /* * NetHack 3.5 mdgrep.h $Date$ $Revision$ - * Copyright (c) Kenneth Lorber, Kensington, Maryland + * Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008 * NetHack may be freely redistributed. See license for details. * - * This file generated by mdgrep.pl version 1.5. + * This file generated by mdgrep.pl version 1.7. * DO NOT EDIT! Your changes will be lost. */ static struct grep_var grep_vars[]={ @@ -70,6 +70,16 @@ static struct grep_var grep_vars[]={ #else {"HANGUPHANDLING", 0}, #endif +#if defined(INSURANCE) + {"INSURANCE", 1}, +#else + {"INSURANCE", 0}, +#endif +#if defined(LIFE) + {"LIFE", 1}, +#else + {"LIFE", 0}, +#endif #if defined(MAC) {"MAC", 1}, #else