diff --git a/arduino-core/src/cc/arduino/Compiler.java b/arduino-core/src/cc/arduino/Compiler.java index d1aa1f2bd..c2c5b0ff6 100644 --- a/arduino-core/src/cc/arduino/Compiler.java +++ b/arduino-core/src/cc/arduino/Compiler.java @@ -134,7 +134,7 @@ public class Compiler implements MessageConsumer { } } - private static final Pattern ERROR_FORMAT = Pattern.compile("(.+\\.\\w+):(\\d+)(:\\d+)*:\\s*(fatal)?\\s*error:\\s*(.*)\\s*", Pattern.MULTILINE | Pattern.DOTALL); + private static final Pattern ERROR_FORMAT = Pattern.compile("(.+\\.\\w+):(\\d+)(:\\d+)*:\\s*((fatal)?\\s*error:\\s*)(.*)\\s*", Pattern.MULTILINE | Pattern.DOTALL); private final File pathToSketch; private final Sketch sketch; @@ -516,16 +516,14 @@ public class Compiler implements MessageConsumer { if (pieces != null) { String msg = ""; - int errorIdx = pieces.length - 1; - String error = pieces[errorIdx]; String filename = pieces[1]; int line = PApplet.parseInt(pieces[2]); - int col; - if (errorIdx > 3) { + int col = -1; + if (pieces[3] != null) { col = PApplet.parseInt(pieces[3].substring(1)); - } else { - col = -1; } + String errorPrefix = pieces[4]; + String error = pieces[6]; if (error.trim().equals("SPI.h: No such file or directory")) { error = tr("Please import the SPI library from the Sketch > Import Library menu."); @@ -585,11 +583,8 @@ public class Compiler implements MessageConsumer { String fileName = ex.getCodeFile().getPrettyName(); int lineNum = ex.getCodeLine() + 1; int colNum = ex.getCodeColumn(); - if (colNum != -1) { - s = fileName + ":" + lineNum + ":" + colNum + ": error: " + error + msg; - } else { - s = fileName + ":" + lineNum + ": error: " + error + msg; - } + String column = (colNum != -1) ? (":" + colNum) : ""; + s = fileName + ":" + lineNum + column + ": " + errorPrefix + error + msg; } if (ex != null) {