summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-03-23 19:36:28 -0700
committerKent Overstreet <koverstreet@google.com>2013-03-23 19:36:28 -0700
commitc8fa100f6de77ce8b7ba0972bacfae80f9092499 (patch)
treede25dd4dfdd855f9d3a02ad3522c479c56a7a5fd
parent5d34ea00206958fb9cf16c21ef4bd9166cd40418 (diff)
move iowrite()
-rw-r--r--st.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/st.c b/st.c
index 47965a6..295dfee 100644
--- a/st.c
+++ b/st.c
@@ -372,7 +372,7 @@ static void sigchld(int a)
exit(EXIT_FAILURE);
}
-static ssize_t xwrite(int fd, char *s, size_t len)
+static ssize_t xwrite(int fd, void *s, size_t len)
{
size_t aux = len;
@@ -2008,15 +2008,6 @@ static void tputc(struct st_window *xw,
bool control = ascii < '\x20' || ascii == 0177;
struct st_term *term = &xw->term;
- if (iofd != -1) {
- if (xwrite(iofd, c, len) < 0) {
- fprintf(stderr, "Error writing in %s:%s\n",
- opt_io, strerror(errno));
- close(iofd);
- iofd = -1;
- }
- }
-
/*
* STR sequences must be checked before anything else
* because it can use some control codes as part of the sequence.
@@ -2390,6 +2381,14 @@ static void ttyread(struct st_window *xw)
sizeof(term->cmdbuf) - term->cmdbuflen)) < 0)
die("Couldn't read from shell: %s\n", SERRNO);
+ if (iofd != -1 &&
+ xwrite(iofd, term->cmdbuf + term->cmdbuflen, ret) < 0) {
+ fprintf(stderr, "Error writing in %s:%s\n",
+ opt_io, strerror(errno));
+ close(iofd);
+ iofd = -1;
+ }
+
/* process every complete utf8 char */
term->cmdbuflen += ret;
ptr = term->cmdbuf;