Skip to content

Commit

Permalink
Skip (and warn for) blank lines in comments.dm
Browse files Browse the repository at this point in the history
The THOR-Soar project was failing to load because the comments.dm has blank
lines, and those caused exceptions during loading (because `line.charAt(0)` was
always out of bounds). After removing the blank lines, the comments appeared
to be on the correct nodes, so we'll just ignore them. I do not know how the
blank lines showed up in the file, but I find it very worrisome.
  • Loading branch information
garfieldnate committed Aug 21, 2024
1 parent 99b70fa commit 81ffc29
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,20 @@ public static boolean readSafe(SoarWorkingMemoryModel swmm, Reader fr, Reader cr
}
}

//If the comment file exists, read in all its comments
// If the comment file exists, read in all its comments
Vector<String> commentVec = new Vector<>();
if (cr != null) {
Scanner scanCR = new Scanner(cr);
int lineNum = 0;
while (scanCR.hasNextLine()) {
commentVec.add(scanCR.nextLine());
lineNum++;
String line = scanCR.nextLine();
if (line.isEmpty()) {
errors.add(
new FeedbackListEntry("Warning: ignoring blank line at comment.dm line " + lineNum));
continue;
}
commentVec.add(line);
}
}

Expand Down

0 comments on commit 81ffc29

Please sign in to comment.