From bdca5a27ec017751c8b2ee7882f5632911f13015 Mon Sep 17 00:00:00 2001 From: HiFiPhile Date: Sun, 10 Sep 2023 13:32:01 +0200 Subject: [PATCH] CYGWIN: Add support for "COM*" naming. --- src/options.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/options.c b/src/options.c index e34c8d1..4f08e6d 100644 --- a/src/options.c +++ b/src/options.c @@ -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; }