summaryrefslogtreecommitdiff
path: root/LedgerSMB/Inifile.pm
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB/Inifile.pm')
-rwxr-xr-xLedgerSMB/Inifile.pm69
1 files changed, 35 insertions, 34 deletions
diff --git a/LedgerSMB/Inifile.pm b/LedgerSMB/Inifile.pm
index dbc3ca37..9922c63c 100755
--- a/LedgerSMB/Inifile.pm
+++ b/LedgerSMB/Inifile.pm
@@ -24,7 +24,7 @@
#
#======================================================================
#
-# This file has NOT undergone whitespace cleanup.
+# This file has undergone whitespace cleanup.
#
#======================================================================
#
@@ -37,54 +37,55 @@ package Inifile;
sub new {
- my ($type, $file) = @_;
+ my ($type, $file) = @_;
- warn "$type has no copy constructor! creating a new object." if ref($type);
- $type = ref($type) || $type;
- my $self = bless {}, $type;
- $self->add_file($file) if defined $file;
+ warn "$type has no copy constructor! creating a new object."
+ if ref($type);
+ $type = ref($type) || $type;
+ my $self = bless {}, $type;
+ $self->add_file($file) if defined $file;
- return $self;
+ return $self;
}
sub add_file {
- my ($self, $file) = @_;
+ my ($self, $file) = @_;
- my $id = "";
- my %menuorder = ();
+ my $id = "";
+ my %menuorder = ();
- for (@{$self->{ORDER}}) { $menuorder{$_} = 1 }
+ for (@{$self->{ORDER}}) { $menuorder{$_} = 1 }
- open FH, "$file" or Form->error("$file : $!");
+ open FH, "$file" or Form->error("$file : $!");
- while (<FH>) {
- next if /^(#|;|\s)/;
- last if /^\./;
+ while (<FH>) {
+ next if /^(#|;|\s)/;
+ last if /^\./;
- chop;
+ chop;
- # strip comments
- s/\s*(#|;).*//g;
+ # strip comments
+ s/\s*(#|;).*//g;
- # remove any trailing whitespace
- s/^\s*(.*?)\s*$/$1/;
-
- if (/^\[/) {
- s/(\[|\])//g;
- $id = $_;
- push @{$self->{ORDER}}, $_ if ! $menuorder{$_};
- $menuorder{$_} = 1;
- next;
- }
-
- # add key=value to $id
- my ($key, $value) = split /=/, $_, 2;
+ # remove any trailing whitespace
+ s/^\s*(.*?)\s*$/$1/;
+
+ if (/^\[/) {
+ s/(\[|\])//g;
+ $id = $_;
+ push @{$self->{ORDER}}, $_ if ! $menuorder{$_};
+ $menuorder{$_} = 1;
+ next;
+ }
+
+ # add key=value to $id
+ my ($key, $value) = split /=/, $_, 2;
- $self->{$id}{$key} = $value;
+ $self->{$id}{$key} = $value;
- }
- close FH;
+ }
+ close FH;
}