diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-05-20 18:31:28 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-05-20 18:31:28 -0700 |
| commit | 219f62ed3f51a1094e75d4bf8823db7608e70b0e (patch) | |
| tree | 4fcfbb08525b61590086ba1494152721d9bbb221 /utf8.h | |
| parent | cc6e25a06fdebbabe4b170ca5f43c399cfa0f70e (diff) | |
Renamed file_t.contents -> file_t.start, added file_t.memory for
canonical tracking of memory for mmap, simplified json printing,
and added support for initiating searches on a specific line (and/or
column).
Diffstat (limited to 'utf8.h')
| -rw-r--r-- | utf8.h | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -4,6 +4,8 @@ #ifndef UTF8__H #define UTF8__H +#include "files.h" + #define UTF8_MAXCHARLEN 4 // // Return the location of the next character or UTF8 codepoint. @@ -30,15 +32,15 @@ static inline const char *next_char(file_t *f, const char *str) __attribute__((nonnull, pure)) static inline const char *prev_char(file_t *f, const char *str) { - if (__builtin_expect(str-1 >= f->contents && (str[-1] & 0x80) == 0x0, 1)) + if (__builtin_expect(str-1 >= f->start && (str[-1] & 0x80) == 0x0, 1)) return str-1; - if (__builtin_expect(str-2 >= f->contents && (str[-2] & 0xe0) == 0xc0, 1)) + if (__builtin_expect(str-2 >= f->start && (str[-2] & 0xe0) == 0xc0, 1)) return str-2; - if (__builtin_expect(str-3 >= f->contents && (str[-3] & 0xf0) == 0xe0, 1)) + if (__builtin_expect(str-3 >= f->start && (str[-3] & 0xf0) == 0xe0, 1)) return str-3; - if (__builtin_expect(str-4 >= f->contents && (str[-4] & 0xf8) == 0xf0, 1)) + if (__builtin_expect(str-4 >= f->start && (str[-4] & 0xf8) == 0xf0, 1)) return str-4; - return __builtin_expect(str-1 >= f->contents, 1) ? str-1 : f->contents; + return __builtin_expect(str-1 >= f->start, 1) ? str-1 : f->start; } #endif // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1 |
