pf-tools commit: r554 [ccaillet-guest] - /trunk/lib/PFTools/Conf.pm

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Fri Jan 18 11:22:44 UTC 2008


Author: ccaillet-guest
Date: Fri Jan 18 11:22:40 2008
New Revision: 554

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=554
Log:
Changing email address

Modified:
    trunk/lib/PFTools/Conf.pm

Modified: trunk/lib/PFTools/Conf.pm
URL: http://svn.debian.org/wsvn/pf-tools/trunk/lib/PFTools/Conf.pm?rev=554&op=diff
==============================================================================
--- trunk/lib/PFTools/Conf.pm (original)
+++ trunk/lib/PFTools/Conf.pm Fri Jan 18 11:22:40 2008
@@ -2,7 +2,7 @@
 ##
 ##  $Id$
 ##
-##  Copyright (C) 2007 Christophe Caillet <tof at sitadelle.com>
+##  Copyright (C) 2007 Christophe Caillet <quadchris at free.fr>
 ##  Copyright (C) 2005-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
 ##  Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
 ##  Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
@@ -44,6 +44,7 @@
 # Error code
 my $ERR_OPEN   = 1;
 my $ERR_SYNTAX = 2;
+my $DEBUG	= 0 ;
 
 # Vars needed by pf-launch
 my $sortie;
@@ -300,20 +301,25 @@
     my ( $fic_conf, $substdestvars ) = @_;
 
     my $CONF     = {};
+    my $LOCATION	= {} ;
     my $current  = ']';
     my @FIC_CONF = ();
+    my @ALL_CONF = ();
+    my @FH	= () ;
     my @line     = ();
     my @cond     = ();
 
     unshift @FIC_CONF, $fic_conf;
+    unshift @ALL_CONF, $fic_conf;
     unshift @line,     0;
-    open( $FIC_CONF[0], $FIC_CONF[0] )
+    print "Opening $FIC_CONF[0]\n" if ( $DEBUG );
+    open( $FH[0], $FIC_CONF[0] )
 	|| Abort( $ERR_OPEN, "Impossible d'ouvrir " . $FIC_CONF[0] );
