4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-03-03 13:35:46 +08:00

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>
This commit is contained in:
Corinna Vinschen 2024-01-16 15:23:06 +01:00
parent a4fead7bdd
commit 069f56db7a
3 changed files with 17 additions and 32 deletions

View File

@ -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[];

View File

@ -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';
}
}
}

View File

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