Skip to content

Commit

Permalink
Fix checkstyle complaint about "modifying a control variable"
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-raffler committed Oct 9, 2024
1 parent 2e76ca4 commit 2aecfa0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/org/sosy_lab/java_smt/basicimpl/Tokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ public static List<String> tokenize(String input) {
boolean inQuoted = false;

int level = 0;
int pos = 0;

StringBuilder token = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
while (pos < input.length()) {
char c = input.charAt(pos);
if (inComment) {
if (c == '\n') {
// End of a comment
Expand All @@ -57,7 +58,7 @@ public static List<String> tokenize(String input) {
// We have a double quote: Check that it's not followed by another and actually closes
// the string.
Optional<Character> n =
(i == input.length() - 1) ? Optional.empty() : Optional.of(input.charAt(i + 1));
(pos == input.length() - 1) ? Optional.empty() : Optional.of(input.charAt(pos + 1));
if (n.isEmpty() || n.orElseThrow() != '"') {
// Close the string
token.append(c);
Expand All @@ -66,7 +67,7 @@ public static List<String> tokenize(String input) {
// Add both quotes to the token and skip one character ahead
token.append(c);
token.append(n.orElseThrow());
i++;
pos++;
}
} else {
token.append(c);
Expand Down Expand Up @@ -128,6 +129,7 @@ public static List<String> tokenize(String input) {
}
}
}
pos++;
}
if (level != 0) {
// Throw an exception if the brackets don't match
Expand Down

0 comments on commit 2aecfa0

Please sign in to comment.