Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 189d03d2

Von Sven Schöling vor mehr als 9 Jahren hinzugefügt

  • ID 189d03d210a5e46239b4ac2afc5c0b280ca6b1be
  • Vorgänger 8f176d2b
  • Nachfolger 590708a7

Inifile: alten Schrott beseitigt

Unterschiede anzeigen:

SL/Inifile.pm
45 45
  my ($type, $file, %options) = @_;
46 46

  
47 47
  my $id = "";
48
  my $skip;
48
  my $cur;
49 49

  
50
  local *FH;
50
  my $self = { FILE => $file, ORDER => [] };
51 51

  
52
  my $self = { "FILE" => $file };
52
  open my $fh, "$file" or $::form->error("$file : $!");
53 53

  
54
  open FH, "$file" or $::form->error("$file : $!");
55

  
56
  while (<FH>) {
54
  for (<$fh>) {
57 55
    chomp;
58 56

  
59 57
    if (!$options{verbatim}) {
60 58
      # strip comments
61
      s/\#.*//;
62

  
63 59
      # remove any trailing whitespace
60
      s/\s*#.*$//;
64 61
      s/^\s*//;
65
      s/\s*$//;
66 62
    } else {
67
      next if (m/^\s*\#/);
63
      next if m/#/;
68 64
    }
69 65

  
70 66
    next unless $_;
71 67

  
72
    if (m/^\[/) {
73
      s/(\[|\])//g;
74

  
75
      $id = $_;
76

  
77
      $self->{$id} ||= { };
68
    if (m/^\[(.*)\]$/) {
69
      $id = $1;
70
      $cur = $self->{$1} ||= { };
78 71

  
79
      push @{ $self->{ORDER} }, $_;
80

  
81
      next;
72
      push @{ $self->{ORDER} }, $1;
73
    } else {
74
      # add key=value to $id
75
      my ($key, $value) = split m/=/, $_, 2;
82 76

  
77
      $cur->{$key} = $value;
83 78
    }
84 79

  
85
    # add key=value to $id
86
    my ($key, $value) = split m/=/, $_, 2;
87

  
88
    $self->{$id}->{$key} = $value;
89

  
90 80
  }
91
  close FH;
81
  close $fh;
92 82

  
93 83
  $main::lxdebug->leave_sub(2);
94 84

  

Auch abrufbar als: Unified diff