Fix failure to re-enable local line discipline when TELOPT_ECHO is
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 24 Oct 2000 11:16:25 +0000 (11:16 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 24 Oct 2000 11:16:25 +0000 (11:16 +0000)
turned _back off_ by the remote server. (server sends WONT)

git-svn-id: svn://svn.tartarus.org/sgt/putty@756 cda61777-01e9-0310-a592-d414129be87e

telnet.c

index ff6681f..8eb6e8a 100644 (file)
--- a/telnet.c
+++ b/telnet.c
@@ -166,6 +166,14 @@ static void deactivate_option (struct Opt *o) {
     o->state = REALLY_INACTIVE;
 }
 
+/*
+ * Generate side effects of enabling or disabling an option.
+ */
+static void option_side_effects(struct Opt *o, int enabled) {
+    if (o->option == TELOPT_ECHO && cfg.ldisc_term)
+       ldisc = enabled ? &ldisc_simple : &ldisc_term;
+}
+
 static void activate_option (struct Opt *o) {
     if (o->send == WILL && o->option == TELOPT_NAWS)
        telnet_size();
@@ -178,8 +186,7 @@ static void activate_option (struct Opt *o) {
         */
        deactivate_option (o->option==TELOPT_NEW_ENVIRON ? &o_oenv : &o_nenv);
     }
-    if (o->option == TELOPT_ECHO && cfg.ldisc_term)
-       ldisc = &ldisc_simple;
+    option_side_effects(o, 1);
 }
 
 static void refused_option (struct Opt *o) {
@@ -188,8 +195,7 @@ static void refused_option (struct Opt *o) {
        send_opt (WILL, TELOPT_OLD_ENVIRON);
        o_oenv.state = REQUESTED;
     }
-    if (o->option == TELOPT_ECHO && cfg.ldisc_term)
-       ldisc = &ldisc_term;
+    option_side_effects(o, 0);
 }
 
 static void proc_rec_opt (int cmd, int option) {
@@ -224,6 +230,7 @@ static void proc_rec_opt (int cmd, int option) {
              case ACTIVE:
                (*o)->state = INACTIVE;
                send_opt ((*o)->nsend, option);
+                option_side_effects(*o, 0);
                break;
              case INACTIVE:
              case REALLY_INACTIVE: