Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/arduino/Arduino.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2020-01-28 17:07:37 +0300
committerMatthijs Kooijman <matthijs@stdin.nl>2020-01-29 21:04:43 +0300
commit8e9f7a630af6f79ebe6fa20ee97e51cf4ef0f030 (patch)
treeb4e455842077add841e24de0c144e018934ab4ca /arduino-core
parent0dbff59b13bc85d6acf973cd38cbc31d169e6c05 (diff)
Fix exception on compiler errors with column numbers
Error messages are detected and parsed using a regex. Part of this regex matches the optional column number. The code that handled this assumed that a missing column would result in less elements in the matches array, but a regex always results in one element per set of parenthesis in the regex, which will be null if no capture was made for that element. In practice, this meant that if no column was present in the error message, a NullPointerException would be raised. Furthermore, gcc 9 seems to have started outputting omitting column numbers (instead of printing 0) for some errors (such as unterminated #ifdef), which exposed this problem. This commit fixes this by simply using the fixed match numbers to take apart the regex match, and by checking for a null column number (all other captures are non-optional, so no need to check there).
Diffstat (limited to 'arduino-core')
-rw-r--r--arduino-core/src/cc/arduino/Compiler.java9
1 files changed, 3 insertions, 6 deletions
diff --git a/arduino-core/src/cc/arduino/Compiler.java b/arduino-core/src/cc/arduino/Compiler.java
index d1aa1f2bd..1663bbd9f 100644
--- a/arduino-core/src/cc/arduino/Compiler.java
+++ b/arduino-core/src/cc/arduino/Compiler.java
@@ -516,16 +516,13 @@ 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 error = pieces[5];
if (error.trim().equals("SPI.h: No such file or directory")) {
error = tr("Please import the SPI library from the Sketch > Import Library menu.");