Sort option parsing as far as practical.

This commit is contained in:
Greg Lehey 2012-11-07 23:37:24 +00:00
parent 530f737839
commit 44f17a8111
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=242722

View File

@ -192,17 +192,9 @@ main(int argc, char *argv[])
f_longform = 0; f_longform = 0;
f_stream = 0; f_stream = 0;
break; break;
case 'B':
f_nonprint = 0;
f_octal = 1;
f_octal_escape = 0;
break;
case 'C': case 'C':
f_sortacross = f_longform = f_singlecol = 0; f_sortacross = f_longform = f_singlecol = 0;
break; break;
case 'D':
f_timeformat = optarg;
break;
case 'l': case 'l':
f_longform = 1; f_longform = 1;
f_singlecol = 0; f_singlecol = 0;
@ -229,16 +221,43 @@ main(int argc, char *argv[])
f_accesstime = 0; f_accesstime = 0;
f_statustime = 0; f_statustime = 0;
break; break;
case 'F': case 'a':
fts_options |= FTS_SEEDOT;
/* FALLTHROUGH */
case 'A':
f_listdot = 1;
break;
/* The -t and -S options override each other. */
case 'S':
f_sizesort = 1;
f_timesort = 0;
break;
case 't':
f_timesort = 1;
f_sizesort = 0;
break;
/* Other flags. Please keep alphabetic. */
case 'B':
f_nonprint = 0;
f_octal = 1;
f_octal_escape = 0;
break;
case 'D':
f_timeformat = optarg;
break;
case 'F':
f_type = 1; f_type = 1;
f_slash = 0; f_slash = 0;
break; break;
case 'G':
setenv("CLICOLOR", "", 1);
break;
case 'H': case 'H':
fts_options |= FTS_COMFOLLOW; fts_options |= FTS_COMFOLLOW;
f_nofollow = 0; f_nofollow = 0;
break; break;
case 'G': case 'I':
setenv("CLICOLOR", "", 1); f_noautodot = 1;
break; break;
case 'L': case 'L':
fts_options &= ~FTS_PHYSICAL; fts_options &= ~FTS_PHYSICAL;
@ -254,14 +273,19 @@ main(int argc, char *argv[])
case 'R': case 'R':
f_recursive = 1; f_recursive = 1;
break; break;
case 'a': case 'T':
fts_options |= FTS_SEEDOT; f_sectime = 1;
/* FALLTHROUGH */
case 'A':
f_listdot = 1;
break; break;
case 'I': case 'W':
f_noautodot = 1; f_whiteout = 1;
break;
case 'Z':
f_label = 1;
break;
case 'b':
f_nonprint = 0;
f_octal = 0;
f_octal_escape = 1;
break; break;
/* The -d option turns off the -R option. */ /* The -d option turns off the -R option. */
case 'd': case 'd':
@ -309,34 +333,11 @@ main(int argc, char *argv[])
case 's': case 's':
f_size = 1; f_size = 1;
break; break;
case 'T':
f_sectime = 1;
break;
/* The -t and -S options override each other. */
case 't':
f_timesort = 1;
f_sizesort = 0;
break;
case 'S':
f_sizesort = 1;
f_timesort = 0;
break;
case 'W':
f_whiteout = 1;
break;
case 'b':
f_nonprint = 0;
f_octal = 0;
f_octal_escape = 1;
break;
case 'w': case 'w':
f_nonprint = 0; f_nonprint = 0;
f_octal = 0; f_octal = 0;
f_octal_escape = 0; f_octal_escape = 0;
break; break;
case 'Z':
f_label = 1;
break;
default: default:
case '?': case '?':
usage(); usage();