*value_r = "";
else {
/* get section name */
- *value_r = line;
- while (!IS_WHITE(*line) && *line != '\0')
- line++;
-
- if (*line != '\0') {
- *line++ = '\0';
- while (IS_WHITE(*line))
+ if (*line != '"') {
+ *value_r = line;
+ while (!IS_WHITE(*line) && *line != '\0')
+ line++;
+ if (*line != '\0') {
+ *line++ = '\0';
+ while (IS_WHITE(*line))
+ line++;
+ }
+ } else {
+ char *value = ++line;
+ while (*line != '"' && *line != '\0')
line++;
+ if (*line == '"') {
+ *line++ = '\0';
+ while (IS_WHITE(*line))
+ line++;
+ *value_r = str_unescape(value);
+ }
}
if (*line != '{') {
*value_r = "Expecting '='";
str_append_n(ctx->list_prefix, key2, p - key2);
else
str_append(ctx->list_prefix, key2);
- if (unique_key && *value != '\0')
- str_printfa(ctx->list_prefix, " %s", value);
+ if (unique_key && *value != '\0') {
+ if (strchr(value, ' ') == NULL)
+ str_printfa(ctx->list_prefix, " %s", value);
+ else
+ str_printfa(ctx->list_prefix, " \"%s\"", str_escape(value));
+ }
str_append(ctx->list_prefix, " {\n");
indent++;
const char *settings_section_escape(const char *name)
{
#define CHAR_NEED_ESCAPE(c) \
- ((c) == '=' || (c) == SETTINGS_SEPARATOR || (c) == '\\')
+ ((c) == '=' || (c) == SETTINGS_SEPARATOR || (c) == '\\' || (c) == ' ')
string_t *str;
unsigned int i;
case '\\':
str_append(str, "\\\\");
break;
+ case ' ':
+ str_append(str, "\\_");
+ break;
default:
str_append_c(str, name[i]);
break;