I'm having a strange problem with Ncurses in C that I can't seem to find documented anywhere, nor on the web. Maybe I'm not using the correct search terms?
I have several windows and panels and LOTs of code. It all works perfectly UNTIL this happens:
mvwprintw(windowptr[i], y, x, NULL); <-- That NULL value is what sets off the bomb
I would expect that a NULL string would simply print a string of 0 length, but that's not what happens. What actually happens is that it corrupts all of my windows/panels. It seems to be somehow deleting all previously written chars and disabling the displaying of new chars on all windows / panels except the current window / panel. The current window / panel does not get blanked, but no new chars can be printed to it.
Is this a bug? ... or maybe an undocumented feature?
$ dpkg -l | grep -i ncurse
ii libncurses5:amd64 6.0+20160213-1ubuntu1 amd64 shared libraries for terminal handling
ii libncurses5:i386 6.0+20160213-1ubuntu1 i386 shared libraries for terminal handling
ii libncurses5-dev:amd64 6.0+20160213-1ubuntu1 amd64 developer's libraries for ncurses
ii libncursesw5:amd64 6.0+20160213-1ubuntu1 amd64 shared libraries for terminal handling (wide character support)
ii libncursesw5:i386 6.0+20160213-1ubuntu1 i386 shared libraries for terminal handling (wide character support)
ii mtr-tiny 0.86-1ubuntu0.1 amd64 Full screen ncurses traceroute tool
ii ncurses-base 6.0+20160213-1ubuntu1 all basic terminal type definitions
ii ncurses-bin 6.0+20160213-1ubuntu1 amd64 terminal-related programs and man pages
ii ncurses-term 6.0+20160213-1ubuntu1 all additional terminal type definitions
Actually (there's no sample MCVE ) to test in this question), ncurses does check for this null pointer and is expected to ignore the printw
which would be called after the wmove
part.
To see this, follow the source-code:
mvprintw
is always a function call (due to the variable-length argument list) vw_printw
is the next step, which calls _nc_printf_string
, which sees the null-pointer for the format, and returns null, vw_printw
ignore the call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.