diff options
author | marha <marha@users.sourceforge.net> | 2012-08-21 07:54:32 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-08-21 07:54:32 +0200 |
commit | 7cd970786d72a68b735f33904bdded6c8aebdf33 (patch) | |
tree | fdfd8b54161aeddb0a2fe485886219b2285d52ff /xorg-server/hw/xquartz/console_redirect.c | |
parent | 5d9b8cf0e4054e774f906cde9dd6b61ceca72d44 (diff) | |
download | vcxsrv-7cd970786d72a68b735f33904bdded6c8aebdf33.tar.gz vcxsrv-7cd970786d72a68b735f33904bdded6c8aebdf33.tar.bz2 vcxsrv-7cd970786d72a68b735f33904bdded6c8aebdf33.zip |
xserver xkeyboard-config mesa pixman git update 21 Aug 2012
Diffstat (limited to 'xorg-server/hw/xquartz/console_redirect.c')
-rw-r--r-- | xorg-server/hw/xquartz/console_redirect.c | 28 |
1 files changed, 17 insertions, 11 deletions
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; } |