| 2033 | } |
| 2034 | |
| 2035 | static void |
| 2036 | add_line_number (COLUMN *p) |
| 2037 | { |
| 2038 | int i; |
| 2039 | char *s; |
| 2040 | int num_width; |
| 2041 | |
| 2042 | /* Cutting off the higher-order digits is more informative than |
| 2043 | lower-order cut off. */ |
| 2044 | num_width = sprintf (number_buff, "%*d", chars_per_number, line_number); |
| 2045 | line_number++; |
| 2046 | s = number_buff + (num_width - chars_per_number); |
| 2047 | for (i = chars_per_number; i > 0; i--) |
| 2048 | (p->char_func) (*s++); |
| 2049 | |
| 2050 | if (columns > 1) |
| 2051 | { |
| 2052 | /* Tabification is assumed for multiple columns, also for n-separators, |
| 2053 | but 'default n-separator = TAB' hasn't been given priority over |
| 2054 | equal column_width also specified by POSIX. */ |
| 2055 | if (number_separator == '\t') |
| 2056 | { |
| 2057 | i = number_width - chars_per_number; |
| 2058 | while (i-- > 0) |
| 2059 | (p->char_func) (' '); |
| 2060 | } |
| 2061 | else |
| 2062 | (p->char_func) (number_separator); |
| 2063 | } |
| 2064 | else |
| 2065 | /* To comply with POSIX, we avoid any expansion of default TAB |
| 2066 | separator with a single column output. No column_width requirement |
| 2067 | has to be considered. */ |
| 2068 | { |
| 2069 | (p->char_func) (number_separator); |
| 2070 | if (number_separator == '\t') |
| 2071 | output_position = POS_AFTER_TAB (chars_per_output_tab, |
| 2072 | output_position); |
| 2073 | } |
| 2074 | |
| 2075 | if (truncate_lines && !parallel_files) |
| 2076 | input_position += number_width; |
| 2077 | } |
| 2078 | |
| 2079 | /* Print (or store) padding until the current horizontal position |
| 2080 | is position. */ |
no outgoing calls
no test coverage detected