commit 21a7825390e81a0a49ab4f9c2299fb7ea7462410
parent e2eb0771342a2c7de70746fba612e44b5d85a098
Author: Jan Klemkow <j.klemkow@wemelug.de>
Date: Wed, 5 Feb 2020 07:52:07 +0100
cleanup style and add comment
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/scroll.c b/scroll.c
@@ -63,13 +63,15 @@ die(const char *fmt, ...)
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
+
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
fputc(' ', stderr);
perror(NULL);
} else {
fputc('\n', stderr);
}
- exit(1);
+
+ exit(EXIT_FAILURE);
}
void
@@ -163,15 +165,16 @@ void
scrollup(void)
{
int rows;
+
+ /* move the text in terminal n lines down */
printf("\033[%dS", ws.ws_row);
fflush(stdout);
/* set cursor position */
write(STDOUT_FILENO, "\033[0;0H", 6);
- for (rows = 0;bottom != NULL && rows < 2 * ws.ws_row; rows++) {
+ for (rows = 0; bottom != NULL && rows < 2 * ws.ws_row; rows++)
bottom = TAILQ_NEXT(bottom, entries);
- }
for (; bottom != NULL && rows > ws.ws_row; rows--) {
bottom = TAILQ_PREV(bottom, tailhead, entries);
@@ -271,5 +274,6 @@ main(int argc, char *argv[])
die("write:");
}
}
- return 0;
+
+ return EXIT_SUCCESS;
}