From 7bb9825d921f91be01144110f6478a0c017cbd79 Mon Sep 17 00:00:00 2001
From: Jason Edmeades <us@edmeades.me.uk>
Date: Tue, 16 Jul 2019 13:51:58 +1000
Subject: [PATCH 2/2] cmd: ftype failed to clear file associations

If a file association was set (e.g. ftype fred=xxx), ftype fred= needs to clear it,
but previously it failed to do so.
---
 programs/cmd/builtins.c                  | 6 +++---
 programs/cmd/tests/test_builtins.cmd     | 9 +++++++++
 programs/cmd/tests/test_builtins.cmd.exp | 5 ++++-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 62ae19a494..e85e553c05 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -4939,11 +4939,11 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
         /* If nothing after '=' then clear value - only valid for ASSOC */
         if (*newValue == 0x00) {
 
-          if (assoc) rc = RegDeleteKeyW(key, args);
-          if (assoc && rc == ERROR_SUCCESS) {
+          rc = RegDeleteTreeW(key, args);
+          if (rc == ERROR_SUCCESS) {
             WINE_TRACE("HKCR Key '%s' deleted\n", wine_dbgstr_w(args));
 
-          } else if (assoc && rc != ERROR_FILE_NOT_FOUND) {
+          } else if (rc != ERROR_FILE_NOT_FOUND) {
             WCMD_print_error();
             errorlevel = 2;
 
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index f4dfc9f26d..0ef049a4ab 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -2440,6 +2440,12 @@ echo echo +++>> tmp.cmd
 echo ftype footype>> tmp.cmd
 cmd /c tmp.cmd
 
+echo --- testing association
+ftype footype=cmd.exe /c "echo '%%1'"
+echo dummy>test.foo
+test.foo
+del test.foo
+
 echo --- resetting association
 assoc .foo=
 
@@ -2471,6 +2477,9 @@ echo .foo=footype
 echo footype=foo_opencmd
 echo +++
 echo footype=foo_opencmd
+echo --- testing association
+echo footype=cmd.exe /c "echo '%%1'"
+echo Skipped as not enough permissions
 echo --- resetting association
 echo original value
 
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index d78d91a6cf..e6ebe06714 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1444,8 +1444,11 @@ footype=foo_opencmd
 footype=foo_opencmd
 +++
 footype=foo_opencmd
+--- testing association
+footype=cmd.exe /c "echo '%1'"
+'@drive@@path@foobar\test.foo'@or_broken@Skipped as not enough permissions
 --- resetting association
-@todo_wine@original value@or_broken@buggyXP@or_broken@!WINE_FOO!
+original value@or_broken@buggyXP@or_broken@!WINE_FOO!
 ------------ Testing CALL ------------
 --- external script
 foo@space@
-- 
2.17.1

