1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Move echo/edit state change functionality out of ldisc_send.

I'm not actually sure why we've always had back ends notify ldisc of
changes to echo/edit settings by giving ldisc_send(ldisc,NULL,0,0) a
special meaning, instead of by having a separate dedicated notify
function with its own prototype and parameter set. Coverity's recent
observation that the two kinds of call don't even have the same
requirements on the ldisc (particularly, whether ldisc->term can be
NULL) makes me realise that it's really high time I separated the two
conceptually different operations into actually different functions.

While I'm here, I've renamed the confusing ldisc_update() function
which that special operation ends up feeding to, because it's not
actually a function applying to an ldisc - it applies to a front end.
So ldisc_send(ldisc,NULL,0,0) is now ldisc_echoedit_update(ldisc), and
that in turn figures out the current echo/edit settings before passing
them on to frontend_echoedit_update(). I think that should be clearer.
This commit is contained in:
Simon Tatham
2014-11-22 16:12:47 +00:00
parent d870b5650e
commit c269dd0135
12 changed files with 32 additions and 57 deletions

View File

@ -194,7 +194,7 @@ int platform_default_i(const char *name, int def)
}
/* Dummy routine, only required in plink. */
void ldisc_update(void *frontend, int echo, int edit)
void frontend_echoedit_update(void *frontend, int echo, int edit)
{
}
@ -3020,7 +3020,7 @@ void reset_terminal_menuitem(GtkMenuItem *item, gpointer data)
struct gui_data *inst = (struct gui_data *)data;
term_pwron(inst->term, TRUE);
if (inst->ldisc)
ldisc_send(inst->ldisc, NULL, 0, 0);
ldisc_echoedit_update(inst->ldisc);
}
void copy_all_menuitem(GtkMenuItem *item, gpointer data)
@ -3088,7 +3088,7 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
*/
if (inst->ldisc) {
ldisc_configure(inst->ldisc, inst->conf);
ldisc_send(inst->ldisc, NULL, 0, 0);
ldisc_echoedit_update(inst->ldisc);
}
/* Pass new config data to the terminal */
term_reconfig(inst->term, inst->conf);
@ -3924,7 +3924,7 @@ int pt_main(int argc, char **argv)
start_backend(inst);
ldisc_send(inst->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */
ldisc_echoedit_update(inst->ldisc); /* cause ldisc to notice changes */
/* now we're reday to deal with the child exit handler being
* called */

View File

@ -152,7 +152,7 @@ int term_ldisc(Terminal *term, int mode)
{
return FALSE;
}
void ldisc_update(void *frontend, int echo, int edit)
void frontend_echoedit_update(void *frontend, int echo, int edit)
{
/* Update stdin read mode to reflect changes in line discipline. */
struct termios mode;
@ -178,8 +178,9 @@ void ldisc_update(void *frontend, int echo, int edit)
mode.c_cc[VMIN] = 1;
mode.c_cc[VTIME] = 0;
/* FIXME: perhaps what we do with IXON/IXOFF should be an
* argument to ldisc_update(), to allow implementation of SSH-2
* "xon-xoff" and Rlogin's equivalent? */
* argument to frontend_echoedit_update(), to allow
* implementation of SSH-2 "xon-xoff" and Rlogin's
* equivalent? */
mode.c_iflag &= ~IXON;
mode.c_iflag &= ~IXOFF;
}
@ -981,7 +982,7 @@ int main(int argc, char **argv)
*/
local_tty = (tcgetattr(STDIN_FILENO, &orig_termios) == 0);
atexit(cleanup_termios);
ldisc_update(NULL, 1, 1);
frontend_echoedit_update(NULL, 1, 1);
sending = FALSE;
now = GETTICKCOUNT();