dumplog lint and formatting
authorPatR <rankin@nethack.org>
Sun, 26 Feb 2017 02:27:21 +0000 (18:27 -0800)
committerPatR <rankin@nethack.org>
Sun, 26 Feb 2017 02:27:21 +0000 (18:27 -0800)
include/extern.h
src/end.c
src/windows.c

index ca51e491f6099c8dc4a1512c34beb5da36244d7c..800969d6f8d7167281a03797539752dede8cc858 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1471112244 2016/08/13 18:17:24 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.570 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1488075978 2017/02/26 02:26:18 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.582 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2716,7 +2716,7 @@ E void FDECL(genl_status_threshold, (int, int, anything, int, int, int));
 
 E void FDECL(dump_open_log, (time_t));
 E void NDECL(dump_close_log);
-E void FDECL(dump_redirect, (boolean));
+E void FDECL(dump_redirect, (BOOLEAN_P));
 E void FDECL(dump_forward_putstr, (winid, int, const char*, int));
 
 /* ### wizard.c ### */
index e2e8a13afcfb001415414a51478a621d85cdbb68..817ca411120805c9139c36a911e408dcbd775846 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 end.c   $NHDT-Date: 1461919723 2016/04/29 08:48:43 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.116 $ */
+/* NetHack 3.6 end.c   $NHDT-Date: 1488075979 2017/02/26 02:26:19 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.127 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -56,6 +56,10 @@ STATIC_DCL int NDECL(set_vanq_order);
 STATIC_DCL void FDECL(list_vanquished, (CHAR_P, BOOLEAN_P));
 STATIC_DCL void FDECL(list_genocided, (CHAR_P, BOOLEAN_P));
 STATIC_DCL boolean FDECL(should_query_disclose_option, (int, char *));
+#ifdef DUMPLOG
+STATIC_DCL void NDECL(dump_plines);
+#endif
+STATIC_DCL void FDECL(dump_everything, (int));
 STATIC_DCL int NDECL(num_extinct);
 
 #if defined(__BEOS__) || defined(MICRO) || defined(WIN32) || defined(OS2)
@@ -672,34 +676,31 @@ STATIC_OVL void
 dump_plines()
 {
     int i;
-    char* str;
-    extern charsaved_plines[];
+    char buf[BUFSZ], **strp;
+    extern char *saved_plines[];
 
+    Strcpy(buf, " ");
     putstr(0, 0, "");
     putstr(0, 0, "Latest messages:");
-    for (i = 0; i < DUMPLOG_MSG_COUNT; ++i)
-    {
-        str = saved_plines[DUMPLOG_MSG_COUNT - 1 - i];
-        if (str) {
-            char buf[BUFSZ];
-            Sprintf(buf, " %s", str);
+    for (i = 0; i < DUMPLOG_MSG_COUNT; ++i) {
+        strp = &saved_plines[DUMPLOG_MSG_COUNT - 1 - i];
+        if (*strp) {
+            copynchars(&buf[1], *strp, BUFSZ - 1 - 1);
             putstr(0, 0, buf);
-        }
 #ifdef FREE_ALL_MEMORY
-        free(str);
+            free(*strp), *strp = 0;
 #endif
+        }
     }
 }
 #endif
 
 STATIC_OVL void
-dump_everything(how, taken)
+dump_everything(how)
 int how;
-boolean taken;
 {
 #ifdef DUMPLOG
-    struct obj* obj;
-    struct topl* topl;
+    struct obj *obj;
     char pbuf[BUFSZ];
 
     dump_redirect(TRUE);
@@ -746,6 +747,8 @@ boolean taken;
     show_overview((how >= PANICKED) ? 1 : 2, how);
     putstr(0, 0, "");
     dump_redirect(FALSE);
+#else
+    nhUse(how);
 #endif
 }
 
@@ -1164,7 +1167,8 @@ int how;
 
     if (strcmp(flags.end_disclose, "none") && how != PANICKED)
         disclose(how, taken);
-    dump_everything(how, taken);
+
+    dump_everything(how);
 
     /* finish_paybill should be called after disclosure but before bones */
     if (bones_ok && taken)
@@ -1820,7 +1824,7 @@ num_genocides()
     return n;
 }
 
