Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jul 2016 16:34:16 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r303489 - head/usr.bin/indent
Message-ID:  <201607291634.u6TGYGwA068126@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Fri Jul 29 16:34:16 2016
New Revision: 303489
URL: https://svnweb.freebsd.org/changeset/base/303489

Log:
  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

Modified:
  head/usr.bin/indent/io.c

Modified: head/usr.bin/indent/io.c
==============================================================================
--- head/usr.bin/indent/io.c	Fri Jul 29 16:33:45 2016	(r303488)
+++ head/usr.bin/indent/io.c	Fri Jul 29 16:34:16 2016	(r303489)
@@ -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)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607291634.u6TGYGwA068126>