Module Name: src Committed By: rillig Date: Fri Jun 23 20:59:04 UTC 2023
Modified Files: src/tests/usr.bin/indent: lsym_comment.c src/usr.bin/indent: pr_comment.c Log Message: indent: fix scanning of no-wrap comments (since 2021.11.07.10.34.03) The "refactoring" back then tried to be too clever. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/indent/lsym_comment.c cvs rdiff -u -r1.170 -r1.171 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/lsym_comment.c diff -u src/tests/usr.bin/indent/lsym_comment.c:1.23 src/tests/usr.bin/indent/lsym_comment.c:1.24 --- src/tests/usr.bin/indent/lsym_comment.c:1.23 Sun Jun 18 07:10:24 2023 +++ src/tests/usr.bin/indent/lsym_comment.c Fri Jun 23 20:59:04 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_comment.c,v 1.23 2023/06/18 07:10:24 rillig Exp $ */ +/* $NetBSD: lsym_comment.c,v 1.24 2023/06/23 20:59:04 rillig Exp $ */ /* * Tests for the token lsym_comment, which starts a comment. @@ -1131,6 +1131,7 @@ int block; /* comment line 1 comment l //indent end +// Ensure that '/*/' is not interpreted as a complete comment. //indent input /*/ comment? or:not; /* */ //indent end @@ -1139,10 +1140,7 @@ int block; /* comment line 1 comment l /* / comment? or:not; /* */ //indent end -//indent run -nfc1 -// $ FIXME: It's a comment, not code. -/*/ comment ? or : not; /* */ -//indent end +//indent run-equals-input -nfc1 /* Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.170 src/usr.bin/indent/pr_comment.c:1.171 --- src/usr.bin/indent/pr_comment.c:1.170 Sun Jun 18 07:32:33 2023 +++ src/usr.bin/indent/pr_comment.c Fri Jun 23 20:59:04 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.170 2023/06/18 07:32:33 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.171 2023/06/23 20:59:04 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pr_comment.c,v 1.170 2023/06/18 07:32:33 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.171 2023/06/23 20:59:04 rillig Exp $"); #include <string.h> @@ -325,12 +325,13 @@ copy_comment_nowrap(void) continue; } - com_add_char(*inp_p++); - if (com.len >= 2 - && com.s[com.len - 2] == '*' - && com.s[com.len - 1] == '/' - && kind == '*') + if (kind == '*' && inp_p[0] == '*' && inp_p[1] == '/') { + com_add_char(*inp_p++); + com_add_char(*inp_p++); return; + } + + com_add_char(*inp_p++); } }