PATCH: fix mbtowc (bug #1324)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

this patch brings mbtowc in line with the msdn documentation and fixes
bug #1324. While i touched the code i also reindented it to match wines
indenting style.

License: LGPL, X11
Changelog:
    Michael Stefaniuc <mstefani@redhat.com>
    - mbtowc returns -1 if we can't find a valid multibyte char in the
      non NULL source string (fixes: #1324)
    - reindented mbtowc

bye
	michael
-- 
Michael Stefaniuc               Tel.: +49-711-96437-199
System Administration           Fax.: +49-711-96437-111
Red Hat GmbH                    Email: mstefani@redhat.com
Hauptstaetterstr. 58            http://www.redhat.de/
D-70178 Stuttgart
Index: dlls/msvcrt/mbcs.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/mbcs.c,v
retrieving revision 1.26
diff -u -r1.26 mbcs.c
--- dlls/msvcrt/mbcs.c	14 Feb 2003 23:26:58 -0000	1.26
+++ dlls/msvcrt/mbcs.c	16 Apr 2003 00:00:15 -0000
@@ -588,16 +588,21 @@
  */
 int MSVCRT_mbtowc(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n)
 {
-  if(n <= 0 || !str)
-    return 0;
-  if(!MultiByteToWideChar(CP_ACP, 0, str, n, dst, 1))
-    return 0;
-  /* return the number of bytes from src that have been used */
-  if(!*str)
-    return 0;
-  if(n >= 2 && MSVCRT_isleadbyte(*str) && str[1])
-    return 2;
-  return 1;
+    /* temp var needed because MultiByteToWideChar wants non NULL destination */
+    MSVCRT_wchar_t tmpdst = '\0';
+
+    if(n <= 0 || !str)
+        return 0;
+    if(!MultiByteToWideChar(CP_ACP, 0, str, n, &tmpdst, 1))
+        return -1;
+    if(dst)
+        *dst = tmpdst;
+    /* return the number of bytes from src that have been used */
+    if(!*str)
+        return 0;
+    if(n >= 2 && MSVCRT_isleadbyte(*str) && str[1])
+        return 2;
+    return 1;
 }
 
 /*********************************************************************

Attachment: pgp00123.pgp
Description: PGP signature


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux