Reverse Ordering on Key
Reverse Ordering on Key

Reverse the sense of key based record comparisions.


Declare reverse order field (reverse)
Field declaration
Segment Source
 119:   int reverse;                  /* Reverse the sense of comparison. */

Insert user message text
Text insertion
Segment Source
 232:   -r               reverse the result of comparisons\n\

Reverse key order
Notes
The essential reversal of the comparision has been inlined and back-propogated into each of the atomic ordering extensions. Logically, this occurs only once, but optimizations scatter this throughout the keycompare() routine.
Segment Element
Code modification

1063:             return key->reverse ? -diff : diff;

Segment Element
Code modification

1080:             return key->reverse ? -diff : diff;

Segment Element
Code modification

1087:             return key->reverse ? -diff : diff;

Segment Element
Code modification

1156:         return key->reverse ? -diff : diff;

Segment Element
Code modification

1158:         return key->reverse ? -diff : diff;

Parse RevKey option (-r)
Code insertion
Segment Source
1697:         case 'r':
1698:           key->reverse = 1;
1699:           break;

Establish global sort options
Code modification
Segment Source
1773:   gkey.numeric =  gkey.general_numeric = gkey.month = gkey.reverse = 0;

Propogate global sort options
Code insertion
Segment Element
Code insertion

2031:     if (!key->ignore && !key->translate && !key->skipsblanks && !key->reverse

Segment Element
Code insertion

2042:         key->reverse = gkey.reverse;