sconsole

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 099cc8e323a2430cf7408936439401c84492147f
parent b0f764d8388a4010bb74eb7b161862d240f4d5e7
Author: Colin Cross <ccross@android.com>
Date:   Mon, 30 Jul 2012 11:22:19 -0700

Don't print '.' for bell character

Add a new valid state -1 to ignore characters without printing a '.',
and use the new state for the bell character (ASCII code 7).

Diffstat:
Msconsole.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/sconsole.c b/sconsole.c @@ -207,6 +207,7 @@ int main(int argc, char *argv[]) for (n = ' '; n < 127; n++) valid[n] = 1; + valid[7] = -1; /* bell */ valid[8] = 1; /* backspace */ valid[9] = 1; /* tab */ valid[10] = 1; /* newline */ @@ -315,11 +316,15 @@ int main(int argc, char *argv[]) } } if ((fds[1].revents & POLLIN) && (read(fd, &x, 1) == 1)) { + unsigned char c = x; if (!valid[x]) - x = '.'; - write(1, &x, 1); - if (logfd != -1) - write(logfd, &x, 1); + c = '.'; + + if (valid[x] != -1) { + write(1, &c, 1); + if (logfd != -1) + write(logfd, &c, 1); + } } } }