aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-09-16 20:43:51 +0200
committerChristoph Lohmann <20h@r-36.net>2012-09-16 20:43:51 +0200
commit426887ccec8577ee33d1fb44f258d6a70a2eddf1 (patch)
tree5df6b8964d82e954d87f1c77a450024c025042ef /st.c
parent58a57a23051deba7c77901c9971d839a0db05db0 (diff)
downloadst-426887ccec8577ee33d1fb44f258d6a70a2eddf1.tar.gz
st-426887ccec8577ee33d1fb44f258d6a70a2eddf1.zip
Applying a shortening proposal for the run loop of k0ga.
Diffstat (limited to 'st.c')
-rw-r--r--st.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/st.c b/st.c
index 6371167..d5ecf61 100644
--- a/st.c
+++ b/st.c
@@ -2329,13 +2329,13 @@ run(void) {
2329 XEvent ev; 2329 XEvent ev;
2330 fd_set rfd; 2330 fd_set rfd;
2331 int xfd = XConnectionNumber(xw.dpy), i; 2331 int xfd = XConnectionNumber(xw.dpy), i;
2332 struct timeval drawtimeout; 2332 struct timeval drawtimeout, *tv = NULL;
2333 2333
2334 for(;;) { 2334 for(i = 0;; i++) {
2335 FD_ZERO(&rfd); 2335 FD_ZERO(&rfd);
2336 FD_SET(cmdfd, &rfd); 2336 FD_SET(cmdfd, &rfd);
2337 FD_SET(xfd, &rfd); 2337 FD_SET(xfd, &rfd);
2338 if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, NULL) < 0) { 2338 if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv) < 0) {
2339 if(errno == EINTR) 2339 if(errno == EINTR)
2340 continue; 2340 continue;
2341 die("select failed: %s\n", SERRNO); 2341 die("select failed: %s\n", SERRNO);
@@ -2345,23 +2345,20 @@ run(void) {
2345 * Stop after a certain number of reads so the user does not 2345 * Stop after a certain number of reads so the user does not
2346 * feel like the system is stuttering. 2346 * feel like the system is stuttering.
2347 */ 2347 */
2348 for(i = 0; i < 1000 && FD_ISSET(cmdfd, &rfd); i++) { 2348 if(i < 1000 && FD_ISSET(cmdfd, &rfd)) {
2349 ttyread(); 2349 ttyread();
2350 2350
2351 FD_ZERO(&rfd);
2352 FD_SET(cmdfd, &rfd);
2353 /* 2351 /*
2354 * Just wait a bit so it isn't disturbing the 2352 * Just wait a bit so it isn't disturbing the
2355 * user and the system is able to write something. 2353 * user and the system is able to write something.
2356 */ 2354 */
2357 drawtimeout.tv_sec = 0; 2355 drawtimeout.tv_sec = 0;
2358 drawtimeout.tv_usec = 5; 2356 drawtimeout.tv_usec = 5;
2359 if(select(cmdfd+1, &rfd, NULL, NULL, &drawtimeout) < 0) { 2357 tv = &drawtimeout;
2360 if(errno == EINTR) 2358 continue;
2361 continue;
2362 die("select failed: %s\n", SERRNO);
2363 }
2364 } 2359 }
2360 i = 0;
2361 tv = NULL;
2365 2362
2366 while(XPending(xw.dpy)) { 2363 while(XPending(xw.dpy)) {
2367 XNextEvent(xw.dpy, &ev); 2364 XNextEvent(xw.dpy, &ev);