| Date: Sat, 10 Apr 2021 18:21:58 +0200
Export diag() function
Diffstat:
M common.h | 1 +
M sacc.c | 16 ++++++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
--- |
| @@ -44,6 +44,7 @@ struct dir {
size_t curline;
};
+extern void (*diag)(char *fmt, ...);
void die(const char *fmt, ...);
size_t mbsprint(const char *s, size_t len);
#ifdef NEED_STRCASESTR |
| @@ -28,9 +28,9 @@ static int devnullfd;
static int parent = 1;
static int interactive;
-static void (*diag)(char *fmt, ...);
+void (*diag)(char *fmt, ...);
-void
+static void
stddiag(char *fmt, ...)
{
va_list arg;
@@ -1013,8 +1013,11 @@ setup(void)
die("mkdir: %s: %s", tmpdir, strerror(errno));
if(interactive = isatty(1)) {
uisetup();
+ diag = uistatus;
sa.sa_handler = uisigwinch;
sigaction(SIGWINCH, &sa, NULL);
+ } else {
+ diag = stddiag;
}
}
@@ -1027,15 +1030,12 @@ main(int argc, char *argv[])
setup();
mainurl = xstrdup(argv[1]);
-
mainentry = moldentry(mainurl);
- if (interactive) {
- diag = uistatus;
+
+ if (interactive)
delve(mainentry);
- } else {
- diag = stddiag;
+ else
printout(mainentry);
- }
exit(0);
} |