regedit: Fix syntax for deleting registry keys (RHBZ#737944).
authorRichard W.M. Jones <rjones@redhat.com>
Sat, 22 Oct 2011 14:48:15 +0000 (15:48 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Sat, 22 Oct 2011 14:49:02 +0000 (15:49 +0100)
Previously we parsed -[...] to delete a registry key, but this is not
correct.  It should be [-...].  Reference:

http://support.microsoft.com/kb/310516
https://secure.wikimedia.org/wikipedia/en/wiki/Windows_Registry#.REG_files

perl/lib/Win/Hivex/Regedit.pm
perl/t/560-regedit-import.t

index 3d7e5ed..8914f9e 100644 (file)
@@ -164,16 +164,16 @@ sub reg_import
             # Ignore comments.
             next if /^\s*;/;
 
-            # Expect to see [...] or -[...]
+            # Expect to see [...] or [-...]
             # to merge or delete a node respectively.
-            if (/^\[(.*)\]\s*$/) {
+            if (/^\[-(.*)\]\s*$/) {
+                _delete_node ($hmap, \%params, $1);
+                $state = "outer";
+            } elsif (/^\[(.*)\]\s*$/) {
                 $state = "inner";
                 $newnode = $1;
                 @newvalues = ();
                 @delvalues = ();
-            } elsif (/^-\[(.*)\]\s*$/) {
-                _delete_node ($hmap, \%params, $1);
-                $state = "outer";
             } else {
                 croak (_unexpected ($_, $lineno));
             }
index 0dca8df..effb024 100644 (file)
@@ -66,7 +66,7 @@ $data = '
 [\A]
 @="Hello"
 
--[\B]
+[-\B]
 ';
 $expected = '[\]
 
@@ -87,7 +87,7 @@ $data = '
 [\A]
 @=-
 
--[\C]
+[-\C]
 
 [\A\B]
 ';
@@ -131,7 +131,7 @@ $data = '
 "Key\"Containing\"Quotes"=-
 "ValueContainingEscapes"=-
 
--[\A]
+[-\A]
 ';
 $expected = '[\]