projects
/
kivitendo-erp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8f176d2
)
Inifile: alten Schrott beseitigt
author
Sven Schöling
<s.schoeling@linet-services.de>
Tue, 23 Jun 2015 14:08:06 +0000
(16:08 +0200)
committer
Sven Schöling
<s.schoeling@linet-services.de>
Mon, 20 Jul 2015 14:37:26 +0000
(16:37 +0200)
SL/Inifile.pm
patch
|
blob
|
history
diff --git
a/SL/Inifile.pm
b/SL/Inifile.pm
index
43689d1
..
91af9fc
100644
(file)
--- a/
SL/Inifile.pm
+++ b/
SL/Inifile.pm
@@
-45,50
+45,40
@@
sub new {
my ($type, $file, %options) = @_;
my $id = "";
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 (<FH>) {
+ for (<$fh>) {
chomp;
if (!$options{verbatim}) {
# strip comments
chomp;
if (!$options{verbatim}) {
# strip comments
- s/\#.*//;
-
# remove any trailing whitespace
# remove any trailing whitespace
+ s/\s*#.*$//;
s/^\s*//;
s/^\s*//;
- s/\s*$//;
} else {
} else {
- next if
(m/^\s*\#/)
;
+ next if
m/#/
;
}
next unless $_;
}
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);
$main::lxdebug->leave_sub(2);