diff options
author | 2016-05-03 16:23:30 -0700 | |
---|---|---|
committer | 2016-05-03 17:14:56 -0700 | |
commit | fc44cffac50e6096528f2bde456d91a4e40ea7c9 (patch) | |
tree | 3c6c928aa0a8568b6e37a0698deb464575ba3fe2 /src/key_reader.cpp | |
parent | 5c8763be0e68bbdec3fdd1edb5754f4c421098e1 (diff) |
restyle switch blocks to match project style
I missed restyling a few "switch" blocks to make them consistent with the rest
of the code base. This fixes that oversight. This should be the final step in
restyling the C++ code to have a consistent style. This also includes a few
trivial cleanups elsewhere.
I also missed restyling the "complete" module when working my way from a to z
so this final change includes restyling that module.
Total lint errors decreased 36%. Cppcheck errors went from 47 to 24. Oclint P2
errors went from 819 to 778. Oclint P3 errors went from 3252 to 1842.
Resolves #2902.
Diffstat (limited to 'src/key_reader.cpp')
-rw-r--r-- | src/key_reader.cpp | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/src/key_reader.cpp b/src/key_reader.cpp index bb4a0075..88173077 100644 --- a/src/key_reader.cpp +++ b/src/key_reader.cpp @@ -5,32 +5,28 @@ Type ^C to exit the program. */ -#include <stdlib.h> +#include <locale.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <termios.h> -#include <locale.h> #include <termcap.h> +#include <termios.h> #include "common.h" #include "fallback.h" // IWYU pragma: keep #include "input_common.h" -int writestr(char *str) -{ +int writestr(char *str) { write_ignore(1, str, strlen(str)); return 0; } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { set_main_thread(); setup_fork_guards(); setlocale(LC_ALL, ""); - - if (argc == 2) - { + if (argc == 2) { static char term_buffer[2048]; char *termtype = getenv("TERM"); char *tbuff = new char[9999]; @@ -38,45 +34,35 @@ int main(int argc, char **argv) tgetent(term_buffer, termtype); res = tgetstr(argv[1], &tbuff); - if (res != 0) - { - while (*res != 0) - { + if (res != 0) { + while (*res != 0) { printf("%d ", *res); - res++; } printf("\n"); - } - else - { + } else { printf("Undefined sequence\n"); } - } - else - { + } else { char scratch[1024]; unsigned int c; - struct termios modes, /* so we can change the modes */ - savemodes; /* so we can reset the modes when we're done */ + struct termios modes, /* so we can change the modes */ + savemodes; /* so we can reset the modes when we're done */ input_common_init(0); + tcgetattr(0, &modes); /* get the current terminal modes */ + savemodes = modes; /* save a copy so we can reset them */ - tcgetattr(0,&modes); /* get the current terminal modes */ - savemodes = modes; /* save a copy so we can reset them */ - - modes.c_lflag &= ~ICANON; /* turn off canonical mode */ + modes.c_lflag &= ~ICANON; /* turn off canonical mode */ modes.c_lflag &= ~ECHO; /* turn off echo mode */ - modes.c_cc[VMIN]=1; - modes.c_cc[VTIME]=0; - tcsetattr(0,TCSANOW,&modes); /* set the new modes */ - while (1) - { - if ((c=input_common_readch(0)) == EOF) - break; + modes.c_cc[VMIN] = 1; + modes.c_cc[VTIME] = 0; + tcsetattr(0, TCSANOW, &modes); /* set the new modes */ + while (1) { + if ((c = input_common_readch(0)) == EOF) break; if ((c > 31) && (c != 127)) sprintf(scratch, "dec: %u hex: %x char: %c\n", c, c, c); else @@ -84,7 +70,7 @@ int main(int argc, char **argv) writestr(scratch); } /* reset the terminal to the saved mode */ - tcsetattr(0,TCSANOW,&savemodes); + tcsetattr(0, TCSANOW, &savemodes); input_common_destroy(); } |