svn commit: r309219 - head/usr.bin/indent

Pedro F. Giffuni pfg at FreeBSD.org
Sun Nov 27 20:30:10 UTC 2016


Author: pfg
Date: Sun Nov 27 20:30:09 2016
New Revision: 309219
URL: https://svnweb.freebsd.org/changeset/base/309219

Log:
  indent(1): fix regression introduced in r303596.
  
  Multi-line comments are always block comments in KNF. Restore properly,
  handling the case when a long one-liner gets wrapped and becomes a
  multi-line comment.
  
  Obtained from:	Piotr Stefaniak

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

Modified: head/usr.bin/indent/pr_comment.c
==============================================================================
--- head/usr.bin/indent/pr_comment.c	Sun Nov 27 20:21:38 2016	(r309218)
+++ head/usr.bin/indent/pr_comment.c	Sun Nov 27 20:30:09 2016	(r309219)
@@ -162,15 +162,19 @@ pr_comment(void)
     if (*buf_ptr != ' ' && !ps.box_com)
 	*e_com++ = ' ';
 
-    /* Don't put a break delimiter if this comment is a one-liner */
-    for (t_ptr = buf_ptr; *t_ptr != '\0' && *t_ptr != '\n'; t_ptr++) {
-	if (t_ptr >= buf_end)
-	    fill_buffer();
-	if (t_ptr[0] == '*' && t_ptr[1] == '/') {
-	    break_delim = false;
-	    break;
+    /*
+     * Don't put a break delimiter if this is a one-liner that won't wrap.
+     */
+    if (break_delim)
+	for (t_ptr = buf_ptr; *t_ptr != '\0' && *t_ptr != '\n'; t_ptr++) {
+	    if (t_ptr >= buf_end)
+		fill_buffer();
+	    if (t_ptr[0] == '*' && t_ptr[1] == '/') {
+		if (adj_max_col >= count_spaces_until(ps.com_col, buf_ptr, t_ptr + 2))
+		    break_delim = false;
+		break;
+	    }
 	}
-    }
 
     if (break_delim) {
 	char       *t = e_com;


More information about the svn-src-all mailing list