Index: trunk/src/NTDLL/rtlstr.cpp
===================================================================
--- trunk/src/NTDLL/rtlstr.cpp	(revision 82)
+++ trunk/src/NTDLL/rtlstr.cpp	(revision 83)
@@ -2,11 +2,8 @@
  * Project Odin Software License can be found in LICENSE.TXT
  * Win32 NT Runtime / NTDLL for OS/2
- *
- * Copyright 1998       original WINE Author
- * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
- *
  * Rtl string functions
  *
  * Copyright 1996-1998 Marcus Meissner
+ * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
  */
 
@@ -16,4 +13,7 @@
 #include <string.h>
 #include <ctype.h>
+
+#include <os2win.h>
+#include <unicode.h>
 
 #include "ntdll.h"
@@ -61,5 +61,7 @@
     return STATUS_BUFFER_OVERFLOW;
 
-  lstrcpynAtoW(uni->Buffer,ansi->Buffer,unilen/2);
+  AsciiToUnicodeN(ansi->Buffer,
+                  uni->Buffer,
+                  unilen/2);
 
   return STATUS_SUCCESS;
@@ -99,6 +101,6 @@
     return STATUS_BUFFER_OVERFLOW;
 
-  lstrcpynAtoW(uni->Buffer,
-               ansi->Buffer,
+  AsciiToUnicodeN(ansi->Buffer,
+               uni->Buffer,
                unilen/2);
   return STATUS_SUCCESS;
@@ -135,7 +137,7 @@
                       (len+1)*sizeof(WCHAR));
 
-  lstrcpynAtoW(x,
-               oemstr,
-               len+1);
+  AsciiToUnicodeN(oemstr,
+                  x,
+                  len+1);
 
   memcpy(unistr,
@@ -178,7 +180,7 @@
                       (len+1)*sizeof(WCHAR));
 
-  lstrcpynAtoW(x,
-               oemstr,
-               len+1);
+  AsciiToUnicodeN(oemstr,
+                  x,
+                  len+1);
 
   memcpy(unistr,
@@ -214,5 +216,5 @@
 
 /**************************************************************************
- *                 RtlInitOemString           
+ *                 RtlInitOemString
  */
 VOID WINAPI RtlInitOemString(POEM_STRING target,
@@ -348,7 +350,7 @@
                      len+1);
 
-  lstrcpynWtoA(x,
-               unistr,
-               len+1);
+  UnicodeToAsciiN(unistr,
+                  x,
+                  len+1);
 
   memcpy(oemstr,
@@ -384,7 +386,7 @@
 
   oem->Length = uni->Length/2;
-  lstrcpynWtoA(oem->Buffer,
-               uni->Buffer,
-               uni->Length/2+1);
+  UnicodeToAsciiN(uni->Buffer,
+                  oem->Buffer,
+                  oem->MaximumLength);
   return 0;
 }
@@ -411,7 +413,7 @@
 
   oem->Length = uni->Length/2;
-  lstrcpynWtoA(oem->Buffer,
-               uni->Buffer,
-               uni->Length/2+1);
+  UnicodeToAsciiN(uni->Buffer,
+                  oem->Buffer,
+                  oem->MaximumLength);
 
   return 0;
Index: trunk/src/kernel32/unicode.cpp
===================================================================
--- trunk/src/kernel32/unicode.cpp	(revision 82)
+++ trunk/src/kernel32/unicode.cpp	(revision 83)
@@ -1,12 +1,7 @@
 /*
- *
  * Project Odin Software License can be found in LICENSE.TXT
- *
- */
-/*
  * Unicode functions
- *
  * Copyright 1998 Joel Troster
- *
+ * Copyright 1999 Patrick haller
  */
 #include <os2win.h>
@@ -136,10 +131,10 @@
   }
   else
