=== modified file 'demo.c' --- demo.c 2011-08-18 10:20:41 +0000 +++ demo.c 2011-04-26 07:28:26 +0000 @@ -1,6 +1,5 @@ #include #include -#include #include "termkey.h" @@ -45,22 +44,13 @@ printf("\e[?%dhMouse mode active\n", mouse); while((ret = termkey_waitkey(tk, &key)) != TERMKEY_RES_EOF) { - if(ret == TERMKEY_RES_KEY) { - termkey_strfkey(tk, buffer, sizeof buffer, &key, format); - printf("%s\n", buffer); + termkey_strfkey(tk, buffer, sizeof buffer, &key, format); + printf("%s\n", buffer); - if(key.type == TERMKEY_TYPE_UNICODE && - key.modifiers & TERMKEY_KEYMOD_CTRL && - (key.code.codepoint == 'C' || key.code.codepoint == 'c')) - break; - } - else if(ret == TERMKEY_RES_ERROR) { - if(errno != EINTR) { - perror("termkey_waitkey"); - break; - } - printf("Interrupted by signal\n"); - } + if(key.type == TERMKEY_TYPE_UNICODE && + key.modifiers & TERMKEY_KEYMOD_CTRL && + (key.code.codepoint == 'C' || key.code.codepoint == 'c')) + break; } if(mouse) === modified file 'termkey.c' --- termkey.c 2011-08-18 10:20:41 +0000 +++ termkey.c 2011-06-16 16:07:47 +0000 @@ -607,7 +607,6 @@ /* fallthrough */ case TERMKEY_RES_EOF: - case TERMKEY_RES_ERROR: return ret; case TERMKEY_RES_AGAIN: @@ -674,7 +673,6 @@ case TERMKEY_RES_NONE: case TERMKEY_RES_EOF: case TERMKEY_RES_AGAIN: - case TERMKEY_RES_ERROR: break; } @@ -823,13 +821,10 @@ switch(ret) { case TERMKEY_RES_KEY: case TERMKEY_RES_EOF: - case TERMKEY_RES_ERROR: return ret; case TERMKEY_RES_NONE: - ret = termkey_advisereadable(tk); - if(ret == TERMKEY_RES_ERROR) - return ret; + termkey_advisereadable(tk); break; case TERMKEY_RES_AGAIN: @@ -844,17 +839,13 @@ fd.fd = tk->fd; fd.events = POLLIN; - int pollret = poll(&fd, 1, tk->waittime); - if(pollret == -1) - return TERMKEY_RES_ERROR; + poll(&fd, 1, tk->waittime); if(fd.revents & (POLLIN|POLLHUP|POLLERR)) ret = termkey_advisereadable(tk); else ret = TERMKEY_RES_NONE; - if(ret == TERMKEY_RES_ERROR) - return ret; if(ret == TERMKEY_RES_NONE) return termkey_getkey_force(tk, key); } @@ -886,12 +877,8 @@ unsigned char buffer[64]; // Smaller than the default size ssize_t len = read(tk->fd, buffer, sizeof buffer); - if(len == -1) { - if(errno == EAGAIN) - return TERMKEY_RES_NONE; - else - return TERMKEY_RES_ERROR; - } + if(len == -1 && (errno == EAGAIN || errno == EINTR)) + return TERMKEY_RES_NONE; else if(len < 1) { tk->is_closed = 1; return TERMKEY_RES_NONE; === modified file 'termkey.h.in' --- termkey.h.in 2011-08-18 10:20:41 +0000 +++ termkey.h.in 2011-04-02 14:07:30 +0000 @@ -102,8 +102,7 @@ TERMKEY_RES_NONE, TERMKEY_RES_KEY, TERMKEY_RES_EOF, - TERMKEY_RES_AGAIN, - TERMKEY_RES_ERROR + TERMKEY_RES_AGAIN } TermKeyResult; typedef enum { === modified file 'termkey_advisereadable.3' --- termkey_advisereadable.3 2011-08-18 10:20:41 +0000 +++ termkey_advisereadable.3 2011-04-03 17:44:48 +0000 @@ -23,9 +23,6 @@ .TP .B TERMKEY_RES_NONE No nore bytes were read. -.TP -.B TERMKEY_RES_ERROR -An IO error occured. \fIerrno\fP will be preserved. .SH "SEE ALSO" .BR termkey_new (3), .BR termkey_getkey (3), === modified file 'termkey_waitkey.3.sh' --- termkey_waitkey.3.sh 2011-08-18 10:20:41 +0000 +++ termkey_waitkey.3.sh 2011-04-04 18:56:33 +0000 @@ -25,9 +25,6 @@ .TP .B TERMKEY_RES_EOF No key events are ready and the terminal has been closed, so no more will arrive. -.TP -.B TERMKEY_RES_ERROR -An IO error occured. \fIerrno\fP will be preserved. .SH EXAMPLE The following example program prints details of every keypress until the user presses "Ctrl-C". .PP