summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-08-02 15:27:50 -0400
committerJakob Kaivo <jkk@ung.org>2019-08-02 15:27:50 -0400
commit6b5c1352e808cb4b1eeb6ec2a2cc944158a6d43f (patch)
treeda5a3f5c85a731580d55759068f8a4ad6fe6a778
parent1e1bb9c04bd7f8504c0cf776b62feca69fb8cb93 (diff)
clean up inner loop of nextsuffix() a bit
-rw-r--r--split.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/split.c b/split.c
index 81671a7..a3d0e77 100644
--- a/split.c
+++ b/split.c
@@ -39,13 +39,14 @@ static char *nextsuffix(size_t n, char s[])
return s;
}
- for (size_t i = n - 1; ; i--) {
- s[i] = *(strchr(alphabet, s[i]) + 1);
- if (s[i] == '\0') {
- if (i == 0) {
+ n--;
+ for (;;) {
+ s[n] = *(strchr(alphabet, s[n]) + 1);
+ if (s[n] == '\0') {
+ if (n == 0) {
return NULL;
}
- s[i] = alphabet[0];
+ s[n--] = alphabet[0];
} else {
break;
}