[json-glib] parser: Do not access GScanner:token



commit 6231cf027a8f9c3b11324c1d49a350ba55353123
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Wed May 26 08:43:10 2010 +0100

    parser: Do not access GScanner:token
    
    The GScanner:token member is declared as GTokenType instead of being an
    unsigned int. This means that comparing it to any other enumeration is
    going to generate a warning in GCC >= 4.5. Unfortunately, extending the
    GTokenType enumeration is the idiomatic way of handling new tokens.
    
    EPIC. FAIL.

 json-glib/json-parser.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c
index f539fe5..9103d86 100644
--- a/json-glib/json-parser.c
+++ b/json-glib/json-parser.c
@@ -890,6 +890,7 @@ json_parser_load (JsonParser   *parser,
       else
         {
           guint expected_token;
+          gint cur_token;
 
           /* we try to show the expected token, if possible */
           expected_token = json_parse_statement (parser, scanner);
@@ -898,8 +899,10 @@ json_parser_load (JsonParser   *parser,
               const gchar *symbol_name;
               gchar *msg;
 
+              cur_token = scanner->token;
               msg = NULL;
               symbol_name = NULL;
+
               if (scanner->scope_id == 0)
                 {
                   if (expected_token > JSON_TOKEN_INVALID &&
@@ -913,13 +916,13 @@ json_parser_load (JsonParser   *parser,
                         msg = g_strconcat ("e.g. '", symbol_name, "'", NULL);
                     }
 
-                  if (scanner->token > JSON_TOKEN_INVALID &&
-                      scanner->token < JSON_TOKEN_LAST)
+                  if (cur_token > JSON_TOKEN_INVALID &&
+                      cur_token < JSON_TOKEN_LAST)
                     {
                       symbol_name = "???";
 
                       for (i = 0; i < n_symbols; i++)
-                        if (symbols[i].token == scanner->token)
+                        if (symbols[i].token == cur_token)
                           symbol_name = symbol_names + symbols[i].name_offset;
                     }
                 }



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