pkgsrc-Changes archive

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

CVS commit: pkgsrc/mk/check



Module Name:    pkgsrc
Committed By:   joerg
Date:           Wed Mar 18 17:47:40 UTC 2020

Modified Files:
        pkgsrc/mk/check: check-portability.awk

Log Message:
Increase developer friendliness by including the line number.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 pkgsrc/mk/check/check-portability.awk

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

Modified files:

Index: pkgsrc/mk/check/check-portability.awk
diff -u pkgsrc/mk/check/check-portability.awk:1.11 pkgsrc/mk/check/check-portability.awk:1.12
--- pkgsrc/mk/check/check-portability.awk:1.11  Fri Mar 13 08:11:36 2020
+++ pkgsrc/mk/check/check-portability.awk       Wed Mar 18 17:47:40 2020
@@ -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 @@ function check_random(line) {
        } 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 @@ function check_test_eqeq(line,  n, word,
                        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 @@ function check_test_eqeq(line,  n, word,
        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