unifdef: Fix case where a multiline comment follows a directive.
Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D41026
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
PACKAGE= tests
|
PACKAGE= tests
|
||||||
|
|
||||||
|
ATF_TESTS_SH= unifdef_test
|
||||||
NETBSD_ATF_TESTS_SH= basic_test
|
NETBSD_ATF_TESTS_SH= basic_test
|
||||||
|
|
||||||
${PACKAGE}FILES+= d_basic.in
|
${PACKAGE}FILES+= d_basic.in
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2023 Klara, Inc.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
atf_test_case hash_comment
|
||||||
|
hash_comment_head() {
|
||||||
|
atf_set descr "multiline comment follows directive"
|
||||||
|
}
|
||||||
|
hash_comment_body() {
|
||||||
|
cat >f <<EOF
|
||||||
|
#if FOO
|
||||||
|
#endif /*
|
||||||
|
*/
|
||||||
|
EOF
|
||||||
|
atf_check -o file:f unifdef <f
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_init_test_cases() {
|
||||||
|
atf_add_test_case hash_comment
|
||||||
|
}
|
||||||
@@ -886,8 +886,9 @@ parseline(void)
|
|||||||
retval = LT_ELIF;
|
retval = LT_ELIF;
|
||||||
}
|
}
|
||||||
/* the following can happen if the last line of the file lacks a
|
/* the following can happen if the last line of the file lacks a
|
||||||
newline or if there is too much whitespace in a directive */
|
newline or if there is too much whitespace in a directive,
|
||||||
if (linestate == LS_HASH) {
|
or if a directive is followed by a multiline comment */
|
||||||
|
if (linestate == LS_HASH && !incomment) {
|
||||||
long len = cp - tline;
|
long len = cp - tline;
|
||||||
if (fgets(tline + len, MAXLINE - len, input) == NULL) {
|
if (fgets(tline + len, MAXLINE - len, input) == NULL) {
|
||||||
if (ferror(input))
|
if (ferror(input))
|
||||||
|
|||||||
Reference in New Issue
Block a user