From a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Wed, 3 Jul 2024 15:52:39 +0200 Subject: format files --- src/tai64nfrac.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/tai64nfrac.c') diff --git a/src/tai64nfrac.c b/src/tai64nfrac.c index f3db977..bb29b44 100644 --- a/src/tai64nfrac.c +++ b/src/tai64nfrac.c @@ -1,11 +1,11 @@ #include "buffer.h" -#include "stralloc.h" #include "exit.h" -#include "readwrite.h" -#include "open.h" -#include "scan.h" #include "fmt.h" #include "getln.h" +#include "open.h" +#include "readwrite.h" +#include "scan.h" +#include "stralloc.h" #define TAI64NLEN 24 @@ -16,11 +16,11 @@ */ char outbuf[64]; -buffer bo = BUFFER_INIT(write,1,outbuf,sizeof(outbuf)); +buffer bo = BUFFER_INIT(write, 1, outbuf, sizeof(outbuf)); static void outs(char *s) { - if (buffer_puts(&bo,s) == -1) _exit(1); + if (buffer_puts(&bo, s) == -1) _exit(1); if (buffer_flush(&bo) == -1) _exit(1); } @@ -28,12 +28,12 @@ static void outi(int i) { char num[FMT_ULONG]; - if (buffer_put(&bo,num,fmt_ulong(num,(unsigned long) i)) == -1) _exit(1); + if (buffer_put(&bo, num, fmt_ulong(num, (unsigned long)i)) == -1) _exit(1); if (buffer_flush(&bo) == -1) _exit(1); } char inbuf[1024]; -buffer bi = BUFFER_INIT(read,0,inbuf,sizeof(inbuf)); +buffer bi = BUFFER_INIT(read, 0, inbuf, sizeof(inbuf)); int main(void) { @@ -41,23 +41,23 @@ int main(void) int i; int match; unsigned long u; - unsigned long seconds; + unsigned long seconds; unsigned long nanoseconds; stralloc line = {0}; -/* Read from stdin */ + /* Read from stdin */ - buffer_init(&bi,read,0,inbuf,sizeof(inbuf)); + buffer_init(&bi, read, 0, inbuf, sizeof(inbuf)); for (;;) { - if (getln(&bi,&line,&match,'\n') != 0) _exit(1); + if (getln(&bi, &line, &match, '\n') != 0) _exit(1); if (!match) break; if (!stralloc_0(&line)) _exit(1); seconds = 0; nanoseconds = 0; - - if (line.s[0] == '@') { /* tai64 timestamp */ + + if (line.s[0] == '@') { /* tai64 timestamp */ for (i = 1; i <= TAI64NLEN; i++) { c = (int)line.s[i]; u = c - '0'; @@ -74,9 +74,14 @@ int main(void) } seconds -= 4611686018427387914ULL; seconds = seconds > 0 ? seconds : 0; - outi(seconds); outs("."); outi(nanoseconds); outs(line.s + i); outs("\n"); + outi(seconds); + outs("."); + outi(nanoseconds); + outs(line.s + i); + outs("\n"); } else { - outs("tai64nfrac: fatal: Wrong TAI64N input format."); outs("\n"); + outs("tai64nfrac: fatal: Wrong TAI64N input format."); + outs("\n"); _exit(1); } } -- cgit v1.2.3