Re: top: allow reverse sort order

2018-11-28 Thread Scott Cheloha
On Wed, Nov 28, 2018 at 12:07:37AM +0100, Klemens Nanni wrote: > On Tue, Nov 27, 2018 at 03:52:52PM -0600, Scott Cheloha wrote: > > > > static int > > > > +getorder(char *field) > > > > +{ > > > > + rev_order = field[0] == '-'; > > > > + > > > > + return string_index(rev_order ? field

Re: top: allow reverse sort order

2018-11-27 Thread Klemens Nanni
On Wed, Nov 28, 2018 at 12:07:37AM +0100, Klemens Nanni wrote: > Note how an empty field is silently treated as the default field > "state", but that's an independent issue I'd like to address in a > separate diff for string_index(). Not a problem of string_index() actually. We consistently

Re: top: allow reverse sort order

2018-11-27 Thread Klemens Nanni
On Tue, Nov 27, 2018 at 03:52:52PM -0600, Scott Cheloha wrote: > > > static int > > > +getorder(char *field) > > > +{ > > > + rev_order = field[0] == '-'; > > > + > > > + return string_index(rev_order ? field + 1 : field, statics.order_names); > > > +} > > > + > > You need to check that the

Re: top: allow reverse sort order

2018-11-27 Thread Klemens Nanni
On Tue, Nov 27, 2018 at 11:28:31AM -0600, Scott Cheloha wrote: > No objections here to the feature in general. We already support reversing > select orderings in systat(1), which I've found useful in practice, so this > is not without precedent and is consistent with at least one other monitoring

Re: top: allow reverse sort order

2018-11-27 Thread Scott Cheloha
On Tue, Nov 27, 2018 at 11:28:31AM -0600, Scott Cheloha wrote: > On Sat, Nov 24, 2018 at 04:06:34PM +0100, Klemens Nanni wrote: > > Sometimes I want to see certain programs with least amount of memory, > > so this diff implements `o -field' to sort in reverse order. > > > > The logic is straight

Re: top: allow reverse sort order

2018-11-27 Thread Scott Cheloha
On Tue, Nov 27, 2018 at 07:38:59PM +, Jason McIntyre wrote: > On Tue, Nov 27, 2018 at 11:28:31AM -0600, Scott Cheloha wrote: > > > @@ -137,13 +137,16 @@ mode. > > > This is identical to > > > .Em batch > > > mode. > > > -.It Fl o Ar field > > > +.It Fl o Oo - Oc Ns Ar field > > > Sort the

Re: top: allow reverse sort order

2018-11-27 Thread Jason McIntyre
On Tue, Nov 27, 2018 at 11:28:31AM -0600, Scott Cheloha wrote: > > @@ -137,13 +137,16 @@ mode. > > This is identical to > > .Em batch > > mode. > > -.It Fl o Ar field > > +.It Fl o Oo - Oc Ns Ar field > > Sort the process display area using the specified > > .Ar field > > as the primary key.

Re: top: allow reverse sort order

2018-11-27 Thread Scott Cheloha
On Sat, Nov 24, 2018 at 04:06:34PM +0100, Klemens Nanni wrote: > Sometimes I want to see certain programs with least amount of memory, > so this diff implements `o -field' to sort in reverse order. > > The logic is straight forward: > > 1. merge common code from argument and command loops into

top: allow reverse sort order

2018-11-24 Thread Klemens Nanni
Sometimes I want to see certain programs with least amount of memory, so this diff implements `o -field' to sort in reverse order. The logic is straight forward: 1. merge common code from argument and command loops into new setorder() 2. introduce global state `rev_order' (set in the helper) 3.