Skip to content

Commit becda0c

Browse files
authored
fix: pass unsigned chars to the cctype functions
Differently from their <locale> counterparts, the functions in <cctype> and <ctype.h> have undefined behavior if their argument is not representable as an unsigned char and is not equal to EOF.
1 parent 1a5b15a commit becda0c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/lib/AST/ParseJavadoc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// Copyright (c) 2023 Vinnie Falco ([email protected])
88
// Copyright (c) 2023 Krystian Stasiowski ([email protected])
99
// Copyright (c) 2024 Alan de Freitas ([email protected])
10+
// Copyright (c) 2025 Gennaro Prota ([email protected])
1011
//
1112
// Official repository: https://github.com/cppalliance/mrdocs
1213
//
@@ -540,7 +541,7 @@ parseStyled(StringRef s)
540541
}
541542
};
542543

543-
auto isPunctuationOrSpace = [](char c) {
544+
auto isPunctuationOrSpace = [](unsigned char c) {
544545
return std::isspace(c) || std::ispunct(c);
545546
};
546547

src/lib/Support/Validate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
//
66
// Copyright (c) 2023 Vinnie Falco ([email protected])
7+
// Copyright (c) 2025 Gennaro Prota ([email protected])
78
//
89
// Official repository: https://github.com/cppalliance/mrdocs
910
//
@@ -29,7 +30,7 @@ validAdocSectionID(
2930
return
3031
s[0] == '_' ||
3132
s[0] == ':' ||
32-
std::isalpha(s[0]);
33+
std::isalpha(static_cast<unsigned char>(s[0]));
3334
}
3435

3536
} // mrdocs

0 commit comments

Comments
 (0)