X-Git-Url: https://git.p6c8.net/devedit.git/blobdiff_plain/45dab0a69a6d22dd13aa625970c4b673afea535c..ce10babcb8d07587e9bf95496e22e9b4e801f207:/modules/Config/DevEdit.pm?ds=inline diff --git a/modules/Config/DevEdit.pm b/modules/Config/DevEdit.pm index 24b3fe1..c387514 100644 --- a/modules/Config/DevEdit.pm +++ b/modules/Config/DevEdit.pm @@ -5,8 +5,8 @@ package Config::DevEdit; # # Read and parse the configuration files # -# Author: Patrick Canterino -# Last modified: 2004-10-28 +# Author: Patrick Canterino +# Last modified: 2005-06-09 # use strict; @@ -14,6 +14,8 @@ use strict; use vars qw(@EXPORT); use Carp qw(croak); +use Text::ParseWords; + ### Export ### use base qw(Exporter); @@ -24,7 +26,7 @@ use base qw(Exporter); # # Read the configuration files of Dev-Editor # -# Params: Path to configuration file +# Params: Path to main configuration file # # Return: Configuration (Hash Reference) @@ -37,6 +39,25 @@ sub read_config($) $config->{'errors'} = parse_config($config->{'error_file'}); $config->{'templates'} = parse_config($config->{'template_file'}); + # Parse list of forbidden files + + if($config->{'forbidden'}) + { + my @files; + + foreach my $file(parse_line('\s+',0,$config->{'forbidden'})) + { + $file =~ tr!\\!/!; + + $file = '/'.$file unless($file =~ m!^/!); + $file =~ s!/+$!!g; + + push(@files,$file); + } + + $config->{'forbidden'} = \@files; + } + return $config; } @@ -53,17 +74,20 @@ sub parse_config($) my $file = shift; local *CF; - open(CF,"<$file") or croak("Open $file: $!"); + open(CF,'<'.$file) or croak("Open $file: $!"); read(CF, my $data, -s $file); close(CF); my @lines = split(/\015\012|\012|\015/,$data); my $config = {}; + my $count = 0; foreach my $line(@lines) { + $count++; + next if($line =~ /^\s*#/); - next if($line !~ /^.+=.+$/); + next if($line !~ /^\s*\S+\s*=.*$/); my ($key,$value) = split(/=/,$line,2); @@ -74,7 +98,7 @@ sub parse_config($) $value =~ s/^\s+//g; $value =~ s/\s+$//g; - croak "Double defined value '$key' in configuration file '$file'" if($config->{$key}); + croak "Configuration option '$key' defined twice in line $count of configuration file '$file'" if($config->{$key}); $config->{$key} = $value; }