pkgsrc-Changes archive

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

CVS commit: pkgsrc



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sun May  3 09:51:07 UTC 2020

Modified Files:
        pkgsrc/mk/help: help.awk
        pkgsrc/regress/infra-unittests: help.sh

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


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 pkgsrc/mk/help/help.awk
cvs rdiff -u -r1.3 -r1.4 pkgsrc/regress/infra-unittests/help.sh

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

Modified files:

Index: pkgsrc/mk/help/help.awk
diff -u pkgsrc/mk/help/help.awk:1.38 pkgsrc/mk/help/help.awk:1.39
--- pkgsrc/mk/help/help.awk:1.38        Sun May  3 09:44:07 2020
+++ pkgsrc/mk/help/help.awk     Sun May  3 09:51:07 2020
@@ -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 @@ BEGIN {
 
        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 @@ print_this_line {
 # 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 @@ $1 ~ /:$/ {
        print_noncomment_lines = no;
 }
 
-$1 == "#" {
+eval_this_line && $1 == "#" {
        comment_lines++;
 }
 
@@ -245,6 +246,7 @@ index(tolower($0), topic) != 0 {
 }
 
 {
+       eval_this_line = substr($0, length($0)) != "\\";
        last_fname = FILENAME;
 }
 

Index: pkgsrc/regress/infra-unittests/help.sh
diff -u pkgsrc/regress/infra-unittests/help.sh:1.3 pkgsrc/regress/infra-unittests/help.sh:1.4
--- pkgsrc/regress/infra-unittests/help.sh:1.3  Sun May  3 08:49:16 2020
+++ pkgsrc/regress/infra-unittests/help.sh      Sun May  3 09:51:07 2020
@@ -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 @@ if test_case_begin "comments without key
 
        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