Make use "some string" to use as config string value, not just unquoted.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Thu, 27 Feb 2014 17:47:17 +0000 (19:47 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Thu, 27 Feb 2014 17:47:17 +0000 (19:47 +0200)
This includes possibility to use multi-line strings and correctly
make difference between "1" and 1 as string and int respectively.
For compatibility it is still saved as unquoted string but that
should be changed in some next release.

src/conf.c

index 10a0667..da9a7f2 100644 (file)
@@ -219,10 +219,31 @@ _skip_all:
                 else
                     g_warning("config: duplicate setting '%s' conflicts, ignored", name);
             }
+            else if (c[0] == '"')
+            {
+                char *p;
+                c++;
+                for (end = p = c; *p && *p != '\n' && *p != '"'; p++, end++)
+                {
+                    if (*p == '\\' && p[1] != '\0' && p[1] != '\n')
+                    {
+                        p++; /* skip quoted char */
+                        if (*p == 'n') /* \n */
+                            *p = '\n';
+                    }
+                    if (p != end)
+                        *end = *p; /* move char skipping '\\' */
+                }
+                if (*end == '"')
+                    goto _make_string;
+                else /* incomplete string */
+                    g_warning("config: unfinished string setting '%s', ignored", name);
+            }
             else
             {
                 for (end = c; *end && *end != '\n'; )
                     end++;
+_make_string:
                 s = _config_setting_try_add(parent, name, PANEL_CONF_TYPE_STRING);
                 if (s)
                 {