mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Preprocessor regexp: "." now matches even line terminators. Closes #1653
This commit is contained in:
parent
e6698e4baa
commit
84e9d70415
@ -257,7 +257,7 @@ public class PdePreprocessor {
|
||||
// pre-processor directive
|
||||
p += "|" + "(^\\s*#.*?$)";
|
||||
|
||||
Pattern pattern = Pattern.compile(p, Pattern.MULTILINE);
|
||||
Pattern pattern = Pattern.compile(p, Pattern.MULTILINE | Pattern.DOTALL);
|
||||
Matcher matcher = pattern.matcher(in);
|
||||
return matcher.replaceAll(" ");
|
||||
}
|
||||
|
34
app/test/processing/app/preproc/LineContinuations.ino
Normal file
34
app/test/processing/app/preproc/LineContinuations.ino
Normal file
@ -0,0 +1,34 @@
|
||||
const char *foo = "\
|
||||
hello \
|
||||
world\n";
|
||||
|
||||
//" delete this comment line and the IDE parser will crash
|
||||
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
/*
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
*/
|
@ -0,0 +1,12 @@
|
||||
const char *foo = ;
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
@ -93,4 +93,18 @@ public class PdePreprocessorTest {
|
||||
assertEquals("Wire.h", pdePreprocessor.getExtraImports().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineContinuations() throws Exception {
|
||||
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("LineContinuations.ino").getFile()));
|
||||
|
||||
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
||||
String actualOutput = pdePreprocessor.strip(s);
|
||||
String expectedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("LineContinuations.stripped.ino").getFile()));
|
||||
|
||||
assertEquals(expectedOutput, actualOutput);
|
||||
|
||||
pdePreprocessor.writePrefix(s);
|
||||
assertEquals(0, pdePreprocessor.getExtraImports().size());
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user