/[libconf]/libconf/perl-Libconf/Glueconf/XF86Config.pm
ViewVC logotype

Diff of /libconf/perl-Libconf/Glueconf/XF86Config.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by dams, Sun Apr 6 23:00:35 2003 UTC revision 1.5 by dams, Fri Apr 11 18:40:30 2003 UTC
# Line 123  sub FETCH { Line 123  sub FETCH {
123      $key eq 'libconf' and return $obj->{libconf};      $key eq 'libconf' and return $obj->{libconf};
124      my @section_positions = $obj->{libconf}->findAtomPos( { type => 'SECTION', section_name => $key, sections => [ ] });      my @section_positions = $obj->{libconf}->findAtomPos( { type => 'SECTION', section_name => $key, sections => [ ] });
125      my %ret;      my %ret;
126      if (Libconf::member($key, 'InputDevice', 'Monitor', 'Device', 'Screen')) {      if (Libconf::member($key,
127                            'InputDevice',
128                            'Device',
129                            'Monitor',
130                            'Modes',
131                            'Screen',
132                            'ServerLayout',
133                            'Vendor',
134                           )) {
135          my @identifier_positions = $obj->{libconf}->findAtomPos(          my @identifier_positions = $obj->{libconf}->findAtomPos(
136                                                                  { type => 'KEY_VALUE',                                                                  { type => 'KEY_VALUE',
137                                                                    key => 'Identifier',                                                                    key => 'Identifier',
# Line 158  sub TIEHASH { Line 166  sub TIEHASH {
166          if (!(@{$atom->{sections}} >= @depth)) {          if (!(@{$atom->{sections}} >= @depth)) {
167              $key++;              $key++;
168              next;              next;
169            }          }
170          Libconf::compare_depth($atom->{sections}, \@depth) or last;          Libconf::compare_depth($atom->{sections}, \@depth) or last;
171          $key++;          $key++;
172      }      }
# Line 167  sub TIEHASH { Line 175  sub TIEHASH {
175                  firstatom => $beginning,                  firstatom => $beginning,
176                  sections => \@depth,                  sections => \@depth,
177                  lastatom => $key,                  lastatom => $key,
178                    Options => {},
179                    Load => {},
180                 );                 );
181  #    print Data::Dumper->Dump([%hash],['hash']) . "\n";  #    print Data::Dumper->Dump([%hash],['hash']) . "\n";
182      print "SectionWrapper - TIEHASH - firstatom : $hash{firstatom} - lastatom : $hash{lastatom} \n";      print "SectionWrapper - TIEHASH - firstatom : $hash{firstatom} - lastatom : $hash{lastatom} \n";
# Line 204  sub DELETE { Line 214  sub DELETE {
214                   $atom->{key} eq $key) {                   $atom->{key} eq $key) {
215              $obj->{libconf}->deleteAtom($_);              $obj->{libconf}->deleteAtom($_);
216              $obj->{lastatom}--;              $obj->{lastatom}--;
217            } elsif ($atom->{type} eq 'VALUE' &&
218                     $atom->{value} eq $key) {
219                $obj->{libconf}->deleteAtom($_);
220                $obj->{lastatom}--;
221          }          }
222      }      }
223  }  }
# Line 215  sub FIRSTKEY { Line 229  sub FIRSTKEY {
229      my $atom = $obj->{libconf}->getAtom($obj->{firstatom}+1);      my $atom = $obj->{libconf}->getAtom($obj->{firstatom}+1);
230      $atom->{type} eq 'SECTION' and return $atom->{section_name};      $atom->{type} eq 'SECTION' and return $atom->{section_name};
231      $atom->{type} eq 'KEY_VALUE' and return $atom->{key};      $atom->{type} eq 'KEY_VALUE' and return $atom->{key};
232        $atom->{type} eq 'VALUE' and return $atom->{value};
233      die "houston, we have a problem";      die "houston, we have a problem";
234  }  }
235    
# Line 225  sub EXISTS { Line 240  sub EXISTS {
240          my $atom = $obj->{libconf}->getAtom($_);          my $atom = $obj->{libconf}->getAtom($_);
241          ($atom->{type} eq 'SECTION' && $atom->{section_name} eq $key) ||          ($atom->{type} eq 'SECTION' && $atom->{section_name} eq $key) ||
242          ($atom->{type} eq 'KEY_VALUE' && $atom->{key} eq $key) and return 1;          ($atom->{type} eq 'KEY_VALUE' && $atom->{key} eq $key) and return 1;
243            ($atom->{type} eq 'VALUE' && $atom->{value} eq $key) and return 1;
244      }      }
245  }  }
246    
# Line 237  sub NEXTKEY { Line 253  sub NEXTKEY {
253              $_+1 == $obj->{lastatom} and return undef;              $_+1 == $obj->{lastatom} and return undef;
254              return $obj->{libconf}->getAtom($_+1)->{section_name};              return $obj->{libconf}->getAtom($_+1)->{section_name};
255          }          }
256          if ($atom->{type} eq 'KEY_VALUE' && $atom->{key} eq $lastkey) {          if ($atom->{type} eq 'KEY_VALUE' && ! $atom->{type2} && $atom->{key} eq $lastkey) {
257              $_+1 == $obj->{lastatom} and return undef;              $_+1 == $obj->{lastatom} and return undef;
258              return $obj->{libconf}->getAtom($_+1)->{key};              return $obj->{libconf}->getAtom($_+1)->{key};
259          }          }
260            if ($atom->{type} eq 'VALUE' && ! $atom->{type2} && $atom->{value} eq $lastkey) {
261                $_+1 == $obj->{lastatom} and return undef;
262                return $obj->{libconf}->getAtom($_+1)->{value};
263            }
264      }      }
265      undef;      undef;
266  }  }
# Line 290  sub FETCH { Line 310  sub FETCH {
310      my ($obj, $key) = @_;      my ($obj, $key) = @_;
311      print "SectionWrapper - FETCH - key : $key\n";      print "SectionWrapper - FETCH - key : $key\n";
312      my $index;      my $index;
313      foreach ($obj->{firstatom}+1..$obj->{lastatom}-1) {      foreach ($obj->{firstatom}+1..$obj->{lastatom}-1) { #CHANGE THIS, don't go into subsections, use better find_atom
314          my $atom = $obj->{libconf}->getAtom($_);          my $atom = $obj->{libconf}->getAtom($_);
315          ($atom->{type} eq 'SECTION' && $atom->{section_name} eq $key) ||          ($atom->{type} eq 'SECTION' && $atom->{section_name} eq $key) ||
316          ($atom->{type} eq 'KEY_VALUE' && $atom->{key} eq $key) and $index = $_, last;          ($atom->{type} eq 'KEY_VALUE' && $atom->{key} eq $key) and $index = $_, last;
317            ($atom->{type} eq 'VALUE' && $atom->{value} eq $key) and $index = $_, last;
318      }      }
319      defined $index or return undef;      defined $index or return undef;
320      my $atom = $obj->{libconf}->getAtom($index);      my $atom = $obj->{libconf}->getAtom($index);
321      if ($atom->{type} eq 'SECTION') {      if ($atom->{type} eq 'SECTION') {
322          my %ret;          my %ret;
323          tie %ret, 'Libconf::Glueconf::XF86Config::SectionWrapper', $obj->{libconf}, $index;          tie %ret, 'Libconf::Glueconf::XF86Config::SectionWrapper', $obj->{libconf}, $index;
324          return %ret;          return \%ret;
325      }      }
326      if ($atom->{type} eq 'KEY_VALUE') {      if ($atom->{type} eq 'KEY_VALUE') {
327          return $atom->{value};          return $atom->{value};
328      }      }
329        if ($atom->{type} eq 'VALUE') {
330            return $atom->{value};
331        }
332  }  }
333    
334    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26