aboutsummaryrefslogtreecommitdiff
path: root/ch5/5-14_rsort.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ch5/5-14_rsort.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/ch5/5-14_rsort.c b/ch5/5-14_rsort.c
index 4c03191..b39a20c 100644
--- a/ch5/5-14_rsort.c
+++ b/ch5/5-14_rsort.c
@@ -129,12 +129,20 @@ int main (int argc, char *argv[]) {
int reverse = 0; /* 1 if reverse sort */
if (argc > 1) {
- int i;
- for (i = 1; --argc; i++) {
- if (strcmp(argv[i], "-n") == 0) {
- numeric = 1;
- } else if (strcmp(argv[i], "-r") == 0) {
- reverse = 1;
+ int i, j;
+ for (i = 1, j = 0; --argc; i++) {
+ if (argv[i][j++] == '-') {
+ while (argv[i][j] != '\0') {
+ switch(argv[i][j]) {
+ case 'n':
+ numeric = 1;
+ break;
+ case 'r':
+ reverse = 1;
+ break;
+ }
+ j++;
+ }
}
}
}
-14 05:02:55 -0700'>2016-10-14updater.sh: add recursion, error handlingZe Libertine Gamer1-43/+101 2016-10-14Correct pipe-handling behaviorZe Libertine Gamer1-1/+9 2016-10-12Clarify a method to move between platformsZe Libertine Gamer1-2/+5