Skip to content

Commit ab94bdc

Browse files
committed
Explain why we are wrapping std::isspace() and friends
Signed-off-by: Razvan Cojocaru <[email protected]>
1 parent 847a673 commit ab94bdc

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

openvpn/common/string.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,20 @@ inline std::string first_line(const std::string &str)
222222
return to_delim(str, '\n');
223223
}
224224

225-
// Define a common interpretation of what constitutes a space character.
226-
// Return true if c is a space char.
225+
/**
226+
* Define a common interpretation of what constitutes a space character.
227+
*
228+
* According to the Notes section at
229+
* https://en.cppreference.com/w/cpp/string/byte/isspace.html:
230+
*
231+
* "Like all other functions from <cctype>, the behavior of `std::isspace`
232+
* is undefined if the argument's value is neither representable as
233+
* `unsigned char` nor equal to `EOF`. To use these functions safely with
234+
* plain chars (or signed chars), the argument should first be converted
235+
* to `unsigned char`"
236+
*
237+
* @return true if c is a space char.
238+
**/
227239
inline bool is_space(const char c)
228240
{
229241
return std::isspace(static_cast<unsigned char>(c)) != 0;

0 commit comments

Comments
 (0)