mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Fix regression
This commit is contained in:
parent
2a85da09d5
commit
e0eea57845
29
src/nnn.c
29
src/nnn.c
|
@ -1944,19 +1944,25 @@ static inline void resetdircolor(int flags)
|
||||||
static char *unescape(const char *str, uint maxcols)
|
static char *unescape(const char *str, uint maxcols)
|
||||||
{
|
{
|
||||||
static wchar_t wbuf[NAME_MAX + 1] __attribute__ ((aligned));
|
static wchar_t wbuf[NAME_MAX + 1] __attribute__ ((aligned));
|
||||||
static wchar_t *buf = wbuf;
|
wchar_t *buf = wbuf;
|
||||||
static size_t len, lencount;
|
size_t len, lencount = 0;
|
||||||
|
|
||||||
/* Convert multi-byte to wide char */
|
/* Convert multi-byte to wide char */
|
||||||
len = mbstowcs(wbuf, str, NAME_MAX);
|
len = mbstowcs(wbuf, str, NAME_MAX);
|
||||||
|
|
||||||
//g_buf[0] = '\0';
|
while (*buf && lencount <= maxcols) {
|
||||||
|
if (*buf <= '\x1f' || *buf == '\x7f')
|
||||||
|
*buf = '\?';
|
||||||
|
|
||||||
if (maxcols) {
|
++buf;
|
||||||
len = lencount = wcswidth(wbuf, len);
|
++lencount;
|
||||||
/* Reduce number of wide chars to max columns */
|
}
|
||||||
if (len > maxcols)
|
|
||||||
lencount = maxcols + 1;
|
len = lencount = wcswidth(wbuf, len);
|
||||||
|
|
||||||
|
/* Reduce number of wide chars to max columns */
|
||||||
|
if (len > maxcols) {
|
||||||
|
lencount = maxcols + 1;
|
||||||
|
|
||||||
/* Reduce wide chars one by one till it fits */
|
/* Reduce wide chars one by one till it fits */
|
||||||
while (len > maxcols)
|
while (len > maxcols)
|
||||||
|
@ -1965,13 +1971,6 @@ static char *unescape(const char *str, uint maxcols)
|
||||||
wbuf[lencount] = L'\0';
|
wbuf[lencount] = L'\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*buf) {
|
|
||||||
if (*buf <= '\x1f' || *buf == '\x7f')
|
|
||||||
*buf = '\?';
|
|
||||||
|
|
||||||
++buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert wide char to multi-byte */
|
/* Convert wide char to multi-byte */
|
||||||
wcstombs(g_buf, wbuf, NAME_MAX);
|
wcstombs(g_buf, wbuf, NAME_MAX);
|
||||||
return g_buf;
|
return g_buf;
|
||||||
|
|
Loading…
Reference in a new issue