mirror of
https://github.com/borgbackup/borg.git
synced 2026-04-24 23:57:23 -04:00
Merge pull request #1091 from ThomasWaldmann/swidth-fallback
fall back to len() if wcswidth returns negative value
This commit is contained in:
commit
4c4aa64410
1 changed files with 6 additions and 1 deletions
|
|
@ -2,4 +2,9 @@ cdef extern from "wchar.h":
|
|||
cdef int wcswidth(const Py_UNICODE *str, size_t n)
|
||||
|
||||
def swidth(s):
|
||||
return wcswidth(s, len(s))
|
||||
str_len = len(s)
|
||||
terminal_width = wcswidth(s, str_len)
|
||||
if terminal_width >= 0:
|
||||
return terminal_width
|
||||
else:
|
||||
return str_len
|
||||
|
|
|
|||
Loading…
Reference in a new issue