Skip to content

Commit

Permalink
Fix windows com port prefix (wjwwood#179)
Browse files Browse the repository at this point in the history
The check in `_prefix_port_if_needed` does not work, as it's currently comparing the whole input string to the prefix. As a consequence, port strings will be prefixed, even if they're already prefixed. This commit changes the call to `wstring::compare` to use an overload that compares a substring of the input string only.
  • Loading branch information
hansmaad authored and ccwanggl committed Jun 25, 2023
1 parent de7aa87 commit c254b94
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/impl/win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ inline wstring
_prefix_port_if_needed(const wstring &input)
{
static wstring windows_com_port_prefix = L"\\\\.\\";
if (input.compare(windows_com_port_prefix) != 0)
if (input.compare(0, windows_com_port_prefix.size(), windows_com_port_prefix) != 0)
{
return windows_com_port_prefix + input;
}
Expand Down

0 comments on commit c254b94

Please sign in to comment.