Merge githash

This commit is contained in:
keni
2018-02-26 09:03:12 -05:00
23 changed files with 535 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 allmain.c $NHDT-Date: 1513130016 2017/12/13 01:53:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.81 $ */
/* NetHack 3.6 allmain.c $NHDT-Date: 1518193644 2018/02/09 16:27:24 $ $NHDT-Branch: githash $:$NHDT-Revision: 1.86 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -737,5 +737,88 @@ const char *msg;
}
}
/*
* Argument processing helpers - for xxmain() to share
* and call.
*
* These should return TRUE if the argument matched,
* whether the processing of the argument was
* successful or not.
*
* Most of these do their thing, then after returning
* to xxmain(), the code exits without starting a game.
*
*/
static struct early_opt earlyopts[] = {
{ARG_DEBUG, "debug", 5, FALSE},
{ARG_VERSION, "version", 4, TRUE},
};
boolean
argcheck(argc, argv, e_arg)
int argc;
char *argv[];
enum earlyarg e_arg;
{
int i, idx;
boolean match = FALSE;
char *userea = (char *)0;
const char *dashdash = "";
for (idx = 0; idx < SIZE(earlyopts); idx++) {
if (earlyopts[idx].e == e_arg)
break;
}
if ((idx >= SIZE(earlyopts)) || (argc <= 1))
return FALSE;
for (i = 1; i < argc; ++i) {
if (argv[i][0] != '-')
continue;
if (argv[i][1] == '-') {
userea = &argv[i][2];
dashdash = "-";
} else {
userea = &argv[i][1];
}
match = match_optname(userea, earlyopts[idx].name,
earlyopts[idx].minlength, earlyopts[idx].valallowed);
if (match) break;
}
if (match) {
switch(e_arg) {
case ARG_DEBUG:
break;
case ARG_VERSION: {
boolean insert_into_pastebuf = FALSE;
const char *extended_opt = index(userea,':');
if (!extended_opt)
extended_opt = index(userea, '=');
if (extended_opt) {
extended_opt++;
if (match_optname(extended_opt, "paste",
5, FALSE)) {
insert_into_pastebuf = TRUE;
} else {
raw_printf(
"-%sversion can only be extended with -%sversion:paste.\n",
dashdash, dashdash);
return TRUE;
}
}
early_version_info(insert_into_pastebuf);
return TRUE;
break;
}
default:
break;
}
};
return FALSE;
}
/*allmain.c*/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 version.c $NHDT-Date: 1506993902 2017/10/03 01:25:02 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.44 $ */
/* NetHack 3.6 version.c $NHDT-Date: 1519155525 2018/02/20 19:38:45 $ $NHDT-Branch: githash $:$NHDT-Revision: 1.47 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -15,6 +15,13 @@
#include "patchlevel.h"
#endif
#if defined(NETHACK_GIT_SHA)
const char * NetHack_git_sha = NETHACK_GIT_SHA;
#endif
#if defined(NETHACK_GIT_BRANCH)
const char * NetHack_git_branch = NETHACK_GIT_BRANCH;
#endif
STATIC_DCL void FDECL(insert_rtoption, (char *));
/* fill buffer with short version (so caller can avoid including date.h) */
@@ -30,23 +37,36 @@ char *
getversionstring(buf)
char *buf;
{
int details = 0;
boolean details = FALSE;
Strcpy(buf, VERSION_ID);
#if defined(RUNTIME_PORT_ID)
details++;
#if defined(RUNTIME_PORT_ID) || \
defined(NETHACK_GIT_SHA) || defined(NETHACK_GIT_BRANCH)
details = TRUE;
#endif
if (details) {
#if defined(RUNTIME_PORT_ID) || defined(NETHACK_GIT_SHA) || defined(NETHACK_GIT_BRANCH)
int c = 0;
#endif
#if defined(RUNTIME_PORT_ID)
char tmpbuf[BUFSZ];
char *tmp = (char *)0;
#endif
Sprintf(eos(buf), " (");
#if defined(RUNTIME_PORT_ID)
tmp = get_port_id(tmpbuf);
if (tmp)
Sprintf(eos(buf), "%s%s", c++ ? "," : "", tmp);
#endif
#if defined(NETHACK_GIT_SHA)
if (NetHack_git_sha)
Sprintf(eos(buf), "%s%s", c++ ? "," : "", NetHack_git_sha);
#endif
#if defined(NETHACK_GIT_BRANCH)
if (NetHack_git_branch)
Sprintf(eos(buf), "%s%s", c++ ? "," : "", NetHack_git_branch);
#endif
Sprintf(eos(buf), ")");
}
@@ -130,6 +150,37 @@ doextversion()
return 0;
}
void early_version_info(pastebuf)
boolean pastebuf;
{
char buf[BUFSZ], buf2[BUFSZ];
char *tmp = getversionstring(buf);
/* this is early enough that we have to do
our own line-splitting */
if (tmp) {
tmp = strstri(buf," (");
if (tmp) *tmp++ = '\0';
}
Sprintf(buf2, "%s\n", buf);
if (tmp) Sprintf(eos(buf2), "%s\n", tmp);
raw_printf("%s", buf2);
if (pastebuf) {
#ifdef RUNTIME_PASTEBUF_SUPPORT
/*
* Call a platform/port-specific routine to insert the
* version information into a paste buffer. Useful for
* easy inclusion in bug reports.
*/
port_insert_pastebuf(buf2);
#else
raw_printf("%s", "Paste buffer copy is not available.\n");
#endif
}
}
extern const char regex_id[];
/*