]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - settings.c
Change the semantics of 'FontSpec' so that it's a dynamically
[PuTTY.git] / settings.c
index de69d66090ab38c5d32282bf012ee713b4d9ece0..7a2bd37c952f1c69579cec642320bbc7c94008b9 100644 (file)
@@ -108,10 +108,11 @@ static void gpps(void *handle, const char *name, const char *def,
  */
 static void gppfont(void *handle, const char *name, Conf *conf, int primary)
 {
-    FontSpec result;
-    if (!read_setting_fontspec(handle, name, &result))
-       result = platform_default_fontspec(name);
-    conf_set_fontspec(conf, primary, &result);
+    FontSpec *result = read_setting_fontspec(handle, name);
+    if (!result)
+        result = platform_default_fontspec(name);
+    conf_set_fontspec(conf, primary, result);
+    fontspec_free(result);
 }
 static void gppfile(void *handle, const char *name, Conf *conf, int primary)
 {
@@ -145,10 +146,8 @@ static int gppmap(void *handle, char *name, Conf *conf, int primary)
     /*
      * Start by clearing any existing subkeys of this key from conf.
      */
-    for (val = conf_get_str_strs(conf, primary, NULL, &key);
-        val != NULL;
-        val = conf_get_str_strs(conf, primary, key, &key))
-       conf_del_str_str(conf, primary, key);
+    while ((key = conf_get_str_nthstrkey(conf, primary, 0)) != NULL)
+        conf_del_str_str(conf, primary, key);
 
     /*
      * Now read a serialised list from the settings and unmarshal it
@@ -384,11 +383,11 @@ static void wprefs(void *sesskey, char *name,
        const char *s = val2key(mapping, nvals,
                                 conf_get_int_int(conf, primary, i));
        if (s) {
-            maxlen += 1 + strlen(s);
+            maxlen += (maxlen > 0 ? 1 : 0) + strlen(s);
         }
     }
 
-    buf = snewn(maxlen, char);
+    buf = snewn(maxlen + 1, char);
     p = buf;
 
     for (i = 0; i < nvals; i++) {
@@ -399,7 +398,8 @@ static void wprefs(void *sesskey, char *name,
        }
     }
 
-    assert(p - buf == maxlen - 1);     /* maxlen counted the NUL */
+    assert(p - buf == maxlen);
+    *p = '\0';
 
     write_setting_s(sesskey, name, buf);
 
@@ -554,7 +554,7 @@ void save_open_settings(void *sesskey, Conf *conf)
     write_setting_s(sesskey, "WinTitle", conf_get_str(conf, CONF_wintitle));
     write_setting_i(sesskey, "TermWidth", conf_get_int(conf, CONF_width));
     write_setting_i(sesskey, "TermHeight", conf_get_int(conf, CONF_height));
-    write_setting_fontspec(sesskey, "Font", *conf_get_fontspec(conf, CONF_font));
+    write_setting_fontspec(sesskey, "Font", conf_get_fontspec(conf, CONF_font));
     write_setting_i(sesskey, "FontQuality", conf_get_int(conf, CONF_font_quality));
     write_setting_i(sesskey, "FontVTMode", conf_get_int(conf, CONF_vtmode));
     write_setting_i(sesskey, "UseSystemColours", conf_get_int(conf, CONF_system_colour));
@@ -622,9 +622,9 @@ void save_open_settings(void *sesskey, Conf *conf)
     write_setting_i(sesskey, "StampUtmp", conf_get_int(conf, CONF_stamp_utmp));
     write_setting_i(sesskey, "LoginShell", conf_get_int(conf, CONF_login_shell));
     write_setting_i(sesskey, "ScrollbarOnLeft", conf_get_int(conf, CONF_scrollbar_on_left));
-    write_setting_fontspec(sesskey, "BoldFont", *conf_get_fontspec(conf, CONF_boldfont));
-    write_setting_fontspec(sesskey, "WideFont", *conf_get_fontspec(conf, CONF_widefont));
-    write_setting_fontspec(sesskey, "WideBoldFont", *conf_get_fontspec(conf, CONF_wideboldfont));
+    write_setting_fontspec(sesskey, "BoldFont", conf_get_fontspec(conf, CONF_boldfont));
+    write_setting_fontspec(sesskey, "WideFont", conf_get_fontspec(conf, CONF_widefont));
+    write_setting_fontspec(sesskey, "WideBoldFont", conf_get_fontspec(conf, CONF_wideboldfont));
     write_setting_i(sesskey, "ShadowBold", conf_get_int(conf, CONF_shadowbold));
     write_setting_i(sesskey, "ShadowBoldOffset", conf_get_int(conf, CONF_shadowboldoffset));
     write_setting_s(sesskey, "SerialLine", conf_get_str(conf, CONF_serline));