New function check_flags(). Split the validation of
options and arguments out of process_flags.
This commit is contained in:
@@ -91,6 +91,7 @@ static void open_files (void);
|
||||
static void fail_exit (int code);
|
||||
static gid_t get_gid (const char *gidstr);
|
||||
static void process_flags (int argc, char **argv);
|
||||
static void check_flags (void);
|
||||
static void check_perms (void);
|
||||
|
||||
/*
|
||||
@@ -434,16 +435,21 @@ static void process_flags (int argc, char **argv)
|
||||
/*
|
||||
* Check the flags consistency
|
||||
*/
|
||||
if (oflg && !gflg) {
|
||||
usage ();
|
||||
}
|
||||
|
||||
if (optind != argc - 1) {
|
||||
usage ();
|
||||
}
|
||||
|
||||
group_name = argv[optind];
|
||||
|
||||
check_flags ();
|
||||
}
|
||||
|
||||
static void check_flags (void)
|
||||
{
|
||||
/* -o does not make sense without -g */
|
||||
if (oflg && !gflg) {
|
||||
usage ();
|
||||
}
|
||||
|
||||
check_new_name ();
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user