Give feedback just before timed levitation runs out
[aNetHack.git] / util / mdgrep.pl
blob429c87374ee25ab4319ef99fe0d217d0a89e4713
1 #!perl
2 # NetHack 3.6 mdgrep.pl $NHDT-Date: 1423877528 2015/02/14 01:32:08 $ $NHDT-Branch$:$NHDT-Revision: 1.7 $
3 # Copyright (c) Kenneth Lorber, Kensington, Maryland
4 # NetHack may be freely redistributed. See license for details.
6 # MAKEDEFS:
7 @commands = qw/grep/;
9 # GREP:
10 # Operating Systems:
11 @os = qw/WIN32 MSDOS VMS UNIX TOS AMIGA MAC WINNT __BEOS__ WIN_CE OS2
12 WIN_CE_SMARTPHONE WIN_CE_POCKETPC WIN_CE_PS2xx
13 WIN32_PLATFORM_HPCPRO WIN32_PLATFORM_WFSP/;
15 # Window Systems:
16 @win = qw/TTY_GRAPHICS MAC_GRAPHICS AMII_GRAPHICS MSWIN_GRAPHICS X11_GRAPHICS
17 QT_GRAPHICS GNOME_GRAPHICS GEM_GRAPHICS/;
19 # Game Features:
20 @feature = qw/ZEROCOMP USE_TILES ASCIIGRAPH CLIPPING TEXTCOLOR
21 COMPRESS ZLIB_COMP RANDOM SECURE USER_SOUNDS
22 SAFERHANGUP MFLOPPY NOCWD_ASSUMPTIONS
23 VAR_PLAYGROUND DLB SHELL SUSPEND NOSAVEONHANGUP HANGUPHANDLING
24 BSD_JOB_CONTROL MAIL POSIX_JOB_CONTROL INSURANCE
25 UNICODE_DRAWING UNICODE_WIDEWINPORT UNICODE_PLAYERTEXT
28 # Miscellaneous
29 @misc = qw/BETA/;
31 # Meta
32 @meta = qw/ALLDOCS/; # convention: use --grep-define ALLDOCS to notate
33 # items that are conditionally available
35 # JUNK:
36 # MICRO BSD __GNUC__ NHSTDC TERMLIB __linux__ LINUX WIN32CON NO_TERMS
37 # ULTRIX_PROTO TERMINFO _DCC DISPMAP OPT_DISPMAP TARGET_API_MAC_CARBON
38 # NOTTYGRAPHICS SYSV ULTRIX MAKEDEFS LEV_LEX_C __STDC__
39 # BITCOUNT TILE_X COLORS_IN_USE CHDIR KR1ED
40 # apollo __APPLE__ AIX_31 PC9800 __MACH__ _GNU_SOURCE __EMX__ DGUX
41 # __MWERKS__ __MRC__ __BORLANDC__ LINT THINK_C __SC__ AZTEC_C __FreeBSD__
42 # USE_PROTOTYPES __DJGPP__ macintosh POSIX_TYPES SUNOS4 _MSC_VER __OpenBSD__
43 # GCC_WARN VOIDYYPUT FLEX_SCANNER FLEXHACK_SCANNER WIERD_LEX
44 # NeXT __osf__ SVR4 _AIX32 _BULL_SOURCE AUX __sgi GNUDOS
45 # TIMED_DELAY DEF_MAILREADER DEF_PAGER NO_SIGNAL PC_LOCKING LATTICE __GO32__
46 # msleep NO_FILE_LINKS bsdi HPUX AMIFLUSH SYSFLAGS
47 # OVERLAY USE_TRAMPOLI USE_OVLx SPEC_LEV DGN_COMP
48 # SCREEN_BIOS SCREEN_DJGPPFAST SCREEN_VGA SCREEN_8514
49 # EXEPATH NOTSTDC SELECTSAVED NOTPARMDECL
51 # constants
52 @const_true = qw/1 TRUE/;
53 @const_false = qw/0 FALSE/;
55 $outfile = "mdgrep.h";
56 sub start_file {
57 ($rev) = ('$NHDT-Revision: 1.7 $') =~ m/: (.*) .$/;
58 my $date = '$NHDT-Date: 1423877529 2015/02/14 01:32:09 $';
59 my $branch = '$NHDT-Branch$';
60 my $revision = '$NHDT-Revision: 1.7 $';
61 open(OUT, ">$outfile") || die "open $outfile: $!";
62 # NB: Date and Revision below will be modified when mdgrep.h is written to
63 # git - this is correct (but it means you must commit changes to mdgrep.pl
64 # before generating mdgrep.h and committing that file).
65 print OUT <<E_O_M;
67 * NetHack 3.6 $outfile $date $branch:$revision
68 * Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008
69 * NetHack may be freely redistributed. See license for details.
71 * This file generated by mdgrep.pl version $rev.
72 * DO NOT EDIT! Your changes will be lost.
74 E_O_M
77 sub end_file {
78 print OUT "/* End of file */\n";
79 close OUT;
82 sub gen_magic {
83 local($v, @x) = @_;
84 foreach (@x){
85 $magic{$_} = $v;
89 # NB: Do NOT make grep_vars const - it needs to be writable for some debugging
90 # options.
91 sub gen_file {
92 print OUT "static struct grep_var grep_vars[]={\n";
93 foreach(@_){
94 if(defined $magic{$_}){
95 print OUT <<E_O_M;
96 {"$_", $magic{$_}},
97 E_O_M
98 next;
100 print OUT <<E_O_M;
101 #if defined($_)
102 {"$_", 1},
103 #else
104 {"$_", 0},
105 #endif
106 E_O_M
108 print OUT "\t{0,0}\n};\n";
111 sub gen_commands {
112 local($x) = 1;
113 print OUT "\n/* Command ids */\n";
114 foreach(@commands){
115 print OUT "#define TODO_\U$_\E $x\n";
117 print OUT "\n";
120 &start_file;
121 &gen_magic(0, @const_false);
122 &gen_magic(1, @const_true);
123 &gen_file(sort(@os,@win,@feature,@misc,@meta,@const_false,@const_true));
124 &gen_commands;
125 &end_file;