Make the variadic functions look more like ordinary code rather than
have the function opening brace be hidden inside the VA_DECL() macro.
That brace is still there, but VA_DECL() now needs to be followed by
a visible brace (which introduces a nested block rather than the
start of the funciton). VA_END() now provides a hidden closing brace
to end the nested block, and the existing closing brace still matches
the one in VA_DECL().
Sample usage:
void foo VA_DECL(int, arg) --macro expansion has a hidden opening brace
{ --new, explicit opening brace (actually introduces a nested block)
VA_START(bar);
...code for foo...
VA_END(); --expansion now provides a closing brace for the nested block
} --existing closing brace, still pairs with the hidden one in VA_DECL()
This should help if/when another round of reformatting ever takes place,
and also with editors or other tools that do brace/bracket/parenthesis
matching.
I had forgotten that there were variadic functions in sys/* and ended
up modifying a lot more files than intended. The majority of changes
to those just inserted a new '{' line so that revised VA_END()'s '}'
won't introduce a syntax error. A couple of them needed VA_END() moved
so that local variables wouldn't go out of scope too soon. Only the
Unix ones have been tested.
92 lines
1.9 KiB
C
92 lines
1.9 KiB
C
/* NetHack 3.6 pctty.c $NHDT-Date: 1431737063 2015/05/16 00:44:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
|
|
/* NetHack 3.6 pctty.c $Date: 2009/05/06 10:50:30 $ $Revision: 1.6 $ */
|
|
/* SCCS Id: @(#)pctty.c 3.5 1990/22/02
|
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
/* tty.c - (PC) version */
|
|
|
|
#define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers \
|
|
*/
|
|
#include "hack.h"
|
|
#include "wintty.h"
|
|
|
|
char erase_char, kill_char;
|
|
|
|
/*
|
|
* Get initial state of terminal, set ospeed (for termcap routines)
|
|
* and switch off tab expansion if necessary.
|
|
* Called by startup() in termcap.c and after returning from ! or ^Z
|
|
*/
|
|
void
|
|
gettty()
|
|
{
|
|
erase_char = '\b';
|
|
kill_char = 21; /* cntl-U */
|
|
iflags.cbreak = TRUE;
|
|
#if !defined(TOS)
|
|
disable_ctrlP(); /* turn off ^P processing */
|
|
#endif
|
|
#if defined(MSDOS) && defined(NO_TERMS)
|
|
gr_init();
|
|
#endif
|
|
}
|
|
|
|
/* reset terminal to original state */
|
|
void
|
|
settty(s)
|
|
const char *s;
|
|
{
|
|
#if defined(MSDOS) && defined(NO_TERMS)
|
|
gr_finish();
|
|
#endif
|
|
end_screen();
|
|
if (s)
|
|
raw_print(s);
|
|
#if !defined(TOS)
|
|
enable_ctrlP(); /* turn on ^P processing */
|
|
#endif
|
|
}
|
|
|
|
/* called by init_nhwindows() and resume_nhwindows() */
|
|
void
|
|
setftty()
|
|
{
|
|
start_screen();
|
|
}
|
|
|
|
#if defined(TIMED_DELAY) && defined(_MSC_VER)
|
|
void
|
|
msleep(mseconds)
|
|
unsigned mseconds;
|
|
{
|
|
/* now uses clock() which is ANSI C */
|
|
clock_t goal;
|
|
|
|
goal = mseconds + clock();
|
|
while (goal > clock()) {
|
|
/* do nothing */
|
|
}
|
|
}
|
|
#endif
|
|
|
|
/* fatal error */
|
|
/*VARARGS1*/
|
|
|
|
void error
|
|
VA_DECL(const char *, s)
|
|
{
|
|
VA_START(s);
|
|
VA_INIT(s, const char *);
|
|
/* error() may get called before tty is initialized */
|
|
if (iflags.window_inited)
|
|
end_screen();
|
|
putchar('\n');
|
|
Vprintf(s, VA_ARGS);
|
|
putchar('\n');
|
|
VA_END();
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
/*pctty.c*/
|