public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: files: slightly simplify suffix handling
@ 2024-02-01 11:38 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-02-01 11:38 UTC (permalink / raw)
  To: cygwin-cvs

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 ())
     {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-01 11:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 11:38 [newlib-cygwin/main] Cygwin: files: slightly simplify suffix handling Corinna Vinschen

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).