]> granicus.if.org Git - nethack/commitdiff
fix 'makedefs -z' for config using FILE_PREFIX
authorPatR <rankin@nethack.org>
Tue, 23 Jan 2018 08:52:57 +0000 (00:52 -0800)
committerPatR <rankin@nethack.org>
Tue, 23 Jan 2018 08:52:57 +0000 (00:52 -0800)
Apply user-contributed patch to make do_vision() handle FILE_PREFIX
correctly.  It was putting that value into the filename buffer, then
overwriting it with the ordinary filename instead of appending.

Deletion of just-made vis_tab.h when creation of vis_tab.c fails would
have failed too if FILE_PREFIX had been working.

The patch was against 3.4.3 and didn't apply cleanly to current code,
but it is a staightforward fix, although the file deletion case was
buggy (failed to clear "vis_tab.c" from buffer before reconstructing
"vis_tab.h" via appending stuff).  FILE_PREFIX seems to be Amiga-only
so I've only tested the usual case where it isn't defined.

doc/fixes36.1
util/makedefs.c

index 3dfa88bbb124c26d10bb91142218df7d2789ee14..28313a87c959e642fd1b3a6bb1cc2c06a58ec6f9 100644 (file)
@@ -637,6 +637,8 @@ PANICTRACE: PANICTRACE_GDB used wrong value for ARGV0 when launching gdb if
 win32gui: gather raw_print error messages into a single dialog window
 win32tty: fix display errors when using a font with double wide or ambiguous
        width characters
+Amiga (untested): 'makedefs -z' didn't handle FILE_PREFIX correctly when
+       building vis_tab.h and vis_tab.c
 
 
 General New Features
index 4d32cc4ad39d03e177c7a14fe12f3c05bafc40bb..f9bab0ef1e1577c7c2ba467452eecf1f638ee18e 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6  makedefs.c  $NHDT-Date: 1506993895 2017/10/03 01:24:55 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.117 $ */
+/* NetHack 3.6  makedefs.c  $NHDT-Date: 1516697571 2018/01/23 08:52:51 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.118 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* Copyright (c) M. Stephenson, 1990, 1991.                       */
 /* Copyright (c) Dean Luick, 1990.                                */
@@ -2816,7 +2816,7 @@ do_vision()
 #ifdef FILE_PREFIX
     Strcat(filename, file_prefix);
 #endif
-    Sprintf(filename, INCLUDE_TEMPLATE, VIS_TAB_H);
+    Sprintf(eos(filename), INCLUDE_TEMPLATE, VIS_TAB_H);
     if (!(ofp = fopen(filename, WRTMODE))) {
         perror(filename);
         exit(EXIT_FAILURE);
@@ -2839,10 +2839,15 @@ do_vision()
 #ifdef FILE_PREFIX
     Strcat(filename, file_prefix);
 #endif
-    Sprintf(filename, SOURCE_TEMPLATE, VIS_TAB_C);
+    Sprintf(eos(filename), SOURCE_TEMPLATE, VIS_TAB_C);
     if (!(ofp = fopen(filename, WRTMODE))) {
         perror(filename);
-        Sprintf(filename, INCLUDE_TEMPLATE, VIS_TAB_H);
+        /* creating vis_tab.c failed; remove the vis_tab.h we just made */
+        filename[0] = '\0';
+#ifdef FILE_PREFIX
+        Strcat(filename, file_prefix);
+#endif
+        Sprintf(eos(filename), INCLUDE_TEMPLATE, VIS_TAB_H);
         Unlink(filename);
         exit(EXIT_FAILURE);
     }