projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Auftrags-Controller: Zahlungs- und Lieferbedingungen
[kivitendo-erp.git]
/
SL
/
Inifile.pm
diff --git
a/SL/Inifile.pm
b/SL/Inifile.pm
index
aadec0a
..
6ecb41f
100644
(file)
--- a/
SL/Inifile.pm
+++ b/
SL/Inifile.pm
@@
-37,54
+37,50
@@
package Inifile;
use IO::File;
use IO::File;
+use strict;
+
sub new {
sub new {
- $main::lxdebug->enter_sub();
+ $main::lxdebug->enter_sub(
2
);
- my ($type, $file) = @_;
+ my ($type, $file
, %options
) = @_;
my $id = "";
my $id = "";
- my $skip;
-
- local *FH;
+ my $cur;
- my $self = {
"FILE" => $file
};
+ my $self = {
FILE => $file, ORDER => []
};
- open
FH, "$file" or F
orm->error("$file : $!");
+ open
my $fh, "$file" or $::f
orm->error("$file : $!");
-
while (<FH
>) {
+
for (<$fh
>) {
chomp;
chomp;
- # strip comments
- s/#.*//g;
-
- # remove any trailing whitespace
- s/^\s*//;
- s/\s*$//;
+ if (!$options{verbatim}) {
+ # strip comments
+ # remove any trailing whitespace
+ s/\s*#.*$//;
+ s/^\s*//;
+ } else {
+ next if m/^\s*#/;
+ }
next unless $_;
next unless $_;
- if (m/^\[/) {
- s/(\[|\])//g;
-
- $id = $_;
+ if (m/^\[(.*)\]$/) {
+ $id = $1;
+ $cur = $self->{$1} ||= { };
- $self->{$id} ||= { };
-
- 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();
+ $main::lxdebug->leave_sub(
2
);
return bless $self, $type;
}
return bless $self, $type;
}
@@
-95,7
+91,7
@@
sub write {
my ($self) = @_;
my $file = $self->{FILE};
my ($self) = @_;
my $file = $self->{FILE};
- my $fh = IO::File->new($file, "w") ||
F
orm->error("$file : $!");
+ my $fh = IO::File->new($file, "w") ||
$::f
orm->error("$file : $!");
foreach my $section_name (sort keys %{ $self }) {
next if $section_name =~ m/^[A-Z]+$/;
foreach my $section_name (sort keys %{ $self }) {
next if $section_name =~ m/^[A-Z]+$/;
@@
-112,4
+108,3
@@
sub write {
}
1;
}
1;
-