From 7cd970786d72a68b735f33904bdded6c8aebdf33 Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 21 Aug 2012 07:54:32 +0200 Subject: xserver xkeyboard-config mesa pixman git update 21 Aug 2012 --- xorg-server/hw/xquartz/console_redirect.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'xorg-server/hw/xquartz/console_redirect.c') diff --git a/xorg-server/hw/xquartz/console_redirect.c b/xorg-server/hw/xquartz/console_redirect.c index 91d693b67..8fdce4699 100644 --- a/xorg-server/hw/xquartz/console_redirect.c +++ b/xorg-server/hw/xquartz/console_redirect.c @@ -110,27 +110,33 @@ _read_redirect(int fd, int flush) /* Increment our returned number read */ total_read += nbytes; - nbytes += (aslr->w - aslr->buf); - aslr->buf[nbytes] = '\0'; + /* Increment our write location */ + aslr->w += nbytes; + aslr->w[0] = '\0'; /* One line at a time */ - for (p = aslr->buf; *p && (p - aslr->buf) < nbytes; p = s + 1) { + for (p = aslr->buf; p < aslr->w; p = s + 1) { // Find null or \n for (s = p; *s && *s != '\n'; s++) ; if (*s == '\n') { *s = '\0'; + } + + if (s < aslr->w || aslr->buf == p) { + /* Either the first of multiple messages or one message which is larger than our buffer */ asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p); } - else if (aslr->buf != p) { + else { + /* We reached the end of the buffer, move this chunk to the start. */ memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf)); aslr->w = aslr->buf + (s - p); break; } - else if (nbytes == BUF_SIZE - 1) { - asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p); - aslr->w = aslr->buf; - break; - } + } + + if (p == aslr->w) { + /* Start writing at the beginning in the case where we flushed */ + aslr->w = aslr->buf; } } @@ -359,8 +365,8 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd) BLOCK_DONE; } redirect_fds = new_array; - memset(redirect_fds + n_redirect_fds, 0, new_n - - n_redirect_fds); + memset(redirect_fds + n_redirect_fds, 0, (new_n - + n_redirect_fds) * sizeof(*redirect_fds)); n_redirect_fds = new_n; } -- cgit v1.2.3