mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 23:08:40 +02:00
Fix up display_len vs len
This commit is contained in:
@@ -941,6 +941,7 @@ static void PrintLeft(char const *s, int width, char pad)
|
|||||||
wchar_t static_buf[128];
|
wchar_t static_buf[128];
|
||||||
wchar_t *buf;
|
wchar_t *buf;
|
||||||
wchar_t *ws;
|
wchar_t *ws;
|
||||||
|
int display_len;
|
||||||
|
|
||||||
if (!len) {
|
if (!len) {
|
||||||
for (i=0; i<width; i++) {
|
for (i=0; i<width; i++) {
|
||||||
@@ -959,14 +960,13 @@ static void PrintLeft(char const *s, int width, char pad)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void) mbstowcs(buf, s, len+1);
|
(void) mbstowcs(buf, s, len+1);
|
||||||
|
display_len = wcswidth(buf, len+1);
|
||||||
|
|
||||||
ws = buf;
|
ws = buf;
|
||||||
for (i=0; i<width; i++) {
|
for (i=0; i<width;) {
|
||||||
if (*ws) {
|
if (*ws) {
|
||||||
PutWideChar(*ws++);
|
PutWideChar(*ws++);
|
||||||
if (wcwidth(*ws) == 0) {
|
i+= wcwidth(*ws);
|
||||||
/* Don't count this character... it's zero-width */
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -975,7 +975,7 @@ static void PrintLeft(char const *s, int width, char pad)
|
|||||||
while (*ws && wcwidth(*ws) == 0) {
|
while (*ws && wcwidth(*ws) == 0) {
|
||||||
PutWideChar(*ws++);
|
PutWideChar(*ws++);
|
||||||
}
|
}
|
||||||
for (i=len; i<width; i++) fputc(pad, stdout);
|
for (i=display_len; i<width; i++) fputc(pad, stdout);
|
||||||
if (buf != static_buf) free(buf);
|
if (buf != static_buf) free(buf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user