Removed some more trailing whitespace.
[wine/multimedia.git] / programs / regapi / regRestorer.pl
blob0fbe3a1b0fb24107300828130708215005c77b29
1 #!/usr/bin/perl
3 # This script takes as STDIN an output from the regFixer.pl
4 # and reformat the file as if it would have been exported from the registry
5 # in the "REGEDIT4" format.
7 # Copyright 1999 Sylvain St-Germain
8 # Copyright 2002 Andriy Palamarchuk
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public
12 # License as published by the Free Software Foundation; either
13 # version 2.1 of the License, or (at your option) any later version.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with this library; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 use strict;
26 use diagnostics;
28 # I do not validate the integrity of the file, I am assuming that
29 # the input file comes from the output of regFixer.pl, therefore things
30 # should be ok, if they are not, submit a bug
32 my $curr_key = "";
33 my $key;
34 my $value;
35 my $rest;
36 my $s;
38 print "REGEDIT4\n";
40 LINE: while($s = <>) {
41 chomp($s); # get rid of new line
43 next LINE if($s =~ /^$/); # this is an empty line
45 if ($s =~ /\]$/) # only key name on the line
47 ($key) = ($s =~ /^\[(.*)\]$/);
48 unless ($key)
50 die "Unrecognized string $s";
52 if ($key ne $curr_key)
54 $curr_key = $key;
55 print "\n[$key]\n";
58 else
60 ($key, $value) = ($s =~ /^\[(.*?)\](.+)$/);
61 if (!defined($key))
63 die "Unrecognized string $s";
65 if ($key ne $curr_key) #curr_key might got chopped from regSet.sh
67 print "\n[$key]\n";
69 print "$value\n"