typetest

Typing speed benchmarker
git clone https://git.sinitax.com/sinitax/typetest
Log | Files | Refs | LICENSE | sfeed.txt

commit bb8a2392d0573b6466720570722ec7bc1a46f139
parent 81eaa32302318b5285f7805ff2083b071e106c56
Author: Louis Burda <quent.burda@gmail.com>
Date:   Wed, 11 Jan 2023 02:21:05 +0100

Replace die

Diffstat:
Mtypetest.c | 35+++++++++++++----------------------
1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/typetest.c b/typetest.c @@ -1,18 +1,19 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdint.h> +#include <unistd.h> +#include <err.h> #include <termio.h> #include <stdarg.h> -#include <unistd.h> #include <time.h> +#include <stdio.h> +#include <string.h> +#include <stdint.h> +#include <stdlib.h> #define LINTERP(a,b,v) ((a) * (v) + (b) * (1 - (v))) enum { C_EOF = 0x03, /* CTRL+C */ C_EOT = 0x04, /* CTRL+D */ - C_DEL = 0x7f, + C_DEL = 0x7f, /* BKSP */ C_SKIP = 0x17, /* CTRL+W */ }; @@ -51,18 +52,6 @@ int typed = 0; float gcps; void -die(const char *fmtstr, ...) -{ - va_list ap; - - va_start(ap, fmtstr); - vfprintf(stderr, fmtstr, ap); - va_end(ap); - - exit(EXIT_FAILURE); -} - -void print_style(const int *props) { const int *iter; @@ -206,11 +195,13 @@ main(int argc, const char **argv) int eof; FILE *f; - if (argc < 2) - die("USAGE: typetest <FILE>\n"); + if (argc < 2) { + printf("Usage: typetest FILE\n"); + return 1; + } if (!(f = fopen(argv[1], "r"))) - die("Failed to read file\n"); + errx(1, "Failed to read file"); setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); @@ -223,7 +214,7 @@ main(int argc, const char **argv) if (!tcsetattr(0, TCSANOW, &t)) atexit(reset); if (getl(f, next, sizeof(next))) - die("Empty input file\n"); + errx(1, "Empty input file"); for (eof = 0; !eof; ) { memcpy(cur, next, sizeof(cur));