NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/57865: Curses addch() family does not handle tab correctly.
>Number: 57865
>Category: lib
>Synopsis: Curses addch() family does not handle tab correctly.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jan 18 12:55:00 +0000 2024
>Originator: Anthony Howe
>Release: 9.3
>Organization:
>Environment:
NetBSD elf.snert.com 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug 4 15:30:37 UTC 2022 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
Displaying a string with tabs using addstr() advances the cursor to the next tab stop, a multiple of 8, just fine.
Displaying a string with tabs via repeated calls to addch(), incorrectly handlings tabs.
>How-To-Repeat:
This short program demonstrates the problem:
```
#include <curses.h>
#include <unistd.h>
void
ruler(void)
{
standout();
addstr("123456789.123456789.123456789.123456789.\n");
standend();
}
void
test_addch_tab(const char *s)
{
for ( ; *s != '\0'; s++) {
/* Historical Curses handling of TAB would advance to
* the next tabstop (a multiple of 8, eg. 0, 8, 16, ...).
* See SUS Curses Issue 7 section 3.4.3.
*/
addch(*s);
}
}
int
main(int argc, char **argv)
{
const char t1[] = "\t9.123\t78\n";
const char t2[] = "1234\t9.123\t\t567\n";
const char t3[] = "Append tab string:";
if (initscr() == NULL) {
return 1;
}
addstr("\nTab behaviour with addstr() normal.\n");
ruler();
addstr(t1);
addstr(t2);
addstr(t3); addstr(t1);
addstr("\nTab behaviour with addch() broken.\n");
ruler();
test_addch_tab(t1);
test_addch_tab(t2);
test_addch_tab(t3); test_addch_tab(t1);
refresh();
sleep(10);
endwin();
return 0;
}
```
>Fix:
Home |
Main Index |
Thread Index |
Old Index