]> granicus.if.org Git - nethack/commitdiff
decode_mixed()'s return type
authorPatR <rankin@nethack.org>
Mon, 18 Mar 2019 21:38:30 +0000 (14:38 -0700)
committerPatR <rankin@nethack.org>
Mon, 18 Mar 2019 21:38:30 +0000 (14:38 -0700)
decode_mixed() writes its output into a 'char *' buffer that's passed
in to it and then returns that buffer.  Some excessively paranoid
error checking forced to return 'const char *'.  Relax that and use
'char *' so callers can work with the result without extra casts.

include/extern.h
src/mapglyph.c

index a908a0432feb50813eeaa17e67bbf4812a34931c..f35623f9a328dea800f5ffc1c6617c6c5d32c087 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1550524545 2019/02/18 21:15:45 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.694 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1552945074 2019/03/18 21:37:54 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.695 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1176,7 +1176,7 @@ E boolean FDECL(usmellmon, (struct permonst *));
 
 E int FDECL(mapglyph, (int, int *, int *, unsigned *, int, int));
 E char *FDECL(encglyph, (int));
-E const char *FDECL(decode_mixed, (char *,const char *));
+E char *FDECL(decode_mixed, (char *, const char *));
 E void FDECL(genl_putmixed, (winid, int, const char *));
 
 /* ### mcastu.c ### */
index 719c8e17526940cbc2111f5187de4b04011906a9..079150657ac2742c32d8ef8fa69336d7165c6935 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mapglyph.c      $NHDT-Date: 1526429201 2018/05/16 00:06:41 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.47 $ */
+/* NetHack 3.6 mapglyph.c      $NHDT-Date: 1552945095 2019/03/18 21:38:15 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.48 $ */
 /* Copyright (c) David Cohrs, 1991                                */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -249,7 +249,7 @@ int glyph;
     return encbuf;
 }
 
-const char *
+char *
 decode_mixed(buf, str)
 char *buf;
 const char *str;
@@ -257,8 +257,8 @@ const char *str;
     static const char hex[] = "00112233445566778899aAbBcCdDeEfF";
     char *put = buf;
 
-    if (!put || !str)
-        return "";
+    if (!str)
+        return strcpy(buf, "");
 
     while (*str) {
         if (*str == '\\') {