-
-    while ( $#FIC_CONF >= 0 ) {
-	my $fh = $FIC_CONF[0];    # Perl gruik, ne pas simplifier!!!
+    print "Filehandles --> @FH\n"  if ( $DEBUG );
+    while ( $#FH >= 0 ) {
+	my $fh = $FH[0];    # Perl gruik, ne pas simplifier!!!
     LOADCONFLINE: while (<$fh>) {
-
+# 		print "Using fh --> $fh\n" ;
 	    # Compter les lignes
 	    $line[0]++;
 
@@ -330,7 +336,7 @@
 	    if (/^\@([^\s]+)$/) {
 		if ( $1 eq "else" ) {
 		    if ( $#cond < 0 ) {
-			Abort( $ERR_SYNTAX,
+			Abort ( $ERR_SYNTAX,
 			          $FIC_CONF[0] . ":"
 				. $line[0]
 				. ": else sans if" );
@@ -412,26 +418,37 @@
 			$fic_conf = "include-" . $fic_conf;
 		    }
 
-		    foreach $oldficconf (@FIC_CONF) {
+		    foreach $oldficconf (@ALL_CONF) {
 			if ( $fic_conf eq $oldficconf ) {
 			    Warn( $ERR_OPEN,
 				      $FIC_CONF[0] . ":"
 				    . $line[0] . ": "
 				    . $fic_conf
-				    . " deja inclus" );
+				    . " deja inclus ligne "
+				    . $LOCATION->{'include'}->{$fic_conf}->{'line'}
+				    . " dans "
+				    . $LOCATION->{'include'}->{$fic_conf}->{'source'} );
 			    next LOADCONFLINE;
 			}
 		    }
-
+			$LOCATION->{'include'}->{$fic_conf}->{'line'} = $line[0] ;
+			$LOCATION->{'include'}->{$fic_conf}->{'source'} = $FIC_CONF[0] ;
 		    unshift @FIC_CONF, $fic_conf;
+		    unshift @ALL_CONF, $fic_conf;
 		    unshift @line,     0;
-		    open( $FIC_CONF[0], $FIC_CONF[0] )
+		    print "Opening $FIC_CONF[0]\n"  if ( $DEBUG );
+		    my $newfh ;
+		    open( $newfh, $FIC_CONF[0] )
 			|| Abort( $ERR_OPEN,
 			      $FIC_CONF[1] . ":"
 			    . $line[1]
 			    . ": Impossible d'inclure "
 			    . $FIC_CONF[0] );
-		    $fh = $FIC_CONF[0];    # Perl gruik, ne pas simplifier!!!
+		    ;    # Perl gruik, ne pas simplifier!!!
+		    print "File list after including $FIC_CONF[0] ".join ( " ", @ALL_CONF )."\n"  if ( $DEBUG );
+		    unshift @FH, $newfh ;
+		    $fh = $newfh ;
+		    print "Filehandles list after inclusion --> @FH\n" if ( $DEBUG );
 		}
 		elsif ( $1 eq "define" ) {
 		    if ( defined( eval $$2 ) ) {
@@ -482,12 +499,12 @@
 			    . $line[0] . ": ["
 			    . $current
 			    . "] dupliquee (precedente a "
-			    . $CONF->{$current}->{_location}
+			    . $LOCATION->{$current}->{_location}
 			    . ")" );
 		}
 		else {
 		    $CONF->{$current} = {};
-		    $CONF->{$current}->{_location}
+		    $LOCATION->{$current}->{_location}
 			= $FIC_CONF[0] . ":" . $line[0];
 		}
 		next;
@@ -495,28 +512,29 @@
 
 	    # Traitement des variables
 	    if (/^([^\s]+)\s*=\s*(.+)$/) {
-		if ( defined( $CONF->{$current}->{$1} ) ) {
+	    	my ( $var, $val ) = ( $1, $2 ) ;
+		if ( defined( $CONF->{$current}->{$var} ) ) {
 		    Abort( $ERR_SYNTAX,
 			      $FIC_CONF[0] . ":"
 			    . $line[0] . ": "
-			    . $1
+			    . $var
 			    . " dupliquee (precedente a "
-			    . $CONF->{$current}->{$1}->{_location}
+			    . $LOCATION->{$current}->{$var}->{_location}
 			    . ")" );
 		}
 		else {
 
-		    if ( Add_var( $CONF->{$current}, $1, $2 ) == $ERR_SYNTAX )
+		    if ( Add_var( $CONF->{$current}, $var, $val ) == $ERR_SYNTAX )
 		    {
 			Abort( $ERR_SYNTAX,
 			          $FIC_CONF[0] . ":"
 				. $line[0] . ": "
-				. $1
+				. $var
 				. " dupliquee (precedente a "
-				. $CONF->{$current}->{$1}->{_location}
+				. $LOCATION->{$current}->{$var}->{_location}
 				. ")" );
 		    }
-		    $CONF->{$current}->{$1}->{_location}
+		    $LOCATION->{$current}->{$var}->{_location}
 			= $FIC_CONF[0] . ":" . $line[0];
 		}
 	    }
@@ -525,7 +543,10 @@
 		    $FIC_CONF[0] . ":" . $line[0] . ": Erreur de syntaxe" );
 	    }
 	}
-	close( $FIC_CONF[0] );
+	close( $FH[0] ) ;
+	print "Closing $FIC_CONF[0] -- $FH[0]\n"  if ( $DEBUG );
+	shift @FH;
+	print "Filehandles after closing --> @FH\n"  if ( $DEBUG );
 	shift @line;
 	shift @FIC_CONF;
     }




More information about the pf-tools-commits mailing list