Save numeric-only string double-quoted to distinguish from number.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Tue, 18 Nov 2014 23:28:26 +0000 (01:28 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Tue, 18 Nov 2014 23:28:26 +0000 (01:28 +0200)
ChangeLog
src/conf.c

index 7fef706..06856d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -56,6 +56,8 @@
     was removed: size wasn't always renegotiated correctly.
 * Fixed range of space reservation in multi-monitor setup (reservation
     might cover another monitor).
+* Numeric-only string will be saved now double-quoted to distinguish it
+    from number in config.
 
 0.7.2
 -------------------------------------------------------------------------
index 29d4981..cf0ff35 100644 (file)
@@ -312,6 +312,16 @@ static void _config_write_setting(const config_setting_t *setting, GString *buf,
     case PANEL_CONF_TYPE_STRING:
         if (!setting->str) /* don't save NULL strings */
             return;
+        if (setting->str[0])
+        {
+            char *end;
+            if (strtol(setting->str, &end, 10)) end = end;
+            if (*end == '\0') /* numeric string, quote it */
+            {
+                g_string_append_printf(buf, "%s=\"%s\"\n", setting->name, setting->str);
+                break;
+            }
+        }
         g_string_append_printf(buf, "%s=%s\n", setting->name, setting->str);
         break;
     case PANEL_CONF_TYPE_GROUP: