widl [1/3]: Set the pointer description offset to zero if there are no pointers

Dan Hipschman dsh at linux.ucla.edu
Wed Sep 19 19:04:09 CDT 2007


If there are no top-level pointers in a complex structure, the pointer
description offset should be zero.  Right now, widl is making it right
passed the end of the format string for the structure.  The tests
apparently pass even without this, but it's better to do the same thing
as MIDL.

---
 tools/widl/typegen.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 6625bda..84efe96 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -1677,9 +1677,10 @@ static size_t write_struct_tfs(FILE *file, type_t *type,
         /* On the sizing pass, type->ptrdesc may be zero, but it's ok as
            nothing is written to file yet.  On the actual writing pass,
            this will have been updated.  */
-        short reloff = type->ptrdesc - *tfsoff;
+        unsigned int absoff = type->ptrdesc ? type->ptrdesc : *tfsoff;
+        short reloff = absoff - *tfsoff;
         print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n",
-                   reloff, reloff, type->ptrdesc);
+                   reloff, reloff, absoff);
         *tfsoff += 2;
     }
     else if ((type->type == RPC_FC_PSTRUCT) ||
@@ -1708,6 +1709,8 @@ static size_t write_struct_tfs(FILE *file, type_t *type,
             if (is_ptr(ft))
                 write_pointer_tfs(file, ft, tfsoff);
         }
+        if (type->ptrdesc == *tfsoff)
+            type->ptrdesc = 0;
     }
 
     current_structure = save_current_structure;



More information about the wine-patches mailing list