Changeset 291 in ProjectBuilder for devel/pb/lib


Ignore:
Timestamp:
Dec 20, 2007, 11:10:49 AM (16 years ago)
Author:
Bruno Cornec
Message:
  • Removes AppConfig dependency by using just a perl regexp instead.
  • Interface to the version field has also changed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/ProjectBuilder/Base.pm

    r288 r291  
    1111use File::Path;
    1212use File::Temp qw /tempdir/;
    13 use AppConfig qw(ARGCOUNT_HASH);
    1413use Data::Dumper;
    1514
     
    127126        }
    128127    }
    129     die "Invalid version name $ENV{'PBVER'} in $ENV{'PBCONF'}/$proj.pb" if (($ENV{'PBVER'} !~ /[0-9.]+/) && (not exists $version{$ENV{'PBVER'}}));
     128    die "Invalid version name $ENV{'PBVER'} in $ENV{'PBCONF'}/$proj.pb" if (($ENV{'PBVER'} !~ /[0-9.]+/) && (not defined $version) && ($ENV{'PBVER'} =~ /$version{$proj}/));
    130129   
    131130    if (not defined $ENV{'PBTAG'}) {
     
    754753}
    755754
    756 sub pb_no_err {
    757 }
    758 
    759755# Function which returns a pointer on a hash
    760756# corresponding to a declaration (arg2) in a conf file (arg1)
     
    765761my $trace;
    766762my @ptr;
     763my %h;
    767764
    768765my $debug = 0;
    769766
    770 if ($debug > 0) {
    771     $trace = 1;
    772 } else {
    773     $trace = 0;
    774 }
    775 
    776 
    777 my $config = AppConfig->new({
    778                             # Auto Create variables mentioned in Conf file
    779                             CREATE => 1,
    780                             DEBUG => $trace,
    781                             ERROR => \&pb_no_err,
    782                             GLOBAL => {
    783                                 # Each conf item is a hash
    784                                 ARGCOUNT => ARGCOUNT_HASH,
    785                             },
    786                         });
    787 $config->file($conffile);
     767open(CONF,$conffile) || die "Unable to open $conffile";
     768while(<CONF>) {
     769    if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
     770        print "DEBUG: 1:$1 2:$2 3:$3\n" if ($debug >= 1);
     771        $h{$1}{$2}=$3;
     772    }
     773}
     774close(CONF);
     775
    788776for my $param (@param) {
    789     push @ptr,$config->get($param);
    790 }
    791 print "DEBUG: params: ".Dumper(@param)." ".Dumper(@ptr)."\n" if ($debug >= 1);
     777    push @ptr,$h{$param};
     778}
     779print "DEBUG: h:".Dumper(%h)." param:".Dumper(@param)." ptr:".Dumper(@ptr)."\n" if ($debug >= 1);
    792780return(@ptr);
    793781}
     
    10301018my $ptr; # returned value pointer on the hash of filters
    10311019my %ptr;
     1020my %h;
    10321021
    10331022# Global filter files first, then package specificities
     
    10621051    print $LOG "DEBUG ffiles: ".Dumper(\@ffiles)."\n" if ($debug >= 1);
    10631052
    1064     my $config = AppConfig->new({
    1065         # Auto Create variables mentioned in Conf file
    1066         CREATE => 1,
    1067         DEBUG => 0,
    1068         GLOBAL => {
    1069             # Each conf item is a hash
    1070             ARGCOUNT => AppConfig::ARGCOUNT_HASH
     1053    foreach my $f (@ffiles) {
     1054        open(CONF,$f) || next;
     1055        while(<CONF>)  {
     1056            if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
     1057                $h{$1}{$2}=$3;
     1058            }
    10711059        }
    1072     });
    1073 
    1074     $config->file(@ffiles);
    1075     $ptr = $config->get("filter");
    1076     print $LOG "DEBUG f:".Dumper($ptr)."\n" if ($debug >= 1);
     1060        close(CONF);
     1061
     1062        $ptr = $h{"filter"};
     1063        print $LOG "DEBUG f:".Dumper($ptr)."\n" if ($debug >= 1);
     1064    }
    10771065} else {
    10781066    $ptr = { };
Note: See TracChangeset for help on using the changeset viewer.