diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d751253b9a4..da66c9d24ce 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2018-09-12 Sergio Durigan Junior + + * common/common-utils.c: Don't include ''. + (is_regular_file): Move to... + * common/filestuff.c (is_regular_file): ... here. + * common/common-utils.h (is_regular_file): Move to... + * common/filestuff.h (is_regular_file): ... here. + 2018-09-12 Simon Marchi * skip.c (debug_skip): New variable. diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c index 8d839d10fa8..24b3936f3dc 100644 --- a/gdb/common/common-utils.c +++ b/gdb/common/common-utils.c @@ -20,7 +20,6 @@ #include "common-defs.h" #include "common-utils.h" #include "host-defs.h" -#include #include /* The xmalloc() (libiberty.h) family of memory management routines. @@ -412,37 +411,6 @@ stringify_argv (const std::vector &args) /* See common/common-utils.h. */ -bool -is_regular_file (const char *name, int *errno_ptr) -{ - struct stat st; - const int status = stat (name, &st); - - /* Stat should never fail except when the file does not exist. - If stat fails, analyze the source of error and return true - unless the file does not exist, to avoid returning false results - on obscure systems where stat does not work as expected. */ - - if (status != 0) - { - if (errno != ENOENT) - return true; - *errno_ptr = ENOENT; - return false; - } - - if (S_ISREG (st.st_mode)) - return true; - - if (S_ISDIR (st.st_mode)) - *errno_ptr = EISDIR; - else - *errno_ptr = EINVAL; - return false; -} - -/* See common/common-utils.h. */ - ULONGEST align_up (ULONGEST v, int n) { diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h index 7bc6e90f05c..a961514fd66 100644 --- a/gdb/common/common-utils.h +++ b/gdb/common/common-utils.h @@ -146,11 +146,6 @@ in_inclusive_range (T value, T low, T high) return value >= low && value <= high; } -/* Return true if the file NAME exists and is a regular file. - If the result is false then *ERRNO_PTR is set to a useful value assuming - we're expecting a regular file. */ -extern bool is_regular_file (const char *name, int *errno_ptr); - /* Ensure that V is aligned to an N byte boundary (B's assumed to be a power of 2). Round up/down when necessary. Examples of correct use include: diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c index f5a754ffa66..fa10165a7ca 100644 --- a/gdb/common/filestuff.c +++ b/gdb/common/filestuff.c @@ -417,3 +417,34 @@ make_cleanup_close (int fd) *saved_fd = fd; return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree); } + +/* See common/filestuff.h. */ + +bool +is_regular_file (const char *name, int *errno_ptr) +{ + struct stat st; + const int status = stat (name, &st); + + /* Stat should never fail except when the file does not exist. + If stat fails, analyze the source of error and return true + unless the file does not exist, to avoid returning false results + on obscure systems where stat does not work as expected. */ + + if (status != 0) + { + if (errno != ENOENT) + return true; + *errno_ptr = ENOENT; + return false; + } + + if (S_ISREG (st.st_mode)) + return true; + + if (S_ISDIR (st.st_mode)) + *errno_ptr = EISDIR; + else + *errno_ptr = EINVAL; + return false; +} diff --git a/gdb/common/filestuff.h b/gdb/common/filestuff.h index 1a09c729f64..e9328f53585 100644 --- a/gdb/common/filestuff.h +++ b/gdb/common/filestuff.h @@ -117,4 +117,9 @@ struct gdb_dir_deleter typedef std::unique_ptr gdb_dir_up; +/* Return true if the file NAME exists and is a regular file. + If the result is false then *ERRNO_PTR is set to a useful value assuming + we're expecting a regular file. */ +extern bool is_regular_file (const char *name, int *errno_ptr); + #endif /* FILESTUFF_H */