Skip to content

Commit

Permalink
Saving unquoted comma regex in a static variable and incrementing ver…
Browse files Browse the repository at this point in the history
…sion number to 1.3.1 RC3
  • Loading branch information
ryu committed Sep 3, 2024
1 parent f27f843 commit a8dcb1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

class ClearBallotCvrReader {

private static final String unQuotedCommaRegex = ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)";

private final String cvrPath;
private final ContestConfig contestConfig;
private final String undeclaredWriteInLabel;
Expand All @@ -58,7 +60,7 @@ void readCastVoteRecords(List<CastVoteRecord> castVoteRecords, String contestId)
Logger.severe("No header row found in cast vote record file: %s", this.cvrPath);
throw new CvrParseException();
}
String[] headerData = firstRow.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
String[] headerData = firstRow.split(unQuotedCommaRegex);
if (headerData.length < CvrColumnField.ChoicesBegin.ordinal()) {
Logger.severe("No choice columns found in cast vote record file: %s", this.cvrPath);
throw new CvrParseException();
Expand Down Expand Up @@ -103,7 +105,7 @@ void readCastVoteRecords(List<CastVoteRecord> castVoteRecords, String contestId)
break;
}
// parse rankings
String[] cvrData = row.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
String[] cvrData = row.split(unQuotedCommaRegex);
ArrayList<Pair<Integer, String>> rankings = new ArrayList<>();
for (var entry : columnIndexToRanking.entrySet()) {
if (Integer.parseInt(cvrData[entry.getKey()]) == 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/network/brightspots/rcv/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class Main extends GuiApplication {

public static final String APP_NAME = "RCTab";
public static final String APP_VERSION = "1.3.1 RC2";
public static final String APP_VERSION = "1.3.1 RC3";

/**
* Main entry point to RCTab.
Expand Down

0 comments on commit a8dcb1a

Please sign in to comment.