changeset 1007:0604a13c629a

make CSS_MAX_STR_LEN a static const integer
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Sun, 15 Mar 2009 21:21:15 +0100
parents 40fbc9a0ca34
children c7ce3eaf3087
files src/cssparser.cc src/cssparser.hh
diffstat 2 files changed, 9 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/cssparser.cc	Sun Mar 15 21:15:08 2009 +0100
+++ b/src/cssparser.cc	Sun Mar 15 21:21:15 2009 +0100
@@ -426,7 +426,7 @@
 
    // handle negative numbers
    if (c == '-') {
-      if (i < CSS_MAX_STR_LEN - 1)
+      if (i < maxStrLen - 1)
          tval[i++] = c;
       c = getc();
    }
@@ -434,7 +434,7 @@
    if (isdigit(c)) {
       ttype = CSS_TK_DECINT;
       do {
-         if (i < CSS_MAX_STR_LEN - 1) {
+         if (i < maxStrLen - 1) {
             tval[i++] = c;
          }
          /* else silently truncated */
@@ -450,10 +450,10 @@
       c = getc();
       if (isdigit(c)) {
          ttype = CSS_TK_FLOAT;
-         if (i < CSS_MAX_STR_LEN - 1)
+         if (i < maxStrLen - 1)
             tval[i++] = '.';
          do {
-            if (i < CSS_MAX_STR_LEN - 1)
+            if (i < maxStrLen - 1)
                tval[i++] = c;
             /* else silently truncated */
             c = getc();
@@ -492,7 +492,7 @@
       i = 1;
       c = getc();
       while (isalnum(c) || c == '_' || c == '-') {
-         if (i < CSS_MAX_STR_LEN - 1) {
+         if (i < maxStrLen - 1) {
             tval[i] = c;
             i++;
          }                      /* else silently truncated */
@@ -534,7 +534,7 @@
             }
          }
 
-         if (i < CSS_MAX_STR_LEN - 1) {
+         if (i < maxStrLen - 1) {
             tval[i] = c;
             i++;
          }                      /* else silently truncated */
@@ -556,7 +556,7 @@
       i = 1;
       c = getc();
       while (isxdigit(c)) {
-         if (i < CSS_MAX_STR_LEN - 1) {
+         if (i < maxStrLen - 1) {
             tval[i] = c;
             i++;
          }                      /* else silently truncated */
--- a/src/cssparser.hh	Sun Mar 15 21:15:08 2009 +0100
+++ b/src/cssparser.hh	Sun Mar 15 21:21:15 2009 +0100
@@ -16,11 +16,9 @@
    CSS_TK_CHAR, CSS_TK_END
 } CssTokenType;
 
-/* Applies to symbol lengths and string literals. */
-#define CSS_MAX_STR_LEN 256
-
 class CssParser {
    private:
+      static const int maxStrLen = 256;
       CssContext *context;
       CssOrigin origin;
 
@@ -28,7 +26,7 @@
       int buflen, bufptr;
 
       CssTokenType ttype;
-      char tval[CSS_MAX_STR_LEN];
+      char tval[maxStrLen];
       bool within_block;
       bool space_separated; /* used when parsing CSS selectors */