projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mi_make_breakpoint: add "evaluated-by" option
[deliverable/binutils-gdb.git]
/
libiberty
/
make-relative-prefix.c
diff --git
a/libiberty/make-relative-prefix.c
b/libiberty/make-relative-prefix.c
index 80e7f92fb418297bec8c14ca22f5cdcb09789a61..fe639d18bd2815a5ec33aef28720386725ab1bd5 100644
(file)
--- a/
libiberty/make-relative-prefix.c
+++ b/
libiberty/make-relative-prefix.c
@@
-1,6
+1,6
@@
/* Relative (relocatable) prefix support.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
/* Relative (relocatable) prefix support.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2006
, 2012
Free Software Foundation, Inc.
This file is part of libiberty.
This file is part of libiberty.
@@
-21,7
+21,8
@@
Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
/*
/*
-@deftypefn Extension {const char*} make_relative_prefix (const char *@var{progname}, const char *@var{bin_prefix}, const char *@var{prefix})
+@deftypefn Extension {const char*} make_relative_prefix (const char *@var{progname}, @
+ const char *@var{bin_prefix}, const char *@var{prefix})
Given three paths @var{progname}, @var{bin_prefix}, @var{prefix},
return the path that is in the same position relative to
Given three paths @var{progname}, @var{bin_prefix}, @var{prefix},
return the path that is in the same position relative to
@@
-57,6
+58,9
@@
relative prefix can be found, return @code{NULL}.
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
#include <string.h>
#include <string.h>
@@
-244,10
+248,15
@@
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
{
char *startp, *endp, *nstore;
size_t prefixlen = strlen (temp) + 1;
{
char *startp, *endp, *nstore;
size_t prefixlen = strlen (temp) + 1;
+ size_t len;
if (prefixlen < 2)
prefixlen = 2;
if (prefixlen < 2)
prefixlen = 2;
- nstore = (char *) alloca (prefixlen + strlen (progname) + 1);
+ len = prefixlen + strlen (progname) + 1;
+#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
+ len += strlen (HOST_EXECUTABLE_SUFFIX);
+#endif
+ nstore = (char *) alloca (len);
startp = endp = temp;
while (1)
startp = endp = temp;
while (1)
@@
-262,7
+271,7
@@
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
}
else
{
}
else
{
-
strn
cpy (nstore, startp, endp - startp);
+
mem
cpy (nstore, startp, endp - startp);
if (! IS_DIR_SEPARATOR (endp[-1]))
{
nstore[endp - startp] = DIR_SEPARATOR;
if (! IS_DIR_SEPARATOR (endp[-1]))
{
nstore[endp - startp] = DIR_SEPARATOR;
@@
-278,8
+287,14
@@
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
#endif
)
{
#endif
)
{
- progname = nstore;
- break;
+#if defined (HAVE_SYS_STAT_H) && defined (S_ISREG)
+ struct stat st;
+ if (stat (nstore, &st) >= 0 && S_ISREG (st.st_mode))
+#endif
+ {
+ progname = nstore;
+ break;
+ }
}
if (*endp == 0)
}
if (*endp == 0)
@@
-292,14
+307,12
@@
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
}
}
}
}
- if ( resolve_links )
- {
- full_progname = lrealpath (progname);
- if (full_progname == NULL)
- return NULL;
- }
+ if (resolve_links)
+ full_progname = lrealpath (progname);
else
else
- full_progname = strdup(progname);
+ full_progname = strdup (progname);
+ if (full_progname == NULL)
+ return NULL;
prog_dirs = split_directories (full_progname, &prog_num);
free (full_progname);
prog_dirs = split_directories (full_progname, &prog_num);
free (full_progname);
This page took
0.024914 seconds
and
4
git commands to generate.