Pull the codepage from the string table

Mike McCormack mike at codeweavers.com
Fri Jun 25 15:16:10 CDT 2004


ChangeLog:
* Pull the codepage from the string table.
-------------- next part --------------
diff -ur dlls/msi.old/msipriv.h dlls/msi/msipriv.h
--- dlls/msi.old/msipriv.h	2004-06-25 15:14:17.000000000 -0500
+++ dlls/msi/msipriv.h	2004-06-25 15:14:23.000000000 -0500
@@ -186,7 +186,7 @@
 extern LPWSTR MSI_makestring( MSIDATABASE *db, UINT stringid);
 extern UINT msi_string2id( string_table *st, LPCWSTR buffer, UINT *id );
 extern UINT msi_string2idA( string_table *st, LPCSTR str, UINT *id );
-extern string_table *msi_init_stringtable( int entries );
+extern string_table *msi_init_stringtable( int entries, UINT codepage );
 extern VOID msi_destroy_stringtable( string_table *st );
 extern UINT msi_string_count( string_table *st );
 extern UINT msi_id_refcount( string_table *st, UINT i );
diff -ur dlls/msi.old/string.c dlls/msi/string.c
--- dlls/msi.old/string.c	2004-06-25 15:14:17.000000000 -0500
+++ dlls/msi/string.c	2004-06-25 15:14:23.000000000 -0500
@@ -47,6 +47,7 @@
 {
     UINT count;         /* the number of strings */
     UINT freeslot;
+    UINT codepage;
     msistring *strings; /* an array of strings (in the tree) */
 };
 
@@ -63,7 +64,7 @@
     return hash;
 }
 
-string_table *msi_init_stringtable( int entries )
+string_table *msi_init_stringtable( int entries, UINT codepage )
 {
     string_table *st;
 
@@ -79,6 +80,7 @@
     }
     st->count = entries;
     st->freeslot = 1;
+    st->codepage = codepage;
 
     return st;
 }
@@ -192,11 +194,11 @@
     }
 
     /* allocate a new string */
-    sz = WideCharToMultiByte( CP_UTF8, 0, data, len, NULL, 0, NULL, NULL );
+    sz = WideCharToMultiByte( st->codepage, 0, data, len, NULL, 0, NULL, NULL );
     st->strings[n].str = HeapAlloc( GetProcessHeap(), 0, sz + 1 );
     if( !st->strings[n].str )
         return -1;
-    WideCharToMultiByte( CP_UTF8, 0, data, len, 
+    WideCharToMultiByte( st->codepage, 0, data, len, 
                          st->strings[n].str, sz, NULL, NULL );
     st->strings[n].str[sz] = 0;
     st->strings[n].refcount = 1;
@@ -245,7 +247,7 @@
     if( !str )
         return ERROR_FUNCTION_FAILED;
 
-    len = MultiByteToWideChar(CP_UTF8,0,str,-1,NULL,0); 
+    len = MultiByteToWideChar(st->codepage,0,str,-1,NULL,0); 
 
     if( !buffer )
     {
@@ -253,7 +255,7 @@
         return ERROR_SUCCESS;
     }
 
-    *sz = MultiByteToWideChar(CP_UTF8,0,str,-1,buffer,*sz); 
+    *sz = MultiByteToWideChar(st->codepage,0,str,-1,buffer,*sz); 
 
     return ERROR_SUCCESS;
 }
@@ -338,13 +340,13 @@
         return ERROR_SUCCESS;
     }
 
-    sz = WideCharToMultiByte( CP_UTF8, 0, buffer, -1, NULL, 0, NULL, NULL );
+    sz = WideCharToMultiByte( st->codepage, 0, buffer, -1, NULL, 0, NULL, NULL );
     if( sz <= 0 )
         return r;
     str = HeapAlloc( GetProcessHeap(), 0, sz );
     if( !str )
         return ERROR_NOT_ENOUGH_MEMORY;
-    WideCharToMultiByte( CP_UTF8, 0, buffer, -1, str, sz, NULL, NULL );
+    WideCharToMultiByte( st->codepage, 0, buffer, -1, str, sz, NULL, NULL );
 
     r = msi_string2idA( st, str, id );
     if( str )
diff -ur dlls/msi.old/table.c dlls/msi/table.c
--- dlls/msi.old/table.c	2004-06-25 15:14:17.000000000 -0500
+++ dlls/msi/table.c	2004-06-25 15:14:23.000000000 -0500
@@ -612,10 +612,10 @@
         goto end;
 
     count = poolsize/4;
-    db->strings = msi_init_stringtable( count );
+    db->strings = msi_init_stringtable( count, pool[0] );
 
-    if( pool[0] || pool[1] )
-        ERR("The first string should be nul, but isn't %04x %04x\n", pool[0], pool[1]);
+    if( pool[1] )
+        ERR("The first string should have zero refcount, but doesn't %04x\n", pool[1]);
     offset = 0;
     for( i=1; i<count; i++ )
     {


More information about the wine-patches mailing list