diff options
author | Yao Qi <yao@codesourcery.com> | 2014-11-24 14:09:43 +0800 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2014-11-28 18:38:16 +0800 |
commit | abbffc8924ff61b64d86ee89775c466e59a32c63 (patch) | |
tree | 1456f586fb02bec24e32b3aa6dc82bfbedbdd7aa /gdb/utils.c | |
parent | 98399780958f38d70550174b8204f5085f3b23d5 (diff) | |
download | gdb-abbffc8924ff61b64d86ee89775c466e59a32c63.zip gdb-abbffc8924ff61b64d86ee89775c466e59a32c63.tar.gz gdb-abbffc8924ff61b64d86ee89775c466e59a32c63.tar.bz2 |
Use canonicalize_file_name unconditionally
gdb:
2014-11-28 Yao Qi <yao@codesourcery.com>
* configure.ac (AC_CHECK_FUNCS): Remove canonicalize_file_name
and realpath.
* config.in: Re-generated.
* configure: Re-generated.
* utils.c (gdb_realpath): Remove code calling realpath,
canonicalize_file_name and pathconf.
[!_WIN32]: Call canonicalize_file_name.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 68 |
1 files changed, 7 insertions, 61 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index ff5c00d..b3720f6 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2868,67 +2868,6 @@ string_to_core_addr (const char *my_string) char * gdb_realpath (const char *filename) { - /* Method 1: The system has a compile time upper bound on a filename - path. Use that and realpath() to canonicalize the name. This is - the most common case. Note that, if there isn't a compile time - upper bound, you want to avoid realpath() at all costs. */ -#if defined (HAVE_REALPATH) && defined (PATH_MAX) - { - char buf[PATH_MAX]; - const char *rp = realpath (filename, buf); - - if (rp == NULL) - rp = filename; - return xstrdup (rp); - } -#endif /* HAVE_REALPATH */ - - /* Method 2: The host system (i.e., GNU) has the function - canonicalize_file_name() which malloc's a chunk of memory and - returns that, use that. */ -#if defined(HAVE_CANONICALIZE_FILE_NAME) - { - char *rp = canonicalize_file_name (filename); - - if (rp == NULL) - return xstrdup (filename); - else - return rp; - } -#endif - - /* FIXME: cagney/2002-11-13: - - Method 2a: Use realpath() with a NULL buffer. Some systems, due - to the problems described in method 3, have modified their - realpath() implementation so that it will allocate a buffer when - NULL is passed in. Before this can be used, though, some sort of - configure time test would need to be added. Otherwize the code - will likely core dump. */ - - /* Method 3: Now we're getting desperate! The system doesn't have a - compile time buffer size and no alternative function. Query the - OS, using pathconf(), for the buffer limit. Care is needed - though, some systems do not limit PATH_MAX (return -1 for - pathconf()) making it impossible to pass a correctly sized buffer - to realpath() (it could always overflow). On those systems, we - skip this. */ -#if defined (HAVE_REALPATH) && defined (_PC_PATH_MAX) - { - /* Find out the max path size. */ - long path_max = pathconf ("/", _PC_PATH_MAX); - - if (path_max > 0) - { - /* PATH_MAX is bounded. */ - char *buf = alloca (path_max); - char *rp = realpath (filename, buf); - - return xstrdup (rp ? rp : filename); - } - } -#endif - /* The MS Windows method. If we don't have realpath, we assume we don't have symlinks and just canonicalize to a Windows absolute path. GetFullPath converts ../ and ./ in relative paths to @@ -2946,6 +2885,13 @@ gdb_realpath (const char *filename) if (len > 0 && len < MAX_PATH) return xstrdup (buf); } +#else + { + char *rp = canonicalize_file_name (filename); + + if (rp != NULL) + return rp; + } #endif /* This system is a lost cause, just dup the buffer. */ |