fix Unix build with DEF_PAGER defined
Eliminate a couple of compile warnings produced when DEF_PAGER is defined: unixmain.c: g.catmore=DEF_PAGER; wintty.c: fd=open(...). Override its use when DLB is also defined since an external pager could access 'license' but not 'history', 'opthelp', &c when those are in the dlb container file. In the commented out value for DEF_PAGER, show a viable value for the default configuration these days.
This commit is contained in:
@@ -838,7 +838,7 @@ struct instance_globals {
|
|||||||
int locknum; /* max num of simultaneous users */
|
int locknum; /* max num of simultaneous users */
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEF_PAGER
|
#ifdef DEF_PAGER
|
||||||
char *catmore; /* default pager */
|
const char *catmore; /* external pager; from getenv() or DEF_PAGER */
|
||||||
#endif
|
#endif
|
||||||
#ifdef MICRO
|
#ifdef MICRO
|
||||||
char levels[PATHLEN]; /* where levels are */
|
char levels[PATHLEN]; /* where levels are */
|
||||||
|
|||||||
@@ -93,10 +93,12 @@
|
|||||||
/*
|
/*
|
||||||
* Define DEF_PAGER as your default pager, e.g. "/bin/cat" or "/usr/ucb/more"
|
* Define DEF_PAGER as your default pager, e.g. "/bin/cat" or "/usr/ucb/more"
|
||||||
* If defined, it can be overridden by the environment variable PAGER.
|
* If defined, it can be overridden by the environment variable PAGER.
|
||||||
* Hack will use its internal pager if DEF_PAGER is not defined.
|
* NetHack will use its internal pager if DEF_PAGER is not defined _or_
|
||||||
* (This might be preferable for security reasons.)
|
* if DLB is defined since an external pager won't know how to access the
|
||||||
|
* contents of the dlb container file.
|
||||||
|
* (Note: leaving DEF_PAGER undefined is preferable for security reasons.)
|
||||||
*/
|
*/
|
||||||
/* #define DEF_PAGER ".../mydir/mypager" */
|
/* #define DEF_PAGER "/usr/bin/less" */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define PORT_HELP to be the name of the port-specfic help file.
|
* Define PORT_HELP to be the name of the port-specfic help file.
|
||||||
|
|||||||
@@ -220,7 +220,8 @@ main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEF_PAGER
|
#ifdef DEF_PAGER
|
||||||
if (!(g.catmore = nh_getenv("HACKPAGER"))
|
if (!(g.catmore = nh_getenv("NETHACKPAGER"))
|
||||||
|
&& !(g.catmore = nh_getenv("HACKPAGER"))
|
||||||
&& !(g.catmore = nh_getenv("PAGER")))
|
&& !(g.catmore = nh_getenv("PAGER")))
|
||||||
g.catmore = DEF_PAGER;
|
g.catmore = DEF_PAGER;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,6 +36,20 @@ extern void msmsg(const char *, ...);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEF_PAGER
|
||||||
|
/* DEF_PAGER implies UNIX; when dlb is in use, the only file accessible
|
||||||
|
to an external pager is 'license'; override 'DEF_PAGER' for that
|
||||||
|
situation rather than using code to fallback to DLB plus internal
|
||||||
|
pager after open() failure */
|
||||||
|
#ifdef DLB
|
||||||
|
#undef DEF_PAGER
|
||||||
|
#else
|
||||||
|
#ifndef O_RDONLY /* (same logic as unixmain.c) */
|
||||||
|
#include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
#endif /* DLB */
|
||||||
|
#endif /* DEF_PAGER */
|
||||||
|
|
||||||
#if defined(TTY_TILES_ESCCODES) || defined(TTY_SOUND_ESCCODES)
|
#if defined(TTY_TILES_ESCCODES) || defined(TTY_SOUND_ESCCODES)
|
||||||
#define VT_ANSI_COMMAND 'z'
|
#define VT_ANSI_COMMAND 'z'
|
||||||
#endif
|
#endif
|
||||||
@@ -2791,7 +2805,7 @@ tty_display_file(const char *fname, boolean complain)
|
|||||||
#ifdef DEF_PAGER /* this implies that UNIX is defined */
|
#ifdef DEF_PAGER /* this implies that UNIX is defined */
|
||||||
{
|
{
|
||||||
/* use external pager; this may give security problems */
|
/* use external pager; this may give security problems */
|
||||||
register int fd = open(fname, 0);
|
int fd = open(fname, O_RDONLY);
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (complain)
|
if (complain)
|
||||||
|
|||||||
Reference in New Issue
Block a user