aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/source.c')
-rw-r--r--gdb/source.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/gdb/source.c b/gdb/source.c
index c2991b5bfd1..c2269fadcd5 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1,6 +1,6 @@
/* List lines of source files for GDB, the GNU debugger.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of GDB.
@@ -674,14 +674,24 @@ openp (const char *path, int try_cwd_first, const char *string,
mode |= O_BINARY;
#endif
- if ((try_cwd_first || IS_ABSOLUTE_PATH (string)) && is_regular_file (string))
+ if (try_cwd_first || IS_ABSOLUTE_PATH (string))
{
int i;
- filename = alloca (strlen (string) + 1);
- strcpy (filename, string);
- fd = open (filename, mode, prot);
- if (fd >= 0)
- goto done;
+
+ if (is_regular_file (string))
+ {
+ filename = alloca (strlen (string) + 1);
+ strcpy (filename, string);
+ fd = open (filename, mode, prot);
+ if (fd >= 0)
+ goto done;
+ }
+ else
+ {
+ filename = NULL;
+ fd = -1;
+ }
+
for (i = 0; string[i]; i++)
if (IS_DIR_SEPARATOR (string[i]))
goto done;