-int
+STATIC_OVL int
 num_extinct()
 {
     int i, n = 0;
index b2939d31fea5f0149ea46eaedaf4f927fd786133..7646620755dcb0fea5fccbb2bedd9961b43f360b 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 windows.c       $NHDT-Date: 1448013599 2015/11/20 09:59:59 $  $NHDT-Branch: master $:$NHDT-Revision: 1.35 $ */
+/* NetHack 3.6 windows.c       $NHDT-Date: 1488075979 2017/02/26 02:26:19 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.39 $ */
 /* Copyright (c) D. Cohrs, 1993. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1033,27 +1033,35 @@ int behavior UNUSED, under UNUSED, over UNUSED;
 #endif /* STATUS_VIA_WINDOWPORT */
 
 STATIC_VAR struct window_procs dumplog_windowprocs_backup;
-STATIC_PTR FILEdumplog_file;
+STATIC_PTR FILE *dumplog_file;
 
 #ifdef DUMPLOG
-char *
+STATIC_VAR time_t dumplog_now;
+
+STATIC_DCL char *FDECL(dump_fmtstr, (const char *, char *));
+
+STATIC_OVL char *
 dump_fmtstr(fmt, buf)
-char *fmt;
+const char *fmt;
 char *buf;
 {
-    char *fp = fmt, *bp = buf;
+    const char *fp = fmt;
+    char *bp = buf;
     int slen, len = 0;
     char tmpbuf[BUFSZ];
     char verbuf[BUFSZ];
+    long uid;
+    time_t now;
 
-    time_t now = getnow();
-    int uid = getuid();
+    now = dumplog_now;
+    uid = (long) getuid();
 
     while (fp && *fp && len < BUFSZ-1) {
         if (*fp == '%') {
             fp++;
             switch (*fp) {
-            default: goto finish;
+            default:
+                goto finish;
             case '\0': /* fallthrough */
             case '%':  /* literal % */
                 Sprintf(tmpbuf,"%%");
@@ -1075,13 +1083,13 @@ char *buf;
                 Sprintf(tmpbuf, "%s", version_string(verbuf));
                 break;
             case 'u': /* UID */
-                Sprintf(tmpbuf, "%d", uid);
+                Sprintf(tmpbuf, "%ld", uid);
                 break;
             case 'n': /* player name */
-                Sprintf(tmpbuf, "%s", (plname ? plname : "unknown"));
+                Sprintf(tmpbuf, "%s", *plname ? plname : "unknown");
                 break;
             case 'N': /* first character of player name */
-                Sprintf(tmpbuf, "%c", (plname ? *plname : 'u'));
+                Sprintf(tmpbuf, "%c", *plname ? *plname : 'u');
                 break;
             }
 
@@ -1106,7 +1114,6 @@ char *buf;
 }
 #endif /* DUMPLOG */
 
-
 void
 dump_open_log(now)
 time_t now;
@@ -1115,6 +1122,7 @@ time_t now;
     char buf[BUFSZ];
     char *fname;
 
+    dumplog_now = now;
 #ifdef SYSCF
     if (!sysopt.dumplogfile)
         return;
@@ -1122,10 +1130,12 @@ time_t now;
 #else
     fname = dump_fmtstr(DUMPLOG_FILE, buf);
 #endif
-
     dumplog_file = fopen(fname, "w");
     dumplog_windowprocs_backup = windowprocs;
-#endif
+
+#else /*!DUMPLOG*/
+    nhUse(now);
+#endif /*?DUMPLOG*/
 }
 
 void
@@ -1150,7 +1160,7 @@ void
 dump_forward_putstr(win, attr, str, no_forward)
 winid win;
 int attr;
-const charstr;
+const char *str;
 int no_forward;
 {
     if (dumplog_file)
@@ -1159,11 +1169,12 @@ int no_forward;
         putstr(win, attr, str);
 }
 
+/*ARGSUSED*/
 STATIC_OVL void
 dump_putstr(win, attr, str)
-winid win;
-int attr;
-const charstr;
+winid win UNUSED;
+int attr UNUSED;
+const char *str;
 {
     if (dumplog_file)
         fprintf(dumplog_file, "%s\n", str);
@@ -1176,45 +1187,50 @@ int dummy;
     return dummy;
 }
 
+/*ARGUSED*/
 STATIC_OVL void
 dump_clear_nhwindow(win)
-winid win;
+winid win UNUSED;
 {
-
+    return;
 }
 
+/*ARGSUSED*/
 STATIC_OVL void
 dump_display_nhwindow(win, p)
-winid win;
-BOOLEAN_P p;
+winid win UNUSED;
+boolean p UNUSED;
 {
-
+    return;
 }
 
+/*ARGUSED*/
 STATIC_OVL void
 dump_destroy_nhwindow(win)
-winid win;
+winid win UNUSED;
 {
-
+    return;
 }
 
+/*ARGUSED*/
 STATIC_OVL void
 dump_start_menu(win)
-winid win;
+winid win UNUSED;
 {
-
+    return;
 }
 
+/*ARGSUSED*/
 STATIC_OVL void
 dump_add_menu(win, glyph, identifier, ch, gch, attr, str, preselected)
-winid win;
-int glyph;
-const ANY_P* identifier;
-CHAR_P ch;
-CHAR_P gch;
-int attr;
-const charstr;
-BOOLEAN_P preselected;
+winid win UNUSED;
+int glyph UNUSED;
+const anything *identifier UNUSED;
+char ch;
+char gch UNUSED;
+int attr UNUSED;
+const char *str;
+boolean preselected UNUSED;
 {
     if (dumplog_file) {
         if (glyph == NO_GLYPH)
@@ -1224,10 +1240,11 @@ BOOLEAN_P preselected;
     }
 }
 
+/*ARGSUSED*/
 STATIC_OVL void
 dump_end_menu(win, str)
-winid win;
-const charstr;
+winid win UNUSED;
+const char *str;
 {
     if (dumplog_file) {
         if (str)
@@ -1238,21 +1255,21 @@ const char* str;
 }
 
 STATIC_OVL int
-dump_select_menu(win, index, item)
-winid win;
-int index;
-MENU_ITEM_P** item;
+dump_select_menu(win, how, item)
+winid win UNUSED;
+int how UNUSED;
+menu_item **item;
 {
-    *item = NULL;
+    *item = (menu_item *) 0;
     return 0;
 }
 
 void
-dump_redirect(flag)
-boolean flag;
+dump_redirect(onoff_flag)
+boolean onoff_flag;
 {
     if (dumplog_file) {
-        if (flag) {
+        if (onoff_flag) {
             windowprocs.win_create_nhwindow = dump_create_nhwindow;
             windowprocs.win_clear_nhwindow = dump_clear_nhwindow;
             windowprocs.win_display_nhwindow = dump_display_nhwindow;
@@ -1265,7 +1282,7 @@ boolean flag;
         } else {
             windowprocs = dumplog_windowprocs_backup;
         }
-        iflags.in_dumplog = flag;
+        iflags.in_dumplog = onoff_flag;
     } else {
         iflags.in_dumplog = FALSE;
     }