diff options
Diffstat (limited to 'booki.c')
| -rw-r--r-- | booki.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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) { |
