Deprecated Field Specification
Deprecated Field Specification

Supports the old [+[-]] field syntax.

Notes
The core role for OldFields is to define which characters are used for the next comparision. The type of sort used (set_ordering() a.k.a. FieldOpts) is an extension of this capability.

Insert user message text
Text insertion
Segment Source
 220:   +POS1 [-POS2]    start a key at POS1, end it before POS2\n\

Declare temporary values (t, t2)
Variable declaration
Segment Source
1720:   int i, t, t2;

Parse start field spec [+..]
Code insertion
Segment Source
1780:       if (argv[i][0] == '+')
1781:         {
1782:           if (key)
1783:             insertkey (key);
1784:           key = (struct keyfield *) xmalloc (sizeof (struct keyfield));
1785:           key_init (key);
1786:           s = argv[i] + 1;
1787:           if (! (ISDIGIT (*s) || (*s == '.' && ISDIGIT (s[1]))))
1788:             badfieldspec (argv[i]);
1789:           for (t = 0; ISDIGIT (*s); ++s)
1790:             t = 10 * t + *s - '0';
1791:           t2 = 0;
1792:           if (*s == '.')
1793:             for (++s; ISDIGIT (*s); ++s)
1794:               t2 = 10 * t2 + *s - '0';
1795:           if (t2 || t)
1796:             {
1797:               key->sword = t;
1798:               key->schar = t2;
1799:             }
1800:           else
1801:             key->sword = -1;
1802:           s = set_ordering (s, key, bl_start);
1803:           if (*s)
1804:             badfieldspec (argv[i]);
1805:         }

Parse end field spec [..[-]]
Code insertion
Segment Source
1809:           if (ISDIGIT (*s) || (*s == '.' && ISDIGIT (s[1])))
1810:             {
1811:               if (!key)
1812:                 {
1813:                   /* Provoke with `sort -9'.  */
1814:                   error (0, 0, _("when using the old-style +POS and -POS \
1815: key specifiers,\nthe +POS specifier must come first"));
1816:                   usage (SORT_FAILURE);
1817:                 }
1818:               for (t = 0; ISDIGIT (*s); ++s)
1819:                 t = t * 10 + *s - '0';
1820:               t2 = 0;
1821:               if (*s == '.')
1822:                 for (++s; ISDIGIT (*s); ++s)
1823:                   t2 = t2 * 10 + *s - '0';
1824:               key->eword = t;
1825:               key->echar = t2;
1826:               s = set_ordering (s, key, bl_end);
1827:               if (*s)
1828:                 badfieldspec (argv[i]);
1829:               insertkey (key);
1830:               key = NULL;
1831:             }
1832:           else