[英]Linux C Ncurses issue
I'm having a strange problem with Ncurses in C that I can't seem to find documented anywhere, nor on the web.我在 C 语言中遇到了 Ncurses 一个奇怪的问题,我似乎无法在任何地方找到文档,也无法在网络上找到。 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.我希望 NULL 字符串只会打印长度为 0 的字符串,但事实并非如此。 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.其实(有没有样品MCVE )在这个问题测试),ncurses的做检查此空指针,预计忽略
printw
这将在之后被称为wmove
一部分。
To see this, follow the source-code:要看到这一点,请遵循源代码:
mvprintw
is always a function call (due to the variable-length argument list) mvprintw
始终是一个函数调用(由于可变长度的参数列表)vw_printw
is the next step, which calls vw_printw
是下一步,它调用_nc_printf_string
, which sees the null-pointer for the format, and returns null, _nc_printf_string
,它查看格式的空指针,并返回空值,vw_printw
ignore the call.vw_printw
忽略调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.