From 795ffc5e62e8ba383575dbcd9943a580d4bd3358 Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Tue, 9 Jul 2024 15:50:21 +0200 Subject: formatting changes Manual format adjustments. Comment adjustments. Remove usage of the register keyword. --- src/byte.c | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'src/byte.c') diff --git a/src/byte.c b/src/byte.c index e113cc3..51f18e1 100644 --- a/src/byte.c +++ b/src/byte.c @@ -1,18 +1,16 @@ #include "byte.h" /** - @file byte.c - @author djb - @brief byte manipulation functions + @file byte.c + @author djb + @brief byte manipulation functions */ -unsigned int byte_chr(char *s, register unsigned int n, int c) +unsigned int byte_chr(char *s, unsigned int n, int c) { - register char ch; - register char *t; + char ch = c; + char *t = s; - ch = c; - t = s; for (;;) { // clang-format off if (!n) { break; } if (*t == ch) { break; } ++t; --n; @@ -24,7 +22,7 @@ unsigned int byte_chr(char *s, register unsigned int n, int c) return t - s; } -void byte_copy(register char *to, register unsigned int n, register char *from) +void byte_copy(char *to, unsigned int n, char *from) { for (;;) { // clang-format off @@ -36,7 +34,7 @@ void byte_copy(register char *to, register unsigned int n, register char *from) } } -void byte_copyr(register char *to, register unsigned int n, register char *from) +void byte_copyr(char *to, unsigned int n, char *from) { to += n; from += n; @@ -51,7 +49,7 @@ void byte_copyr(register char *to, register unsigned int n, register char *from) } } -int byte_diff(register char *s, register unsigned int n, register char *t) +int byte_diff(char *s, unsigned int n, char *t) { for (;;) { // clang-format off @@ -64,30 +62,25 @@ int byte_diff(register char *s, register unsigned int n, register char *t) return ((int)(unsigned int)(unsigned char)*s) - ((int)(unsigned int)(unsigned char)*t); } -unsigned int byte_rchr(char *s, register unsigned int n, int c) +unsigned int byte_rchr(char *s, unsigned int n, int c) { - register char ch; - register char *t; - register char *u; + char ch = c; + char *t = s; + char *u = 0; - ch = c; - t = s; - u = 0; for (;;) { // clang-format off - if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; - if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; + if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; + if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; if (!n) { break; } if (*t == ch) { u = t; } ++t; --n; // clang-format on } - if (!u) { - u = t; - } + if (!u) u = t; return u - s; } -void byte_zero(char *s, register unsigned int n) +void byte_zero(char *s, unsigned int n) { for (;;) { // clang-format off @@ -99,11 +92,10 @@ void byte_zero(char *s, register unsigned int n) } } -void byte_fill(char *s, register unsigned int n, const int c) +void byte_fill(char *s, unsigned int n, int c) { - register char ch; + char ch = c; - ch = c; for (;;) { // clang-format off if (!n) { break; } *s++ = ch; --n; -- cgit v1.2.3