aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Winston2024-06-06 22:37:34 -0400
committerBen Winston2024-06-06 22:37:34 -0400
commit5b163ece6dbdad4867902c1d30de644062a2b0ab (patch)
tree7150a9d92b4d211fb003dcda22dc6af8bbf5ccf1
parentcbcd1fbb716664be4d784d7e8b359e342cb073c9 (diff)
refactor: less locals
-rw-r--r--booki.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/booki.c b/booki.c
index a199701..770ea00 100644
--- a/booki.c
+++ b/booki.c
@@ -22,20 +22,18 @@ char* characters_from_end(char* str, int len_in_bytes, int number_of_chars) {
return str;
// start at the end of the string, locate all code points
- char* newptr = str + len_in_bytes; // will update to last character in do..while
unsigned char ch;
do {
- // update the pointer, get the character
- newptr--;
+ // get the last/previous byte
len_in_bytes--;
- ch = (unsigned char) *newptr;
+ ch = (unsigned char) *(str + len_in_bytes);
// if we're at the first byte of a unicode point, we've found a whole character
if (ch < 0x80 || ch >= 0xC3)
number_of_chars--;
} while (number_of_chars > 0 && len_in_bytes > 0);
- return newptr;
+ return str + len_in_bytes;
}
bool comparable(const char* pattern, const char* candidate, int len) {