[gtk+] cssparser: Make _gtk_css_parser_has_number() a bit smarter



commit 3056d793a40d20574fa95cd6a4f6cc619b724039
Author: Benjamin Otte <otte redhat com>
Date:   Tue Feb 23 04:19:42 2016 +0100

    cssparser: Make _gtk_css_parser_has_number() a bit smarter
    
    Previously we just checked the first character. And if that was a "-" as
    in "-gtk-some-special-value", we assumed it was a number. Which it
    clearly wasn't.
    
    Test included

 gtk/gtkcssparser.c                                 |    9 ++++++++-
 testsuite/css/parser/Makefile.am                   |    2 ++
 .../parser/background-win32-color-is-no-error.css  |    3 +++
 .../background-win32-color-is-no-error.ref.css     |    9 +++++++++
 4 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c
index 86320f3..44ff7bc 100644
--- a/gtk/gtkcssparser.c
+++ b/gtk/gtkcssparser.c
@@ -599,8 +599,15 @@ _gtk_css_parser_try_double (GtkCssParser *parser,
 gboolean
 _gtk_css_parser_has_number (GtkCssParser *parser)
 {
+  char c;
+
+  if (parser->data[0] == '-' || parser->data[0] == '+')
+    c = parser->data[1];
+  else
+    c = parser->data[0];
+
   /* ahem */
-  return strchr ("+-0123456789.", parser->data[0]) != NULL;
+  return g_ascii_isdigit (c) || c == '.';
 }
 
 GtkCssValue *
diff --git a/testsuite/css/parser/Makefile.am b/testsuite/css/parser/Makefile.am
index 54c9506..d774476 100644
--- a/testsuite/css/parser/Makefile.am
+++ b/testsuite/css/parser/Makefile.am
@@ -195,6 +195,8 @@ test_data = \
        background-shorthand-single.ref.css \
         background-size.css \
         background-size.ref.css \
+       background-win32-color-is-no-error.css \
+       background-win32-color-is-no-error.ref.css \
        border.css \
        border.errors \
        border.ref.css \
diff --git a/testsuite/css/parser/background-win32-color-is-no-error.css 
b/testsuite/css/parser/background-win32-color-is-no-error.css
new file mode 100644
index 0000000..3b17e20
--- /dev/null
+++ b/testsuite/css/parser/background-win32-color-is-no-error.css
@@ -0,0 +1,3 @@
+a {
+  background: -gtk-win32-color(edit, highlight);
+}
diff --git a/testsuite/css/parser/background-win32-color-is-no-error.ref.css 
b/testsuite/css/parser/background-win32-color-is-no-error.ref.css
new file mode 100644
index 0000000..7879519
--- /dev/null
+++ b/testsuite/css/parser/background-win32-color-is-no-error.ref.css
@@ -0,0 +1,9 @@
+a {
+  background-clip: border-box;
+  background-color: -gtk-win32-color(edit, highlight);
+  background-image: none;
+  background-origin: padding-box;
+  background-position: left top;
+  background-repeat: repeat;
+  background-size: auto;
+}


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