From edf0e3e67345934561af560b1068ca75ae761bbd Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 31 Dec 2021 18:15:34 -0800 Subject: [PATCH] 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'. --- src/nhlua.c | 28 ++++++++++++++++++++++------ win/Qt/qt_main.cpp | 6 ++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/nhlua.c b/src/nhlua.c index 4f1787a5f..36713a28d 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -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 "." although we check to see + whether it is "Lua-." and strip prefix if so; + LUA_RELEASE is . 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; diff --git a/win/Qt/qt_main.cpp b/win/Qt/qt_main.cpp index 59543bd1f..1b99f3fd9 100644 --- a/win/Qt/qt_main.cpp +++ b/win/Qt/qt_main.cpp @@ -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; }