[PATCH 1/2] msvcrt: Move the code to demangle a name with its template argument list out of get_class() and into a separate function.

Michael Stefaniuc mstefani at redhat.de
Thu Apr 5 17:49:18 CDT 2007


---
 dlls/msvcrt/undname.c |   53 ++++++++++++++++++++++++++++--------------------
 1 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/dlls/msvcrt/undname.c b/dlls/msvcrt/undname.c
index a775e72..c266686 100644
--- a/dlls/msvcrt/undname.c
+++ b/dlls/msvcrt/undname.c
@@ -427,6 +427,36 @@ static char* get_literal_string(struct parsed_symbol* sym)
 }
 
 /******************************************************************
+ *		get_template_name
+ * Parses a name with a template argument list and returns it as
+ * a string.
+ * In a template argument list the back reference to the names
+ * table is separately created. '0' points to the class component
+ * name with the template arguments.  We use the same stack array
+ * to hold the names but save/restore the stack state before/after
+ * parsing the template argument list.
+ */
+static char* get_template_name(struct parsed_symbol* sym)
+{
+    const char* name = NULL;
+    char*       args = NULL;
+    unsigned    num_mark = sym->names.num;
+    unsigned    start_mark = sym->names.start;
+    unsigned    stack_mark = sym->stack.num;
+
+    sym->names.start = sym->names.num;
+    if (!(name = get_literal_string(sym)))
+        return FALSE;
+    args = get_args(sym, NULL, FALSE, '<', '>');
+    if (args != NULL)
+        name = str_printf(sym, "%s%s", name, args);
+    sym->names.num = num_mark;
+    sym->names.start = start_mark;
+    sym->stack.num = stack_mark;
+    return name;
+}
+
+/******************************************************************
  *		get_class
  * Parses class as a list of parent-classes, terminated by '@' and stores the
  * result in 'a' array. Each parent-classes, as well as the inner element
@@ -457,29 +487,8 @@ static BOOL get_class(struct parsed_symbol* sym)
         case '?':
             if (*++sym->current == '$') 
             {
-                /* In a template argument list the back reference to names
-                   table is separately created. '0' points to the class
-                   component name with the template arguments. We use the same
-                   stack array to hold the names but save/restore the stack
-                   state before/after parsing the template argument list. */
-                char*           args = NULL;
-                unsigned        num_mark = sym->names.num;
-                unsigned        start_mark = sym->names.start;
-                unsigned        stack_mark = sym->stack.num;
-
-                sym->names.start = sym->names.num;
                 sym->current++;
-                if (!(name = get_literal_string(sym)))
-                    return FALSE;
-                args = get_args(sym, NULL, FALSE, '<', '>');
-                if (args != NULL)
-                    name = str_printf(sym, "%s%s", name, args);
-                sym->names.num = num_mark;
-                sym->names.start = start_mark;
-                sym->stack.num = stack_mark;
-                /* Now that we are back to the standard name scope push
-                   the class component with all its template arguments
-                   to the names array for back reference. */
+                name = get_template_name(sym);
                 str_array_push(sym, name, -1, &sym->names);
             }
             break;
-- 
1.5.0.6
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20070406/262d7720/attachment.pgp


More information about the wine-patches mailing list