diff options
Diffstat (limited to 'src/str.c')
-rw-r--r-- | src/str.c | 57 |
1 files changed, 24 insertions, 33 deletions
@@ -3,20 +3,19 @@ #include "stralloc.h" /** - @file str.c - @author djb - @source qmail - @brief string handling functions + @file str.c + @author djb + @source qmail + @brief string handling functions */ -unsigned int str_copy(register char *s, register const char *t) +unsigned int str_copy(char *s, const char *t) { - register int len; + int len = 0; - len = 0; for (;;) { // clang-format off - if (!(*s = *t)) { return len; } ++s; ++t; ++len; + if (!(*s = *t)) { return len; } ++s; ++t; ++len; if (!(*s = *t)) { return len; } ++s; ++t; ++len; if (!(*s = *t)) { return len; } ++s; ++t; ++len; if (!(*s = *t)) { return len; } ++s; ++t; ++len; @@ -24,11 +23,9 @@ unsigned int str_copy(register char *s, register const char *t) } } -unsigned int str_copyb(register char *s, register const char *t, unsigned int max) +unsigned int str_copyb(char *s, const char *t, unsigned int max) { - register int len; - - len = 0; + int len = 0; while (max-- > 0) { // clang-format off @@ -42,9 +39,9 @@ unsigned int str_copyb(register char *s, register const char *t, unsigned int ma return len; } -int str_diff(register const char *s, register const char *t) +int str_diff(const char *s, const char *t) { - register char x; + char x; for (;;) { // clang-format off @@ -57,9 +54,9 @@ int str_diff(register const char *s, register const char *t) return ((int)(unsigned int)(unsigned char)x) - ((int)(unsigned int)(unsigned char)*t); } -int str_diffn(register const char *s, register const char *t, unsigned int len) +int str_diffn(const char *s, const char *t, unsigned int len) { - register char x; + char x; for (;;) { // clang-format off @@ -72,11 +69,10 @@ int str_diffn(register const char *s, register const char *t, unsigned int len) return ((int)(unsigned int)(unsigned char)x) - ((int)(unsigned int)(unsigned char)*t); } -unsigned int str_len(register const char *s) +unsigned int str_len(const char *s) { - register const char *t; + const char *t = s; - t = s; for (;;) { // clang-format off if (!*t) { return t - s; } ++t; @@ -87,13 +83,11 @@ unsigned int str_len(register const char *s) } } -unsigned int str_chr(register const char *s, int c) +unsigned int str_chr(const char *s, int c) { - register char ch; - register const char *t; + char ch = c; + const char *t = s; - ch = c; - t = s; for (;;) { // clang-format off if (!*t) { break; } if (*t == ch) { break; } ++t; @@ -105,15 +99,12 @@ unsigned int str_chr(register const char *s, int c) return t - s; } -unsigned int str_rchr(register const char *s, int c) +unsigned int str_rchr(const char *s, int c) { - register char ch; - register const char *t; - register const char *u; + char ch = c; + const char *t = s; + const char *u = 0; - ch = c; - t = s; - u = 0; for (;;) { // clang-format off if (!*t) { break; } if (*t == ch) { u = t; } ++t; @@ -126,9 +117,9 @@ unsigned int str_rchr(register const char *s, int c) return u - s; } -int str_start(register const char *s, register const char *t) +int str_start(const char *s, const char *t) { - register char x; + char x; for (;;) { // clang-format off |