[ros-diffs] [dchapyshev] 40866: - Sync profile functions with Wine 1.1.20

dchapyshev at svn.reactos.org dchapyshev at svn.reactos.org
Sat May 9 14:40:35 CEST 2009


Author: dchapyshev
Date: Sat May  9 16:40:35 2009
New Revision: 40866

URL: http://svn.reactos.org/svn/reactos?rev=40866&view=rev
Log:
- Sync profile functions with Wine 1.1.20

Modified:
    trunk/reactos/dll/win32/kernel32/misc/profile.c

Modified: trunk/reactos/dll/win32/kernel32/misc/profile.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/profile.c?rev=40866&r1=40865&r2=40866&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/profile.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/profile.c [iso-8859-1] Sat May  9 16:40:35 2009
@@ -130,7 +130,7 @@
 static __inline void PROFILE_ByteSwapShortBuffer(WCHAR * buffer, int len)
 {
     int i;
-    USHORT * shortbuffer = (USHORT *)buffer;
+    USHORT * shortbuffer = buffer;
     for (i = 0; i < len; i++)
         shortbuffer[i] = RtlUshortByteSwap(shortbuffer[i]);
 }
@@ -293,7 +293,7 @@
     INT flags =   IS_TEXT_UNICODE_SIGNATURE |
                   IS_TEXT_UNICODE_REVERSE_SIGNATURE |
                   IS_TEXT_UNICODE_ODD_LENGTH;
-    if (*len >= (int)sizeof(bom_utf8) && !memcmp(buffer, bom_utf8, sizeof(bom_utf8)))
+    if (*len >= sizeof(bom_utf8) && !memcmp(buffer, bom_utf8, sizeof(bom_utf8)))
     {
         *len = sizeof(bom_utf8);
         return ENCODING_UTF8;
@@ -334,7 +334,7 @@
     DPRINT("%p\n", hFile);
 
     dwFileSize = GetFileSize(hFile, NULL);
-    if (dwFileSize == INVALID_FILE_SIZE)
+    if (dwFileSize == INVALID_FILE_SIZE || dwFileSize == 0)
         return NULL;
 
     buffer_base = HeapAlloc(GetProcessHeap(), 0 , dwFileSize);
@@ -359,40 +359,40 @@
     case ENCODING_ANSI:
         DPRINT("ANSI encoding\n");
 
-        len = MultiByteToWideChar(CP_ACP, 0, (char *)pBuffer, dwFileSize, NULL, 0);
+        len = MultiByteToWideChar(CP_ACP, 0, pBuffer, dwFileSize, NULL, 0);
         szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
         if (!szFile)
         {
             HeapFree(GetProcessHeap(), 0, buffer_base);
             return NULL;
         }
-        MultiByteToWideChar(CP_ACP, 0, (char *)pBuffer, dwFileSize, szFile, len);
+        MultiByteToWideChar(CP_ACP, 0, pBuffer, dwFileSize, szFile, len);
         szEnd = szFile + len;
         break;
 
     case ENCODING_UTF8:
         DPRINT("UTF8 encoding\n");
 
-        len = MultiByteToWideChar(CP_UTF8, 0, (char *)pBuffer, dwFileSize, NULL, 0);
+        len = MultiByteToWideChar(CP_UTF8, 0, pBuffer, dwFileSize, NULL, 0);
         szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
         if (!szFile)
         {
             HeapFree(GetProcessHeap(), 0, buffer_base);
             return NULL;
         }
-        MultiByteToWideChar(CP_UTF8, 0, (char *)pBuffer, dwFileSize, szFile, len);
+        MultiByteToWideChar(CP_UTF8, 0, pBuffer, dwFileSize, szFile, len);
         szEnd = szFile + len;
         break;
 
     case ENCODING_UTF16LE:
         DPRINT("UTF16 Little Endian encoding\n");
-        szFile = (WCHAR *)pBuffer;// + 1;
+        szFile = pBuffer;// + 1;
         szEnd = (WCHAR *)((char *)pBuffer + dwFileSize);
         break;
 
     case ENCODING_UTF16BE:
         DPRINT("UTF16 Big Endian encoding\n");
-        szFile = (WCHAR *)pBuffer;// + 1;
+        szFile = pBuffer;// + 1;
         szEnd = (WCHAR *)((char *)pBuffer + dwFileSize);
         PROFILE_ByteSwapShortBuffer(szFile, dwFileSize / sizeof(WCHAR));
         break;
@@ -834,6 +834,7 @@
 			 else
 			 {
                  DPRINT("(%S): already opened, needs refreshing (mru=%d)\n", buffer, i);
+				 PROFILE_Free(CurProfile->section);
                  CurProfile->section = PROFILE_Load(hFile, &CurProfile->encoding);
                  CurProfile->LastWriteTime = LastWriteTime;
 			 }
@@ -1459,8 +1460,7 @@
     else if (PROFILE_Open( filename, TRUE ))
     {
         if (!section) {
-            DPRINT1("(NULL?, %S, %S, %S)?\n",
-                        entry, string, filename);
+            SetLastError(ERROR_FILE_NOT_FOUND);
         } else {
             ret = PROFILE_SetString( section, entry, string, FALSE);
             PROFILE_FlushFile();
@@ -1733,7 +1733,7 @@
                 {
                     BOOL highnibble = TRUE;
                     BYTE b = 0, val;
-                    LPBYTE binbuf = (LPBYTE)buf;
+                    LPBYTE binbuf = buf;
 
                     end -= 2; /* don't include checksum in output data */
                     /* translate ASCII hex format into binary data */



More information about the Ros-diffs mailing list