css: Use %f, not %.17f

The testusite failures explain why:
We don't want to print "1.00000000000000000", but "1".
This commit is contained in:
Benjamin Otte
2019-05-29 14:29:25 +02:00
parent 9ee2b23176
commit 89fb752a8f
4 changed files with 4 additions and 4 deletions

View File

@@ -386,7 +386,7 @@ gdk_rgba_to_string (const GdkRGBA *rgba)
{
gchar alpha[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", CLAMP (rgba->alpha, 0, 1));
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (rgba->alpha, 0, 1));
return g_strdup_printf ("rgba(%d,%d,%d,%s)",
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),

View File

@@ -1527,7 +1527,7 @@ string_append_double (GString *string,
{
char buf[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", d);
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%g", d);
g_string_append (string, buf);
}

View File

@@ -406,7 +406,7 @@ gtk_css_token_print (const GtkCssToken *token,
/* fall through */
case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
case GTK_CSS_TOKEN_DIMENSION:
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", token->dimension.value);
g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, token->dimension.value);
g_string_append (string, buf);
append_ident (string, token->dimension.dimension);
break;

View File

@@ -198,7 +198,7 @@ gtk_css_value_dimension_print (const GtkCssValue *number,
g_string_append (string, "infinite");
else
{
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", number->value);
g_ascii_dtostr (buf, sizeof (buf), number->value);
g_string_append (string, buf);
if (number->value != 0.0)
g_string_append (string, names[number->unit]);