From: keni <keni> Date: Tue, 11 Oct 2011 02:37:31 +0000 (+0000) Subject: display version and build info at startup (trunk only) X-Git-Tag: MOVE2GIT~163 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e5e7203346c970fa4e8304c66b2adfe2241b775;p=nethack display version and build info at startup (trunk only) Tested on the unix port; I've updated as many other ports as I can figure out but they're not tested. See window.doc for info on the changed banner lines. Also adds the ability to override the generic "Unix" port - used now to get "MacOSX" into the version line instead of "Unix" (so we don't scare people who don't know what's going on). --- diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 3c637f30b..303ef1f83 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -527,6 +527,7 @@ when a sokoban puzzle has been completed (last pit or hole filled in), stop assessing luck penalties and lift most movement restrictions '`' command to show discoveries for one class of objects add "about nethack" to '?' menu as an alternate way to view 'v'+'#version' +display version and build information at startup Platform- and/or Interface-Specific New Features diff --git a/doc/window.doc b/doc/window.doc index 29c955ace..fb79adf0f 100644 --- a/doc/window.doc +++ b/doc/window.doc @@ -875,14 +875,15 @@ VIII. Conventions init_nhwindows() is expected to display a gee-whiz banner window, including the Copyright message. It is recommended that the COPYRIGHT_BANNER_A, -COPYRIGHT_BANNER_B, and COPYRIGHT_BANNER_C macros from patchlevel.h be used -for constructing the Copyright message. COPYRIGHT_BANNER_A is a -quoted string that has the NetHack copyright declaration, -COPYRIGHT_BANNER_B is a quoted string that states who the copyright -belongs to, and COPYRIGHT_BANNER_C simply says "See License for -details." Be sure to #include "patchlevel.h" to define these macros. -Using the macros will prevent having to update the Copyright information -in each window-port prior to each release. +COPYRIGHT_BANNER_B, COPYRIGHT_BANNER_C, and COPYRIGHT_BANNER_D macros from +patchlevel.h and date.h be used for constructing the Copyright message. +COPYRIGHT_BANNER_A is a quoted string that has the NetHack copyright declaration, +COPYRIGHT_BANNER_B is a quoted string that states who the copyright belongs to, +COPYRIGHT_BANNER_C is a quoted string generated by makedefs that includes version +and build information. and COPYRIGHT_BANNER_D simply says "See License for details." +Be sure to #include "patchlevel.h" and date.h to define these macros. Using the +macros will prevent having to update the Copyright information in each window-port +prior to each release. Ports (MSDOS, TOS, MAC, etc) _may_ use window-port specific routines in their port specific files, _AT_THEIR_OWN_RISK_. Since "port" and diff --git a/include/global.h b/include/global.h index f71048848..f728c33c7 100644 --- a/include/global.h +++ b/include/global.h @@ -191,6 +191,9 @@ typedef char nhptext; # ifdef MAC # define PORT_ID "Mac" # endif +# ifdef __APPLE__ +# define PORT_ID "MacOSX" +# endif # ifdef MSDOS # ifdef PC9800 # define PORT_ID "PC-9800" @@ -213,8 +216,11 @@ typedef char nhptext; # ifdef TOS # define PORT_ID "ST" # endif -# ifdef UNIX -# define PORT_ID "Unix" + /* Check again in case something more specific has been defined above. */ +# ifndef PORT_ID +# ifdef UNIX +# define PORT_ID "Unix" +# endif # endif # ifdef VMS # define PORT_ID "VMS" diff --git a/include/patchlevel.h b/include/patchlevel.h index 1b85ed42d..2fee2b03f 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -17,11 +17,10 @@ #define COPYRIGHT_BANNER_A \ "NetHack, Copyright 1985-2011" - #define COPYRIGHT_BANNER_B \ " By Stichting Mathematisch Centrum and M. Stephenson." - -#define COPYRIGHT_BANNER_C \ + /* COPYRIGHT_BANNER_C is generated by makedefs into date.h */ +#define COPYRIGHT_BANNER_D \ " See license for details." /* diff --git a/src/restore.c b/src/restore.c index ee8ee3556..4d5136f7a 100644 --- a/src/restore.c +++ b/src/restore.c @@ -1276,8 +1276,8 @@ winid bannerwin; /* if not WIN_ERR, clear window and show copyright in menu */ if (bannerwin != WIN_ERR) { /* for tty; erase copyright notice and redo it in the menu */ clear_nhwindow(bannerwin); - /* COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, COPYRIGHT_BANNER_C */ - for (k = 1; k <= 3; ++k) + /* COPYRIGHT_BANNER_[ABCD] */ + for (k = 1; k <= 4; ++k) add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, copyright_banner_line(k), MENU_UNSELECTED); add_menu(tmpwin, NO_GLYPH, &any, 0, 0, diff --git a/sys/amiga/Makefile.agc b/sys/amiga/Makefile.agc index 3479f085d..fb3b4694d 100644 --- a/sys/amiga/Makefile.agc +++ b/sys/amiga/Makefile.agc @@ -1244,7 +1244,7 @@ $(O)termcap.o: $(TTY)termcap.c $(HDEP) $(I)wintty.h $(I)tcap.h $(O)topl.o: $(TTY)topl.c $(HDEP) $(I)wintty.h $(I)tcap.h $(O)wintty.o: $(TTY)wintty.c $(HDEP) $(I)wintty.h $(I)tcap.h \ - $(I)patchlevel.h + $(I)date.h $(I)patchlevel.h $(O)amitty.o: $(AMI)amitty.c $(HDEP) diff --git a/sys/amiga/Makefile.ami b/sys/amiga/Makefile.ami index 6eed61b1b..d926333dd 100644 --- a/sys/amiga/Makefile.ami +++ b/sys/amiga/Makefile.ami @@ -1583,7 +1583,7 @@ $(O)termcap.o: $(TTY)termcap.c $(HDEP) $(I)wintty.h $(I)tcap.h $(O)topl.o: $(TTY)topl.c $(HDEP) $(I)wintty.h $(I)tcap.h $(O)wintty.o: $(TTY)wintty.c $(HDEP) $(I)wintty.h $(I)tcap.h \ - $(I)patchlevel.h + $(I)date.h $(I)patchlevel.h $(O)amitty.o: $(AMI)amitty.c $(HDEP) diff --git a/sys/amiga/winfuncs.c b/sys/amiga/winfuncs.c index 197eaa169..d1b631a7b 100644 --- a/sys/amiga/winfuncs.c +++ b/sys/amiga/winfuncs.c @@ -7,6 +7,7 @@ #include "NH:sys/amiga/winext.h" #include "NH:sys/amiga/winproto.h" #include "patchlevel.h" +#include "date.h" extern struct TagItem scrntags[]; @@ -1304,6 +1305,7 @@ amii_init_nhwindows(argcp,argv) amii_putstr( WIN_BASE, 0, COPYRIGHT_BANNER_A); amii_putstr( WIN_BASE, 0, COPYRIGHT_BANNER_B); amii_putstr( WIN_BASE, 0, COPYRIGHT_BANNER_C); + amii_putstr( WIN_BASE, 0, COPYRIGHT_BANNER_D); amii_putstr( WIN_BASE, 0, ""); Initialized = 1; diff --git a/sys/msdos/Makefile.BC b/sys/msdos/Makefile.BC index 7869cae65..b5175e3a8 100644 --- a/sys/msdos/Makefile.BC +++ b/sys/msdos/Makefile.BC @@ -1629,7 +1629,7 @@ $(O)topl.B: $(PCHB) $(WTTY)\topl.c $(HACK_H) $(TERMCAP_H) $(WINTTY_H) @echo $(BCOPTS2) $(CFLAGUB) >> $(VROOMMCFG) $(CC) $(FLAGUB) $(COBJNAM)$@ $(WTTY)\topl.c -$(O)wintty.o: $(PCHO) $(CONFIG_H) $(WTTY)\wintty.c $(PATCHLEVEL_H) +$(O)wintty.o: $(PCHO) $(CONFIG_H) $(WTTY)\wintty.c $(PATCHLEVEL_H) $(DATE_H) @type schema$(SCHEMA).bc | find "$(@B)_o" > $(VROOMMCFG) @echo $(BCOPTS1) >> $(VROOMMCFG) @echo $(BCOPTS2) $(CFLAGUO) >> $(VROOMMCFG) diff --git a/sys/msdos/Makefile.GCC b/sys/msdos/Makefile.GCC index 930e349cb..9e4e42578 100644 --- a/sys/msdos/Makefile.GCC +++ b/sys/msdos/Makefile.GCC @@ -1068,7 +1068,7 @@ $(O)termcap.o: ../win/tty/termcap.c $(HACK_H) $(INCL)/tcap.h $(O)topl.o: ../win/tty/topl.c $(HACK_H) $(INCL)/tcap.h $(CC) $(cflags) -o$@ ../win/tty/topl.c $(O)wintty.o: ../win/tty/wintty.c $(HACK_H) $(INCL)/dlb.h \ - $(PATCHLEV_H) $(INCL)/tcap.h + $(INCL)/date.h $(PATCHLEV_H) $(INCL)/tcap.h $(CC) $(cflags) -o$@ ../win/tty/wintty.c $(O)Window.o: ../win/X11/Window.c $(INCL)/xwindowp.h $(INCL)/xwindow.h \ $(CONFIG_H) diff --git a/sys/msdos/Makefile.MSC b/sys/msdos/Makefile.MSC index 7ea3bdcde..3880f2323 100644 --- a/sys/msdos/Makefile.MSC +++ b/sys/msdos/Makefile.MSC @@ -988,7 +988,7 @@ termcap.o: $(WIN)\termcap.c $(HACK_H) $(INCL)\tcap.h topl.o: $(WIN)\topl.c $(HACK_H) $(INCL)\tcap.h @$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(WIN)\topl.c wintty.o: $(WIN)\wintty.c $(HACK_H) $(INCL)\dlb.h \ - $(INCL)\patchlev.h $(INCL)\tcap.h + $(INCL)\date.h $(INCL)\patchlev.h $(INCL)\tcap.h @$(CC) $(CFLAGS) $(SPECOPTS) /Fo$@ $(WIN)\wintty.c # src dependencies diff --git a/sys/os2/Makefile.os2 b/sys/os2/Makefile.os2 index 5e5b37f7d..6f62ef6fd 100644 --- a/sys/os2/Makefile.os2 +++ b/sys/os2/Makefile.os2 @@ -1240,7 +1240,7 @@ $(OBJ)\termcap.o : $(WIN)\$(CB) $(HACK_H) $(INCL)\tcap.h $(WINCC) $(OBJ)\topl.o : $(WIN)\$(CB) $(HACK_H) $(INCL)\tcap.h $(WINCC) -$(OBJ)\wintty.o : $(WIN)\$(CB) $(HACK_H) $(INCL)\tcap.h +$(OBJ)\wintty.o : $(WIN)\$(CB) $(HACK_H) $(INCL)\tcap.h $(INCL)\date.h $(WINCC) # diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index da1873f81..67ea332db 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -6,6 +6,7 @@ #include "hack.h" #include "dlb.h" +#include "date.h" #ifdef SHORT_FILENAMES #include "patchlev.h" #else @@ -278,9 +279,9 @@ char *argv[]; error("Your clock is incorrectly set!"); #endif if (!dlb_init()) { - pline("%s\n%s\n%s\n\nNetHack was unable to open the required file \"%s\".%s", + pline("%s\n%s\n%s\n%s\n\nNetHack was unable to open the required file \"%s\".%s", COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, - COPYRIGHT_BANNER_C, DLBFILE, + COPYRIGHT_BANNER_C, COPYRIGHT_BANNER_D, DLBFILE, #ifdef WIN32 "\nAre you perhaps trying to run NetHack within a zip utility?"); #else diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 0c923c116..fe7f8054f 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -612,7 +612,7 @@ termcap.o: ../win/tty/termcap.c $(HACK_H) ../include/tcap.h topl.o: ../win/tty/topl.c $(HACK_H) ../include/tcap.h $(CC) $(CFLAGS) -c ../win/tty/topl.c wintty.o: ../win/tty/wintty.c $(HACK_H) ../include/dlb.h \ - ../include/patchlevel.h ../include/tcap.h + ../include/date.h ../include/patchlevel.h ../include/tcap.h $(CC) $(CFLAGS) -c ../win/tty/wintty.c Window.o: ../win/X11/Window.c ../include/xwindowp.h ../include/xwindow.h \ $(CONFIG_H) diff --git a/sys/vms/Makefile.src b/sys/vms/Makefile.src index 69e23db37..a50ee357b 100644 --- a/sys/vms/Makefile.src +++ b/sys/vms/Makefile.src @@ -352,7 +352,7 @@ getline.obj : $(TTY)getline.c $(HACK_H) $(INC)func_tab.h termcap.obj : $(TTY)termcap.c $(HACK_H) $(INC)tcap.h topl.obj : $(TTY)topl.c $(HACK_H) $(INC)tcap.h wintty.obj : $(TTY)wintty.c $(HACK_H) $(INC)dlb.h \ - $(INC)patchlevel.h $(INC)tcap.h + $(INC)date.h $(INC)patchlevel.h $(INC)tcap.h Window.obj : $(X11)Window.c $(INC)xwindowp.h $(INC)xwindow.h $(CONFIG_H) dialogs.obj : $(X11)dialogs.c $(CONFIG_H) winX.obj : $(X11)winX.c $(HACK_H) $(INC)winX.h $(INC)dlb.h \ diff --git a/sys/wince/bootstrp.mak b/sys/wince/bootstrp.mak index dbeef2dcf..1a5bd429d 100644 --- a/sys/wince/bootstrp.mak +++ b/sys/wince/bootstrp.mak @@ -679,7 +679,7 @@ $(O)termcap.o: ..\win\tty\termcap.c $(HACK_H) $(INCL)\tcap.h $(O)topl.o: ..\win\tty\topl.c $(HACK_H) $(INCL)\tcap.h $(CC) $(CFLAGSU) -Fo$@ ..\win\tty\topl.c $(O)wintty.o: ..\win\tty\wintty.c $(HACK_H) $(INCL)\dlb.h \ - $(INCL)\patchlevel.h $(INCL)\tcap.h + $(INCL)\date.h $(INCL)\patchlevel.h $(INCL)\tcap.h $(CC) $(CFLAGSU) -Fo$@ ..\win\tty\wintty.c $(O)Window.o: ..\win\X11\Window.c $(INCL)\xwindowp.h $(INCL)\xwindow.h \ $(CONFIG_H) diff --git a/sys/wince/mhmain.c b/sys/wince/mhmain.c index dc1c91c47..28a29c137 100644 --- a/sys/wince/mhmain.c +++ b/sys/wince/mhmain.c @@ -11,6 +11,7 @@ #include "mhmsgwnd.h" #include "mhcmd.h" #include "mhmap.h" +#include "date.h" #include "patchlevel.h" #define MAX_LOADSTRING 100 @@ -996,7 +997,8 @@ LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) NH_A2W( COPYRIGHT_BANNER_A "\n" COPYRIGHT_BANNER_B "\n" - COPYRIGHT_BANNER_C, + COPYRIGHT_BANNER_C "\n" + COPYRIGHT_BANNER_D, wbuf, NHSTR_BUFSIZE ) ); diff --git a/sys/winnt/Makefile.bcc b/sys/winnt/Makefile.bcc index 69fd27d5a..358feb966 100644 --- a/sys/winnt/Makefile.bcc +++ b/sys/winnt/Makefile.bcc @@ -1176,7 +1176,7 @@ $(O)termcap.o: ..\win\tty\termcap.c $(HACK_H) $(INCL)\tcap.h $(O)topl.o: ..\win\tty\topl.c $(HACK_H) $(INCL)\tcap.h $(cc) $(CFLAGS) -o$@ ..\win\tty\topl.c $(O)wintty.o: ..\win\tty\wintty.c $(HACK_H) $(INCL)\dlb.h \ - $(INCL)\patchlevel.h $(INCL)\tcap.h + $(INCL)\date.h $(INCL)\patchlevel.h $(INCL)\tcap.h $(cc) $(CFLAGS) -o$@ ..\win\tty\wintty.c $(O)Window.o: ..\win\X11\Window.c $(INCL)\xwindowp.h $(INCL)\xwindow.h \ $(CONFIG_H) diff --git a/sys/winnt/Makefile.gcc b/sys/winnt/Makefile.gcc index 44a7c1d4e..a6e618386 100644 --- a/sys/winnt/Makefile.gcc +++ b/sys/winnt/Makefile.gcc @@ -1142,7 +1142,7 @@ $(O)termcap.o: ../win/tty/termcap.c $(HACK_H) $(INCL)/tcap.h $(O)topl.o: ../win/tty/topl.c $(HACK_H) $(INCL)/tcap.h $(cc) $(CFLAGS) -o$@ ../win/tty/topl.c $(O)wintty.o: ../win/tty/wintty.c $(HACK_H) $(INCL)/dlb.h \ - $(INCL)/patchlevel.h $(INCL)/tcap.h + $(INCL)/date.h $(INCL)/patchlevel.h $(INCL)/tcap.h $(cc) $(CFLAGS) -o$@ ../win/tty/wintty.c $(O)Window.o: ../win/X11/Window.c $(INCL)/xwindowp.h $(INCL)/xwindow.h \ $(CONFIG_H) diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index 4202ef946..aec40ac59 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -1250,7 +1250,7 @@ $(O)termcap.o: ..\win\tty\termcap.c $(HACK_H) $(INCL)\tcap.h $(O)topl.o: ..\win\tty\topl.c $(HACK_H) $(INCL)\tcap.h @$(CC) $(cflagsUtil) -Fo$@ ..\win\tty\topl.c $(O)wintty.o: ..\win\tty\wintty.c $(HACK_H) $(INCL)\dlb.h \ - $(INCL)\patchlevel.h $(INCL)\tcap.h + $(INCL)\date.h $(INCL)\patchlevel.h $(INCL)\tcap.h @$(CC) $(cflagsUtil) -Fo$@ ..\win\tty\wintty.c $(O)Window.o: ..\win\X11\Window.c $(INCL)\xwindowp.h $(INCL)\xwindow.h \ $(CONFIG_H) diff --git a/util/makedefs.c b/util/makedefs.c index 628b2a1b7..fea8c0f5a 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -165,6 +165,7 @@ extern void NDECL(objects_init); /* objects.c */ static void NDECL(make_version); static char *FDECL(version_string, (char *, const char *)); static char *FDECL(version_id_string, (char *,const char *)); +static char *FDECL(bannerc_string, (char *,const char *)); static char *FDECL(xcrypt, (const char *)); static int FDECL(check_control, (char *)); static char *FDECL(without_control, (char *)); @@ -1097,6 +1098,33 @@ const char *build_date; return outbuf; } +static char * +bannerc_string(outbuf, build_date) +char *outbuf; +const char *build_date; +{ + char subbuf[64], versbuf[64]; + + subbuf[0] = '\0'; +#ifdef PORT_SUB_ID + subbuf[0] = ' '; + Strcpy(&subbuf[1], PORT_SUB_ID); +#endif +#ifdef BETA + Strcat(subbuf, " Beta"); +#endif + + Sprintf(outbuf, " Version %s %s%s, built %s.", +version_string(versbuf, "."), +PORT_ID, subbuf, &build_date[4]); +#if 0 + Sprintf(outbuf, "%s NetHack%s %s Copyright 1985-%s (built %s)", + PORT_ID, subbuf, version_string(versbuf,"."), RELEASE_YEAR, + &build_date[4]); +#endif + return outbuf; +} + void do_date() { @@ -1158,6 +1186,8 @@ do_date() Fprintf(ofp,"#define VERSION_STRING \"%s\"\n", version_string(buf,".")); Fprintf(ofp,"#define VERSION_ID \\\n \"%s\"\n", version_id_string(buf, cbuf)); + Fprintf(ofp,"#define COPYRIGHT_BANNER_C \\\n \"%s\"\n", + bannerc_string(buf, cbuf)); Fprintf(ofp,"\n"); #ifdef AMIGA { diff --git a/win/X11/winX.c b/win/X11/winX.c index 1532c1f24..7d2bbc594 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -55,6 +55,7 @@ #else #include "patchlevel.h" #endif +#include "date.h" #ifndef NO_SIGNAL #include <signal.h> @@ -995,6 +996,7 @@ char** argv; COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, COPYRIGHT_BANNER_C, + COPYRIGHT_BANNER_D, "", "", 0 diff --git a/win/tty/wintty.c b/win/tty/wintty.c index e93a74cf0..3baba362e 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -11,6 +11,7 @@ #include "hack.h" #include "dlb.h" +#include "date.h" #ifdef SHORT_FILENAMES #include "patchlev.h" #else @@ -351,6 +352,7 @@ char** argv; tty_putstr(BASE_WINDOW, 0, COPYRIGHT_BANNER_A); tty_putstr(BASE_WINDOW, 0, COPYRIGHT_BANNER_B); tty_putstr(BASE_WINDOW, 0, COPYRIGHT_BANNER_C); + tty_putstr(BASE_WINDOW, 0, COPYRIGHT_BANNER_D); tty_putstr(BASE_WINDOW, 0, ""); tty_display_nhwindow(BASE_WINDOW, FALSE); } diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index 34694722e..313c8b365 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -5,6 +5,7 @@ #include "winMS.h" #include <commdlg.h> +#include "date.h" #include "patchlevel.h" #include "resource.h" #include "mhmsg.h" @@ -986,7 +987,8 @@ LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) NH_A2W( COPYRIGHT_BANNER_A "\n" COPYRIGHT_BANNER_B "\n" - COPYRIGHT_BANNER_C, + COPYRIGHT_BANNER_C "\n" + COPYRIGHT_BANNER_D, wbuf, BUFSZ ) ); diff --git a/win/win32/mhsplash.c b/win/win32/mhsplash.c index 6c6729766..1c54d2410 100644 --- a/win/win32/mhsplash.c +++ b/win/win32/mhsplash.c @@ -8,6 +8,7 @@ #include "mhsplash.h" #include "mhmsg.h" #include "mhfont.h" +#include "date.h" #include "patchlevel.h" #include "dlb.h" @@ -85,8 +86,8 @@ void mswin_display_splash_window (BOOL show_ver) clientrt.right - 2 * SPLASH_OFFSET_X, controlrt.bottom, TRUE); /* Fill the text control */ - Sprintf (buf, "%s\r\n%s\r\n%s\r\n\r\n", COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, - COPYRIGHT_BANNER_C); + Sprintf (buf, "%s\r\n%s\r\n%s\r\n%s\r\n\r\n", COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, + COPYRIGHT_BANNER_C, COPYRIGHT_BANNER_D); strsize = strlen(buf); if (show_ver) {