pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/check Increase developer friendliness by including ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/cbe7e478c802
branches:  trunk
changeset: 413335:cbe7e478c802
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Wed Mar 18 17:47:40 2020 +0000

description:
Increase developer friendliness by including the line number.

diffstat:

 mk/check/check-portability.awk |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (67 lines):

diff -r 0d2b9082ecc3 -r cbe7e478c802 mk/check/check-portability.awk
--- a/mk/check/check-portability.awk    Wed Mar 18 17:46:18 2020 +0000
+++ b/mk/check/check-portability.awk    Wed Mar 18 17:47:40 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-portability.awk,v 1.11 2020/03/13 08:11:36 rillig Exp $
+# $NetBSD: check-portability.awk,v 1.12 2020/03/18 17:47:40 joerg Exp $
 #
 # Checks a shell file for possible portability problems.
 #
@@ -9,10 +9,11 @@
 BEGIN {
        found_random = no;
        found_test_eqeq = no;
+       lineno = 0;
 }
 
 # Check for $RANDOM, which is specific to ksh and bash.
-function check_random(line) {
+function check_random(line, lineno) {
 
        # $RANDOM together with the PID is often found in GNU-style
        # configure scripts and is considered acceptable.
@@ -25,11 +26,11 @@
        } else if (line ~ /\$RANDOM/) {
                found_random = yes;
                cs_warning_heading("Found $RANDOM:");
-               cs_warning_msg(cs_fname ": " $0);
+               cs_warning_msg(cs_fname ":" lineno ": " $0);
        }
 }
 
-function check_test_eqeq(line,  n, word, i) {
+function check_test_eqeq(line, lineno, n, word, i) {
 
        if (length(line) == 0)
                return;
@@ -39,12 +40,16 @@
                        if (word[i-2] == "test" || word[i-2] == "[") {
                                found_test_eqeq = yes;
                                cs_error_heading("Found test ... == ...:");
-                               cs_error_msg(cs_fname ": " $0);
+                               cs_error_msg(cs_fname ":" lineno ": " $0);
                        }
                }
        }
 }
 
+/^$/ {
+       ++lineno;
+}
+
 /./ {
        # Note: This code does not find _all_ instances of
        # unportable code. If a single line contains an unsafe and
@@ -54,9 +59,10 @@
        line = $0;
        gsub(/^#.*/, "", line);
        gsub(/[[:space:]]#.*/, "", line);
+       ++lineno;
 
-       check_random(line);
-       check_test_eqeq(line);
+       check_random(line, lineno);
+       check_test_eqeq(line, lineno);
 }
 
 END {



Home | Main Index | Thread Index | Old Index