nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] [PATCH] Add pick -reverse switch to print reversed output

2016-03-27 23:46:21
Sorry, I have a whole bunch of unread nmh related mail saved
up waiting to read sometime when there is available time ... but this
one caught my eye.

I'd suggest it would be better to change the implementation of that
switch a little, instead on internal variable "reverse", call it
"direction" and init it to one...

        int direction = 1;      /* not int reverse = 0; */

then in
        case REVSW:
                direction = -direction;
                continue;

That allows

pick: -reverse

in the profile, to default to running backwards, and then the
command
        pick -reverse ...
would swap that around and go forward.

Then, in the loop, the 3rd term of the "for" is just

        msgnum += direction;

and the tests in the 1st and 2nd parts of the for stmt need to check
"direction < 0" where they currently just test "reverse" ... it would
actually be nice to avoid the conditional in the test (2nd term), which
would be easy if it was possible to make the test "!=" instead of <= or >=
(is there any way mshnum can go past the bound without being equal to it first?
... if it is somehow possible before the loop starts, that is, if there are
no messages in the range, that could be tested outside the loop.)

kre


_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>