-  {
-   for(i = 0; i < unilen; i++) {
-        astring[i] = (char)ustring[i];
-   }
-   astring[unilen] = 0;
-  }
+   /* idiots unicode conversion :) */
+   for(i = 0; i < unilen; i++)
+     astring[i] = (char)ustring[i];
+
+  astring[unilen] = 0; // @@@PH: 1999/06/09 fix - always terminate string
+
   return(unilen);
 }
@@ -217,4 +212,6 @@
 
   unicode[asciilen] = 0;
+//SvL: Messes up the heap
+//  unicode[len+1] = 0; /* @@@PH 98/06/07 */
 }
 //******************************************************************************
Index: trunk/src/user32/RESSTRING.C
===================================================================
--- trunk/src/user32/RESSTRING.C	(revision 82)
+++ trunk/src/user32/RESSTRING.C	(revision 83)
@@ -23,110 +23,140 @@
 #include "unicode.h"
 
-static char *UnicodeToAsciiN(WCHAR *wstring, char *astring, int maxlen);
-
 /******************************************************************************/
-//Strings stored as original: WORD    len 
+//Strings stored as original: WORD    len
 //                            UNICODE string (not null terminated)
 /******************************************************************************/
-int OS2LoadStringAscii(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer)
+int OS2LoadStringAscii(HINSTANCE hinst,
+                       UINT      wID,
+                       LPSTR     lpBuffer,
+                       int       cchBuffer)
 {
- APIRET  rc;
- WCHAR  *szbuf;
- char    modname[128];
- HMODULE hmodule;
+  APIRET  rc;
+  WCHAR  *szbuf;
+  char    modname[128];
+  HMODULE hmodule;
 
-  if(hinst != 0 && hinst != -1) {
-	if(Win32QueryModuleName(hinst, modname, sizeof(modname)) == 0) {
-#ifdef DEBUG
-		WriteLog("Can't determine handle of dll %X\n", hinst);
-#endif
-		return(0);
-	}
-	rc = DosQueryModuleHandle(modname, &hmodule);
-	if(rc) {
-#ifdef DEBUG
-		WriteLog("Can't determine handle of dll %s\n", modname);
-#endif
-		return(0);
-	}
+  if(hinst != 0 && hinst != -1)
+  {
+    if(Win32QueryModuleName(hinst,
+                            modname,
+                            sizeof(modname)) == 0)
+    {
+      dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %08xh\n",
+               hinst));
+      return(0);
+   }
+
+   rc = DosQueryModuleHandle(modname,
+                             &hmodule);
+   if(rc)
+   {
+     dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %s\n",
+              modname));
+
+     return(0);
+   }
   }
-  else 	hmodule = 0;
+  else
+    hmodule = 0;
 
-  rc = DosGetResource(hmodule, RT_RCDATA, wID, (PPVOID)&szbuf);
-  if(rc) {
-#ifdef DEBUG
-	WriteLog("OS2LoadString failed with rc %d\n", rc);
-#endif
-	if(lpBuffer)	*lpBuffer = 0;
-	return(0);	//TODO: SetLastError!
+  rc = DosGetResource(hmodule,
+                      RT_RCDATA,
+                      wID,
+                      (PPVOID)&szbuf);
+  if(rc)
+  {
+    dprintf(("USER32: OS2LoadStringAscii failed with rc %08xh\n",
+             rc));
+
+    if(lpBuffer)
+      *lpBuffer = 0;
+
+    return(0);  //TODO: SetLastError!
   }
-  UnicodeToAsciiN(szbuf+1, lpBuffer, min((*szbuf), cchBuffer-1));
-#ifdef DEBUG
-  WriteLog("OS2LoadString retrieved string '%s' (size %d)\n", lpBuffer, (int)*szbuf);
-#endif
+
+  UnicodeToAsciiN(szbuf+1,
+                  lpBuffer,
+                  min((*szbuf), cchBuffer-1));
+
+  dprintf(("USER32: OS2LoadStringA retrieved string '%s' (size %d)\n",
+           lpBuffer,
+           (int)*szbuf));
+
   DosFreeResource(szbuf);
-  return(strlen(lpBuffer));	//not including null terminator!
+  return(strlen(lpBuffer));              //not including null terminator!
 }
 //******************************************************************************
 //******************************************************************************
