changeset 993:6fa2d325a913

add support for negative numbers in CSS parser
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Tue, 10 Mar 2009 17:55:58 +0100
parents 5e2c7a06f7ab
children 7fbd059a5164
files ChangeLog src/cssparser.cc
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 10 12:54:59 2009 +0100
+++ b/ChangeLog	Tue Mar 10 17:55:58 2009 +0100
@@ -69,6 +69,7 @@
  - Remove text_color, link_color, and force_my_colors dillorc options.
  - Fix CSS string parsing bug.
  - Replace visited_color dillorc option.
+ - Add support for negative numbers in CSS parser.
    Patches: Johannes Hofmann
 +- Updated the GPL copyright note in the source files.
    Patch: Detlef Riekenberg
--- a/src/cssparser.cc	Tue Mar 10 12:54:59 2009 +0100
+++ b/src/cssparser.cc	Tue Mar 10 17:55:58 2009 +0100
@@ -426,7 +426,13 @@
       }
    }
 
-   // \todo handle negative numbers according to CSS 2.1
+   // handle negative numbers
+   if (c == '-') {
+      if (i < MAX_STR_LEN - 1)
+         parser->tval[i++] = c;
+      c = Css_getc(parser);
+   }
+
    if (isdigit(c)) {
       parser->ttype = CSS_TK_DECINT;
       do {
@@ -475,6 +481,12 @@
       return;
    }
 
+   if (i) {
+      Css_ungetc(parser); /* ungetc '-' */
+      i--;
+      c = Css_getc(parser);
+   }
+
    if (isalpha(c) || c == '_' || c == '-') {
       parser->ttype = CSS_TK_SYMBOL;