# HG changeset patch # User Ed Swartz <ed.swartz@nokia.com> # Date 1263588626 21600 # Node ID dd82c352e68f7f40c4e2bbf14ba6fdc24517dc25 # Parent 774b5f74e4edcdc14972eafafd56675b553dc2af Merge rev 768 from default (fix for bug #10519) diff -r 774b5f74e4ed -r dd82c352e68f 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 Fri Jan 15 11:19:08 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 14:50:26 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 774b5f74e4ed -r dd82c352e68f 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 Fri Jan 15 11:19:08 2010 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/BaseTokenizer.java Fri Jan 15 14:50:26 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)