Support &s as key of dict entry in format string

Partial fix for bug 613618.
This commit is contained in:
Ryan Lortie 2010-03-23 09:17:15 -05:00
parent 816990a011
commit a6c57591c0
2 changed files with 25 additions and 8 deletions

View File

@ -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;

View File

@ -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));