3 # Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
13 my $PREFIX = "CONFIG_";
19 open FILE
, "$file" or die "can't open file";
22 /^$PREFIX(.+?)=(.+)/ and do {
26 /^# $PREFIX(.+?) is not set/ and do {
27 $config{$1} = "#undef";
31 /^(.+)$/ and warn "WARNING: can't parse line: $1\n";
42 foreach my $config (keys %$cfg1) {
43 my $val1 = $cfg1->{$config};
44 my $val2 = $cfg2->{$config};
45 $val2 and ($val1 eq $val2) and do {
46 $config{$config} = $val1;
62 foreach my $config (keys %cfg) {
63 next if $mod_plus and $config{$config} and $config{$config} eq "y";
64 $config{$config} = $cfg{$config};
75 foreach my $config (keys %$cfg2) {
76 if (!defined($cfg1->{$config}) or $cfg1->{$config} ne $cfg2->{$config}) {
77 $config{$config} = $cfg2->{$config};
86 my %config = %{$cfg1};
88 foreach my $config (keys %$cfg2) {
89 delete $config{$config};
94 sub print_cfgline
($$) {
97 if ($val eq '#undef' or $val eq 'n') {
98 print "# $PREFIX$name is not set\n";
100 print "$PREFIX$name=$val\n";
107 die "argument error in dump_config" unless ($cfg);
109 foreach my $config (sort keys %config) {
110 print_cfgline
($config, $config{$config});
118 my $arg = $arg[$$pos++];
120 die "Parse error" if (!$arg);
123 my $arg1 = parse_expr
($pos);
124 my $arg2 = parse_expr
($pos);
125 return config_and
($arg1, $arg2);
126 } elsif ($arg =~ /^\+/) {
127 my $arg1 = parse_expr
($pos);
128 my $arg2 = parse_expr
($pos);
129 return config_add
($arg1, $arg2, 0);
130 } elsif ($arg =~ /^m\+/) {
131 my $arg1 = parse_expr
($pos);
132 my $arg2 = parse_expr
($pos);
133 return config_add
($arg1, $arg2, 1);
134 } elsif ($arg eq '>') {
135 my $arg1 = parse_expr
($pos);
136 my $arg2 = parse_expr
($pos);
137 return config_diff
($arg1, $arg2);
138 } elsif ($arg eq '-') {
139 my $arg1 = parse_expr
($pos);
140 my $arg2 = parse_expr
($pos);
141 return config_sub
($arg1, $arg2);
143 return load_config
($arg);
147 while (@ARGV > 0 and $ARGV[0] =~ /^-\w+$/) {
148 my $cmd = shift @ARGV;
149 if ($cmd =~ /^-n$/) {
151 } elsif ($cmd =~ /^-p$/) {
152 $PREFIX = shift @ARGV;
154 die "Invalid option: $cmd\n";
160 dump_config
(parse_expr
(\
$pos));
161 die "Parse error" if ($arg[$pos]);
This page took 0.064151 seconds and 5 git commands to generate.