summaryrefslogtreecommitdiff
path: root/src/byte.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/byte.c')
-rw-r--r--src/byte.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/byte.c b/src/byte.c
index c9d6d23..e113cc3 100644
--- a/src/byte.c
+++ b/src/byte.c
@@ -6,7 +6,7 @@
@brief byte manipulation functions
*/
-unsigned int byte_chr(char *s,register unsigned int n,int c)
+unsigned int byte_chr(char *s, register unsigned int n, int c)
{
register char ch;
register char *t;
@@ -14,49 +14,57 @@ unsigned int byte_chr(char *s,register unsigned int n,int c)
ch = c;
t = s;
for (;;) {
+ // clang-format off
if (!n) { break; } if (*t == ch) { break; } ++t; --n;
if (!n) { break; } if (*t == ch) { break; } ++t; --n;
if (!n) { break; } if (*t == ch) { break; } ++t; --n;
if (!n) { break; } if (*t == ch) { break; } ++t; --n;
+ // clang-format on
}
return t - s;
}
-void byte_copy(register char *to,register unsigned int n,register char *from)
+void byte_copy(register char *to, register unsigned int n, register char *from)
{
for (;;) {
+ // clang-format off
if (!n) { return; } *to++ = *from++; --n;
if (!n) { return; } *to++ = *from++; --n;
if (!n) { return; } *to++ = *from++; --n;
if (!n) { return; } *to++ = *from++; --n;
+ // clang-format on
}
}
-void byte_copyr(register char *to,register unsigned int n,register char *from)
+void byte_copyr(register char *to, register unsigned int n, register char *from)
{
to += n;
from += n;
+
for (;;) {
+ // clang-format off
if (!n) { return; } *--to = *--from; --n;
if (!n) { return; } *--to = *--from; --n;
if (!n) { return; } *--to = *--from; --n;
if (!n) { return; } *--to = *--from; --n;
+ // clang-format on
}
}
-int byte_diff(register char *s,register unsigned int n,register char *t)
+int byte_diff(register char *s, register unsigned int n, register char *t)
{
for (;;) {
+ // clang-format off
if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n;
if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n;
if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n;
if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n;
+ // clang-format on
}
- return ((int)(unsigned int)(unsigned char) *s)
- - ((int)(unsigned int)(unsigned 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, register unsigned int n, int c)
{
register char ch;
register char *t;
@@ -66,34 +74,42 @@ unsigned int byte_rchr(char *s,register unsigned int n,int 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;
+ // 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, register unsigned int n)
{
for (;;) {
+ // clang-format off
if (!n) { break; } *s++ = 0; --n;
if (!n) { break; } *s++ = 0; --n;
if (!n) { break; } *s++ = 0; --n;
if (!n) { break; } *s++ = 0; --n;
+ // clang-format on
}
}
-void byte_fill(char *s,register unsigned int n,const int c)
+void byte_fill(char *s, register unsigned int n, const int c)
{
register char ch;
-
+
ch = c;
for (;;) {
+ // clang-format off
if (!n) { break; } *s++ = ch; --n;
if (!n) { break; } *s++ = ch; --n;
if (!n) { break; } *s++ = ch; --n;
if (!n) { break; } *s++ = ch; --n;
+ // clang-format on
}
}