From 88eea6be3ad1c805f05ad915db9b609df42a8ca8 Mon Sep 17 00:00:00 2001 From: Ken Patel Date: Wed, 18 Nov 2009 19:46:23 +0000 Subject: [PATCH] allow - modifier to append rather than prepend paths within .init definition files --- dtool/src/attach/ctattch.pl | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/dtool/src/attach/ctattch.pl b/dtool/src/attach/ctattch.pl index 660b1db846..69f1a2ed3b 100644 --- a/dtool/src/attach/ctattch.pl +++ b/dtool/src/attach/ctattch.pl @@ -138,6 +138,10 @@ sub CTAttachMod { &CTUDebug( "post-pending '" . $_[1] . "' to " . $_[0] . "\n" ) ; $newenv{$_[0]} = $newenv{$_[0]} . " " . $_[1] ; + } elsif ( $envpostpendexceptions{$_[0]}{$_[1]} ) { + &CTUDebug( "post-pending (by exception) '" . $_[1] . "' to '" . $_[0] . + "'\n" ) ; + $newenv{$_[0]} = $newenv{$_[0]} . " " . $_[1] ; } else { &CTUDebug( "pre-pending '" . $_[1] . "' to " . $_[0] . "\n" ) ; @@ -232,6 +236,7 @@ sub CTAttachCompute { local( %localdo ); local( $localdocnt ) = 0 ; local( %localpost ); + local( %localpostexceptions ) = () ; if ( -e $init ) { &CTUDebug( "scanning " . $_[0] . ".init\n" ) ; local( @linesplit ) ; @@ -249,19 +254,37 @@ sub CTAttachCompute { $linetmp = $linesplit[1] ; shift( @linesplit ) ; shift( @linesplit ) ; + $linesplitjoin = join( " ", @linesplit ) ; + if ( $linesplit[0] eq "-" ) { + shift( @linesplit ) ; + $linesplitjoin = join( " ", @linesplit ) ; + $localpostexceptions{$linetmp}{$linesplitjoin} = 1 ; + &CTUDebug( "Creating post-pend exception for '" . + $linetmp . "':'" . $linesplitjoin . "'\n" ) ; + } if ( $localmod{$linetmp} eq "" ) { - $localmod{$linetmp} = join( " ", @linesplit ) ; + $localmod{$linetmp} = $linesplitjoin ; } else { $localmod{$linetmp} = $localmod{$linetmp} . " " . - join( " ", @linesplit ) ; + $linesplitjoin ; } } elsif ( $_ =~ /^MODREL/ ) { @linesplit = split ; $linetmp = $linesplit[1] ; shift( @linesplit ) ; shift( @linesplit ) ; + $postexception = 0 ; foreach $loop ( @linesplit ) { + if ( $loop eq "-" ) { + $postexception = 1 ; + next ; + } $looptmp = $root . "/" . &CTUShellEval($loop) ; + if ( $postexception ) { + $localpostexceptions{$linetmp}{$looptmp} = 1 ; + &CTUDebug( "Creating post-pend exception for '" . + $linetmp . "':'" . $looptmp . "'\n" ) ; + } if ( -e $looptmp ) { if ( $localmod{$linetmp} eq "" ) { $localmod{$linetmp} = $looptmp ; @@ -398,6 +421,7 @@ sub CTAttachCompute { foreach $item ( keys %localpost ) { $envpostpend{$item} = $localpost{$item} ; } + %envpostpendexceptions = %localpostexceptions; foreach $item ( keys %localmod ) { local( @splitthis ) = split( / +/, $localmod{$item} ) ; local( $thing ) ; @@ -415,6 +439,7 @@ sub CTAttachCompute { $envdo{$docnt} = $localdo{$item} ; $docnt++ ; } + %envpostpendexceptions = () ; } &CTUDebug( "out of CTAttachCompute\n" ) ;