diff --git a/tests/usr.bin/indent/token_comment.c b/tests/usr.bin/indent/token_comment.c index bb40d69d6f97..05a5f826aa28 100644 --- a/tests/usr.bin/indent/token_comment.c +++ b/tests/usr.bin/indent/token_comment.c @@ -1,4 +1,4 @@ -/* $NetBSD: token_comment.c,v 1.16 2021/11/04 18:31:22 rillig Exp $ */ +/* $NetBSD: token_comment.c,v 1.17 2021/11/04 18:38:37 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -952,16 +952,13 @@ f(void) /* * Test for an edge cases in comment handling, having a block comment inside - * a line comment. + * a line comment. Before NetBSD pr_comment.c 1.96 from 2021-11-04, indent + * wrongly assumed that the comment would end at the '*' '/', tokenizing the + * second word 'still' as a type_at_paren_level_0. */ #indent input /* block comment */ // line comment /* still a line comment */ still a line comment #indent end -/* FIXME: The line comment must not be indented. */ -/* FIXME: The '*' '/' in the line comment must not be removed. */ -#indent run -/* block comment */ - // line comment /* still a line comment still a line comment -#indent end +#indent run-equals-input diff --git a/usr.bin/indent/pr_comment.c b/usr.bin/indent/pr_comment.c index 61d458f9f5e6..ca8e859f4dd0 100644 --- a/usr.bin/indent/pr_comment.c +++ b/usr.bin/indent/pr_comment.c @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.95 2021/11/04 17:37:03 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.96 2021/11/04 18:38:37 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c 8.1 (Berkeley) 6/6/93"; #include #if defined(__NetBSD__) -__RCSID("$NetBSD: pr_comment.c,v 1.95 2021/11/04 17:37:03 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.96 2021/11/04 18:38:37 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $"); #endif @@ -270,7 +270,7 @@ copy_comment(int adj_max_line_length, bool break_delim, bool may_wrap) case '*': inbuf_skip(); - if (*inp.s == '/') { + if (*inp.s == '/' && token.e[-1] == '*') { end_of_comment: inbuf_skip(); @@ -285,7 +285,7 @@ copy_comment(int adj_max_line_length, bool break_delim, bool may_wrap) if (!ch_isblank(com.e[-1]) && may_wrap) com_add_char(' '); - if (token.e[-1] != '/') { + if (token.e[-1] == '*') { com_add_char('*'); com_add_char('/'); }