]> diplodocus.org Git - nmh/commitdiff
uip/prompter.c: Delete obfuscating ERASE, etc., macros.
authorRalph Corderoy <ralph@inputplus.co.uk>
Thu, 25 May 2017 10:21:40 +0000 (11:21 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Thu, 25 May 2017 10:21:40 +0000 (11:21 +0100)
Their few uses are clearer as `t_io.c_cc[VERASE]' as otherwise the
storage, t_io, isn't mentioned, and c_cc and VERASE match termios.h's
man page.

uip/prompter.c

index c79d4e9af7371937828a733c32a2019b5becbdc9..ec2ea3fbc764a027392d8c7bb24d71423de30cca 100644 (file)
@@ -38,11 +38,7 @@ DEFINE_SWITCH_ENUM(PROMPTER);
 DEFINE_SWITCH_ARRAY(PROMPTER, switches);
 #undef X
 
 DEFINE_SWITCH_ARRAY(PROMPTER, switches);
 #undef X
 
-
 static struct termios tio;
 static struct termios tio;
-#define ERASE tio.c_cc[VERASE]
-#define KILL  tio.c_cc[VKILL]
-#define INTR  tio.c_cc[VINTR]
 
 static int wtuser = 0;
 static int sigint = 0;
 
 static int wtuser = 0;
 static int sigint = 0;
@@ -154,20 +150,20 @@ main (int argc, char **argv)
        tcgetattr(0, &tio);
 
        /* save original kill, erase character for later */
        tcgetattr(0, &tio);
 
        /* save original kill, erase character for later */
-       save_kill = KILL;
-       save_erase = ERASE;
+       save_kill = tio.c_cc[VKILL];
+       save_erase = tio.c_cc[VERASE];
 
        /* set new kill, erase character in terminal structure */
 
        /* set new kill, erase character in terminal structure */
-       KILL = killp ? chrcnv (killp) : save_kill;
-       ERASE = erasep ? chrcnv (erasep) : save_erase;
+       tio.c_cc[VKILL] = killp ? chrcnv (killp) : save_kill;
+       tio.c_cc[VERASE] = erasep ? chrcnv (erasep) : save_erase;
 
        /* set the new terminal attributes */
         tcsetattr(0, TCSADRAIN, &tio);
 
        /* print out new kill erase characters */
 
        /* set the new terminal attributes */
         tcsetattr(0, TCSADRAIN, &tio);
 
        /* print out new kill erase characters */
-       chrdsp ("erase", ERASE);
-       chrdsp (", kill", KILL);
-       chrdsp (", intr", INTR);
+       chrdsp ("erase", tio.c_cc[VERASE]);
+       chrdsp (", kill", tio.c_cc[VKILL]);
+       chrdsp (", intr", tio.c_cc[VINTR]);
        putchar ('\n');
        fflush (stdout);
 
        putchar ('\n');
        fflush (stdout);
 
@@ -176,8 +172,8 @@ main (int argc, char **argv)
         * setup in terminal structure so we can easily
         * restore it upon exit.
         */
         * setup in terminal structure so we can easily
         * restore it upon exit.
         */
-       KILL = save_kill;
-       ERASE = save_erase;
+       tio.c_cc[VKILL] = save_kill;
+       tio.c_cc[VERASE] = save_erase;
     }
 
     sigint = 0;
     }
 
     sigint = 0;