Trim Fields
Trim spaces from a field.
- Define trim modes (blankttype)
-
Type definition
- Segment Source
-
70: /* The kind of blanks for '-b' to skip in various options. */
71: enum blanktype { bl_start, bl_end, bl_both };
72:
- Declare trim fields (skipsblanks, skipeblanks)
- Field declaration
Segment Element
Field declaration
-
107: int skipsblanks; /* Skip leading white space at start. */
Segment Element
Field declaration
-
110: int skipeblanks; /* Skip trailing white space at finish. */
- Insert user message text
-
Text insertion
- Segment Source
-
221: -b ignore leading blanks in sort fields or keys\n\
- Skip leading blanks
- Code insertion
- Segment Source
- 562: if (key->skipsblanks)
563: while (ptr < lim && blanks[UCHAR (*ptr)])
564: ++ptr;
565:
- Skip leading blanks
- Code insertion
-
Change the way characters are counted if leading blanks
are being skipped.
- Segment Source
-
661: /* If we're skipping leading blanks, don't start counting characters
662: until after skipping past any leading blanks. */
663: if (key->skipsblanks)
664: while (ptr < lim && blanks[UCHAR (*ptr)])
665: ++ptr;
666:
- Define trim_trailing_blanks()
-
Function definition
- Notes
- What's with the FIX ME comment?
- Segment Source
- 676: /* FIXME */
677:
678: void
679: trim_trailing_blanks (const char *a_start, char **a_end)
680: {
681: while (*a_end > a_start && blanks[UCHAR (*(*a_end - 1))])
682: --(*a_end);
683: }
684:
- Trim beginning of first field
-
Code insertion
- Segment Source
-
729: if (key->skipsblanks)
730: while (blanks[UCHAR (*beg)])
731: ++beg;
- Trim end of first field
-
Code insertion
- Segment Source
-
734: if (key->skipeblanks)
735: {
736: trim_trailing_blanks (lines->lines[lines->used].keybeg,
737: &lines->lines[lines->used].keylim);
738: }
- Trim beginning of current fields
-
Code insertion
- Segment Source
-
1014: if (key->skipsblanks)
1015: {
1016: while (texta < lima && blanks[UCHAR (*texta)])
1017: ++texta;
1018: while (textb < limb && blanks[UCHAR (*textb)])
1019: ++textb;
1020: }
- Trim end of current fields
-
Code insertion
- Segment Source
-
1038: if (key->skipeblanks)
1039: {
1040: char *a_end = texta + lena;
1041: char *b_end = textb + lenb;
1042: trim_trailing_blanks (texta, &a_end);
1043: trim_trailing_blanks (textb, &b_end);
1044: lena = a_end - texta;
1045: lenb = b_end - textb;
1046: }
1047:
- Command line processing
Segment Element
Parameter insertion
-
1666: set_ordering (register const char *s, struct keyfield *key,
1667: enum blanktype blanktype)
Segment Element
Code insertion
-
1673: case 'b':
1674: if (blanktype == bl_start || blanktype == bl_both)
1675: key->skipsblanks = 1;
1676: if (blanktype == bl_end || blanktype == bl_both)
1677: key->skipeblanks = 1;
1678: break;
- Establish global sort options
-
Code insertion
- Segment Source
-
1774: gkey.skipsblanks = gkey.skipeblanks = 0;
- Default field trimming
Segment Element
Argument insertion
-
1802: s = set_ordering (s, key, bl_start);
Segment Element
Argument insertion
-
1826: s = set_ordering (s, key, bl_end);
Segment Element
Argument insertion
-
1835: s = set_ordering (s, &gkey, bl_both);
Segment Element
Argument insertion
-
1900: s = set_ordering (s, key, bl_start);
Segment Element
Argument insertion
-
1950: s = set_ordering (s, key, bl_end);
- Propogate global sort options
-
Code insertion
Segment Element
Code insertion
-
2031: if (!key->ignore && !key->translate && !key->skipsblanks && !key->reverse
2032: && !key->skipeblanks && !key->month && !key->numeric
Segment Element
Code insertion
-
2037: key->skipsblanks = gkey.skipsblanks;
2038: key->skipeblanks = gkey.skipeblanks;
Segment Element
Code insertion
-
2045: if (!keyhead.next && (gkey.ignore || gkey.translate || gkey.skipsblanks
2046: || gkey.skipeblanks || gkey.month || gkey.numeric