-int OS2LoadStringUnicode(HINSTANCE hinst, UINT wID, WCHAR *lpBuffer, int cchBuffer)
+int OS2LoadStringUnicode(HINSTANCE hinst,
+                         UINT      wID,
+                         WCHAR     *lpBuffer,
+                         int       cchBuffer)
 {
- APIRET  rc;
- WCHAR  *szbuf;
- char    modname[128];
- HMODULE hmodule;
+  APIRET  rc;
+  WCHAR  *szbuf;
+  char    modname[128];
+  HMODULE hmodule;
+
 #ifdef DEBUG
  char   *astring;
 #endif
 
-  if(hinst != 0 && hinst != -1) {
-	if(Win32QueryModuleName(hinst, modname, sizeof(modname)) == 0) {
-#ifdef DEBUG
-		WriteLog("Can't determine handle of dll %X\n", hinst);
-#endif
-		return(0);
-	}
-	rc = DosQueryModuleHandle(modname, &hmodule);
-	if(rc) {
-#ifdef DEBUG
-		WriteLog("Can't determine handle of dll %s\n", modname);
-#endif
-		return(0);
-	}
+  if(hinst != 0 && hinst != -1)
+  {
+    if(Win32QueryModuleName(hinst,
+                            modname,
+                            sizeof(modname)) == 0)
+    {
+      dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %08xh\n",
+               hinst));
+      return(0);
+   }
+
+   rc = DosQueryModuleHandle(modname,
+                             &hmodule);
+   if(rc)
+   {
+     dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %s\n",
+              modname));
+
+     return(0);
+   }
   }
-  else 	hmodule = 0;
+  else
+    hmodule = 0;
 
-  rc = DosGetResource(hmodule, RT_RCDATA, wID, (PPVOID)&szbuf);
-  if(rc) {
-#ifdef DEBUG
-	WriteLog("OS2LoadString failed with rc %d\n", rc);
-#endif
-	if(lpBuffer)	*lpBuffer = 0;
-	return(0);	//TODO: SetLastError!
+  rc = DosGetResource(hmodule,
+                      RT_RCDATA,
+                      wID,
+                      (PPVOID)&szbuf);
+  if(rc)
+  {
+    dprintf(("USER32: OS2LoadStringUnicode failed with rc %08xh\n",
+             rc));
+
+    if(lpBuffer)
+      *lpBuffer = 0;
+
+    return(0);  //TODO: SetLastError!
   }
-  memcpy(lpBuffer, szbuf+1, min((*szbuf), cchBuffer-1)*sizeof(WCHAR));
+
+
+  memcpy(lpBuffer,
+         szbuf+1,
+         min((*szbuf), cchBuffer-1) * sizeof(WCHAR));
+
   lpBuffer[min((*szbuf), cchBuffer-1)] = 0;
 
 #ifdef DEBUG
   astring = UnicodeToAsciiString(lpBuffer);
-  WriteLog("OS2LoadStringW retrieved string '%s' of size %d\n", astring, (int)*szbuf);
+  WriteLog("USER32: OS2LoadStringUnicode retrieved string '%s' of size %d\n",
+           astring,
+           (int)*szbuf);
   FreeAsciiString(astring);
 #endif
+
   DosFreeResource(szbuf);
-  return(UniStrlen(lpBuffer));	//not including null terminator!
+  return(UniStrlen(lpBuffer));           //not including null terminator!
 }
-//******************************************************************************
-//******************************************************************************
-static char *UnicodeToAsciiN(WCHAR *wstring, char *astring, int maxlen)
-{
- int i;
 
-  for(i=0;i<maxlen;i++) {
-	astring[i] = (UCHAR)wstring[i];
-  }
-  astring[maxlen] = 0;
-  return(astring);
-}
-/******************************************************************************/
-/******************************************************************************/
-
