Skip to content

Commit c809a49

Browse files
committed
refactor: consider Unicode chars when checking for whitespace
1 parent 1105081 commit c809a49

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/kotlin/com/github/lppedd/cc/parser/specConventionalCommit.flex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ package com.github.lppedd.cc.parser;
3434
int pushback = 0;
3535

3636
// Push back trailing whitespace
37-
for (; i >= 0 && Character.isWhitespace(yycharat(i)); i--, pushback++);
37+
for (; i >= 0 && isWhitespace(yycharat(i)); i--, pushback++);
3838

3939
// Check whether we now have a trailing '#'
4040
while (i >= 0 && yycharat(i) == '#') {
4141
// If '#' is attached (e.g., 'Something#'), keep it as part of the type and stop
42-
if (i - 1 >= 0 && !Character.isWhitespace(yycharat(i - 1))) {
42+
if (i - 1 >= 0 && !isWhitespace(yycharat(i - 1))) {
4343
break;
4444
}
4545

@@ -48,12 +48,16 @@ package com.github.lppedd.cc.parser;
4848
pushback++;
4949

5050
// Push back any whitespace before the '#' we have just encountered
51-
for (; i >= 0 && Character.isWhitespace(yycharat(i)); i--, pushback++);
51+
for (; i >= 0 && isWhitespace(yycharat(i)); i--, pushback++);
5252
}
5353

5454
return pushback;
5555
}
5656

57+
private boolean isWhitespace(final char ch) {
58+
return Character.isWhitespace(ch) || Character.isSpaceChar(ch);
59+
}
60+
5761
private CCToken token(final CCToken.Type type) {
5862
return token(type, yytext());
5963
}

0 commit comments

Comments
 (0)