Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc mk/help: do not treat continuation lines as textual co...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/1d5ec2507cd7
branches:  trunk
changeset: 430679:1d5ec2507cd7
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun May 03 09:51:07 2020 +0000

description:
mk/help: do not treat continuation lines as textual comments

diffstat:

 mk/help/help.awk                |   8 +++++---
 regress/infra-unittests/help.sh |  29 ++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 4 deletions(-)

diffs (84 lines):

diff -r 8dc5cb5c8801 -r 1d5ec2507cd7 mk/help/help.awk
--- a/mk/help/help.awk  Sun May 03 09:44:07 2020 +0000
+++ b/mk/help/help.awk  Sun May 03 09:51:07 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: help.awk,v 1.38 2020/05/03 09:44:07 rillig Exp $
+# $NetBSD: help.awk,v 1.39 2020/05/03 09:51:07 rillig Exp $
 #
 
 # This program extracts the inline documentation from *.mk files.
@@ -16,6 +16,7 @@
 
        found_anything = no;    # has some help text been found at all?
        last_fname = "";
+       eval_this_line = yes;
        print_this_line = yes;
        ignore_next_empty_line = no;
        ignore_this_section = no;
@@ -178,7 +179,7 @@
 # be all-lowercase (make targets) or all-uppercase (variable names).
 # Everything else is assumed to belong to the explaining text.
 #
-NF >= 1 && !/^[\t.]/ && !/^#*$/ && !/^#\t\t/ {
+eval_this_line && NF >= 1 && !/^[\t.]/ && !/^#*$/ && !/^#\t\t/ {
        w = ($1 ~ /^#[A-Z]/) ? substr($1, 2) : ($1 == "#") ? $2 : $1;
 
        # Reduce VAR.<param>, VAR.${param} and VAR.* to VAR.
@@ -232,7 +233,7 @@
        print_noncomment_lines = no;
 }
 
-$1 == "#" {
+eval_this_line && $1 == "#" {
        comment_lines++;
 }
 
@@ -245,6 +246,7 @@
 }
 
 {
+       eval_this_line = substr($0, length($0)) != "\\";
        last_fname = FILENAME;
 }
 
diff -r 8dc5cb5c8801 -r 1d5ec2507cd7 regress/infra-unittests/help.sh
--- a/regress/infra-unittests/help.sh   Sun May 03 09:44:07 2020 +0000
+++ b/regress/infra-unittests/help.sh   Sun May 03 09:51:07 2020 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: help.sh,v 1.3 2020/05/03 08:49:16 rillig Exp $
+# $NetBSD: help.sh,v 1.4 2020/05/03 09:51:07 rillig Exp $
 #
 # Test cases for "bmake help", mainly implemented in mk/help/help.awk.
 #
@@ -115,3 +115,30 @@
 
        test_case_end
 fi
+
+
+if test_case_begin "commented variables with continuation lines"; then
+
+       # When a variable assignment is commented out, it can still
+       # contain continuation lines.  These are not ordinary comments
+       # and therefore do not count to the minimum number of comment
+       # lines.
+       #
+       # Found in mk/defaults/mk.conf.
+
+       create_file_lines "mk.conf" \
+               '# Australia.' \
+               '#' \
+               '#MASTER_SITE_OPENOFFICE=       ... \' \
+               '#                              ... \' \
+               '#                              ...' \
+               '#'
+
+       TOPIC=':all' awk -f "$pkgsrcdir/mk/help/help.awk" \
+               'mk.conf' >"out"
+
+       assert_that 'out' --file-is-lines \
+               'No help found for :all.'
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index