1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-23 04:04:54 +08:00

Fix windows com port prefix

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.
This commit is contained in:
Hannes Kamecke 2018-05-29 14:44:15 +02:00 committed by GitHub
parent 5a354eaab7
commit 9d9c1397d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}