1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Fix factor-of-1000 error in Unix bell overload config.

During the transition to cmake, commit b00e5fb129 renamed
unix/unix.h to unix/platform.h, and for visual consistency, also
renamed the guard macro PUTTY_UNIX_H to PUTTY_UNIX_PLATFORM_H.

But I had failed to notice that that guard macro is re-tested in
settings.c, as a convenient method of knowing whether we're building
the Windows or Unix version of PuTTY in order to store some settings
differently. So all those '#ifdef PUTTY_UNIX_H' statements silently
became equivalent to '#if 0', because PUTTY_UNIX_H is _never_ defined
any more.

Specifically, these ifdefs were causing the time intervals relating to
bell overloads to be off by a factor of 1000, because for some reason
I can't remember, we were storing those intervals using a different
time unit on Unix and Windows. In my own configuration, for example,
~/.putty/sessions/Default%20Settings contains "BellOverloadT=2000000"
and "BellOverloadS=5000000", which originally meant that too many
bells within 2 seconds would silence the bell until there were 5
seconds of silence - but current PuTTY shows it in the configurer as
2000 and 5000 seconds!

This commit belatedly rewrites the ifdefs in settings.c, so that saved
sessions from before 0.77 will now be interpreted correctly. Saved
sessions from after that may need a rewrite. (But you have to have one
or the other.)
This commit is contained in:
Simon Tatham 2023-04-26 10:45:10 +01:00
parent 289d123fb8
commit 62b69a4f16

View File

@ -660,12 +660,12 @@ void save_open_settings(settings_w *sesskey, Conf *conf)
write_setting_b(sesskey, "BellOverload", conf_get_bool(conf, CONF_bellovl));
write_setting_i(sesskey, "BellOverloadN", conf_get_int(conf, CONF_bellovl_n));
write_setting_i(sesskey, "BellOverloadT", conf_get_int(conf, CONF_bellovl_t)
#ifdef PUTTY_UNIX_H
#ifdef PUTTY_UNIX_PLATFORM_H
* 1000
#endif
);
write_setting_i(sesskey, "BellOverloadS", conf_get_int(conf, CONF_bellovl_s)
#ifdef PUTTY_UNIX_H
#ifdef PUTTY_UNIX_PLATFORM_H
* 1000
#endif
);
@ -1093,22 +1093,22 @@ void load_open_settings(settings_r *sesskey, Conf *conf)
gppb(sesskey, "BellOverload", true, conf, CONF_bellovl);
gppi(sesskey, "BellOverloadN", 5, conf, CONF_bellovl_n);
i = gppi_raw(sesskey, "BellOverloadT", 2*TICKSPERSEC
#ifdef PUTTY_UNIX_H
#ifdef PUTTY_UNIX_PLATFORM_H
*1000
#endif
);
conf_set_int(conf, CONF_bellovl_t, i
#ifdef PUTTY_UNIX_H
#ifdef PUTTY_UNIX_PLATFORM_H
/ 1000
#endif
);
i = gppi_raw(sesskey, "BellOverloadS", 5*TICKSPERSEC
#ifdef PUTTY_UNIX_H
#ifdef PUTTY_UNIX_PLATFORM_H
*1000
#endif
);
conf_set_int(conf, CONF_bellovl_s, i
#ifdef PUTTY_UNIX_H
#ifdef PUTTY_UNIX_PLATFORM_H
/ 1000
#endif
);