[glib] GVariant parser: parse "inf", "-inf" and "nan"



commit 85633f11824bc806bef3d18b8c8a0bdb96af6a16
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Mar 31 14:48:10 2011 +0530

    GVariant parser: parse "inf", "-inf" and "nan"

 glib/gvariant-parser.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
index b5cfe24..9550b91 100644
--- a/glib/gvariant-parser.c
+++ b/glib/gvariant-parser.c
@@ -1777,8 +1777,9 @@ number_get_pattern (AST     *ast,
   Number *number = (Number *) ast;
 
   if (strchr (number->token, '.') ||
-      (!g_str_has_prefix (number->token, "0x") &&
-       strchr (number->token, 'e')))
+      (!g_str_has_prefix (number->token, "0x") && strchr (number->token, 'e')) ||
+      strstr (number->token, "inf") ||
+      strstr (number->token, "nan"))
     return g_strdup ("Md");
 
   return g_strdup ("MN");
@@ -2264,6 +2265,11 @@ parse (TokenStream  *stream,
   else if (token_stream_consume (stream, "false"))
     result = boolean_new (FALSE);
 
+  else if (token_stream_is_numeric (stream) ||
+           token_stream_peek_string (stream, "inf") ||
+           token_stream_peek_string (stream, "nan"))
+    result = number_parse (stream, app, error);
+
   else if (token_stream_peek (stream, 'n') ||
            token_stream_peek (stream, 'j'))
     result = maybe_parse (stream, app, error);
@@ -2272,9 +2278,6 @@ parse (TokenStream  *stream,
            token_stream_is_keyword (stream))
     result = typedecl_parse (stream, app, error);
 
-  else if (token_stream_is_numeric (stream))
-    result = number_parse (stream, app, error);
-
   else if (token_stream_peek (stream, '\'') ||
            token_stream_peek (stream, '"'))
     result = string_parse (stream, app, error);



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