diff --git a/app/src/processing/mode/java/preproc/PdePreprocessor.java b/app/src/processing/mode/java/preproc/PdePreprocessor.java index 2d4ac8945..542bbfd8c 100644 --- a/app/src/processing/mode/java/preproc/PdePreprocessor.java +++ b/app/src/processing/mode/java/preproc/PdePreprocessor.java @@ -283,11 +283,15 @@ public class PdePreprocessor { */ static public String scrubComments(String what) { char p[] = what.toCharArray(); + // Track quotes to avoid problems with code like: String t = "*/*"; + // http://code.google.com/p/processing/issues/detail?id=1435 + boolean insideQuote = false; int index = 0; while (index < p.length) { // for any double slash comments, ignore until the end of the line - if ((p[index] == '/') && + if (!insideQuote && + (p[index] == '/') && (index < p.length - 1) && (p[index+1] == '/')) { p[index++] = ' '; @@ -299,7 +303,8 @@ public class PdePreprocessor { // check to see if this is the start of a new multiline comment. // if it is, then make sure it's actually terminated somewhere. - } else if ((p[index] == '/') && + } else if (!insideQuote && + (p[index] == '/') && (index < p.length - 1) && (p[index+1] == '*')) { p[index++] = ' '; @@ -321,6 +326,10 @@ public class PdePreprocessor { throw new RuntimeException("Missing the */ from the end of a " + "/* comment */"); } + } else if (p[index] == '"' && index > 0 && p[index-1] != '\\') { + insideQuote = !insideQuote; + index++; + } else { // any old character, move along index++; } diff --git a/todo.txt b/todo.txt index 45a4c093b..0fa9ee6c9 100644 --- a/todo.txt +++ b/todo.txt @@ -67,15 +67,14 @@ X casey: accidentally typing a letter at the top of the tab X throws you onto the end of the last tab... exactly the worst location o if the error cannot be placed, just don't change tabs/placement at all X prevent errors on first line of a new tab from highlighting on previous tab +X crashes in PdePreprocessor.scrubComments(PdePreprocessor.java:321) +X String t = "*/*"; +X http://code.google.com/p/processing/issues/detail?id=1435 earlier X The sketch name can't begin with '_' (underscore) X http://code.google.com/p/processing/issues/detail?id=859 -_ crashes in PdePreprocessor.scrubComments(PdePreprocessor.java:321) -_ String t = "*/*"; -_ http://code.google.com/p/processing/issues/detail?id=1435 - https://processing-js.lighthouseapp.com/ _ add to build.xml