]> granicus.if.org Git - nethack/commitdiff
more warnings
authornhmall <nhmall@nethack.org>
Sun, 24 Nov 2019 23:01:48 +0000 (18:01 -0500)
committernhmall <nhmall@nethack.org>
Sun, 24 Nov 2019 23:01:48 +0000 (18:01 -0500)
include/extern.h
src/hacklib.c
src/sp_lev.c

index a0ffd7d65b6b96fd11106e851dce9aadd41c85b8..58d71e472aa4e9199c52a47a5076980187e48565 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1573940539 2019/11/16 21:42:19 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.741 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1574636502 2019/11/24 23:01:42 $  $NHDT-Branch: paxed-quest-lua $:$NHDT-Revision: 1.760 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -980,6 +980,7 @@ E void FDECL(strbuf_append, (strbuf_t *, const char *));
 E void FDECL(strbuf_reserve, (strbuf_t *, int));
 E void FDECL(strbuf_empty, (strbuf_t *));
 E void FDECL(strbuf_nl_to_crlf, (strbuf_t *));
+E char *FDECL(nonconst, (const char *, char *));
 
 /* ### invent.c ### */
 
index 59f63e624f787b04128aabd094abe89ab079130d..d823351f976bd60a1e8431ca26575ea51d846d47 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 hacklib.c       $NHDT-Date: 1552639487 2019/03/15 08:44:47 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.67 $ */
+/* NetHack 3.6 hacklib.c       $NHDT-Date: 1574636502 2019/11/24 23:01:42 $  $NHDT-Branch: paxed-quest-lua $:$NHDT-Revision: 1.79 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2007. */
 /* Copyright (c) Robert Patrick Rankin, 1991                      */
@@ -71,6 +71,7 @@
         void            strbuf_reserve  (strbuf *, int)
         void            strbuf_empty    (strbuf *)
         void            strbuf_nl_to_crlf (strbuf_t *)
+        char *          nonconst        (const char *, char *)
 =*/
 #ifdef LINT
 #define Static /* pacify lint */
@@ -1261,4 +1262,19 @@ strbuf_t *strbuf;
     }
 }
 
+char *
+nonconst(str, buf)
+const char *str;
+char *buf;
+{
+    char *retval = emptystr;
+
+    if (str && buf)
+        if ((int) strlen(str) < BUFSZ - 1) {
+           Strcpy(buf, str);
+            retval = buf;
+        }
+    return retval;
+}
+
 /*hacklib.c*/
index cb35286ed8b12bd5879f0ef363680fffdcb2374d..3f3fe8f54d4b172f836ad68d6b7d7d895a7535bf 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 sp_lev.c        $NHDT-Date: 1567805254 2019/09/06 21:27:34 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.117 $ */
+/* NetHack 3.6 sp_lev.c        $NHDT-Date: 1574636502 2019/11/24 23:01:42 $  $NHDT-Branch: paxed-quest-lua $:$NHDT-Revision: 1.141 $ */
 /*      Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -3373,24 +3373,25 @@ lua_State *L;
     spltrap tmptrap;
     int x, y;
     int argc = lua_gettop(L);
+    char ncbuf[BUFSZ];
 
     create_des_coder();
 
     if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) {
         const char *trapstr = luaL_checkstring(L, 1);
 
-        tmptrap.type = get_traptype_byname(trapstr);
+        tmptrap.type = get_traptype_byname(nonconst(trapstr, ncbuf));
         x = y = -1;
     } else if (argc == 2 && lua_type(L, 1) == LUA_TSTRING
                && lua_type(L, 2) == LUA_TTABLE) {
         const char *trapstr = luaL_checkstring(L, 1);
 
-        tmptrap.type = get_traptype_byname(trapstr);
+        tmptrap.type = get_traptype_byname(nonconst(trapstr, ncbuf));
         get_coord(L, 2, &x, &y);
     } else if (argc == 3) {
         const char *trapstr = luaL_checkstring(L, 1);
 
-        tmptrap.type = get_traptype_byname(trapstr);
+        tmptrap.type = get_traptype_byname(nonconst(trapstr, ncbuf));
         x = luaL_checkinteger(L, 2);
         y = luaL_checkinteger(L, 3);
     } else {