Don't assume zero-length wchars are incomplete. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 3206dba4f40428b4a8eadc72c083c439481f5d99
(DIR) parent 61e58874ed963bad57f4f1df19e1308207bd6085
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Fri, 17 Feb 2017 23:45:28 -0600
Don't assume zero-length wchars are incomplete.
Some libcs view zero-byte sequences as incomplete
wide characters, causing mbrtowc to return -2.
Others consider them L'\0', causing mbrtowc to
return 0.
Our multibyte processing code assumed the -2 case.
It no longer does.
Diffstat:
sam/io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
(DIR) diff --git a/sam/io.c b/sam/io.c
@@ -90,7 +90,7 @@ static inline size_t
testmbchar(File *f)
{
mbstate_t ts = f->ps;
- return mbrtowc(NULL, f->mbbuf, f->mblen, &ts);
+ return f->mblen? mbrtowc(NULL, f->mbbuf, f->mblen, &ts) : (size_t)-2;
}
static size_t