[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] [PATCH] uniq: don't continue field processing after end

From: Pádraig Brady
Subject: Re: [coreutils] [PATCH] uniq: don't continue field processing after end of line
Date: Mon, 17 Jan 2011 09:56:38 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100227 Thunderbird/3.0.3

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]