public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: files: slightly simplify suffix handling Date: Thu, 1 Feb 2024 11:38:45 +0000 (GMT) [thread overview] Message-ID: <20240201113845.C25AC38582A1@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=069f56db7a8d6d6c65913631902852f2366c1e32 commit 069f56db7a8d6d6c65913631902852f2366c1e32 Author: Corinna Vinschen <corinna@vinschen.de> AuthorDate: Tue Jan 16 15:23:06 2024 +0100 Commit: Corinna Vinschen <corinna@vinschen.de> CommitDate: Wed Jan 31 20:11:57 2024 +0100 Cygwin: files: slightly simplify suffix handling - drop appending .exe.lnk to files - drop exe_suffixes, it's the same as stat_suffixes for a long time Signed-off-by: Corinna Vinschen <corinna@vinschen.de> 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_includes/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 = 0): name (s), addon (addit) {} + suffix_info (const char *s): name (s) {} }; 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 @@ suffix_info stat_suffixes[] = { - suffix_info ("", 1), - suffix_info (".exe", 1), + suffix_info (""), + suffix_info (".exe"), suffix_info (NULL) }; @@ -2836,7 +2836,6 @@ enum SCAN_JUSTCHECK, SCAN_JUSTCHECKTHIS, /* Never try to append a suffix. */ SCAN_APPENDLNK, - SCAN_EXTRALNK, SCAN_DONE, }; @@ -2923,16 +2922,12 @@ suffix_scan::next () nextstate = SCAN_LNK; return 1; } - nextstate = SCAN_EXTRALNK; - /* fall through to suffix checking below */ - break; - case SCAN_HASLNK: - nextstate = SCAN_APPENDLNK; /* Skip SCAN_BEG */ - return 1; - case SCAN_EXTRALNK: nextstate = SCAN_DONE; *eopath = '\0'; return 0; + case SCAN_HASLNK: + nextstate = SCAN_APPENDLNK; /* Skip SCAN_BEG */ + return 1; case SCAN_JUSTCHECK: nextstate = SCAN_LNK; return 1; @@ -2954,19 +2949,18 @@ suffix_scan::next () return 0; } - while (suffixes && suffixes->name) - if (nextstate == SCAN_EXTRALNK - && (!suffixes->addon || namelen > NAME_MAX - 8)) + if (suffixes && suffixes->name) + { + strcpy (eopath, suffixes->name); suffixes++; - else - { - strcpy (eopath, suffixes->name); - if (nextstate == SCAN_EXTRALNK) - strcat (eopath, ".lnk"); - suffixes++; - return 1; - } + return 1; + } suffixes = NULL; + if (nextstate == SCAN_BEG) + { + nextstate = SCAN_LNK; + *eopath = '\0'; + } } } 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" -static const suffix_info exe_suffixes[] = -{ - 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& err, unsigned opt) err = 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); if (buf.isdir ()) {
reply other threads:[~2024-02-01 11:38 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240201113845.C25AC38582A1@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).