diff options
Diffstat (limited to 'vendor/librune/lib/utf8/u8prev.c')
-rw-r--r-- | vendor/librune/lib/utf8/u8prev.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/vendor/librune/lib/utf8/u8prev.c b/vendor/librune/lib/utf8/u8prev.c index fac0fc7..a219ae9 100644 --- a/vendor/librune/lib/utf8/u8prev.c +++ b/vendor/librune/lib/utf8/u8prev.c @@ -1,9 +1,10 @@ +#define _RUNE_NO_MACRO_WRAPPER 1 #include "rune.h" #include "utf8.h" #include "internal/common.h" -const char8_t * +int u8prev(rune *ch, const char8_t **p, const char8_t *start) { int off; @@ -12,7 +13,7 @@ u8prev(rune *ch, const char8_t **p, const char8_t *start) ptrdiff_t d = s - start; if (d <= 0) { - return nullptr; + return 0; } else if (U1(s[-1])) { *ch = s[-1]; off = 1; @@ -29,9 +30,11 @@ u8prev(rune *ch, const char8_t **p, const char8_t *start) } else match = false; - if (match && u8chkr(*ch)) - return *p -= off; + if (!(match && u8chkr(*ch))) { + *ch = RUNE_ERROR; + off = 1; + } - *ch = RUNE_ERROR; - return *p--; + *p -= off; + return off; } |