From 7e8be5a204330c0307e07a5a96844fc8fc65d6cb Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 26 Apr 2023 10:45:10 +0100 Subject: [PATCH] Fix factor-of-1000 error in Unix bell overload config. During the transition to cmake, commit b00e5fb12929da5 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.) (cherry picked from commit 62b69a4f16875e75ece3c06fbe474104c5b5c089) --- settings.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/settings.c b/settings.c index cd286eb4..04e53a00 100644 --- a/settings.c +++ b/settings.c @@ -686,12 +686,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 ); @@ -1119,22 +1119,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 );