forked from AuroraMiddleware/gtk
cssparser: Simplify
Remove the uint parser (and use the int parser in the one user of it). And avoid unnecessarily going through a macro.
This commit is contained in:
parent
73760e5835
commit
d9ef734458
@ -254,7 +254,7 @@ gtk_css_ease_value_parse_cubic_bezier (GtkCssParser *parser)
|
||||
static GtkCssValue *
|
||||
gtk_css_ease_value_parse_steps (GtkCssParser *parser)
|
||||
{
|
||||
guint n_steps;
|
||||
int n_steps;
|
||||
gboolean start;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, "(", TRUE))
|
||||
@ -263,11 +263,16 @@ gtk_css_ease_value_parse_steps (GtkCssParser *parser)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_uint (parser, &n_steps))
|
||||
if (!_gtk_css_parser_try_int (parser, &n_steps))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected number of steps");
|
||||
return NULL;
|
||||
}
|
||||
else if (n_steps < 1)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Number of steps must be > 0");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
|
@ -281,14 +281,17 @@ _gtk_css_parser_skip_whitespace (GtkCssParser *parser)
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_parser_try_len (GtkCssParser *parser,
|
||||
_gtk_css_parser_try (GtkCssParser *parser,
|
||||
const char *string,
|
||||
gsize string_len,
|
||||
gboolean skip_whitespace)
|
||||
{
|
||||
gsize string_len;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), FALSE);
|
||||
g_return_val_if_fail (string != NULL, FALSE);
|
||||
|
||||
string_len = strlen (string);
|
||||
|
||||
if (g_ascii_strncasecmp (parser->data, string, string_len) != 0)
|
||||
return FALSE;
|
||||
|
||||
@ -562,33 +565,6 @@ _gtk_css_parser_try_int (GtkCssParser *parser,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_css_parser_try_uint (GtkCssParser *parser,
|
||||
guint *value)
|
||||
{
|
||||
guint64 result;
|
||||
char *end;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
errno = 0;
|
||||
result = g_ascii_strtoull (parser->data, &end, 10);
|
||||
if (errno)
|
||||
return FALSE;
|
||||
if (result > G_MAXUINT)
|
||||
return FALSE;
|
||||
if (parser->data == end)
|
||||
return FALSE;
|
||||
|
||||
parser->data = end;
|
||||
*value = result;
|
||||
|
||||
_gtk_css_parser_skip_whitespace (parser);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_css_parser_try_double (GtkCssParser *parser,
|
||||
gdouble *value)
|
||||
|
@ -61,10 +61,8 @@ gboolean _gtk_css_parser_is_string (GtkCssParser *parser
|
||||
* however is fine to call if you don’t know yet if the token is a foo or a bar,
|
||||
* you can _try_bar() if try_foo() failed.
|
||||
*/
|
||||
#define _gtk_css_parser_try(p, s, skip) (gtk_css_parser_try_len (p, s, strlen(s), skip))
|
||||
gboolean gtk_css_parser_try_len (GtkCssParser *parser,
|
||||
gboolean _gtk_css_parser_try (GtkCssParser *parser,
|
||||
const char *string,
|
||||
gsize string_len,
|
||||
gboolean skip_whitespace);
|
||||
char * _gtk_css_parser_try_ident (GtkCssParser *parser,
|
||||
gboolean skip_whitespace);
|
||||
@ -72,8 +70,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_uint (GtkCssParser *parser,
|
||||
guint *value);
|
||||
gboolean _gtk_css_parser_try_double (GtkCssParser *parser,
|
||||
gdouble *value);
|
||||
gboolean _gtk_css_parser_try_hash_color (GtkCssParser *parser,
|
||||
|
Loading…
Reference in New Issue
Block a user