- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 28 Mar 2008 08:02:25 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser/analyzer In directory hutz:/tmp/cvs-serv16219 Modified Files: CssParser.java Log Message: See CssParser.jj Index: CssParser.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- CssParser.java 27 Mar 2008 13:20:44 -0000 1.39 +++ CssParser.java 28 Mar 2008 08:02:23 -0000 1.40 @@ -64,6 +64,10 @@ */ public abstract class CssParser implements CssParserConstants { + private static char hexdigits[] = { '0', '1', '2', '3', + '4', '5', '6', '7', + '8', '9', 'a', 'b', + 'c', 'd', 'e', 'f' }; // the current atRule protected AtRule atRule; protected String mediaDeclaration = "off"; @@ -1601,7 +1605,7 @@ jj_consume_token(S); } contextual = selector(); - if (contextual != null) { + if (contextual != null) { context_set.addElement(contextual); } } @@ -1639,9 +1643,12 @@ } else {*/ if (value_set != null) { boolean first = true; - for (Enumeration e = context_set.elements(); e.hasMoreElements();) { + CssSelectors sel = null; + Enumeration<CssSelectors> e = context_set.elements(); + while (e.hasMoreElements()) { + sel = e.nextElement(); if (first) { - handleRule((CssSelectors) e.nextElement(), value_set); + handleRule(sel, value_set); first = false; } else { // we need to duplicate properties in that case @@ -1652,7 +1659,7 @@ for (int i=0; i<vsize; i++) { v.addElement(value_set.elementAt(i).duplicate()); } - handleRule((CssSelectors) e.nextElement(), v); + handleRule(sel, v); } } setSelectorList(context_set); @@ -3052,8 +3059,10 @@ } String convertStringIndex(String s, int start, int len) throws ParseException { - StringBuffer buf = new StringBuffer(len); + StringBuilder buf = new StringBuilder(len); int index = start; + int t; + int maxCount = 0; while (index < len) { char c = s.charAt(index); @@ -3067,26 +3076,51 @@ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': int numValue = Character.digit(c, 16); int count = 1; - int p = 16; - - int maxCount = (ac.getCssVersion().equals("css1") ? 4 : 6); + if (maxCount == 0) { + maxCount = (ac.getCssVersion().equals("css1") ? + 4 : 6); + } while (index + 1 < len) { c = s.charAt(index+1); - - if (Character.digit(c, 16) != -1 && count++ < maxCount) { - numValue = (numValue * 16) + Character.digit(c, 16); - p *= 16; + t = Character.digit(c, 16); + if (t != -1 && count++ < maxCount) { + numValue = (numValue<<4) | t; index++; } else { - if (c == ' ' || c == '\t' ) { + if (c == ' ' || c == '\t' || + c == '\n' || c == '\f' ) { // skip the latest white space index++; + } else if ( c == '\r' ) { + index++; + // special case for \r\n + if (index+1 < len) { + if (s.charAt(index + 1) == '\n') { + index++; + } + } } break; } } - - buf.append((char) numValue); + if (numValue < 255 && numValue>31) { + if (! ( (numValue>96 && numValue<123) // [a-z] + || (numValue>64 && numValue<91) // [A-Z] + || (numValue>47 && numValue<58) // [0-9] + || (numValue == 95) // _ + || (numValue == 45) )) { // - + buf.append('\\'); + } + buf.append((char) numValue); + break; + } + char b[] = new char[maxCount]; + t = maxCount; + while (t > 0) { + b[--t] = hexdigits[numValue & 0xF]; + numValue >>>= 4; + } + buf.append('\\').append(b); break; case '\n': case '\f': @@ -3098,8 +3132,21 @@ } } break; - default: + case '-' : case '_' : case 'g' : case 'G' : + case 'h' : case 'H' : case 'i' : case 'I' : + case 'j' : case 'J' : case 'k' : case 'K' : + case 'l' : case 'L' : case 'm' : case 'M' : + case 'n' : case 'N' : case 'o' : case 'O' : + case 'p' : case 'P' : case 'q' : case 'Q' : + case 'r' : case 'R' : case 's' : case 'S' : + case 't' : case 'T' : case 'u' : case 'U' : + case 'v' : case 'V' : case 'w' : case 'W' : + case 'x' : case 'X' : case 'y' : case 'Y' : + case 'z' : case 'Z' : buf.append(c); + break; + default: + buf.append('\\').append(c); } } else { throw new ParseException("invalid string"); @@ -3109,7 +3156,6 @@ } index++; } - return buf.toString(); }
Received on Friday, 28 March 2008 08:03:35 UTC