- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 11 Mar 2008 10:21:03 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser/analyzer In directory hutz:/tmp/cvs-serv6127 Modified Files: CssParser.java CssParser.jj Log Message: Fix for bug 4981 <http://www.w3.org/Bugs/Public/show_bug.cgi?id=4981> The issue was in skipStatement, used very often to populate a CssError, but it was possible for it to fail with a TokenMgrError, now caught, and single char is read until the tokenizer can find something. Index: CssParser.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- CssParser.java 27 Sep 2007 08:46:45 -0000 1.28 +++ CssParser.java 11 Mar 2008 10:21:01 -0000 1.29 @@ -107,8 +107,7 @@ /** * The ac for handling errors and warnings. * - * @param ac - * the new ac for the parser. + * @param ac the new ac for the parser. */ public final void setApplContext(ApplContext ac) { this.ac = ac; @@ -117,8 +116,7 @@ /** [...7447 lines suppressed...] jj_rescan = false; } @@ -4088,15 +6135,10 @@ final private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { - if (p.next == null) { - p = p.next = new JJCalls(); - break; - } + if (p.next == null) { p = p.next = new JJCalls(); break; } p = p.next; } - p.gen = jj_gen + xla - jj_la; - p.first = token; - p.arg = xla; + p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } static final class JJCalls { Index: CssParser.jj =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.jj,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- CssParser.jj 27 Sep 2007 08:46:45 -0000 1.25 +++ CssParser.jj 11 Mar 2008 10:21:01 -0000 1.26 @@ -173,7 +173,7 @@ * @param stream the stream data to parse. * @param ac the new ac to use for parsing. */ - public void ReInit(InputStream stream, ApplContext ac) { + public void ReInitWithAc(InputStream stream, ApplContext ac) { ReInit(new CommentSkipperInputStream(stream)); markRule = false; setApplContext(ac); @@ -1861,26 +1861,37 @@ s.append(tok.image); } while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - getNextToken(); - s.append(skip_to_matching_brace()); - getNextToken(); + try { tok = getToken(1); - break; - } else if ((tok.kind == RBRACE) || (tok.kind == SEMICOLON)) { + if (tok.kind == EOF) { + return null; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + getNextToken(); + s.append(skip_to_matching_brace()); + getNextToken(); + tok = getToken(1); + break; + } else if ((tok.kind == RBRACE) || (tok.kind == SEMICOLON)) { + getNextToken(); + tok = getToken(1); + break; + } getNextToken(); - tok = getToken(1); - break; + } catch (TokenMgrError tokenerror) { + // read one char at a time, and loop + try { + s.append(jj_input_stream.readChar()); + continue; + } catch (java.io.IOException ioex) { + return s.toString().trim(); + } } - getNextToken(); } // skip white space + // FIXME check for error as well here. while (tok.kind == S) { getNextToken(); tok = getToken(1);
Received on Tuesday, 11 March 2008 10:21:10 UTC