Merge pull request #204 from HiFiPhile/com

CYGWIN: Add support for "COM*" naming.
This commit is contained in:
Martin Lund 2023-09-10 13:55:47 +02:00 committed by GitHub
commit 46a72d8254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -492,6 +492,19 @@ void options_parse_final(int argc, char *argv[])
optind = 1; // Reset option index to restart scanning of argv
options_parse(argc, argv);
#ifdef __CYGWIN__
unsigned char portnum;
char *tty_win;
if ( ((strncmp("COM", tty_device, 3) == 0)
|| (strncmp("com", tty_device, 3) == 0) )
&& (sscanf(tty_device + 3, "%hhu", &portnum) == 1)
&& (portnum > 0) )
{
asprintf(&tty_win, "/dev/ttyS%hhu", portnum - 1);
tty_device = tty_win;
}
#endif
/* Restore tty device */
option.tty_device = tty_device;
}