mvaddch() cursor movement not as expected

Avinash Sonawane <[email protected]> Mon, 30 Mar 2015 15:19:18 +0530
Newsgroups gmane.comp.lib.ncurses.general
Message-ID <CAJ9BSW-5bO1PuL6wc-gOPJUbC06aXrWUXek+8sV3xx1AU7Oocw@mail.gmail.com>
Hello there! I have a query regarding mvaddch cursor movement. Please
go through the following code snippet.

Code:

#include <ncurses.h>

int main(int argc, char **argv)
{
    initscr();
    noecho();
    cbreak();

    mvprintw(0, 0, curses_version());
    mvprintw(1, 0, "Hello World");
    mvaddch(2, 0, mvinch(1, 4));                 // Why doesn't this work?

    getch();
    endwin();

    return 0;
}

Output:

ncurses 5.9.20130608
Hello World

with pointer blinking (waiting for getch ) just after o of Hello.

Question:
As in C, arguments passed to a function are evaluated first before
calling that function, mvinch() will be called first and when it'll
return the character o the call to mvaddch() will be made.
But then why character o is not printed on line 2 (just below Hello
World)? Instead mvaddch prints o at current cursor position (thanks to
winch which is 1,4). Here mvaddch() behaves just like addch paying no
respect to the mv prefix and the explicit movement coordinates given
to it. Why?

Is this a possible bug in mvaddch() or am I missing something?

-- 
Avinash Sonawane (RootKea)
PICT, Pune
http://rootkea.wordpress.com