diff --git a/sys/unix/hints/macosx b/sys/unix/hints/macosx index 10fac071d..594c6f8d2 100644 --- a/sys/unix/hints/macosx +++ b/sys/unix/hints/macosx @@ -45,7 +45,7 @@ GAMEGRP = $(GAMEUID) #CC=gcc -W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN -CC=gcc -Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN +CC=gcc -Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN # # You shouldn't need to change anything below here. @@ -131,10 +131,10 @@ ifdef WANT_WIN_X11 endif endif -CC=gcc -W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN # ~/Library/Preferences/NetHack Defaults # OPTIONS=name:player,number_pad,menustyle:partial,!time,showexp # OPTIONS=hilite_pet,toptenwin,msghistory:200,windowtype:Qt # -# Install.Qt mentions a patch for macos - it's not there. +# Install.Qt mentions a patch for macos - it's not there (it seems to be in the Qt binary +# package under the docs directory). diff --git a/util/lev_comp.l b/util/lev_comp.l index 4431a3fc9..9f6734f23 100644 --- a/util/lev_comp.l +++ b/util/lev_comp.l @@ -70,7 +70,7 @@ void FDECL(init_yyout, (FILE *)); */ extern YYSTYPE yylval; -int line_number = 1, colon_line_number = 1; +int nh_line_number = 1, colon_line_number = 1; static char map[4096]; static int map_cnt = 0; @@ -92,14 +92,14 @@ static int map_cnt = 0; int len = yyleng; /* convert \r\n to \n */ if (len >= 2 && yytext[len - 2] == '\r') len -= 1; - line_number++; + nh_line_number++; (void) strncpy(map + map_cnt, yytext, len); map_cnt += len; map[map_cnt - 1] = '\n'; map[map_cnt] = '\0'; } -^#.*\n { line_number++; } -: { colon_line_number = line_number; return ':'; } +^#.*\n { nh_line_number++; } +: { colon_line_number = nh_line_number; return ':'; } MESSAGE return MESSAGE_ID; MAZE return MAZE_ID; NOMAP return NOMAP_ID; @@ -107,7 +107,7 @@ LEVEL return LEVEL_ID; INIT_MAP return LEV_INIT_ID; FLAGS return FLAGS_ID; GEOMETRY return GEOMETRY_ID; -^MAP\r?\n { BEGIN(MAPC); line_number++; } +^MAP\r?\n { BEGIN(MAPC); nh_line_number++; } OBJECT return OBJECT_ID; CONTAINER return COBJECT_ID; MONSTER return MONSTER_ID; @@ -206,7 +206,7 @@ shortsighted { yylval.i=SHORTSIGHTED; return FLAG_TYPE; } yylval.map = (char *) alloc(strlen(yytext+1)+1); Strcpy(yylval.map, yytext+1); /* Discard the first \" */ return STRING; } -\r?\n { line_number++; } +\r?\n { nh_line_number++; } [ \t]+ ; '\\.' { yylval.i = yytext[2]; return CHAR; } '.' { yylval.i = yytext[1]; return CHAR; } diff --git a/util/lev_main.c b/util/lev_main.c index f08c88538..63a4ff331 100644 --- a/util/lev_main.c +++ b/util/lev_main.c @@ -209,7 +209,7 @@ extern unsigned int nfountain, npool, nsink; extern unsigned int max_x_map, max_y_map; -extern int line_number, colon_line_number; +extern int nh_line_number, colon_line_number; int main(argc, argv) @@ -282,7 +282,7 @@ char **argv; } else { init_yyin(fin); (void) yyparse(); - line_number = 1; + nh_line_number = 1; if (fatal_error > 0) { errors_encountered = TRUE; fatal_error = 0; @@ -308,7 +308,7 @@ yyerror(s) const char *s; { (void) fprintf(stderr, "%s: line %d : %s\n", fname, - (*s >= 'A' && *s <= 'Z') ? colon_line_number : line_number, s); + (*s >= 'A' && *s <= 'Z') ? colon_line_number : nh_line_number, s); if (++fatal_error > MAX_ERRORS) { (void) fprintf(stderr,"Too many errors, good bye!\n"); exit(EXIT_FAILURE); diff --git a/util/makedefs.c b/util/makedefs.c index c3acc3b14..2d2c0b2eb 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -348,9 +348,16 @@ char *options; static FILE *inputfp; static FILE *outputfp; -#define TODO_GREP 1; +struct grep_var { + const char *name; + int is_defined; /* 0 undef; 1 defined */ +}; +/* struct grep_var grep_vars[] and TODO_* constants in include file: */ +#include "mdgrep.h" + static void NDECL(do_grep); static void NDECL(do_grep_showvars); +static struct grep_var *FDECL(grepsearch, (char *)); static int grep_trace = 0; static void @@ -403,7 +410,7 @@ do_ext_makedefs(int argc, char **argv){ Fprintf(stderr, "Can't do grep and something else.\n"); exit(EXIT_FAILURE); } - todo = 1; + todo = TODO_GREP; CONTINUE; } IS_OPTION("grep-showvars"){ @@ -414,11 +421,29 @@ do_ext_makedefs(int argc, char **argv){ grep_trace = 1; CONTINUE; } -#ifdef notyet IS_OPTION("grep-define"){ + CONSUME; + struct grep_var *p = grepsearch(argv[0]); + if(p){ + p->is_defined = 1; + } else { + Fprintf(stderr, "Unknown symbol '%s'\n", argv[0]); + exit(EXIT_FAILURE); + } + CONTINUE; } IS_OPTION("grep-undef"){ + CONSUME; + struct grep_var *p = grepsearch(argv[0]); + if(p){ + p->is_defined = 0; + } else { + Fprintf(stderr, "Unknown symbol '%s'\n", argv[0]); + exit(EXIT_FAILURE); + } + CONTINUE; } +#ifdef notyet IS_OPTION("help"){ } #endif @@ -438,7 +463,7 @@ do_ext_makedefs(int argc, char **argv){ case 0: Fprintf(stderr, "Nothing to do?\n"); exit(EXIT_FAILURE); - case 1: + case TODO_GREP: do_grep(); break; } } @@ -473,7 +498,9 @@ do_ext_makedefs(int argc, char **argv){ */ #define GREP_MAGIC '^' #define GREP_STACK_SIZE 100 +#ifdef notyet static int grep_rewrite = 0; /* need to (possibly) rewrite lines */ +#endif static int grep_writing = 1; /* need to copy lines to output */ static int grep_errors = 0; static int grep_sp = 0; @@ -484,13 +511,6 @@ static int grep_sp = 0; static int grep_stack[GREP_STACK_SIZE] = {ST_LD(1,0)}; static int grep_lineno = 0; -struct grep_var { - const char *name; - int is_defined; /* 0 undef; 1 defined */ -}; -/* struct grep_var grep_vars[] in include file: */ -#include "mdgrep.h" - static void do_grep_showvars(){ int x; @@ -627,6 +647,7 @@ do_grep_control(buf) return NULL; } +#ifdef notyet static void do_grep_rewrite(buf) char *buf; @@ -634,6 +655,7 @@ do_grep_rewrite(buf) /* no language features use this yet */ return; } +#endif static void do_grep(){ @@ -670,8 +692,10 @@ do_grep(){ } else { buf1 = buf; } +#ifdef notyet if(grep_rewrite) do_grep_rewrite(buf1); +#endif if(grep_writing) Fprintf(outputfp, "%s\n", buf1); } diff --git a/util/mdgrep.h b/util/mdgrep.h index 70c08e448..5444d1d28 100644 --- a/util/mdgrep.h +++ b/util/mdgrep.h @@ -264,4 +264,7 @@ static struct grep_var grep_vars[]={ #endif {0,0} }; + +/* Command ids */ +#define TODO_GREP 1 /* End of file */ diff --git a/util/mdgrep.pl b/util/mdgrep.pl index 472a3611b..fc1475439 100644 --- a/util/mdgrep.pl +++ b/util/mdgrep.pl @@ -3,6 +3,10 @@ # Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008 # NetHack may be freely redistributed. See license for details. +# MAKEDEFS: +@commands = qw/grep/; + +# GREP: # Operating Systems: @os = qw/WIN32 MSDOS VMS UNIX TOS AMIGA MAC WINNT __BEOS__ WIN_CE OS2 WIN_CE_SMARTPHONE WIN_CE_POCKETPC WIN_CE_PS2xx @@ -67,6 +71,8 @@ sub gen_magic { } } +# NB: Do NOT make grep_vars const - it needs to be writable for some debugging +# options. sub gen_file { print OUT "static struct grep_var grep_vars[]={\n"; foreach(@_){ @@ -87,8 +93,18 @@ E_O_M print OUT "\t{0,0}\n};\n"; } +sub gen_commands { + local($x) = 1; + print OUT "\n/* Command ids */\n"; + foreach(@commands){ + print OUT "#define TODO_\U$_\E $x\n"; + } + print OUT "\n"; +} + &start_file; &gen_magic(0, @const_false); &gen_magic(1, @const_true); &gen_file(sort(@os,@win,@feature,@misc,@const_false,@const_true)); +&gen_commands; &end_file;