mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 02:37:15 +00:00
cp: Move the flags around a bit.
- The HLPR flags are grouped together at the beginning because they are the standard flags for programs using FTS. Move the N flag out from among them to its correct place in the sequence. - The Pflag variable isn't used outside main(), but moving it out lets us skip initialization and keeps it with its friends H, L and R. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43063
This commit is contained in:
parent
ac56b9d83c
commit
0f4467ce44
13
bin/cp/cp.c
13
bin/cp/cp.c
|
@ -73,7 +73,7 @@ static char emptystring[] = "";
|
||||||
PATH_T to = { to.p_path, emptystring, "" };
|
PATH_T to = { to.p_path, emptystring, "" };
|
||||||
|
|
||||||
int Nflag, fflag, iflag, lflag, nflag, pflag, sflag, vflag;
|
int Nflag, fflag, iflag, lflag, nflag, pflag, sflag, vflag;
|
||||||
static int Hflag, Lflag, Rflag, rflag;
|
static int Hflag, Lflag, Pflag, Rflag, rflag;
|
||||||
volatile sig_atomic_t info;
|
volatile sig_atomic_t info;
|
||||||
|
|
||||||
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
|
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
|
||||||
|
@ -86,12 +86,11 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct stat to_stat, tmp_stat;
|
struct stat to_stat, tmp_stat;
|
||||||
enum op type;
|
enum op type;
|
||||||
int Pflag, ch, fts_options, r, have_trailing_slash;
|
int ch, fts_options, r, have_trailing_slash;
|
||||||
char *target;
|
char *target;
|
||||||
|
|
||||||
fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
|
fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
|
||||||
Pflag = 0;
|
while ((ch = getopt(argc, argv, "HLPRafilNnprsvx")) != -1)
|
||||||
while ((ch = getopt(argc, argv, "HLNPRafilnprsvx")) != -1)
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'H':
|
case 'H':
|
||||||
Hflag = 1;
|
Hflag = 1;
|
||||||
|
@ -101,9 +100,6 @@ main(int argc, char *argv[])
|
||||||
Lflag = 1;
|
Lflag = 1;
|
||||||
Hflag = Pflag = 0;
|
Hflag = Pflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'N':
|
|
||||||
Nflag = 1;
|
|
||||||
break;
|
|
||||||
case 'P':
|
case 'P':
|
||||||
Pflag = 1;
|
Pflag = 1;
|
||||||
Hflag = Lflag = 0;
|
Hflag = Lflag = 0;
|
||||||
|
@ -128,6 +124,9 @@ main(int argc, char *argv[])
|
||||||
case 'l':
|
case 'l':
|
||||||
lflag = 1;
|
lflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'N':
|
||||||
|
Nflag = 1;
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
nflag = 1;
|
nflag = 1;
|
||||||
fflag = iflag = 0;
|
fflag = iflag = 0;
|
||||||
|
|
Loading…
Reference in a new issue