add Lua to Qt's "About nethack"

Add "Lua" and its version number of the 'About' popup.  No copyright
information is included since neither nethack's nor Qt's is shown.

Lua copyright text is included in the output of '#version'.
This commit is contained in:
PatR
2021-12-31 18:15:34 -08:00
parent f96d1b4342
commit edf0e3e673
2 changed files with 26 additions and 8 deletions

View File

@@ -1412,17 +1412,33 @@ DISABLE_WARNING_CONDEXPR_IS_CONSTANT
const char *
get_lua_version(void)
{
size_t len = (size_t) 0;
const char *vs = (const char *) 0;
lua_State *L;
if (g.lua_ver[0] == 0) {
L = nhl_init();
lua_State *L = nhl_init();
if (L) {
lua_getglobal(L, "_VERSION");
size_t len = 0;
const char *vs = (const char *) 0;
/* LUA_VERSION yields "<major>.<minor>" although we check to see
whether it is "Lua-<major>.<minor>" and strip prefix if so;
LUA_RELEASE is <LUA_VERSION>.<LUA_VERSION_RELEASE> but doesn't
get set up as a lua global */
lua_getglobal(L, "_RELEASE");
if (lua_isstring(L, -1))
vs = lua_tolstring (L, -1, &len);
#ifdef LUA_RELEASE
else
vs = LUA_RELEASE, len = strlen(vs);
#endif
if (!vs) {
lua_getglobal(L, "_VERSION");
if (lua_isstring(L, -1))
vs = lua_tolstring (L, -1, &len);
#ifdef LUA_VERSION
else
vs = LUA_VERSION, len = strlen(vs);
#endif
}
if (vs && len < sizeof g.lua_ver) {
if (!strncmpi(vs, "Lua", 3)) {
vs += 3;

View File

@@ -459,7 +459,7 @@ aboutMsg()
char *p, vbuf[BUFSZ];
/* nethack's getversionstring() includes a final period
but we're using it mid-sentence so strip period off */
if ((p = strrchr(getversionstring(vbuf), '.')) != 0 && *(p + 1) == '\0')
if ((p = strrchr(::getversionstring(vbuf), '.')) != 0 && *(p + 1) == '\0')
*p = '\0';
/* it's also long; break it into two pieces */
(void) strsubst(vbuf, " - ", "\n- ");
@@ -471,7 +471,7 @@ aboutMsg()
#endif
" the Qt %d GUI toolkit.\n" // short Qt version
"\n"
"This is %s%s.\n" // long nethack version and full Qt version
"This is %s%s and Lua %s.\n" // long nethack version, Qt & Lua versions
"\n"
"NetHack's Qt interface originally developed by Warwick Allison.\n"
"\n"
@@ -486,6 +486,7 @@ aboutMsg()
#else
"Qt:\n http://www.troll.no/\n" // obsolete
#endif
"Lua:\n https://lua.org/\n"
"NetHack:\n %s\n", // DEVTEAM_URL
// arguments
#ifdef QT_VERSION_MAJOR
@@ -499,6 +500,7 @@ aboutMsg()
#else
"",
#endif
::get_lua_version(),
DEVTEAM_URL);
return msg;
}