diff options
author | Jody Bruchon <jody@jodybruchon.com> | 2017-03-30 18:15:54 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-03-30 18:15:54 +0200 |
commit | 8808f7fc2ec434621a213c1deb5966833bcfec58 (patch) | |
tree | 3f881e4741d22afcba561c3bac46b8c799d8cc6d /coreutils | |
parent | 257734855cbcc12ddeb0a6ab0fd8ce161becf671 (diff) | |
download | busybox-w32-8808f7fc2ec434621a213c1deb5966833bcfec58.tar.gz busybox-w32-8808f7fc2ec434621a213c1deb5966833bcfec58.tar.bz2 busybox-w32-8808f7fc2ec434621a213c1deb5966833bcfec58.zip |
uniq: add -i option to ignore case
Signed-off-by: Jody Bruchon <jody@jodybruchon.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/uniq.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/coreutils/uniq.c b/coreutils/uniq.c index be550b5cd..1c23e1d08 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c | |||
@@ -54,12 +54,13 @@ int uniq_main(int argc UNUSED_PARAM, char **argv) | |||
54 | OPT_f = 0x8, | 54 | OPT_f = 0x8, |
55 | OPT_s = 0x10, | 55 | OPT_s = 0x10, |
56 | OPT_w = 0x20, | 56 | OPT_w = 0x20, |
57 | OPT_i = 0x40, | ||
57 | }; | 58 | }; |
58 | 59 | ||
59 | skip_fields = skip_chars = 0; | 60 | skip_fields = skip_chars = 0; |
60 | max_chars = INT_MAX; | 61 | max_chars = INT_MAX; |
61 | 62 | ||
62 | opt = getopt32(argv, "cduf:+s:+w:+", &skip_fields, &skip_chars, &max_chars); | 63 | opt = getopt32(argv, "cduf:+s:+w:+i", &skip_fields, &skip_chars, &max_chars); |
63 | argv += optind; | 64 | argv += optind; |
64 | 65 | ||
65 | input_filename = argv[0]; | 66 | input_filename = argv[0]; |
@@ -106,7 +107,12 @@ int uniq_main(int argc UNUSED_PARAM, char **argv) | |||
106 | ++cur_compare; | 107 | ++cur_compare; |
107 | } | 108 | } |
108 | 109 | ||
109 | if (!old_line || strncmp(old_compare, cur_compare, max_chars)) { | 110 | if (!old_line) |
111 | break; | ||
112 | if ((opt & OPT_i) | ||
113 | ? strncasecmp(old_compare, cur_compare, max_chars) | ||
114 | : strncmp(old_compare, cur_compare, max_chars) | ||
115 | ) { | ||
110 | break; | 116 | break; |
111 | } | 117 | } |
112 | 118 | ||