(*one)++;
}
- else if (**one == 'N' && strchr ("ynqiuxthd", **the_other))
+ else if (**one == 'N' && strchr ("ynqiuxthfd", **the_other))
+ {
+ *out++ = *(*the_other)++;
+ (*one)++;
+ }
+
+ else if (**one == 'D' && (**the_other == 'f' || **the_other == 'd'))
{
*out++ = *(*the_other)++;
(*one)++;
pattern[j++] = 'i';
break;
+ case 'D':
+ pattern[j++] = 'd';
+ break;
+
default:
pattern[j++] = pattern[i];
break;
/* the basic types,
* plus undetermined number type and undetermined string type.
*/
- if (!strchr ("bynqiuxthdsogNS", key_char))
+ if (!strchr ("bynqiuxthfdsogNDS", key_char))
{
ast_set_error (ast, error, NULL,
G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED,
(!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 ("MD");
return g_strdup ("MN");
}
Number *number = (Number *) ast;
const gchar *token;
gboolean negative;
- gboolean floating;
guint64 abs_val;
gdouble dbl_val;
+ gchar typechar;
gchar *end;
+ typechar = *g_variant_type_peek_string (type);
token = number->token;
- if (g_variant_type_equal (type, G_VARIANT_TYPE_DOUBLE))
+ if (typechar == 'f' || typechar == 'd')
{
- floating = TRUE;
-
errno = 0;
dbl_val = g_ascii_strtod (token, &end);
if (dbl_val != 0.0 && errno == ERANGE)
}
else
{
- floating = FALSE;
negative = token[0] == '-';
if (token[0] == '-')
token++;
return NULL;
}
- if (floating)
- return g_variant_new_double (dbl_val);
-
- switch (*g_variant_type_peek_string (type))
+ switch (typechar)
{
case 'y':
if (negative || abs_val > G_MAXUINT8)
return number_overflow (ast, type, error);
return g_variant_new_handle (negative ? -abs_val : abs_val);
+ case 'f':
+ return g_variant_new_float (dbl_val);
+
+ case 'd':
+ return g_variant_new_double (dbl_val);
+
default:
return ast_type_error (ast, type, error);
}
else if (token_stream_consume (stream, "uint64"))
type = g_variant_type_copy (G_VARIANT_TYPE_UINT64);
+ else if (token_stream_consume (stream, "float"))
+ type = g_variant_type_copy (G_VARIANT_TYPE_FLOAT);
+
else if (token_stream_consume (stream, "double"))
type = g_variant_type_copy (G_VARIANT_TYPE_DOUBLE);