#define STARTCOOKIE '<'
#define ENDCOOKIE '>'
-void visualize(int c, char *buf)
+static void visualize(int c, /*@out@*/char *buf)
{
char *end;
bool unprintable;
buf[0] = '\0';
- if (c & ALT) {
+ if ((c & ALT) != 0) {
unprintable = true;
c &=~ ALT;
buf[0] = STARTCOOKIE;
buf[1] = '\0';
- strcat(buf, "ALT-");
+ (void) strcat(buf, "ALT-");
}
if (c <= ' ') {
*end++ = STARTCOOKIE;
*end++ = '\0';
} if (c > 0 && c < 27) {
- strcat(buf, "CTL-");
+ (void) strcat(buf, "CTL-");
end = buf + strlen(buf);
*end++ = (c + 0x40);
*end++ = '=';
*end = 0;
}
- strcat(buf, lowchars[c]);
+ (void) strcat(buf, lowchars[c]);
}
else if (c == 0x3F) {
unprintable = true;
- strcat(buf, "DEL");
+ (void) strcat(buf, "DEL");
} else {
unprintable = false;
buf[0] = c;
{
struct termios cooked, raw;
unsigned char c;
- unsigned int i, timeouts;
+ int i;
char intrchar[32], quitchar[32];
+ /*@-unrecog@*/
for (i = SIGHUP; i <= SIGIO; i++)
- (void) signal(c, catcher);
+ (void) signal(i, catcher);
+ /*@=unrecog@*/
// Get the state of the tty
(void) tcgetattr(0, &cooked);
(void) printf("Terminate with your shell interrupt %s or quit %s character.\n",
intrchar, quitchar);
signalled = 0;
- while (!signalled)
+ while (signalled == 0)
{
char cbuf[32];
- read(0, &c, 1);
+ (void)read(0, &c, 1);
visualize(c, cbuf);
(void)fputs(cbuf, stdout);
(void) fflush(stdout);
(void) printf("\nBye...\n");
// Restore the cooked state
(void) tcsetattr(0, TCSANOW, &cooked);
+ exit(0);
}
/* showkey.c ends here */