mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-03-02 13:05:42 +08:00
* spawn.cc (perhaps_suffix): Record errno-type error value in third argument.
(find_exec): On error, set errno returned from perhaps_suffix. (spawn_guts): Ditto.
This commit is contained in:
parent
b56c466b2c
commit
04dfd98dc6
@ -1,3 +1,10 @@
|
|||||||
|
2005-08-24 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
* spawn.cc (perhaps_suffix): Record errno-type error value in third
|
||||||
|
argument.
|
||||||
|
(find_exec): On error, set errno returned from perhaps_suffix.
|
||||||
|
(spawn_guts): Ditto.
|
||||||
|
|
||||||
2005-08-24 Christopher Faylor <cgf@timesys.com>
|
2005-08-24 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* fhandler_virtual.cc (fhandler_virtual::close): Don't free filebuf if
|
* fhandler_virtual.cc (fhandler_virtual::close): Don't free filebuf if
|
||||||
|
@ -54,15 +54,24 @@ DWORD dwExeced;
|
|||||||
Returns (possibly NULL) suffix */
|
Returns (possibly NULL) suffix */
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
perhaps_suffix (const char *prog, path_conv& buf)
|
perhaps_suffix (const char *prog, path_conv& buf, int& err)
|
||||||
{
|
{
|
||||||
char *ext;
|
char *ext;
|
||||||
|
|
||||||
|
err = 0;
|
||||||
debug_printf ("prog '%s'", prog);
|
debug_printf ("prog '%s'", prog);
|
||||||
buf.check (prog, PC_SYM_FOLLOW, std_suffixes);
|
buf.check (prog, PC_SYM_FOLLOW | PC_NULLEMPTY, std_suffixes);
|
||||||
|
|
||||||
if (!buf.exists () || buf.isdir ())
|
if (buf.isdir ())
|
||||||
ext = NULL;
|
{
|
||||||
|
err = EACCES;
|
||||||
|
ext = NULL;
|
||||||
|
}
|
||||||
|
else if (!buf.exists ())
|
||||||
|
{
|
||||||
|
err = ENOENT;
|
||||||
|
ext = NULL;
|
||||||
|
}
|
||||||
else if (buf.known_suffix)
|
else if (buf.known_suffix)
|
||||||
ext = (char *) buf + (buf.known_suffix - buf.get_win32 ());
|
ext = (char *) buf + (buf.known_suffix - buf.get_win32 ());
|
||||||
else
|
else
|
||||||
@ -90,12 +99,13 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
|
|||||||
char tmp[CYG_MAX_PATH];
|
char tmp[CYG_MAX_PATH];
|
||||||
const char *posix = (opt & FE_NATIVE) ? NULL : name;
|
const char *posix = (opt & FE_NATIVE) ? NULL : name;
|
||||||
bool has_slash = strchr (name, '/');
|
bool has_slash = strchr (name, '/');
|
||||||
|
int err;
|
||||||
|
|
||||||
/* Check to see if file can be opened as is first.
|
/* Check to see if file can be opened as is first.
|
||||||
Win32 systems always check . first, but PATH may not be set up to
|
Win32 systems always check . first, but PATH may not be set up to
|
||||||
do this. */
|
do this. */
|
||||||
if ((has_slash || opt & FE_CWD)
|
if ((has_slash || opt & FE_CWD)
|
||||||
&& (suffix = perhaps_suffix (name, buf)) != NULL)
|
&& (suffix = perhaps_suffix (name, buf, err)) != NULL)
|
||||||
{
|
{
|
||||||
if (posix && !has_slash)
|
if (posix && !has_slash)
|
||||||
{
|
{
|
||||||
@ -149,7 +159,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
|
|||||||
|
|
||||||
debug_printf ("trying %s", tmp);
|
debug_printf ("trying %s", tmp);
|
||||||
|
|
||||||
if ((suffix = perhaps_suffix (tmp, buf)) != NULL)
|
if ((suffix = perhaps_suffix (tmp, buf, err)) != NULL)
|
||||||
{
|
{
|
||||||
if (posix == tmp)
|
if (posix == tmp)
|
||||||
{
|
{
|
||||||
@ -181,6 +191,8 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
|
|||||||
debug_printf ("%s = find_exec (%s)", (char *) buf, name);
|
debug_printf ("%s = find_exec (%s)", (char *) buf, name);
|
||||||
if (known_suffix)
|
if (known_suffix)
|
||||||
*known_suffix = suffix ?: strchr (buf, '\0');
|
*known_suffix = suffix ?: strchr (buf, '\0');
|
||||||
|
if (!retval && err)
|
||||||
|
set_errno (err);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,10 +462,11 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
|||||||
goto skip_arg_parsing;
|
goto skip_arg_parsing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int err;
|
||||||
const char *ext;
|
const char *ext;
|
||||||
if ((ext = perhaps_suffix (prog_arg, real_path)) == NULL)
|
if ((ext = perhaps_suffix (prog_arg, real_path, err)) == NULL)
|
||||||
{
|
{
|
||||||
set_errno (ENOENT);
|
set_errno (err);
|
||||||
res = -1;
|
res = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user