[glib] GVariant parser: tweak lexer for format strings



commit 57cd876321f563bade0f6230108b1fce18d9b0c6
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Apr 17 12:12:20 2013 -0400

    GVariant parser: tweak lexer for format strings
    
    Tweak the lexer so that '[%s]' gets parsed as three separate tokens,
    instead of the closing bracket getting sucked into the format string.

 glib/gvariant-parser.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
index 1421a34..c60bd77 100644
--- a/glib/gvariant-parser.c
+++ b/glib/gvariant-parser.c
@@ -223,10 +223,11 @@ token_stream_prepare (TokenStream *stream)
     case '@': case '%':
       /* stop at the first space, comma, colon or unmatched bracket.
        * deals nicely with cases like (%i, %i) or {%i: %i}.
+       * Also: ] and > are never in format strings.
        */
       for (end = stream->stream + 1;
            end != stream->end && *end != ',' &&
-           *end != ':' && *end != '>' && !g_ascii_isspace (*end);
+           *end != ':' && *end != '>' && *end != ']' && !g_ascii_isspace (*end);
            end++)
 
         if (*end == '(' || *end == '{')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]