From 43fcc2ac704d94640abbfccc53b247243c33d6e0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 14 Sep 2019 13:10:22 +0200 Subject: [PATCH] findprog-in: Better mimic the system on native Windows. Reported by Paul Smith . * lib/findprog-in.c (find_in_given_path): On native Windows, don't try non-empty suffixes when the file name already contains a '.'. --- ChangeLog | 7 +++++++ lib/findprog-in.c | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ef2c89215..d62a962847 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-09-14 Bruno Haible + + findprog-in: Better mimic the system on native Windows. + Reported by Paul Smith . + * lib/findprog-in.c (find_in_given_path): On native Windows, don't try + non-empty suffixes when the file name already contains a '.'. + 2019-09-10 Bruno Haible wctob: Fix autoconf test. diff --git a/lib/findprog-in.c b/lib/findprog-in.c index 99b3c314d9..d601e060d9 100644 --- a/lib/findprog-in.c +++ b/lib/findprog-in.c @@ -118,8 +118,9 @@ find_in_given_path (const char *progname, const char *path, const char *suffix = suffixes[i]; #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */ - /* File names without a '.' are not considered executable. */ - if (*suffix != '\0' || strchr (progbasename, '.') != NULL) + /* File names without a '.' are not considered executable, and + for file names with a '.' no additional suffix is tried. */ + if ((*suffix != '\0') != (strchr (progbasename, '.') != NULL)) #endif { /* Concatenate progname and suffix. */ @@ -185,8 +186,9 @@ find_in_given_path (const char *progname, const char *path, const char *suffix = suffixes[i]; #if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */ - /* File names without a '.' are not considered executable. */ - if (*suffix != '\0' || strchr (progname, '.') != NULL) + /* File names without a '.' are not considered executable, and + for file names with a '.' no additional suffix is tried. */ + if ((*suffix != '\0') != (strchr (progname, '.') != NULL)) #endif { /* Concatenate dir, progname, and suffix. */ -- 2.39.5