From 258ad6a1d52f1811f9de1d6b976f3797f5b31a2b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 13 Aug 2020 11:36:29 +0100 Subject: win32: code shrink Add a new function, has_path(), to detect that an executable name doesn't require a path look-up. Also, since is_absolute_path() is now only used in shell/ash.c move its definition there from include/mingw.h. Saves 128 bytes. --- win32/mingw.c | 8 ++++++++ win32/process.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index faa9f2b57..d9bb6e973 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -1803,3 +1803,11 @@ void *get_proc_addr(const char *dll, const char *function, errno = ENOSYS; return proc->pfunction; } + +/* Return true if file is referenced using a path. This means a path + * look-up isn't required. */ +int has_path(const char *file) +{ + return strchr(file, '/') || strchr(file, '\\') || + has_dos_drive_prefix(file); +} diff --git a/win32/process.c b/win32/process.c index ac63a9c58..1118eb18a 100644 --- a/win32/process.c +++ b/win32/process.c @@ -348,7 +348,7 @@ mingw_spawn_1(int mode, const char *cmd, char *const *argv, char *const *envp) return mingw_spawn_applet(mode, argv, envp); else #endif - if (strchr(cmd, '/') || strchr(cmd, '\\') || has_dos_drive_prefix(cmd)) { + if (has_path(cmd)) { const char *path = auto_win32_extension(cmd); return mingw_spawn_interpreter(mode, path ? path : cmd, argv, envp, 0); } -- cgit v1.2.3-55-g6feb