mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-05 11:20:50 +02:00
second set of ANSI C changes: C89-style function declarations, more inline functions, remove register keyword
This commit is contained in:
@@ -52,13 +52,13 @@ extern int errno;
|
||||
#endif
|
||||
|
||||
/* Static functions defined and used in this file. */
|
||||
static char *_find_user_command_internal PARAMS((const char *, int));
|
||||
static char *find_user_command_internal PARAMS((const char *, int));
|
||||
static char *find_user_command_in_path PARAMS((const char *, char *, int, int *));
|
||||
static char *find_in_path_element PARAMS((const char *, char *, int, int, struct stat *, int *));
|
||||
static char *find_absolute_program PARAMS((const char *, int));
|
||||
static char *_find_user_command_internal (const char *, int);
|
||||
static char *find_user_command_internal (const char *, int);
|
||||
static char *find_user_command_in_path (const char *, char *, int, int *);
|
||||
static char *find_in_path_element (const char *, char *, int, int, struct stat *, int *);
|
||||
static char *find_absolute_program (const char *, int);
|
||||
|
||||
static char *get_next_path_element PARAMS((char *, int *));
|
||||
static char *get_next_path_element (char *, int *);
|
||||
|
||||
/* The file name which we would try to execute, except that it isn't
|
||||
possible to execute it. This is the first file that matches the
|
||||
@@ -89,15 +89,13 @@ static struct ignorevar execignore =
|
||||
};
|
||||
|
||||
void
|
||||
setup_exec_ignore (varname)
|
||||
char *varname;
|
||||
setup_exec_ignore (char *varname)
|
||||
{
|
||||
setup_ignore_patterns (&execignore);
|
||||
}
|
||||
|
||||
static int
|
||||
exec_name_should_ignore (name)
|
||||
const char *name;
|
||||
exec_name_should_ignore (const char *name)
|
||||
{
|
||||
struct ign *p;
|
||||
|
||||
@@ -112,8 +110,7 @@ exec_name_should_ignore (name)
|
||||
The EXECABLE bit is non-zero the file is executable.
|
||||
Zero is returned if the file is not found. */
|
||||
int
|
||||
file_status (name)
|
||||
const char *name;
|
||||
file_status (const char *name)
|
||||
{
|
||||
struct stat finfo;
|
||||
int r;
|
||||
@@ -202,8 +199,7 @@ file_status (name)
|
||||
executable file is; do not change this unless YOU know
|
||||
what an executable file is. */
|
||||
int
|
||||
executable_file (file)
|
||||
const char *file;
|
||||
executable_file (const char *file)
|
||||
{
|
||||
int s;
|
||||
|
||||
@@ -216,15 +212,13 @@ executable_file (file)
|
||||
}
|
||||
|
||||
int
|
||||
is_directory (file)
|
||||
const char *file;
|
||||
is_directory (const char *file)
|
||||
{
|
||||
return (file_status (file) & FS_DIRECTORY);
|
||||
}
|
||||
|
||||
int
|
||||
executable_or_directory (file)
|
||||
const char *file;
|
||||
executable_or_directory (const char *file)
|
||||
{
|
||||
int s;
|
||||
|
||||
@@ -238,8 +232,7 @@ executable_or_directory (file)
|
||||
couldn't be found. If a file is found that isn't executable,
|
||||
and that is the only match, then return that. */
|
||||
char *
|
||||
find_user_command (name)
|
||||
const char *name;
|
||||
find_user_command (const char *name)
|
||||
{
|
||||
return (find_user_command_internal (name, FS_EXEC_PREFERRED|FS_NODIRS));
|
||||
}
|
||||
@@ -250,16 +243,13 @@ find_user_command (name)
|
||||
returns the first readable file found; designed to be used to look
|
||||
for shell scripts or files to source. */
|
||||
char *
|
||||
find_path_file (name)
|
||||
const char *name;
|
||||
find_path_file (const char *name)
|
||||
{
|
||||
return (find_user_command_internal (name, FS_READABLE));
|
||||
}
|
||||
|
||||
static char *
|
||||
_find_user_command_internal (name, flags)
|
||||
const char *name;
|
||||
int flags;
|
||||
_find_user_command_internal (const char *name, int flags)
|
||||
{
|
||||
char *path_list, *cmd;
|
||||
SHELL_VAR *var;
|
||||
@@ -280,9 +270,7 @@ _find_user_command_internal (name, flags)
|
||||
}
|
||||
|
||||
static char *
|
||||
find_user_command_internal (name, flags)
|
||||
const char *name;
|
||||
int flags;
|
||||
find_user_command_internal (const char *name, int flags)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
char *res, *dotexe;
|
||||
@@ -305,9 +293,7 @@ find_user_command_internal (name, flags)
|
||||
the index is modified by this function.
|
||||
Return the next element of PATH_LIST or NULL if there are no more. */
|
||||
static char *
|
||||
get_next_path_element (path_list, path_index_pointer)
|
||||
char *path_list;
|
||||
int *path_index_pointer;
|
||||
get_next_path_element (char *path_list, int *path_index_pointer)
|
||||
{
|
||||
char *path;
|
||||
|
||||
@@ -333,9 +319,7 @@ get_next_path_element (path_list, path_index_pointer)
|
||||
environment and should use the Posix standard path.
|
||||
Returns a newly-allocated string. */
|
||||
char *
|
||||
search_for_command (pathname, flags)
|
||||
const char *pathname;
|
||||
int flags;
|
||||
search_for_command (const char *pathname, int flags)
|
||||
{
|
||||
char *hashed_file, *command, *path_list;
|
||||
int temp_path, st;
|
||||
@@ -415,9 +399,7 @@ search_for_command (pathname, flags)
|
||||
}
|
||||
|
||||
char *
|
||||
user_command_matches (name, flags, state)
|
||||
const char *name;
|
||||
int flags, state;
|
||||
user_command_matches (const char *name, int flags, int state)
|
||||
{
|
||||
register int i;
|
||||
int path_index, name_len;
|
||||
@@ -498,9 +480,7 @@ user_command_matches (name, flags, state)
|
||||
}
|
||||
|
||||
static char *
|
||||
find_absolute_program (name, flags)
|
||||
const char *name;
|
||||
int flags;
|
||||
find_absolute_program (const char *name, int flags)
|
||||
{
|
||||
int st;
|
||||
|
||||
@@ -520,12 +500,7 @@ find_absolute_program (name, flags)
|
||||
}
|
||||
|
||||
static char *
|
||||
find_in_path_element (name, path, flags, name_len, dotinfop, rflagsp)
|
||||
const char *name;
|
||||
char *path;
|
||||
int flags, name_len;
|
||||
struct stat *dotinfop;
|
||||
int *rflagsp;
|
||||
find_in_path_element (const char *name, char *path, int flags, int name_len, struct stat *dotinfop, int *rflagsp)
|
||||
{
|
||||
int status;
|
||||
char *full_path, *xpath;
|
||||
@@ -607,10 +582,7 @@ find_in_path_element (name, path, flags, name_len, dotinfop, rflagsp)
|
||||
FS_NODIRS: Don't find any directories.
|
||||
*/
|
||||
static char *
|
||||
find_user_command_in_path (name, path_list, flags, rflagsp)
|
||||
const char *name;
|
||||
char *path_list;
|
||||
int flags, *rflagsp;
|
||||
find_user_command_in_path (const char *name, char *path_list, int flags, int *rflagsp)
|
||||
{
|
||||
char *full_path, *path;
|
||||
int path_index, name_len, rflags;
|
||||
@@ -687,10 +659,7 @@ find_user_command_in_path (name, path_list, flags, rflagsp)
|
||||
/* External interface to find a command given a $PATH. Separate from
|
||||
find_user_command_in_path to allow future customization. */
|
||||
char *
|
||||
find_in_path (name, path_list, flags)
|
||||
const char *name;
|
||||
char *path_list;
|
||||
int flags;
|
||||
find_in_path (const char *name, char *path_list, int flags)
|
||||
{
|
||||
return (find_user_command_in_path (name, path_list, flags, (int *)0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user