indent(1): Removed whitespace shouldn't be considered in column calculations.

This piece of code removed tabs and space characters from after colons
that follow labels by decrementing the e_lab (end of label) "pointer"
which is later used to calculate the width of the string that fprintf()
puts into "output". But pad_output() gets the length from the actual
string, so it miscalculated what the current column is.

Fixed by putting a string terminator at the e_lab "pointer".

Differential Revision: https://reviews.freebsd.org/D6966
(Partial)
Obtained from:	Piotr Stefaniak
This commit is contained in:
pfg 2016-07-29 16:34:16 +00:00
parent 5507f31d44
commit e1d02e308d

View File

@ -116,6 +116,7 @@ dump_line(void)
}
while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t'))
e_lab--;
*e_lab = '\0';
cur_col = pad_output(1, compute_label_target());
if (s_lab[0] == '#' && (strncmp(s_lab, "#else", 5) == 0
|| strncmp(s_lab, "#endif", 6) == 0)) {