# HG changeset patch # User Ed Swartz # Date 1263584712 21600 # Node ID 2a21d00efb72e09e10aee8c58ae796391f55fe20 # Parent b31077a6aa47dbe64d17a2abdddadafa44d813bf Fix #10519, exception in MMP parser when encountering a Makefile diff -r b31077a6aa47 -r 2a21d00efb72 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView5.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView5.java Thu Jan 14 17:00:15 2010 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView5.java Fri Jan 15 13:45:12 2010 -0600 @@ -520,4 +520,27 @@ getView(mmpConfig); } + + /** In this bug, somehow Carbide reads a *.mk file as an MMP. + * Whatever the reason, we want to avoid IllegalStateException when + * parsing and rewriting it. + */ + public void testBug10519() { + + // The tricky part here is, there is a trailing "\" on a line with only spaces on the next. + // We need to fully consume those spaces as part of the mifconv statement. + String makefile = + "RESOURCE :\r\n" + + "\r\n" + + " mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \\\r\n" + + " /c24,8 ..\\Rolodex_icon\\back.svg \\\r\n" + + " \r\n" + + " \r\n" + + "FREEZE : do_nothing\r\n" + + ""; + + makeModel(makefile); + IMMPView view = getView(mmpConfig); + commitTest(view, makefile); + } } diff -r b31077a6aa47 -r 2a21d00efb72 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/BaseTokenizer.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/BaseTokenizer.java Thu Jan 14 17:00:15 2010 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/BaseTokenizer.java Fri Jan 15 13:45:12 2010 -0600 @@ -163,18 +163,14 @@ char ch; int start = idx; while ((ch = peek()) != 0) { - consumeCatenatedLine(); - if (isWhitespace(ch)) + if (isWhitespace(ch)) { get(); - /*else if (ch == '\\') { - int prev = idx; - if (!consumeCatenatedLine()) { - idx = prev; + } else if (ch == '\\') { + if (!consumeCatenatedLine(true)) break; - } - }*/ - else + } else { break; + } } return start != idx; } @@ -290,19 +286,22 @@ /** * Consume \\ and EOL for catenated line + * @param addToToken if true, include catenation characters in current token * @return true if catenation detected and skipped */ - protected boolean consumeCatenatedLine() { + protected boolean consumeCatenatedLine(boolean addToToken) { if (peek() == '\\') { int prevIdx = idx; - skip(); - if (peek() == '\r') { - skip(); - if (peek() == '\n') - skip(); + if (addToToken) get(); else skip(); + char ch = peek(); + if (ch == '\r') { + if (addToToken) get(); else skip(); + if (peek() == '\n') { + if (addToToken) get(); else skip(); + } return true; - } else if (peek() == '\n') { - skip(); + } else if (ch == '\n') { + if (addToToken) get(); else skip(); return true; } idx = prevIdx; @@ -311,6 +310,14 @@ } /** + * Consume \\ and EOL for catenated line + * @return true if catenation detected and skipped + */ + protected boolean consumeCatenatedLine() { + return consumeCatenatedLine(false); + } + + /** * Consume a numeric sequence. This starts with a number * and contains other numbers and letters and '.' and ('e' + '-'|'+'). * @return true if matched (and skipped), else false (and no idx change)