diff options
author | June McEnroe <june@causal.agency> | 2020-04-25 13:01:33 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-04-25 13:01:33 -0400 |
commit | 9de0ae65101269afdf8ea44775e6d2f2cef887b4 (patch) | |
tree | c48e459860da85b325f3807a5ab51c264787a15c /port/wcwidth/wcswidth.c | |
parent | Add Markus Kuhn's wcwidth implementation (diff) | |
download | src-9de0ae65101269afdf8ea44775e6d2f2cef887b4.tar.gz src-9de0ae65101269afdf8ea44775e6d2f2cef887b4.zip |
Replace wcwidth implementation with that of musl
Imported from musl 1.2.0 sources.
Diffstat (limited to '')
-rw-r--r-- | port/wcwidth/wcswidth.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/port/wcwidth/wcswidth.c b/port/wcwidth/wcswidth.c new file mode 100644 index 00000000..5c8a5a4d --- /dev/null +++ b/port/wcwidth/wcswidth.c @@ -0,0 +1,8 @@ +#include <wchar.h> + +int wcswidth(const wchar_t *wcs, size_t n) +{ + int l=0, k=0; + for (; n-- && *wcs && (k = wcwidth(*wcs)) >= 0; l+=k, wcs++); + return (k < 0) ? k : l; +} |