+2018-02-13 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * defs.h (enum openp_flags): New enum.
+ (OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH):
+ Move to enum openp_flags.
+ (openp_flags): New enum flags.
+ (openp): Change parameter type to openp_flags.
+ * source.c (openp): Change parameter type to openp_flags.
+ * cli/cli-cmds.c (find_and_open_script): Use openp_flags.
+ * dwarf2read.c (try_open_dwop_file): Use openp_flags.
+
2018-02-13 Simon Marchi <simon.marchi@polymtl.ca>
* maint.c (_initialize_maint_cmds): Fix prefix of maint set/show
find_and_open_script (const char *script_file, int search_path)
{
int fd;
- int search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
+ openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
gdb::optional<open_script> opened;
gdb::unique_xmalloc_ptr<char> file (tilde_expand (script_file));
/* From source.c */
/* See openp function definition for their description. */
-#define OPF_TRY_CWD_FIRST 0x01
-#define OPF_SEARCH_IN_PATH 0x02
-#define OPF_RETURN_REALPATH 0x04
-extern int openp (const char *, int, const char *, int, char **);
+enum openp_flag
+{
+ OPF_TRY_CWD_FIRST = 0x01,
+ OPF_SEARCH_IN_PATH = 0x02,
+ OPF_RETURN_REALPATH = 0x04,
+};
+
+DEF_ENUM_FLAGS_TYPE(openp_flag, openp_flags);
+
+extern int openp (const char *, openp_flags, const char *, int, char **);
extern int source_full_path_of (const char *, char **);
try_open_dwop_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
const char *file_name, int is_dwp, int search_cwd)
{
- int desc, flags;
+ int desc;
char *absolute_name;
/* Blech. OPF_TRY_CWD_FIRST also disables searching the path list if
FILE_NAME contains a '/'. So we can't use it. Instead prepend "."
else
search_path = xstrdup (debug_file_directory);
- flags = OPF_RETURN_REALPATH;
+ openp_flags flags = OPF_RETURN_REALPATH;
if (is_dwp)
flags |= OPF_SEARCH_IN_PATH;
desc = openp (search_path, flags, file_name,
/* >>>> This should only allow files of certain types,
>>>> eg executable, non-directory. */
int
-openp (const char *path, int opts, const char *string,
+openp (const char *path, openp_flags opts, const char *string,
int mode, char **filename_opened)
{
int fd;