diff options
Diffstat (limited to 'coreutils/uniq.c')
-rw-r--r-- | coreutils/uniq.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/coreutils/uniq.c b/coreutils/uniq.c index be550b5cd..2b62ad3ae 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c | |||
@@ -26,6 +26,7 @@ | |||
26 | //usage: "\n -c Prefix lines by the number of occurrences" | 26 | //usage: "\n -c Prefix lines by the number of occurrences" |
27 | //usage: "\n -d Only print duplicate lines" | 27 | //usage: "\n -d Only print duplicate lines" |
28 | //usage: "\n -u Only print unique lines" | 28 | //usage: "\n -u Only print unique lines" |
29 | //usage: "\n -i Ignore case" | ||
29 | //usage: "\n -f N Skip first N fields" | 30 | //usage: "\n -f N Skip first N fields" |
30 | //usage: "\n -s N Skip first N chars (after any skipped fields)" | 31 | //usage: "\n -s N Skip first N chars (after any skipped fields)" |
31 | //usage: "\n -w N Compare N characters in line" | 32 | //usage: "\n -w N Compare N characters in line" |
@@ -54,12 +55,13 @@ int uniq_main(int argc UNUSED_PARAM, char **argv) | |||
54 | OPT_f = 0x8, | 55 | OPT_f = 0x8, |
55 | OPT_s = 0x10, | 56 | OPT_s = 0x10, |
56 | OPT_w = 0x20, | 57 | OPT_w = 0x20, |
58 | OPT_i = 0x40, | ||
57 | }; | 59 | }; |
58 | 60 | ||
59 | skip_fields = skip_chars = 0; | 61 | skip_fields = skip_chars = 0; |
60 | max_chars = INT_MAX; | 62 | max_chars = INT_MAX; |
61 | 63 | ||
62 | opt = getopt32(argv, "cduf:+s:+w:+", &skip_fields, &skip_chars, &max_chars); | 64 | opt = getopt32(argv, "cduf:+s:+w:+i", &skip_fields, &skip_chars, &max_chars); |
63 | argv += optind; | 65 | argv += optind; |
64 | 66 | ||
65 | input_filename = argv[0]; | 67 | input_filename = argv[0]; |
@@ -106,7 +108,12 @@ int uniq_main(int argc UNUSED_PARAM, char **argv) | |||
106 | ++cur_compare; | 108 | ++cur_compare; |
107 | } | 109 | } |
108 | 110 | ||
109 | if (!old_line || strncmp(old_compare, cur_compare, max_chars)) { | 111 | if (!old_line) |
112 | break; | ||
113 | if ((opt & OPT_i) | ||
114 | ? strncasecmp(old_compare, cur_compare, max_chars) | ||
115 | : strncmp(old_compare, cur_compare, max_chars) | ||
116 | ) { | ||
110 | break; | 117 | break; |
111 | } | 118 | } |
112 | 119 | ||