mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-30 15:31:34 +00:00
cssparser: Get rid of _gtk_css_parser_try_double()
Use gtk_css_parser_consume_number() everywhere instead.
This commit is contained in:
parent
f0d2f99239
commit
23080d47b5
@ -548,11 +548,9 @@ _gtk_css_color_value_parse_function (GtkCssParser *parser,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_double (parser, &tmp))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Invalid number for color value");
|
||||
if (!gtk_css_parser_consume_number (parser, &tmp))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_gtk_css_parser_try (parser, "%", TRUE))
|
||||
tmp /= 100.0;
|
||||
else
|
||||
@ -575,12 +573,9 @@ _gtk_css_color_value_parse_function (GtkCssParser *parser,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_double (parser, &rgba.alpha))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Invalid number for alpha value");
|
||||
if (!gtk_css_parser_consume_number (parser, &rgba.alpha))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
rgba.alpha = 1.0;
|
||||
|
||||
@ -626,9 +621,8 @@ _gtk_css_color_value_parse_function (GtkCssParser *parser,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_double (parser, &d))
|
||||
if (!gtk_css_parser_consume_number (parser, &d))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected number in color definition");
|
||||
_gtk_css_value_unref (child1);
|
||||
if (child2)
|
||||
_gtk_css_value_unref (child2);
|
||||
|
@ -339,7 +339,7 @@ _gtk_css_keyframes_parse (GtkCssParser *parser)
|
||||
progress = 0;
|
||||
else if (gtk_css_parser_try_ident (parser, "to"))
|
||||
progress = 1;
|
||||
else if (_gtk_css_parser_try_double (parser, &progress) &&
|
||||
else if (gtk_css_parser_consume_number (parser, &progress) &&
|
||||
_gtk_css_parser_try (parser, "%", TRUE))
|
||||
{
|
||||
if (progress < 0 || progress > 100)
|
||||
|
@ -775,26 +775,28 @@ _gtk_css_parser_try_int (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_css_parser_try_double (GtkCssParser *parser,
|
||||
gdouble *value)
|
||||
gtk_css_parser_consume_number (GtkCssParser *self,
|
||||
double *number)
|
||||
{
|
||||
gdouble result;
|
||||
char *end;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
g_return_val_if_fail (GTK_IS_CSS_PARSER (self), FALSE);
|
||||
g_return_val_if_fail (number != NULL, FALSE);
|
||||
|
||||
errno = 0;
|
||||
result = g_ascii_strtod (parser->data, &end);
|
||||
if (errno)
|
||||
return FALSE;
|
||||
if (parser->data == end)
|
||||
result = g_ascii_strtod (self->data, &end);
|
||||
if (errno ||
|
||||
self->data == end)
|
||||
{
|
||||
_gtk_css_parser_error (self, "Expected a number");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
parser->data = end;
|
||||
*value = result;
|
||||
self->data = end;
|
||||
*number = result;
|
||||
|
||||
_gtk_css_parser_skip_whitespace (parser);
|
||||
_gtk_css_parser_skip_whitespace (self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -811,17 +813,6 @@ gtk_css_parser_consume_ident (GtkCssParser *self)
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_parser_consume_number (GtkCssParser *self,
|
||||
double *number)
|
||||
{
|
||||
if (_gtk_css_parser_try_double (self, number))
|
||||
return TRUE;
|
||||
|
||||
_gtk_css_parser_error (self, "Expected a number");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_css_parser_has_number (GtkCssParser *parser)
|
||||
{
|
||||
|
@ -92,8 +92,6 @@ char * _gtk_css_parser_try_name (GtkCssParser *parser
|
||||
gboolean skip_whitespace);
|
||||
gboolean _gtk_css_parser_try_int (GtkCssParser *parser,
|
||||
int *value);
|
||||
gboolean _gtk_css_parser_try_double (GtkCssParser *parser,
|
||||
gdouble *value);
|
||||
gboolean _gtk_css_parser_try_hash_color (GtkCssParser *parser,
|
||||
GdkRGBA *rgba);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user