From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id C25AC38582A1; Thu, 1 Feb 2024 11:38:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C25AC38582A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706787525; bh=8+fgMM4gSfPX8EpV5wUZV9xeuGm+KYlCRorgkanVW8U=; h=From:To:Subject:Date:From; b=hf8Yy3jZxPvBWpjTT7p32XjhaI2IAXYMWFsF6zll58Cfum/fiujNN7osVoq0uc0sl L+PtjXCKCAgZpVpHwl+50wnpHQ80HBefebCE0xqc08GO+jvFhiE87d6MA8snbcs3Hn ChmdVJixATnrWKJh2AXyXqSDfUzxeg5AvEP85cbk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: files: slightly simplify suffix handling X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: a4fead7bdd88668fd035413e2efa678f9212adab X-Git-Newrev: 069f56db7a8d6d6c65913631902852f2366c1e32 Message-Id: <20240201113845.C25AC38582A1@sourceware.org> Date: Thu, 1 Feb 2024 11:38:45 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D069f56db7a8= d6d6c65913631902852f2366c1e32 commit 069f56db7a8d6d6c65913631902852f2366c1e32 Author: Corinna Vinschen AuthorDate: Tue Jan 16 15:23:06 2024 +0100 Commit: Corinna Vinschen CommitDate: Wed Jan 31 20:11:57 2024 +0100 Cygwin: files: slightly simplify suffix handling =20 - drop appending .exe.lnk to files - drop exe_suffixes, it's the same as stat_suffixes for a long time =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/local_includes/path.h | 3 +-- winsup/cygwin/path.cc | 36 +++++++++++++++------------------= --- winsup/cygwin/spawn.cc | 10 +--------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/winsup/cygwin/local_includes/path.h b/winsup/cygwin/local_incl= udes/path.h index d19721e0cd3f..4e62287f6a6e 100644 --- a/winsup/cygwin/local_includes/path.h +++ b/winsup/cygwin/local_includes/path.h @@ -34,8 +34,7 @@ enum executable_states struct suffix_info { const char *name; - int addon; - suffix_info (const char *s, int addit =3D 0): name (s), addon (addit) {} + suffix_info (const char *s): name (s) {} }; =20 extern suffix_info stat_suffixes[]; diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index b8e5746fdd2a..4e0c0082e684 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -70,8 +70,8 @@ =20 suffix_info stat_suffixes[] =3D { - suffix_info ("", 1), - suffix_info (".exe", 1), + suffix_info (""), + suffix_info (".exe"), suffix_info (NULL) }; =20 @@ -2836,7 +2836,6 @@ enum SCAN_JUSTCHECK, SCAN_JUSTCHECKTHIS, /* Never try to append a suffix. */ SCAN_APPENDLNK, - SCAN_EXTRALNK, SCAN_DONE, }; =20 @@ -2923,16 +2922,12 @@ suffix_scan::next () nextstate =3D SCAN_LNK; return 1; } - nextstate =3D SCAN_EXTRALNK; - /* fall through to suffix checking below */ - break; - case SCAN_HASLNK: - nextstate =3D SCAN_APPENDLNK; /* Skip SCAN_BEG */ - return 1; - case SCAN_EXTRALNK: nextstate =3D SCAN_DONE; *eopath =3D '\0'; return 0; + case SCAN_HASLNK: + nextstate =3D SCAN_APPENDLNK; /* Skip SCAN_BEG */ + return 1; case SCAN_JUSTCHECK: nextstate =3D SCAN_LNK; return 1; @@ -2954,19 +2949,18 @@ suffix_scan::next () return 0; } =20 - while (suffixes && suffixes->name) - if (nextstate =3D=3D SCAN_EXTRALNK - && (!suffixes->addon || namelen > NAME_MAX - 8)) + if (suffixes && suffixes->name) + { + strcpy (eopath, suffixes->name); suffixes++; - else - { - strcpy (eopath, suffixes->name); - if (nextstate =3D=3D SCAN_EXTRALNK) - strcat (eopath, ".lnk"); - suffixes++; - return 1; - } + return 1; + } suffixes =3D NULL; + if (nextstate =3D=3D SCAN_BEG) + { + nextstate =3D SCAN_LNK; + *eopath =3D '\0'; + } } } =20 diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index dc1c4ac17c80..8a2db5cf72e2 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -30,13 +30,6 @@ details. */ #include "ntdll.h" #include "shared_info.h" =20 -static const suffix_info exe_suffixes[] =3D -{ - suffix_info ("", 1), - suffix_info (".exe", 1), - suffix_info (NULL) -}; - /* Add .exe to PROG if not already present and see if that exists. If not, return PROG (converted from posix to win32 rules if necessary). The result is always BUF. @@ -50,8 +43,7 @@ perhaps_suffix (const char *prog, path_conv& buf, int& er= r, unsigned opt) =20 err =3D 0; debug_printf ("prog '%s'", prog); - buf.check (prog, PC_SYM_FOLLOW | PC_NULLEMPTY | PC_POSIX, - (opt & FE_DLL) ? stat_suffixes : exe_suffixes); + buf.check (prog, PC_SYM_FOLLOW | PC_NULLEMPTY | PC_POSIX, stat_suffixes); =20 if (buf.isdir ()) {