mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Enforcing string start/end check. See #1687
This commit is contained in:
@ -327,6 +327,25 @@ public class PdePreprocessor {
|
||||
return functionMatches;
|
||||
}
|
||||
|
||||
private boolean isStartOrEndOfString(char p[], int index) {
|
||||
if (p[index] != '\"') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p[index - 1] == '\\') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (index - 2 >= 0 && p[index - 2] == '\\') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all commented portions of a given String as spaces.
|
||||
@ -338,7 +357,7 @@ public class PdePreprocessor {
|
||||
int index = 0;
|
||||
boolean insideString = false;
|
||||
while (index < p.length) {
|
||||
if (p[index] == '\"') {
|
||||
if (isStartOrEndOfString(p, index)) {
|
||||
insideString = !insideString;
|
||||
}
|
||||
// for any double slash comments, ignore until the end of the line
|
||||
|
@ -1,6 +1,10 @@
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
// "comment with a double quote
|
||||
/* \" other comment with double quote */
|
||||
Serial.println("Accept: */*");
|
||||
Serial.println("Accept: \" */*");
|
||||
Serial.println("Accept: \\"); // */*");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -1,5 +1,9 @@
|
||||
void setup() {
|
||||
|
||||
|
||||
|
||||
Serial.println( );
|
||||
Serial.println( );
|
||||
Serial.println( );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user