dumplog lint and formatting

This commit is contained in:
PatR
2017-02-25 18:27:21 -08:00
parent 7d8b4d4f97
commit fd2cfba544
3 changed files with 86 additions and 65 deletions
+2 -2
View 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. */ /* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */ /* 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 FDECL(dump_open_log, (time_t));
E void NDECL(dump_close_log); 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)); E void FDECL(dump_forward_putstr, (winid, int, const char*, int));
/* ### wizard.c ### */ /* ### wizard.c ### */
+21 -17
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* 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_vanquished, (CHAR_P, BOOLEAN_P));
STATIC_DCL void FDECL(list_genocided, (CHAR_P, BOOLEAN_P)); STATIC_DCL void FDECL(list_genocided, (CHAR_P, BOOLEAN_P));
STATIC_DCL boolean FDECL(should_query_disclose_option, (int, char *)); 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); STATIC_DCL int NDECL(num_extinct);
#if defined(__BEOS__) || defined(MICRO) || defined(WIN32) || defined(OS2) #if defined(__BEOS__) || defined(MICRO) || defined(WIN32) || defined(OS2)
@@ -672,34 +676,31 @@ STATIC_OVL void
dump_plines() dump_plines()
{ {
int i; int i;
char* str; char buf[BUFSZ], **strp;
extern char* saved_plines[]; extern char *saved_plines[];
Strcpy(buf, " ");
putstr(0, 0, ""); putstr(0, 0, "");
putstr(0, 0, "Latest messages:"); putstr(0, 0, "Latest messages:");
for (i = 0; i < DUMPLOG_MSG_COUNT; ++i) for (i = 0; i < DUMPLOG_MSG_COUNT; ++i) {
{ strp = &saved_plines[DUMPLOG_MSG_COUNT - 1 - i];
str = saved_plines[DUMPLOG_MSG_COUNT - 1 - i]; if (*strp) {
if (str) { copynchars(&buf[1], *strp, BUFSZ - 1 - 1);
char buf[BUFSZ];
Sprintf(buf, " %s", str);
putstr(0, 0, buf); putstr(0, 0, buf);
}
#ifdef FREE_ALL_MEMORY #ifdef FREE_ALL_MEMORY
free(str); free(*strp), *strp = 0;
#endif #endif
}
} }
} }
#endif #endif
STATIC_OVL void STATIC_OVL void
dump_everything(how, taken) dump_everything(how)
int how; int how;
boolean taken;
{ {
#ifdef DUMPLOG #ifdef DUMPLOG
struct obj* obj; struct obj *obj;
struct topl* topl;
char pbuf[BUFSZ]; char pbuf[BUFSZ];
dump_redirect(TRUE); dump_redirect(TRUE);
@@ -746,6 +747,8 @@ boolean taken;
show_overview((how >= PANICKED) ? 1 : 2, how); show_overview((how >= PANICKED) ? 1 : 2, how);
putstr(0, 0, ""); putstr(0, 0, "");
dump_redirect(FALSE); dump_redirect(FALSE);
#else
nhUse(how);
#endif #endif
} }
@@ -1164,7 +1167,8 @@ int how;
if (strcmp(flags.end_disclose, "none") && how != PANICKED) if (strcmp(flags.end_disclose, "none") && how != PANICKED)
disclose(how, taken); disclose(how, taken);
dump_everything(how, taken);
dump_everything(how);
/* finish_paybill should be called after disclosure but before bones */ /* finish_paybill should be called after disclosure but before bones */
if (bones_ok && taken) if (bones_ok && taken)
@@ -1820,7 +1824,7 @@ num_genocides()
return n; return n;
} }
int STATIC_OVL int
num_extinct() num_extinct()
{ {
int i, n = 0; int i, n = 0;
+63 -46
View 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. */ /* Copyright (c) D. Cohrs, 1993. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1033,27 +1033,35 @@ int behavior UNUSED, under UNUSED, over UNUSED;
#endif /* STATUS_VIA_WINDOWPORT */ #endif /* STATUS_VIA_WINDOWPORT */
STATIC_VAR struct window_procs dumplog_windowprocs_backup; STATIC_VAR struct window_procs dumplog_windowprocs_backup;
STATIC_PTR FILE* dumplog_file; STATIC_PTR FILE *dumplog_file;
#ifdef DUMPLOG #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) dump_fmtstr(fmt, buf)
char *fmt; const char *fmt;
char *buf; char *buf;
{ {
char *fp = fmt, *bp = buf; const char *fp = fmt;
char *bp = buf;
int slen, len = 0; int slen, len = 0;
char tmpbuf[BUFSZ]; char tmpbuf[BUFSZ];
char verbuf[BUFSZ]; char verbuf[BUFSZ];
long uid;
time_t now;
time_t now = getnow(); now = dumplog_now;
int uid = getuid(); uid = (long) getuid();
while (fp && *fp && len < BUFSZ-1) { while (fp && *fp && len < BUFSZ-1) {
if (*fp == '%') { if (*fp == '%') {
fp++; fp++;
switch (*fp) { switch (*fp) {
default: goto finish; default:
goto finish;
case '\0': /* fallthrough */ case '\0': /* fallthrough */
case '%': /* literal % */ case '%': /* literal % */
Sprintf(tmpbuf,"%%"); Sprintf(tmpbuf,"%%");
@@ -1075,13 +1083,13 @@ char *buf;
Sprintf(tmpbuf, "%s", version_string(verbuf)); Sprintf(tmpbuf, "%s", version_string(verbuf));
break; break;
case 'u': /* UID */ case 'u': /* UID */
Sprintf(tmpbuf, "%d", uid); Sprintf(tmpbuf, "%ld", uid);
break; break;
case 'n': /* player name */ case 'n': /* player name */
Sprintf(tmpbuf, "%s", (plname ? plname : "unknown")); Sprintf(tmpbuf, "%s", *plname ? plname : "unknown");
break; break;
case 'N': /* first character of player name */ case 'N': /* first character of player name */
Sprintf(tmpbuf, "%c", (plname ? *plname : 'u')); Sprintf(tmpbuf, "%c", *plname ? *plname : 'u');
break; break;
} }
@@ -1106,7 +1114,6 @@ char *buf;
} }
#endif /* DUMPLOG */ #endif /* DUMPLOG */
void void
dump_open_log(now) dump_open_log(now)
time_t now; time_t now;
@@ -1115,6 +1122,7 @@ time_t now;
char buf[BUFSZ]; char buf[BUFSZ];
char *fname; char *fname;
dumplog_now = now;
#ifdef SYSCF #ifdef SYSCF
if (!sysopt.dumplogfile) if (!sysopt.dumplogfile)
return; return;
@@ -1122,10 +1130,12 @@ time_t now;
#else #else
fname = dump_fmtstr(DUMPLOG_FILE, buf); fname = dump_fmtstr(DUMPLOG_FILE, buf);
#endif #endif
dumplog_file = fopen(fname, "w"); dumplog_file = fopen(fname, "w");
dumplog_windowprocs_backup = windowprocs; dumplog_windowprocs_backup = windowprocs;
#endif
#else /*!DUMPLOG*/
nhUse(now);
#endif /*?DUMPLOG*/
} }
void void
@@ -1150,7 +1160,7 @@ void
dump_forward_putstr(win, attr, str, no_forward) dump_forward_putstr(win, attr, str, no_forward)
winid win; winid win;
int attr; int attr;
const char* str; const char *str;
int no_forward; int no_forward;
{ {
if (dumplog_file) if (dumplog_file)
@@ -1159,11 +1169,12 @@ int no_forward;
putstr(win, attr, str); putstr(win, attr, str);
} }
/*ARGSUSED*/
STATIC_OVL void STATIC_OVL void
dump_putstr(win, attr, str) dump_putstr(win, attr, str)
winid win; winid win UNUSED;
int attr; int attr UNUSED;
const char* str; const char *str;
{ {
if (dumplog_file) if (dumplog_file)
fprintf(dumplog_file, "%s\n", str); fprintf(dumplog_file, "%s\n", str);
@@ -1176,45 +1187,50 @@ int dummy;
return dummy; return dummy;
} }
/*ARGUSED*/
STATIC_OVL void STATIC_OVL void
dump_clear_nhwindow(win) dump_clear_nhwindow(win)
winid win; winid win UNUSED;
{ {
return;
} }
/*ARGSUSED*/
STATIC_OVL void STATIC_OVL void
dump_display_nhwindow(win, p) dump_display_nhwindow(win, p)
winid win; winid win UNUSED;
BOOLEAN_P p; boolean p UNUSED;
{ {
return;
} }
/*ARGUSED*/
STATIC_OVL void STATIC_OVL void
dump_destroy_nhwindow(win) dump_destroy_nhwindow(win)
winid win; winid win UNUSED;
{ {
return;
} }
/*ARGUSED*/
STATIC_OVL void STATIC_OVL void
dump_start_menu(win) dump_start_menu(win)
winid win; winid win UNUSED;
{ {
return;
} }
/*ARGSUSED*/
STATIC_OVL void STATIC_OVL void
dump_add_menu(win, glyph, identifier, ch, gch, attr, str, preselected) dump_add_menu(win, glyph, identifier, ch, gch, attr, str, preselected)
winid win; winid win UNUSED;
int glyph; int glyph UNUSED;
const ANY_P* identifier; const anything *identifier UNUSED;
CHAR_P ch; char ch;
CHAR_P gch; char gch UNUSED;
int attr; int attr UNUSED;
const char* str; const char *str;
BOOLEAN_P preselected; boolean preselected UNUSED;
{ {
if (dumplog_file) { if (dumplog_file) {
if (glyph == NO_GLYPH) if (glyph == NO_GLYPH)
@@ -1224,10 +1240,11 @@ BOOLEAN_P preselected;
} }
} }
/*ARGSUSED*/
STATIC_OVL void STATIC_OVL void
dump_end_menu(win, str) dump_end_menu(win, str)
winid win; winid win UNUSED;
const char* str; const char *str;
{ {
if (dumplog_file) { if (dumplog_file) {
if (str) if (str)
@@ -1238,21 +1255,21 @@ const char* str;
} }
STATIC_OVL int STATIC_OVL int
dump_select_menu(win, index, item) dump_select_menu(win, how, item)
winid win; winid win UNUSED;
int index; int how UNUSED;
MENU_ITEM_P** item; menu_item **item;
{ {
*item = NULL; *item = (menu_item *) 0;
return 0; return 0;
} }
void void
dump_redirect(flag) dump_redirect(onoff_flag)
boolean flag; boolean onoff_flag;
{ {
if (dumplog_file) { if (dumplog_file) {
if (flag) { if (onoff_flag) {
windowprocs.win_create_nhwindow = dump_create_nhwindow; windowprocs.win_create_nhwindow = dump_create_nhwindow;
windowprocs.win_clear_nhwindow = dump_clear_nhwindow; windowprocs.win_clear_nhwindow = dump_clear_nhwindow;
windowprocs.win_display_nhwindow = dump_display_nhwindow; windowprocs.win_display_nhwindow = dump_display_nhwindow;
@@ -1265,7 +1282,7 @@ boolean flag;
} else { } else {
windowprocs = dumplog_windowprocs_backup; windowprocs = dumplog_windowprocs_backup;
} }
iflags.in_dumplog = flag; iflags.in_dumplog = onoff_flag;
} else { } else {
iflags.in_dumplog = FALSE; iflags.in_dumplog = FALSE;
} }