From 1182a02286e99d3521b95c3196beda99173ee393 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 20 Jan 2016 14:26:48 +0800
Subject: [PATCH] widl: Fix generation of resources containing an old typelib.

---
 tools/widl/register.c | 7 ++++++-
 tools/widl/widl.c     | 5 +++--
 tools/widl/widl.h     | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/widl/register.c b/tools/widl/register.c
index 210fb74..1987ccf 100644
--- a/tools/widl/register.c
+++ b/tools/widl/register.c
@@ -286,7 +286,12 @@ void write_typelib_regscript( const statement_list_t *stmts )
         if (count && !strendswith( typelib_name, ".res" ))
             error( "Cannot store multiple typelibs into %s\n", typelib_name );
         else
-            create_msft_typelib( stmt->u.lib );
+        {
+            if (do_old_typelib)
+                create_sltg_typelib( stmt->u.lib );
+            else
+                create_msft_typelib( stmt->u.lib );
+        }
         count++;
     }
     if (count && strendswith( typelib_name, ".res" )) flush_output_resources( typelib_name );
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 1180e65..afeea39 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -103,6 +103,7 @@ int do_everything = 1;
 static int preprocess_only = 0;
 int do_header = 0;
 int do_typelib = 0;
+int do_old_typelib = 0;
 int do_proxies = 0;
 int do_client = 0;
 int do_server = 0;
@@ -308,6 +309,7 @@ static void set_everything(int x)
 {
   do_header = x;
   do_typelib = x;
+  do_old_typelib = x;
   do_proxies = x;
   do_client = x;
   do_server = x;
@@ -682,8 +684,7 @@ int main(int argc,char *argv[])
       do_typelib = 1;
       break;
     case OLD_TYPELIB_OPTION:
-      do_everything = 0;
-      do_typelib = 2;
+      do_old_typelib = 1;
       break;
     case 'T':
       typelib_name = xstrdup(optarg);
diff --git a/tools/widl/widl.h b/tools/widl/widl.h
index 7530f9f..73b9152 100644
--- a/tools/widl/widl.h
+++ b/tools/widl/widl.h
@@ -38,6 +38,7 @@ extern int pedantic;
 extern int do_everything;
 extern int do_header;
 extern int do_typelib;
+extern int do_old_typelib;
 extern int do_proxies;
 extern int do_client;
 extern int do_server;
-- 
1.9.1

