Module Name:    src
Committed By:   rillig
Date:           Sun May 14 17:13:37 UTC 2023

Modified Files:
        src/tests/usr.bin/indent: opt_fc1.c
        src/usr.bin/indent: pr_comment.c

Log Message:
indent: in comments, keep a leading tab

This kind of comments is used for the CVS IDs at the top of files.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_fc1.c
cvs rdiff -u -r1.135 -r1.136 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/opt_fc1.c
diff -u src/tests/usr.bin/indent/opt_fc1.c:1.9 src/tests/usr.bin/indent/opt_fc1.c:1.10
--- src/tests/usr.bin/indent/opt_fc1.c:1.9	Sat May 13 16:40:18 2023
+++ src/tests/usr.bin/indent/opt_fc1.c	Sun May 14 17:13:37 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_fc1.c,v 1.9 2023/05/13 16:40:18 rillig Exp $ */
+/* $NetBSD: opt_fc1.c,v 1.10 2023/05/14 17:13:37 rillig Exp $ */
 
 /*
  * Tests for the options '-fc1' and '-nfc1'.
@@ -55,8 +55,8 @@
 /* $ The indentation got removed. */
 /* space */
 
-/* $ The indentation got removed, only the leading tab got replaced by a space. */
-/* indented tab	*/
+/* $ The indentation got removed. */
+/*	indented tab	*/
 
 /* $ The space between these comments got removed. */
 /* block1 *//* block2 */
@@ -76,7 +76,7 @@
  /* space */
 
 /* $ The indentation was changed from a single tab to a single space. */
- /* indented tab	*/
+ /*	indented tab	*/
 
 /* $ The space between these two comments got removed. */
 /* $ XXX: The option '-nfc1' says that comments in column 1 do not get */

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.135 src/usr.bin/indent/pr_comment.c:1.136
--- src/usr.bin/indent/pr_comment.c:1.135	Sun May 14 16:47:06 2023
+++ src/usr.bin/indent/pr_comment.c	Sun May 14 17:13:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.135 2023/05/14 16:47:06 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.136 2023/05/14 17:13:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pr_comment.c,v 1.135 2023/05/14 16:47:06 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.136 2023/05/14 17:13:37 rillig Exp $");
 
 #include <string.h>
 
@@ -145,16 +145,16 @@ analyze_comment(bool *p_may_wrap, bool *
 	ps.n_comment_delta = -ind_add(0, inp_line_start(), inp_p() - 2);
     } else {
 	ps.n_comment_delta = 0;
-	while (ch_isblank(inp_peek()))
-	    inp_skip();
+	if (!(inp_peek() == '\t' && !ch_isblank(inp_lookahead(1))))
+	    while (ch_isblank(inp_peek()))
+		inp_skip();
     }
 
     ps.comment_delta = 0;
     com_add_char('/');
     com_add_char(token.e[-1]);	/* either '*' or '/' */
 
-    /* TODO: Maybe preserve a single '\t' as well. */
-    if (inp_peek() != ' ' && may_wrap)
+    if (may_wrap && !ch_isblank(inp_peek()))
 	com_add_char(' ');
 
     if (break_delim && fits_in_one_line(com_ind, adj_max_line_length))

Reply via email to