On 16/01/11 23:53, Sami Kerola wrote: > Hi, > > I notice uniq -f 'insane_large_number' will make process to be busy > long time without good reason. Attached patch should fix this symptom.
I'd slightly amend that to the following, to match the other limit checks in the function. diff --git a/src/uniq.c b/src/uniq.c index 7bdbc4f..9c7e37c 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -214,7 +214,7 @@ find_field (struct linebuffer const *line) size_t size = line->length - 1; size_t i = 0; - for (count = 0; count < skip_fields; count++) + for (count = 0; count < skip_fields && i < size; count++) { while (i < size && isblank (to_uchar (lp[i]))) > I found the bug after friend of mine asked why uniq does not allow > specifying field separator, similar way sort -t. I could not answer > anything rational, so I look the code and tested how it works. That > inspired me to send bug fix, which is obvious thing to do. But how > about that -t, do you think this would be worth while addition to > uniq? yes. Basically `uniq` should support the same -k and -t functionality that `sort` does. See also http://debbugs.gnu.org/5832 cheers, Pádraig.