pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/lintpkgsrc/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Tue Aug  9 19:53:02 UTC 2022

Modified Files:
        pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl

Log Message:
lintpkgsrc: clean up parsing of variable assignments


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl

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

Modified files:

Index: pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
diff -u pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.62 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.63
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.62 Tue Aug  9 19:42:46 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl      Tue Aug  9 19:53:02 2022
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.62 2022/08/09 19:42:46 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.63 2022/08/09 19:53:02 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -589,25 +589,28 @@ sub parse_makefile_vars($$) {
                        next;
                }
 
-               if (/^ *([-\w\.]+)\s*([:+?]?)=\s*(.*)/) {
-                       my ($key, $plus, $value) = ($1, $2, $3);
+               if (/^[ ]* ([-\w\.]+) \s* ([:+?]?=) \s* (.*)/x) {
+                       my ($varname, $op, $value) = ($1, $2, $3);
 
-                       if ($plus eq ':') {
-                               $vars{$key} = parse_expand_vars($value, \%vars);
-                       } elsif ($plus eq '+' && defined $vars{$key}) {
-                               $vars{$key} .= " $value";
-                       } elsif ($plus ne '?' || !defined $vars{$key}) {
-                               $vars{$key} = $value;
+                       if ($op eq ':=') {
+                               $vars{$varname} = parse_expand_vars($value, \%vars);
+                       } elsif ($op eq '+=' && defined $vars{$varname}) {
+                               $vars{$varname} .= " $value";
+                               # TODO: Handle append to undefined variable.
+                       } elsif ($op eq '?=' && defined $vars{$varname}) {
+                               # Do nothing.
+                       } else {
+                               $vars{$varname} = $value;
                        }
-                       debug("assignment: $key$plus=[$value] ($vars{$key})\n");
+                       debug($op eq '='
+                           ? "assignment: $varname $op $value\n"
+                           : "assignment: $varname $op $value => $vars{$varname}\n");
 
                        # Give python a little hand (XXX - do we wanna consider actually
                        # implementing make .for loops, etc?
                        #
-                       if ($key eq 'PYTHON_VERSIONS_ACCEPTED') {
-                               my ($pv);
-
-                               foreach $pv (split(/\s+/, $vars{PYTHON_VERSIONS_ACCEPTED})) {
+                       if ($varname eq 'PYTHON_VERSIONS_ACCEPTED') {
+                               foreach my $pv (split(/\s+/, $vars{PYTHON_VERSIONS_ACCEPTED})) {
                                        $vars{'_PYTHON_VERSION_FIRSTACCEPTED'} ||= $pv;
                                        $vars{"_PYTHON_VERSION_${pv}_OK"} = 'yes';
                                }



Home | Main Index | Thread Index | Old Index