imcontext: Fix a regression in Compose file parsing

We accidentally dropped the handing of # comments.
Bring it back.

Fixes: #3664
This commit is contained in:
Matthias Clasen
2021-02-14 11:54:05 -05:00
parent 5c6aa76979
commit 22960c5c20

View File

@ -77,28 +77,40 @@ parse_compose_value (GtkComposeData *compose_data,
const char *val, const char *val,
const char *line) const char *line)
{ {
char *word;
const char *p; const char *p;
gsize len;
GString *value; GString *value;
gunichar ch; gunichar ch;
char *endp; char *endp;
len = strlen (val); if (val[0] != '"')
if (val[0] != '"' || val[len - 1] != '"')
{ {
g_warning ("Need to double-quote the value: %s: %s", val, line); g_warning ("Need to double-quote the value: %s: %s", val, line);
goto fail; goto fail;
} }
word = g_strndup (val + 1, len - 2);
value = g_string_new (""); value = g_string_new ("");
p = word; p = val + 1;
while (*p) while (*p)
{ {
if (*p == '\\') if (*p == '\0')
{
g_warning ("Missing closing '\"': %s: %s", val, line);
goto fail;
}
else if (*p == '\"')
{
p++;
while (*p && g_ascii_isspace (*p))
p++;
if (*p != '\0' && *p != '#')
{
g_warning ("Garbage after closing '\"': %s: %s", val, line);
goto fail;
}
break;
}
else if (*p == '\\')
{ {
if (p[1] == '"') if (p[1] == '"')
{ {
@ -148,8 +160,6 @@ parse_compose_value (GtkComposeData *compose_data,
compose_data->value = g_string_free (value, FALSE); compose_data->value = g_string_free (value, FALSE);
g_free (word);
return TRUE; return TRUE;
fail: fail: