From: Sven Schöling Date: Tue, 23 Jun 2015 14:08:06 +0000 (+0200) Subject: Inifile: alten Schrott beseitigt X-Git-Tag: release-3.3.0beta~31^2~31 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=189d03d210a5e46239b4ac2afc5c0b280ca6b1be;p=kivitendo-erp.git Inifile: alten Schrott beseitigt --- diff --git a/SL/Inifile.pm b/SL/Inifile.pm index 43689d1c0..91af9fc79 100644 --- a/SL/Inifile.pm +++ b/SL/Inifile.pm @@ -45,50 +45,40 @@ sub new { my ($type, $file, %options) = @_; my $id = ""; - my $skip; + my $cur; - local *FH; + my $self = { FILE => $file, ORDER => [] }; - my $self = { "FILE" => $file }; + open my $fh, "$file" or $::form->error("$file : $!"); - open FH, "$file" or $::form->error("$file : $!"); - - while () { + for (<$fh>) { chomp; if (!$options{verbatim}) { # strip comments - s/\#.*//; - # remove any trailing whitespace + s/\s*#.*$//; s/^\s*//; - s/\s*$//; } else { - next if (m/^\s*\#/); + next if m/#/; } next unless $_; - if (m/^\[/) { - s/(\[|\])//g; - - $id = $_; - - $self->{$id} ||= { }; + if (m/^\[(.*)\]$/) { + $id = $1; + $cur = $self->{$1} ||= { }; - push @{ $self->{ORDER} }, $_; - - next; + push @{ $self->{ORDER} }, $1; + } else { + # add key=value to $id + my ($key, $value) = split m/=/, $_, 2; + $cur->{$key} = $value; } - # add key=value to $id - my ($key, $value) = split m/=/, $_, 2; - - $self->{$id}->{$key} = $value; - } - close FH; + close $fh; $main::lxdebug->leave_sub(2);