projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
unistr/u8-mbsnlen: Fix return value for incomplete character.
[pspp]
/
lib
/
unistr
/
u8-mbsnlen.c
diff --git
a/lib/unistr/u8-mbsnlen.c
b/lib/unistr/u8-mbsnlen.c
index 913bbf0d234b2655994bbe24a07ada98ef0c4580..9ddc42ea2f0c4a74b24189a3ef26c440f7e24f11 100644
(file)
--- a/
lib/unistr/u8-mbsnlen.c
+++ b/
lib/unistr/u8-mbsnlen.c
@@
-28,12
+28,15
@@
u8_mbsnlen (const uint8_t *s, size_t n)
characters = 0;
while (n > 0)
{
- int count = u8_mblen (s, n);
+ ucs4_t uc;
+ int count = u8_mbtoucr (&uc, s, n);
+ characters++;
+ if (count == -2)
+ break;
if (count <= 0)
count = 1;
s += count;
n -= count;
- characters++;
}
return characters;
}