mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-22 08:22:04 +03:00
Preprocessor regexp: "." now matches even line terminators. Closes #1653
This commit is contained in:
@ -257,7 +257,7 @@ public class PdePreprocessor {
|
|||||||
// pre-processor directive
|
// pre-processor directive
|
||||||
p += "|" + "(^\\s*#.*?$)";
|
p += "|" + "(^\\s*#.*?$)";
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile(p, Pattern.MULTILINE);
|
Pattern pattern = Pattern.compile(p, Pattern.MULTILINE | Pattern.DOTALL);
|
||||||
Matcher matcher = pattern.matcher(in);
|
Matcher matcher = pattern.matcher(in);
|
||||||
return matcher.replaceAll(" ");
|
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
|
||||||
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
|
*/
|
@ -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));
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user