mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-26 04:02:09 +01:00
Support &s as key of dict entry in format string
Partial fix for bug 613618.
This commit is contained in:
parent
816990a011
commit
a6c57591c0
@ -2745,15 +2745,25 @@ g_variant_format_string_scan (const gchar *string,
|
||||
case '{':
|
||||
c = next_char();
|
||||
|
||||
if (c == '@')
|
||||
c = next_char ();
|
||||
if (c == '&')
|
||||
{
|
||||
c = next_char ();
|
||||
|
||||
/* ISO/IEC 9899:1999 (C99) §7.21.5.2:
|
||||
* The terminating null character is considered to be
|
||||
* part of the string.
|
||||
*/
|
||||
if (c != '\0' && strchr ("bynqiuxthdsog?", c) == NULL)
|
||||
return FALSE;
|
||||
if (c != 's' && c != 'o' && c != 'g')
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c == '@')
|
||||
c = next_char ();
|
||||
|
||||
/* ISO/IEC 9899:1999 (C99) §7.21.5.2:
|
||||
* The terminating null character is considered to be
|
||||
* part of the string.
|
||||
*/
|
||||
if (c != '\0' && strchr ("bynqiuxthdsog?", c) == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!g_variant_format_string_scan (string, limit, &string))
|
||||
return FALSE;
|
||||
|
@ -2699,6 +2699,13 @@ test_format_strings (void)
|
||||
*end == '\0');
|
||||
g_assert (g_variant_format_string_scan ("{yv}", NULL, &end) &&
|
||||
*end == '\0');
|
||||
g_assert (!g_variant_format_string_scan ("{&?v}", NULL, &end));
|
||||
g_assert (g_variant_format_string_scan ("{@?v}", NULL, &end) &&
|
||||
*end == '\0');
|
||||
g_assert (!g_variant_format_string_scan ("{&@sv}", NULL, &end));
|
||||
g_assert (!g_variant_format_string_scan ("{@&sv}", NULL, &end));
|
||||
g_assert (g_variant_format_string_scan ("{&sv}", NULL, &end) &&
|
||||
*end == '\0');
|
||||
g_assert (!g_variant_format_string_scan ("{vv}", NULL, &end));
|
||||
g_assert (!g_variant_format_string_scan ("{y}", NULL, &end));
|
||||
g_assert (!g_variant_format_string_scan ("{yyy}", NULL, &end));
|
||||
|
Loading…
x
Reference in New Issue
Block a user