Skip to content

Commit

Permalink
minor update: handles deeply nested comments (extraneous info) in sim…
Browse files Browse the repository at this point in the history
…ple names, e.g. "...(...(...))..."
  • Loading branch information
justparking authored and scroix committed Apr 1, 2024
1 parent ea2c575 commit 802fec5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nodel-framework/src/main/java/org/nodel/core/Nodel.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ public static String reduce(String name, boolean removeCommentsOnly) {

char lastChar = 0;

boolean inComment = false;
int commentLevel = 0;

for (int a = 0; a < len; a++) {
char c = name.charAt(a);

// deal with '(___)' comments
// deal with '(___)' comments, nested too
if (c == '(') {
inComment = true;
commentLevel += 1;
}

else if (inComment) {
else if (commentLevel > 0) {
if (c == ')')
inComment = false;
commentLevel -= 1;
else
; // don't capture
}
Expand Down

0 comments on commit 802fec5

Please sign in to comment.