[PATCH 4/6] [DbgHelp]: Move SymMatchString core implementation to Unicode

Eric Pouech eric.pouech at orange.fr
Mon Jan 2 14:06:05 CST 2012




A+
---

 dlls/dbghelp/symbol.c |   40 +++++++++++++++++++---------------------
 1 files changed, 19 insertions(+), 21 deletions(-)


diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c
index 0960f86..3346f51 100644
--- a/dlls/dbghelp/symbol.c
+++ b/dlls/dbghelp/symbol.c
@@ -1880,43 +1880,41 @@ DWORD WINAPI UnDecorateSymbolName(PCSTR DecoratedName, PSTR UnDecoratedName,
  */
 BOOL WINAPI SymMatchStringA(PCSTR string, PCSTR re, BOOL _case)
 {
-    regexw_t    preg;
-    BOOL        ret;
+    WCHAR*      strW;
+    WCHAR*      reW;
+    BOOL        ret = FALSE;
+    DWORD       sz;
 
     TRACE("%s %s %c\n", string, re, _case ? 'Y' : 'N');
 
-    compile_regex(re, -1, &preg, _case);
-    ret = match_regexp(&preg, string);
-    regfreeW(&preg);
+    sz = MultiByteToWideChar(CP_ACP, 0, string, -1, NULL, 0);
+    if ((strW = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
+        MultiByteToWideChar(CP_ACP, 0, string, -1, strW, sz);
+    sz = MultiByteToWideChar(CP_ACP, 0, re, -1, NULL, 0);
+    if ((reW = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
+        MultiByteToWideChar(CP_ACP, 0, re, -1, reW, sz);
+
+    if (strW && reW)
+        ret = SymMatchStringW(strW, reW, _case);
+    HeapFree(GetProcessHeap(), 0, strW);
+    HeapFree(GetProcessHeap(), 0, reW);
     return ret;
 }
 
 /******************************************************************
  *		SymMatchStringW (DBGHELP.@)
  *
- * FIXME: SymMatchStringA should convert and pass the strings to SymMatchStringW,
- *        but that needs a unicode RE library.
  */
 BOOL WINAPI SymMatchStringW(PCWSTR string, PCWSTR re, BOOL _case)
 {
     BOOL ret;
-    LPSTR s, r;
-    DWORD len;
+    regexw_t preg;
 
     TRACE("%s %s %c\n", debugstr_w(string), debugstr_w(re), _case ? 'Y' : 'N');
 
-    len = WideCharToMultiByte( CP_ACP, 0, string, -1, NULL, 0, NULL, NULL );
-    s = HeapAlloc( GetProcessHeap(), 0, len );
-    WideCharToMultiByte( CP_ACP, 0, string, -1, s, len, NULL, NULL );
-
-    len = WideCharToMultiByte( CP_ACP, 0, re, -1, NULL, 0, NULL, NULL );
-    r = HeapAlloc( GetProcessHeap(), 0, len );
-    WideCharToMultiByte( CP_ACP, 0, re, -1, r, len, NULL, NULL );
-
-    ret = SymMatchStringA(s, r, _case);
-
-    HeapFree( GetProcessHeap(), 0, r );
-    HeapFree( GetProcessHeap(), 0, s );
+    compile_regexW(re, -1, &preg, _case);
+    ret = match_regexpW(&preg, string);
+    regfreeW(&preg);
     return ret;
 }
 




More information about the wine-patches mailing list